diff --git a/tools/taxonomy-parser.cpp b/tools/taxonomy-parser.cpp index 765504af..45012ee7 100644 --- a/tools/taxonomy-parser.cpp +++ b/tools/taxonomy-parser.cpp @@ -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(),"Show the children of node ") ("parent,P",value(),"Show the parent taxon of node ") + ("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(),"Show the top high-degree nodes") ("write-tree,T","Write out the result as a tree") ("write-taxonomy",value(),"Write out the result as a taxonomy to directory 'arg'") @@ -283,6 +284,11 @@ std::function 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[]) { @@ -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;