Skip to content

Enhancement/crate level docs for alignment, alphabets and asr modules - #185

Open
junniest wants to merge 24 commits into
developfrom
enhancement/crate_level_docs
Open

junniest wants to merge 24 commits into
developfrom
enhancement/crate_level_docs

Conversation

@junniest

@junniest junniest commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor

Properly documented the alignment, alphabets and asr modules, including missing docstrings/tests and module-level docs for each.
Includes slight changes in the public API by making some string constants pub(crate) instead of pub.

alignment: hide module-level docs from re-imports to reduce clutter. Documentation
of re-imported stuff will be inlined.
alignment: replace Vec<String> used to map node indices to sequence ids with a named type with a description
alignment: fix docstrings (use IDs instead of ids) for consistency among docs
alphabets: hide submodule docs for public re-export of the parsimony_set submodule
alphabets: add doctrings for static objects such as alphabets and pre-computed conditional probabilities
alphabets: replace incorrect use of HashSet for an empty parsimony set with the predefined ParsimonySet type
Added module-level docs for the ASR module with an example.
Added an example tree file with ancestral node labels.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Resolve the public API regression and crate-wide documentation-lint CI failures.

Get a fresh assessment by requesting another Copilot review.

Pull request overview

Adds crate-level documentation and examples for alignment, alphabets, and asr, plus ASR test coverage and fixture data.

Changes:

  • Enables crate-wide missing_docs warnings.
  • Adds module/API documentation and examples.
  • Adds an ancestral reconstruction test and Newick fixture.
File summaries
File Summary
phylo/src/lib.rs Enables missing-documentation warnings.
phylo/src/asr/tests.rs Adds ancestral reconstruction test coverage.
phylo/src/asr/mod.rs Adds ASR module documentation and example.
phylo/src/alphabets/mod.rs Documents alphabet APIs and statics.
phylo/src/alignment/mod.rs Documents alignment APIs and examples.
phylo/examples/data/tree_with_ancestral_ids.newick Provides test tree data.
Review details

Suppressed comments (3)

phylo/src/alignment/mod.rs:187

  • The new description's phrase by its node index is grammatically incorrect and redundant; the node index is the selector for the sequence being updated.
    /// Updates the `Mapping` of the ancestral sequence associated with the given internal node by
    /// its node index.

phylo/src/alphabets/mod.rs:364

  • The new documentation contains the typo beused; it should be two words.
    /// Static definition of an unknown alphabet, can beused as a fallback when the alphabet of a

phylo/src/alphabets/mod.rs:456

  • This doc comment is indented with three spaces inside the lazy_static! block, so the repository's rustfmt check will rewrite it to four spaces and fail the formatting job. Please align it with the surrounding declarations.
   /// Static parsimony sets for each amino acid character.
  • Files reviewed: 6/6 changed files
  • Comments generated: 4
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread phylo/src/alphabets/mod.rs Resolved
Comment thread phylo/src/lib.rs Resolved
Comment thread phylo/src/alignment/mod.rs Resolved
Comment thread phylo/src/alphabets/mod.rs Resolved
@github-actions

github-actions Bot commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor

Test Results

991 tests  +8   990 ✅ +8   14m 58s ⏱️ -26s
  2 suites ±0     1 💤 ±0 
  1 files   ±0     0 ❌ ±0 

Results for commit a4678c5. ± Comparison against base commit 752d213.

This pull request removes 15 and adds 23 tests. Note that renamed tests count towards both.
src/alignment/mod.rs - alignment::MASA ‑ from_aligned (line 408)
src/alignment/mod.rs - alignment::MASA ‑ from_aligned_with_ancestral_unchecked (line 514)
src/alignment/mod.rs - alignment::MSA ‑ alphabet (line 191)
src/alignment/mod.rs - alignment::MSA ‑ from_aligned_unchecked (line 282)
src/alignment/mod.rs - alignment::MSA ‑ len (line 219)
src/alignment/mod.rs - alignment::MSA ‑ seq_count (line 247)
src/alphabets/mod.rs - alphabets::Alphabet ‑ ambiguous (line 112)
src/alphabets/mod.rs - alphabets::Alphabet ‑ char_encoding (line 156)
src/alphabets/mod.rs - alphabets::Alphabet ‑ gap_set (line 203)
src/alphabets/mod.rs - alphabets::Alphabet ‑ index (line 139)
…
alphabets::tests ‑ alphabet_names
asr::tests ‑ test_reconstruct_ancestral_seqs
src/alignment/mod.rs - alignment (line 17)
src/alignment/mod.rs - alignment::MASA ‑ from_aligned (line 498)
src/alignment/mod.rs - alignment::MASA ‑ from_aligned_with_ancestral_unchecked (line 604)
src/alignment/mod.rs - alignment::MSA ‑ alphabet (line 276)
src/alignment/mod.rs - alignment::MSA ‑ from_aligned_unchecked (line 367)
src/alignment/mod.rs - alignment::MSA ‑ len (line 304)
src/alignment/mod.rs - alignment::MSA ‑ seq_count (line 332)
src/alphabets/mod.rs - alphabets (line 12)
…

♻️ This comment has been updated with latest results.

@codecov

codecov Bot commented Sep 16, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.65%. Comparing base (527040d) to head (32bf5a6).
⚠️ Report is 38 commits behind head on develop.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop     #185      +/-   ##
===========================================
+ Coverage    96.32%   96.65%   +0.33%     
===========================================
  Files           32       46      +14     
  Lines         4355     5475    +1120     
===========================================
+ Hits          4195     5292    +1097     
- Misses         160      183      +23     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Comment thread phylo/src/asr/mod.rs
//! Ancestral sequence reconstruction module.
//!
//! Provides the `AncestralSequenceReconstruction` trait for reconstructing ancestral sequences
//! given a leaf alignment or an existing ancestral alignment and a phylogenetic tree.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

existing ancestral alignment

Perhaps say that the ancestral sequences will be ignored in that case. Since its only passed as Alignment so we dont have access to the ancestral sequences.

Comment on lines +9 to +10
//! The Sequences object is used to store the sequences in the alignment, and the lengths of
//! the sequences in the alignment must be consistent.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

... and the lengths of the sequences in the alignment must be consistent.

But right now the lens of the seqs in the Sequences obj that is a field of the alignment must not be of equal length, as their gaps are removed. Only when we call from_aligned, passing a Sequences, must they be of equal length.

Comment thread phylo/src/alignment/mod.rs Resolved
//! The sequence IDs must be unique within the collection.
//! The sequences stored in the object can be aligned or unaligned.
//!
//! Contains the [`Alignment`] and [`AncestralAlignment`] traits for representing and manipulating

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps mention that the alignment and how its implemented here depends on a tree, since we are using NodeIdx for some its fields (like SeqMaps). So the alignment should always be seen as belonging to some tree.

Comment on lines +67 to 70
/// Represents the mapping of sequences for nodes in the tree as a `hashbrown::HashMap`
/// where the key is the node index (of type [`NodeIdx`]) and the value is the [`Mapping`] of
/// sequences for that node.
pub type SeqMaps = HashMap<NodeIdx, Mapping>;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

... tree ...

Perhaps link the Tree struct here?

Comment on lines +179 to 180
/// Returns the `Mapping` of the ancestral sequence associated with the given internal node.
fn ancestral_map(&self, node_idx: &NodeIdx) -> &Mapping;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// Returns the `Mapping` of the ancestral sequence associated with the given internal node.
fn ancestral_map(&self, node_idx: &NodeIdx) -> &Mapping;
/// Returns the `Mapping` of the ancestral sequence corresponding to the given internal node index.
fn ancestral_map(&self, node_idx: &NodeIdx) -> &Mapping;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To match the doc for the leaf_map()

/// Represents a multiple sequence alignment (MSA) with associated leaf mappings and internal alignments.
///
/// This structure stores the sequences and their corresponding mappings for leaf nodes,
/// as well as the internal alignments and a mapping from node indices in the tree to sequence IDs.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

... internal alignments ...

Perhaps mention that these are created according to the tree that was passed on creation.
This also applies for the MASA doc.

pub(crate) static AMB_AMINOACIDS: &[u8] = b"BJZX";

/// All single-letter symbols for valid non-ambiguous nucleotides used in the alphabet.
/// This is legacy sorting, i.e., conforming with tools like RaXML and PhyML, and is used also

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😆

Comment on lines +52 to 53
/// The character representing a gap in the alphabet used in MSAs.
pub static GAP: u8 = b'-';

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// The character representing a gap in the alphabet used in MSAs.
pub static GAP: u8 = b'-';
/// The character in the alphabet representing a gap as used in MSAs.

or The character in the alphabets representing a gap.

or The character representing a gap in MSAs.

pub struct Alphabet {
/// Human-readable name of the alphabet.
name: &'static str,
/// Unambiguous symbols in the alphabet, in matrix order.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps link the QMatrix here?

pub(crate) static AMB_NUCLEOTIDES: &[u8] = b"RYSWKMBDHVNZX";

/// The character representing an ambiguous symbol in both the amino acid and nucleotide alphabets.
pub(crate) static AMB_CHAR: u8 = b'X';

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the upcoming simulation #140 , but also in parsimony_presence_absence, and EdgeSeqsReestimator I use these X chars as mention in the docs, since I want to tell the user which char will be used for indicating any char. This will not be possible when having this only pub(crate) and not pub. Same holds for the GAP.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants