Skip to content

[DO NOT MERGE] Parsing Phylogenetic trees - #58

Draft
ChinmayMoghe wants to merge 1 commit into
LCrossman:mainfrom
ChinmayMoghe:51-parsing-phylogenetic-trees
Draft

ChinmayMoghe wants to merge 1 commit into
LCrossman:mainfrom
ChinmayMoghe:51-parsing-phylogenetic-trees

Conversation

@ChinmayMoghe

@ChinmayMoghe ChinmayMoghe commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Feature: Parsing phylogenetic trees

#51

What changed ?

Added a new member called phylo - This is to make sure that this module forms a logical grouping for everything related to phylogenetic trees

  • Added phylo - phylo provides memory-efficient data structures and algorithms for phylogenetic analysis and inference

Added phylo/src/lib.rs - Implements Scanner, PhyloParser

  • Scanner -> Read multi line newick tree files, is an iterator that emits Vec - that represents a single newick tree
  • PhyloParser -> Takes in scanner, is an iterator that emits PhyloTree (as per phylo crate)

This PR is to showcase work in progress and for reference, please share any feedback

@ChinmayMoghe
ChinmayMoghe marked this pull request as draft October 20, 2026 11:31
@LCrossman

Copy link
Copy Markdown
Owner

In terms of robust parsing, I looked through some of my trees and there can be unusual characters in the label, for example:
#, ' (as a biochemical symbol) , -, _ is very common, | , space , [, ], and . is also common

characters reserved in the tree format ( : , ) ; could not ever be in the label, because that would break the format (but it is a possible reason why the format might be invalid)

@ChinmayMoghe

ChinmayMoghe commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor Author

@LCrossman This is helpful, can you share an example of such a tree with unusual labels, this could become a test case against current implementation, current implementation only creates a Vec<u8> including the ; so that it represents a newick tree, and I let downstream lib (phylo) handle parsing of that tree, we could test out some edge cases with this, if there are any.

@LCrossman

Copy link
Copy Markdown
Owner

Edge Cases/tests:

Campylobacter tree of genbank labels and branch lengths:
attached file 1403.aln.treefile.txt
1403.aln.treefile.txt

Multitree file of 10 Staph:
attached file RAxML_bootstrap.my_run.txt
RAxML_bootstrap.my_run.txt

Midpoint rooted and fully Bootstrapped final tree of proteins from Staph:
the bootstraps are specified as 83.7/67 which is bootstrapping values from two different models output from a popular treemaking software.

((((((((((((((((sp|A5IV27|RL16_STAA9:0,sp|Q7A461|RL16_STAAN:0):0,sp|Q5HDW5|RL16_STAAC:0):0,sp|Q99S28|RL16_STAAM:0):0,sp|Q2FEP6|RL16_STAA3:0):0,sp|Q2YYQ3|RL16_STAAB:0):0,sp|Q6G778|RL16_STAAS:0):0,sp|Q6GEJ0|RL16_STAAR:0):0,sp|Q2FW13|RL16_STAA8:0):0,sp|A7X5F4|RL16_STAA1:0):0,sp|A6U3W8|RL16_STAA2:0):0,sp|Q7A080|RL16_STAAW:0):1e-06,sp|A6QJ85|RL16_STAAE:1e-06)83.7/67:0.0071479917,sp|B9DM40|RL16_STACT:0.0216542727)0/23:1e-06,sp|Q4L8A7|RL16_STAHJ:1e-06)0/30:1e-06,(sp|Q5HM06|RL16_STAEQ:1e-06,sp|Q8CRG7|RL16_STAES:1e-06)87.4/88:0.0144074702)NA:0.00725453595,sp|Q49ZG1|RL16_STAS1:0.02891080865);

popular program iqtree2 which creates trees we might want to parse says this:

To avoid problems with downstream software (like tree viewers), IQ-Tree (and also other phylogenetic software) checks the names for such potentially interfering characters and substitutes them by underscores . Permitted characters in sequence names are alphanumeric letters, underscores , dash -, dot ., slash \ and vertical bar |. All other characters are substituted, like e.g. hawk's-eye is converted to hawk_s-eye as which it will appear in the tree.

This branch has not been deployed

No deployments
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.

2 participants