Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/report-taxon-root-dist' into sin…
Browse files Browse the repository at this point in the history
…k-action
  • Loading branch information
mtholder committed Jul 10, 2024
2 parents d258bc9 + 67e6a4a commit 280ccb8
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions tools/taxonomy-parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ variables_map parse_cmd_line(int argc,char* argv[]) {
("extinct-to-incert,E","Adds an incertae_sedis flag to every extinct taxa (use with write-taxonomy)")
("children,C",value<long>(),"Show the children of node <arg>")
("parent,P",value<OttId>(),"Show the parent taxon of node <arg>")
("report-dist-to-root","Report the number of nodes between from the root to each OTT ID (the root reports 1)")
("high-degree-nodes",value<int>(),"Show the top <arg> high-degree nodes")
("write-tree,T","Write out the result as a tree")
("write-taxonomy",value<string>(),"Write out the result as a taxonomy to directory 'arg'")
Expand Down Expand Up @@ -283,6 +284,11 @@ std::function<bool(tax_flags)> get_flags_match(variables_map& args) {
}
}

void report_dist_to_root(std::ostream & out, const Taxonomy & taxonomy) {
for (auto & rec : taxonomy) {
out << rec.id << '\t' << rec.depth << '\n';
}
}

int main(int argc, char* argv[])
{
Expand Down Expand Up @@ -391,6 +397,9 @@ int main(int argc, char* argv[])
if (args.count("version")) {
std::cout << taxonomy.get_version() << std::endl;
}
if (args.count("report-dist-to-root")) {
report_dist_to_root(std::cout, taxonomy);
}
} catch (std::exception& e) {
cerr << "otc-taxonomy-parser: Error! " << e.what() << std::endl;
return 1;
Expand Down

0 comments on commit 280ccb8

Please sign in to comment.