From d4feb524eb7895d799bb3e9bdd3ae4fe2fa6f575 Mon Sep 17 00:00:00 2001 From: Sarah Lutteropp Date: Mon, 13 May 2019 14:44:36 +0200 Subject: [PATCH 01/31] updated submodule --- libs/pll-modules | 2 +- src/bootstrap/TransferBootstrapTree.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/libs/pll-modules b/libs/pll-modules index 840a1952..73df129c 160000 --- a/libs/pll-modules +++ b/libs/pll-modules @@ -1 +1 @@ -Subproject commit 840a19525ed133ad243afb23124911b849d4685d +Subproject commit 73df129c27d5b6eb01f353e70acb71ae1cf46f7d diff --git a/src/bootstrap/TransferBootstrapTree.cpp b/src/bootstrap/TransferBootstrapTree.cpp index d89f5680..79f223d6 100644 --- a/src/bootstrap/TransferBootstrapTree.cpp +++ b/src/bootstrap/TransferBootstrapTree.cpp @@ -45,7 +45,7 @@ void TransferBootstrapTree::add_tree(const pll_unode_t& root) else { pllmod_utree_tbe_nature(_ref_splits.get(), splits.get(), (pll_unode_t*) &root, - _num_tips, support.data(), _split_info); + _num_tips, support.data(), _split_info, 0, NULL); } add_splits_to_hashtable(_ref_splits, support, 1); From 7618f86928d2be48a1a7cd1b1904f614a07222f9 Mon Sep 17 00:00:00 2001 From: Sarah Lutteropp Date: Wed, 12 Jun 2019 13:52:09 +0200 Subject: [PATCH 02/31] added extra tbe output --- .gitmodules | 2 +- libs/pll-modules | 2 +- src/CommandLineParser.cpp | 9 ++++++++ src/Options.cpp | 3 +++ src/Options.hpp | 11 ++++++++++ src/bootstrap/TransferBootstrapTree.cpp | 29 +++++++++++++++++++++++-- src/bootstrap/TransferBootstrapTree.hpp | 6 ++++- src/io/TBEExtraArrayStream.cpp | 26 ++++++++++++++++++++++ src/io/TBEExtraTableStream.cpp | 26 ++++++++++++++++++++++ src/io/TBEExtraTreeStream.cpp | 26 ++++++++++++++++++++++ src/io/file_io.hpp | 25 +++++++++++++++++++++ src/main.cpp | 20 +++++++++++++++++ 12 files changed, 180 insertions(+), 5 deletions(-) create mode 100644 src/io/TBEExtraArrayStream.cpp create mode 100644 src/io/TBEExtraTableStream.cpp create mode 100644 src/io/TBEExtraTreeStream.cpp diff --git a/.gitmodules b/.gitmodules index c0cbe2a9..c4a6c272 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,6 +1,6 @@ [submodule "libs/pll-modules"] path = libs/pll-modules - url = https://github.com/ddarriba/pll-modules.git + url = https://github.com/lutteropp/pll-modules.git [submodule "libs/terraphast"] path = libs/terraphast url = https://github.com/amkozlov/terraphast-one diff --git a/libs/pll-modules b/libs/pll-modules index 73df129c..398281c8 160000 --- a/libs/pll-modules +++ b/libs/pll-modules @@ -1 +1 @@ -Subproject commit 73df129c27d5b6eb01f353e70acb71ae1cf46f7d +Subproject commit 398281c8b7770640f1f3c97f260c29c64656aa30 diff --git a/src/CommandLineParser.cpp b/src/CommandLineParser.cpp index 798249c0..234d7dc5 100644 --- a/src/CommandLineParser.cpp +++ b/src/CommandLineParser.cpp @@ -737,6 +737,15 @@ void CommandLineParser::parse_options(int argc, char** argv, Options &opts) opts.tbe_naive = true; else if (eopt == "tbe-nature") opts.tbe_naive = false; + else if (sscanf(eopt.c_str(), "tbe-cutoff{%lf}", &opts.tbe_extra_cutoff) == 1) + void(); + else if (eopt == "tbe_extra_table") + opts.tbe_extra_table = true; + else if (eopt == "tbe_extra_array") + opts.tbe_extra_array = true; + else if (eopt == "tbe_extra_tree") + opts.tbe_extra_tree = true; + // TODO: put TBE bool flags here else throw InvalidOptionValueException("Unknown extra option: " + string(optarg)); } diff --git a/src/Options.cpp b/src/Options.cpp index fc7f40d9..c31e14bd 100644 --- a/src/Options.cpp +++ b/src/Options.cpp @@ -30,6 +30,9 @@ void Options::set_default_outfiles() set_default_outfile(outfile_names.support_tree, "support"); set_default_outfile(outfile_names.fbp_support_tree, "supportFBP"); set_default_outfile(outfile_names.tbe_support_tree, "supportTBE"); + set_default_outfile(outfile_names.tbe_extra_table, "tbeExtraTable"); + set_default_outfile(outfile_names.tbe_extra_array, "tbeExtraArray"); + set_default_outfile(outfile_names.tbe_extra_tree, "tbeExtraTree"); set_default_outfile(outfile_names.terrace, "terrace"); set_default_outfile(outfile_names.binary_msa, "rba"); set_default_outfile(outfile_names.bootstrap_msa, "bootstrapMSA"); diff --git a/src/Options.hpp b/src/Options.hpp index 4f4f93bc..69f59b9d 100644 --- a/src/Options.hpp +++ b/src/Options.hpp @@ -17,6 +17,9 @@ struct OutputFileNames std::string bootstrap_trees; std::string support_tree; std::string tbe_support_tree; + std::string tbe_extra_table; + std::string tbe_extra_array; + std::string tbe_extra_tree; std::string fbp_support_tree; std::string terrace; std::string binary_msa; @@ -40,6 +43,7 @@ class Options spr_cutoff(1.0), brlen_linkage(PLLMOD_COMMON_BRLEN_SCALED), brlen_opt_method(PLLMOD_OPT_BLO_NEWTON_FAST), brlen_min(RAXML_BRLEN_MIN), brlen_max(RAXML_BRLEN_MAX), + tbe_extra_cutoff(0), tbe_extra_table(false), tbe_extra_array(false), tbe_extra_tree(false), num_searches(1), terrace_maxsize(100), num_bootstraps(1000), bootstop_criterion(BootstopCriterion::none), bootstop_cutoff(0.03), bootstop_interval(RAXML_BOOTSTOP_INTERVAL), bootstop_permutations(RAXML_BOOTSTOP_PERMUTES), @@ -82,6 +86,10 @@ class Options int brlen_opt_method; double brlen_min; double brlen_max; + unsigned int tbe_extra_cutoff; + bool tbe_extra_table; + bool tbe_extra_array; + bool tbe_extra_tree; unsigned int num_searches; unsigned long long terrace_maxsize; @@ -135,6 +143,9 @@ class Options std::string bootstrap_partition_file() const; const std::string rfdist_file() const { return outfile_names.rfdist; } const std::string cons_tree_file() const { return outfile_names.cons_tree + consense_type_name(); } + const std::string& tbe_extra_table_file() const { return outfile_names.tbe_extra_table; } + const std::string& tbe_extra_array_file() const { return outfile_names.tbe_extra_array; } + const std::string& tbe_extra_tree_file() const { return outfile_names.tbe_extra_tree; } const std::string asr_tree_file() const { return outfile_names.asr_tree; } const std::string asr_probs_file() const { return outfile_names.asr_probs; } diff --git a/src/bootstrap/TransferBootstrapTree.cpp b/src/bootstrap/TransferBootstrapTree.cpp index 79f223d6..02a700fe 100644 --- a/src/bootstrap/TransferBootstrapTree.cpp +++ b/src/bootstrap/TransferBootstrapTree.cpp @@ -1,6 +1,17 @@ #include "TransferBootstrapTree.hpp" -TransferBootstrapTree::TransferBootstrapTree(const Tree& tree, bool naive) : +/*typedef unsigned int TBEFlags; + +const unsigned int TBE_DO_TABLE = 1; +const unsigned int TBE_DO_ARRAY = 2; +const unsigned int TBE_DO_OTHER = 4; + +TransferBootstrapTree bstree(tree, true, 1., TBE_DO_TABLE | TBE_DO_OTHER); + +TransferBootstrapTree bstree(tree, true, 1., false, true, false); +*/ + +TransferBootstrapTree::TransferBootstrapTree(const Tree& tree, bool naive, unsigned int d = 0, bool doTable = false, bool doArray = false, bool doTree = false) : SupportTree (tree), _split_info(nullptr), _naive_method(naive) { assert(num_splits() > 0); @@ -13,13 +24,27 @@ TransferBootstrapTree::TransferBootstrapTree(const Tree& tree, bool naive) : { _split_info = pllmod_utree_tbe_nature_init((pll_unode_t*) &pll_utree_root(), _num_tips, (const pll_unode_t**) _node_split_map.data()); + if (doTable || doArray || doTree) { + _extra_info = pllmod_tbe_extra_info_create(num_splits(), _num_tips, doTable, doArray, doTree); + } } } +pllmod_tbe_extra_info_t* TransferBootstrapTree::get_extra_info() { + return _extra_info; +} + +void TransferBootstrapTree::collect_support() { + SupportTree::collect_support(); + // do the postprocessing of extra info +} + TransferBootstrapTree::~TransferBootstrapTree() { if (_split_info) free(_split_info); + if (_extra_info) + pllmod_tbe_extra_info_destroy(_extra_info, num_splits()); } void TransferBootstrapTree::add_tree(const pll_unode_t& root) @@ -45,7 +70,7 @@ void TransferBootstrapTree::add_tree(const pll_unode_t& root) else { pllmod_utree_tbe_nature(_ref_splits.get(), splits.get(), (pll_unode_t*) &root, - _num_tips, support.data(), _split_info, 0, NULL); + _num_tips, support.data(), _split_info); } add_splits_to_hashtable(_ref_splits, support, 1); diff --git a/src/bootstrap/TransferBootstrapTree.hpp b/src/bootstrap/TransferBootstrapTree.hpp index fa44aefe..79b6c273 100644 --- a/src/bootstrap/TransferBootstrapTree.hpp +++ b/src/bootstrap/TransferBootstrapTree.hpp @@ -6,9 +6,12 @@ class TransferBootstrapTree : public SupportTree { public: - TransferBootstrapTree(const Tree& tree, bool naive = false); + TransferBootstrapTree(const Tree& tree, bool naive = false, unsigned int d = 0, bool doTable = false, bool doArray = false, bool doTree = false); virtual ~TransferBootstrapTree(); + void postprocess_extra(); //... + pllmod_tbe_extra_info_t* get_extra_info(); + protected: virtual void add_tree(const pll_unode_t& root); @@ -17,6 +20,7 @@ class TransferBootstrapTree : public SupportTree private: pllmod_tbe_split_info_t * _split_info; + pllmod_tbe_extra_info_t * _extra_info; bool _naive_method; }; diff --git a/src/io/TBEExtraArrayStream.cpp b/src/io/TBEExtraArrayStream.cpp new file mode 100644 index 00000000..20d0241b --- /dev/null +++ b/src/io/TBEExtraArrayStream.cpp @@ -0,0 +1,26 @@ +#include "file_io.hpp" + +using namespace std; + + +TBEExtraArrayStream& operator<<(NewickStream& stream, const TransferBootstrapTree& tree) +{ + pllmod_tbe_extra_info_t* extra_info = tree.get_extra_info(); + //... + + auto print_cb = stream.brlens() ? newick_print_cb : newick_name_cb; + char * newick_str = pll_utree_export_newick(&root, print_cb); + if (newick_str) + { + stream << newick_str << std::endl; + free(newick_str); + } + else + { + assert(pll_errno); + libpll_check_error("Failed to generate Newick"); + } + return stream; +} + + diff --git a/src/io/TBEExtraTableStream.cpp b/src/io/TBEExtraTableStream.cpp new file mode 100644 index 00000000..19263425 --- /dev/null +++ b/src/io/TBEExtraTableStream.cpp @@ -0,0 +1,26 @@ +#include "file_io.hpp" + +using namespace std; + + +TBEExtraTableStream& operator<<(NewickStream& stream, const TransferBootstrapTree& tree) +{ + pllmod_tbe_extra_info_t* extra_info = tree.get_extra_info(); + //... + + auto print_cb = stream.brlens() ? newick_print_cb : newick_name_cb; + char * newick_str = pll_utree_export_newick(&root, print_cb); + if (newick_str) + { + stream << newick_str << std::endl; + free(newick_str); + } + else + { + assert(pll_errno); + libpll_check_error("Failed to generate Newick"); + } + return stream; +} + + diff --git a/src/io/TBEExtraTreeStream.cpp b/src/io/TBEExtraTreeStream.cpp new file mode 100644 index 00000000..e112be03 --- /dev/null +++ b/src/io/TBEExtraTreeStream.cpp @@ -0,0 +1,26 @@ +#include "file_io.hpp" + +using namespace std; + + +TBEExtraTreeStream& operator<<(NewickStream& stream, const TransferBootstrapTree& tree) +{ + pllmod_tbe_extra_info_t* extra_info = tree.get_extra_info(); + //... + + auto print_cb = stream.brlens() ? newick_print_cb : newick_name_cb; + char * newick_str = pll_utree_export_newick(&root, print_cb); + if (newick_str) + { + stream << newick_str << std::endl; + free(newick_str); + } + else + { + assert(pll_errno); + libpll_check_error("Failed to generate Newick"); + } + return stream; +} + + diff --git a/src/io/file_io.hpp b/src/io/file_io.hpp index 5e26187b..19600f0c 100644 --- a/src/io/file_io.hpp +++ b/src/io/file_io.hpp @@ -6,6 +6,7 @@ #include "../Tree.hpp" #include "../AncestralStates.hpp" #include "../bootstrap/BootstrapTree.hpp" +#include "../bootstrap/TransferBootstrapTree.hpp" #include "../bootstrap/BootstrapGenerator.hpp" #include "../PartitionedMSAView.hpp" @@ -23,6 +24,30 @@ class NewickStream : public std::fstream bool _brlens; }; +class TBEExtraTableStream : public std::fstream +{ +public: + TBEExtraTableStream(const std::string& fname) : std::fstream(fname, std::ios::out) {}; + TBEExtraTableStream(const std::string& fname, std::ios_base::openmode mode) : + std::fstream(fname, mode) {}; +}; + +class TBEExtraArrayStream : public std::fstream +{ +public: + TBEExtraArrayStream(const std::string& fname) : std::fstream(fname, std::ios::out) {}; + TBEExtraArrayStream(const std::string& fname, std::ios_base::openmode mode) : + std::fstream(fname, mode) {}; +}; + +class TBEExtraTreeStream : public std::fstream +{ +public: + TBEExtraTreeStream(const std::string& fname) : std::fstream(fname, std::ios::out) {}; + TBEExtraTreeStream(const std::string& fname, std::ios_base::openmode mode) : + std::fstream(fname, mode) {}; +}; + class MSAFileStream { public: diff --git a/src/main.cpp b/src/main.cpp index b0cc222c..51560864 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1364,6 +1364,7 @@ void draw_bootstrap_support(RaxmlInstance& instance, Tree& ref_tree, const TreeC } sup_tree->draw_support(support_in_pct); + instance.support_trees[metric] = sup_tree; } } @@ -1804,6 +1805,25 @@ void print_final_output(const RaxmlInstance& instance, const Checkpoint& checkp) LOG_INFO << "Best ML tree with " << metric_name << " support values saved to: " << sysutil_realpath(sup_file) << endl; + + if (it.first == BranchSupportMetric::tbe) + { + if (opts.tbe_extra_table) { + auto extra_table_file = opts.tbe_extra_table_file(); + TBEExtraTableStream tbeExtraTable(extra_table_file); + tbeExtraTable << *it.second; + } + if (opts.tbe_extra_array) { + auto extra_array_file = opts.tbe_extra_array_file(); + TBEExtraArrayStream tbeExtraArray(extra_array_file); + tbeExtraArray << *it.second; + } + if (opts.tbe_extra_tree) { + auto extra_tree_file = opts.tbe_extra_tree_file(); + TBEExtraTreeStream tbeExtraTree(extra_tree_file); + tbeExtraTree << *it.second; + } + } } } } From 92e14cbc6bfc7dd998d344071140b317ec2522f5 Mon Sep 17 00:00:00 2001 From: Sarah Lutteropp Date: Wed, 12 Jun 2019 14:27:28 +0200 Subject: [PATCH 03/31] fixed compile errors --- src/bootstrap/BootstrapTree.cpp | 4 ++-- src/bootstrap/ConsensusTree.cpp | 4 ++-- src/bootstrap/SupportTree.cpp | 2 +- src/bootstrap/SupportTree.hpp | 2 +- src/bootstrap/TransferBootstrapTree.cpp | 16 +++++++++++----- src/bootstrap/TransferBootstrapTree.hpp | 3 ++- src/io/TBEExtraArrayStream.cpp | 6 +++--- src/io/TBEExtraTableStream.cpp | 6 +++--- src/io/TBEExtraTreeStream.cpp | 9 ++++++--- src/io/file_io.hpp | 4 ++++ src/main.cpp | 10 +++++----- 11 files changed, 40 insertions(+), 26 deletions(-) diff --git a/src/bootstrap/BootstrapTree.cpp b/src/bootstrap/BootstrapTree.cpp index 48ae2883..6c2aae1b 100644 --- a/src/bootstrap/BootstrapTree.cpp +++ b/src/bootstrap/BootstrapTree.cpp @@ -5,7 +5,7 @@ BootstrapTree::BootstrapTree (const Tree& tree) : SupportTree(tree) { assert(num_splits() > 0); - _node_split_map.resize(num_splits()); + _split_node_map.resize(num_splits()); /* extract reference tree splits and add them into hashtable */ add_tree(pll_utree_root()); @@ -18,7 +18,7 @@ BootstrapTree::~BootstrapTree () void BootstrapTree::add_tree(const pll_unode_t& root) { bool ref_tree = (_num_bs_trees == 0); - pll_unode_t ** node_split_map = ref_tree ? _node_split_map.data() : nullptr; + pll_unode_t ** node_split_map = ref_tree ? _split_node_map.data() : nullptr; int update_only = ref_tree ? 0 : 1; doubleVector support(num_splits(), ref_tree ? 0. : 1.); diff --git a/src/bootstrap/ConsensusTree.cpp b/src/bootstrap/ConsensusTree.cpp index 3327897b..dcb62829 100644 --- a/src/bootstrap/ConsensusTree.cpp +++ b/src/bootstrap/ConsensusTree.cpp @@ -70,13 +70,13 @@ bool ConsensusTree::compute_support() pll_utree(_num_tips, *cons_tree->tree); /* map pll_unodes to splits */ - _node_split_map.resize(_pll_utree->inner_count); + _split_node_map.resize(_pll_utree->inner_count); _support.resize(_pll_utree->inner_count); for (unsigned int i = 0; i < _pll_utree->inner_count; ++i) { auto node = _pll_utree->nodes[_pll_utree->tip_count + i]; assert(node->data); - _node_split_map[i] = node; + _split_node_map[i] = node; _support[i] = ((pll_consensus_data_t *) node->data)->support; } diff --git a/src/bootstrap/SupportTree.cpp b/src/bootstrap/SupportTree.cpp index 388744ae..3df90a6a 100644 --- a/src/bootstrap/SupportTree.cpp +++ b/src/bootstrap/SupportTree.cpp @@ -121,7 +121,7 @@ void SupportTree::draw_support(bool support_in_pct) // printf("node_id %d, split_id %d\n", _node_split_map[i]->node_index, i); // printf("\n\n"); - pll_unode_t ** node_map = _node_split_map.empty() ? nullptr : _node_split_map.data(); + pll_unode_t ** node_map = _split_node_map.empty() ? nullptr : _split_node_map.data(); pllmod_utree_draw_support(_pll_utree.get(), _support.data(), node_map, support_in_pct ? support_fmt_pct : support_fmt_prop); diff --git a/src/bootstrap/SupportTree.hpp b/src/bootstrap/SupportTree.hpp index 0bb67435..a0cca24c 100644 --- a/src/bootstrap/SupportTree.hpp +++ b/src/bootstrap/SupportTree.hpp @@ -34,7 +34,7 @@ class SupportTree : public Tree protected: size_t _num_bs_trees; bitv_hashtable_t* _pll_splits_hash; - std::vector _node_split_map; + std::vector _split_node_map; doubleVector _support; }; diff --git a/src/bootstrap/TransferBootstrapTree.cpp b/src/bootstrap/TransferBootstrapTree.cpp index 02a700fe..0be0e81f 100644 --- a/src/bootstrap/TransferBootstrapTree.cpp +++ b/src/bootstrap/TransferBootstrapTree.cpp @@ -11,11 +11,11 @@ TransferBootstrapTree bstree(tree, true, 1., TBE_DO_TABLE | TBE_DO_OTHER); TransferBootstrapTree bstree(tree, true, 1., false, true, false); */ -TransferBootstrapTree::TransferBootstrapTree(const Tree& tree, bool naive, unsigned int d = 0, bool doTable = false, bool doArray = false, bool doTree = false) : +TransferBootstrapTree::TransferBootstrapTree(const Tree& tree, bool naive, unsigned int d, bool doTable, bool doArray, bool doTree) : SupportTree (tree), _split_info(nullptr), _naive_method(naive) { assert(num_splits() > 0); - _node_split_map.resize(num_splits()); + _split_node_map.resize(num_splits()); /* extract reference tree splits and add them into hashtable */ add_tree(pll_utree_root()); @@ -23,21 +23,27 @@ TransferBootstrapTree::TransferBootstrapTree(const Tree& tree, bool naive, unsig if (!_naive_method) { _split_info = pllmod_utree_tbe_nature_init((pll_unode_t*) &pll_utree_root(), _num_tips, - (const pll_unode_t**) _node_split_map.data()); + (const pll_unode_t**) _split_node_map.data()); if (doTable || doArray || doTree) { _extra_info = pllmod_tbe_extra_info_create(num_splits(), _num_tips, doTable, doArray, doTree); } } } -pllmod_tbe_extra_info_t* TransferBootstrapTree::get_extra_info() { +const std::vector TransferBootstrapTree::get_split_node_map() const { + return _split_node_map; +} + +pllmod_tbe_extra_info_t* TransferBootstrapTree::get_extra_info() const { return _extra_info; } +/* void TransferBootstrapTree::collect_support() { SupportTree::collect_support(); // do the postprocessing of extra info } +*/ TransferBootstrapTree::~TransferBootstrapTree() { @@ -54,7 +60,7 @@ void TransferBootstrapTree::add_tree(const pll_unode_t& root) if (ref_tree) { - _ref_splits = extract_splits_from_tree(root, _node_split_map.data()); + _ref_splits = extract_splits_from_tree(root, _split_node_map.data()); add_splits_to_hashtable(_ref_splits, support, 0); } diff --git a/src/bootstrap/TransferBootstrapTree.hpp b/src/bootstrap/TransferBootstrapTree.hpp index 79b6c273..525dc706 100644 --- a/src/bootstrap/TransferBootstrapTree.hpp +++ b/src/bootstrap/TransferBootstrapTree.hpp @@ -10,7 +10,8 @@ class TransferBootstrapTree : public SupportTree virtual ~TransferBootstrapTree(); void postprocess_extra(); //... - pllmod_tbe_extra_info_t* get_extra_info(); + pllmod_tbe_extra_info_t* get_extra_info() const; + const std::vector get_split_node_map() const; protected: virtual void add_tree(const pll_unode_t& root); diff --git a/src/io/TBEExtraArrayStream.cpp b/src/io/TBEExtraArrayStream.cpp index 20d0241b..e1088cf6 100644 --- a/src/io/TBEExtraArrayStream.cpp +++ b/src/io/TBEExtraArrayStream.cpp @@ -3,12 +3,12 @@ using namespace std; -TBEExtraArrayStream& operator<<(NewickStream& stream, const TransferBootstrapTree& tree) +TBEExtraArrayStream& operator<<(TBEExtraArrayStream& stream, const TransferBootstrapTree& tree) { pllmod_tbe_extra_info_t* extra_info = tree.get_extra_info(); //... - auto print_cb = stream.brlens() ? newick_print_cb : newick_name_cb; + /*auto print_cb = stream.brlens() ? newick_print_cb : newick_name_cb; char * newick_str = pll_utree_export_newick(&root, print_cb); if (newick_str) { @@ -19,7 +19,7 @@ TBEExtraArrayStream& operator<<(NewickStream& stream, const TransferBootstrapTre { assert(pll_errno); libpll_check_error("Failed to generate Newick"); - } + }*/ return stream; } diff --git a/src/io/TBEExtraTableStream.cpp b/src/io/TBEExtraTableStream.cpp index 19263425..bb89b448 100644 --- a/src/io/TBEExtraTableStream.cpp +++ b/src/io/TBEExtraTableStream.cpp @@ -3,12 +3,12 @@ using namespace std; -TBEExtraTableStream& operator<<(NewickStream& stream, const TransferBootstrapTree& tree) +TBEExtraTableStream& operator<<(TBEExtraTableStream& stream, const TransferBootstrapTree& tree) { pllmod_tbe_extra_info_t* extra_info = tree.get_extra_info(); //... - auto print_cb = stream.brlens() ? newick_print_cb : newick_name_cb; + /*auto print_cb = stream.brlens() ? newick_print_cb : newick_name_cb; char * newick_str = pll_utree_export_newick(&root, print_cb); if (newick_str) { @@ -19,7 +19,7 @@ TBEExtraTableStream& operator<<(NewickStream& stream, const TransferBootstrapTre { assert(pll_errno); libpll_check_error("Failed to generate Newick"); - } + }*/ return stream; } diff --git a/src/io/TBEExtraTreeStream.cpp b/src/io/TBEExtraTreeStream.cpp index e112be03..9619a826 100644 --- a/src/io/TBEExtraTreeStream.cpp +++ b/src/io/TBEExtraTreeStream.cpp @@ -3,12 +3,15 @@ using namespace std; -TBEExtraTreeStream& operator<<(NewickStream& stream, const TransferBootstrapTree& tree) +TBEExtraTreeStream& operator<<(TBEExtraTreeStream& stream, const TransferBootstrapTree& tree) { pllmod_tbe_extra_info_t* extra_info = tree.get_extra_info(); + const std::vector split_node_map = tree.get_split_node_map(); //... - auto print_cb = stream.brlens() ? newick_print_cb : newick_name_cb; + tree.pll_utree(); + + /*auto print_cb = stream.brlens() ? newick_print_cb : newick_name_cb; char * newick_str = pll_utree_export_newick(&root, print_cb); if (newick_str) { @@ -19,7 +22,7 @@ TBEExtraTreeStream& operator<<(NewickStream& stream, const TransferBootstrapTree { assert(pll_errno); libpll_check_error("Failed to generate Newick"); - } + }*/ return stream; } diff --git a/src/io/file_io.hpp b/src/io/file_io.hpp index 19600f0c..19e92a7d 100644 --- a/src/io/file_io.hpp +++ b/src/io/file_io.hpp @@ -187,6 +187,10 @@ RaxmlPartitionStream& operator<<(RaxmlPartitionStream& stream, const Partitioned AncestralProbStream& operator<<(AncestralProbStream& stream, const AncestralStates& ancestral); AncestralStateStream& operator<<(AncestralStateStream& stream, const AncestralStates& ancestral); +TBEExtraTableStream& operator<<(TBEExtraTableStream& stream, const TransferBootstrapTree& tree); +TBEExtraArrayStream& operator<<(TBEExtraArrayStream& stream, const TransferBootstrapTree& tree); +TBEExtraTreeStream& operator<<(TBEExtraTreeStream& stream, const TransferBootstrapTree& tree); + std::string to_newick_string_rooted(const Tree& tree, double root_brlen = 0.0); #endif /* RAXML_FILE_IO_HPP_ */ diff --git a/src/main.cpp b/src/main.cpp index 51560864..dd1df69f 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1811,18 +1811,18 @@ void print_final_output(const RaxmlInstance& instance, const Checkpoint& checkp) if (opts.tbe_extra_table) { auto extra_table_file = opts.tbe_extra_table_file(); TBEExtraTableStream tbeExtraTable(extra_table_file); - tbeExtraTable << *it.second; + tbeExtraTable << *dynamic_cast(it.second.get()); } - if (opts.tbe_extra_array) { + /*if (opts.tbe_extra_array) { auto extra_array_file = opts.tbe_extra_array_file(); TBEExtraArrayStream tbeExtraArray(extra_array_file); - tbeExtraArray << *it.second; + tbeExtraArray << dynamic_cast(it.second); } if (opts.tbe_extra_tree) { auto extra_tree_file = opts.tbe_extra_tree_file(); TBEExtraTreeStream tbeExtraTree(extra_tree_file); - tbeExtraTree << *it.second; - } + tbeExtraTree << dynamic_cast(*it.second); + }*/ } } } From 4b5d3be2b721aabdd24eceada28c0683c3defd6d Mon Sep 17 00:00:00 2001 From: Sarah Lutteropp Date: Wed, 12 Jun 2019 14:28:08 +0200 Subject: [PATCH 04/31] updated submodule --- libs/pll-modules | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/pll-modules b/libs/pll-modules index 398281c8..8c3f3283 160000 --- a/libs/pll-modules +++ b/libs/pll-modules @@ -1 +1 @@ -Subproject commit 398281c8b7770640f1f3c97f260c29c64656aa30 +Subproject commit 8c3f328393587c24440e5a25eefbd3cc90a9a5fa From 799129606ab52cd8428df0c2df06d2977a30197d Mon Sep 17 00:00:00 2001 From: Sarah Lutteropp Date: Wed, 12 Jun 2019 14:48:21 +0200 Subject: [PATCH 05/31] implemented basic tbe extra table and tbe extra array output --- src/io/TBEExtraArrayStream.cpp | 16 +++------------- src/io/TBEExtraTableStream.cpp | 21 ++++++++------------- 2 files changed, 11 insertions(+), 26 deletions(-) diff --git a/src/io/TBEExtraArrayStream.cpp b/src/io/TBEExtraArrayStream.cpp index e1088cf6..7268671a 100644 --- a/src/io/TBEExtraArrayStream.cpp +++ b/src/io/TBEExtraArrayStream.cpp @@ -6,20 +6,10 @@ using namespace std; TBEExtraArrayStream& operator<<(TBEExtraArrayStream& stream, const TransferBootstrapTree& tree) { pllmod_tbe_extra_info_t* extra_info = tree.get_extra_info(); - //... - - /*auto print_cb = stream.brlens() ? newick_print_cb : newick_name_cb; - char * newick_str = pll_utree_export_newick(&root, print_cb); - if (newick_str) - { - stream << newick_str << std::endl; - free(newick_str); + stream << "taxon_id;taxon_transfer_stat\n"; + for (size_t i = 0; i < tree.num_tips(); ++i) { + stream << i << ";" << (double) (extra_info->extra_taxa_array[i]) / extra_info->num_close_enough_branches << "\n"; } - else - { - assert(pll_errno); - libpll_check_error("Failed to generate Newick"); - }*/ return stream; } diff --git a/src/io/TBEExtraTableStream.cpp b/src/io/TBEExtraTableStream.cpp index bb89b448..450a5321 100644 --- a/src/io/TBEExtraTableStream.cpp +++ b/src/io/TBEExtraTableStream.cpp @@ -6,20 +6,15 @@ using namespace std; TBEExtraTableStream& operator<<(TBEExtraTableStream& stream, const TransferBootstrapTree& tree) { pllmod_tbe_extra_info_t* extra_info = tree.get_extra_info(); - //... - - /*auto print_cb = stream.brlens() ? newick_print_cb : newick_name_cb; - char * newick_str = pll_utree_export_newick(&root, print_cb); - if (newick_str) - { - stream << newick_str << std::endl; - free(newick_str); + for (size_t i = 0; i < tree.num_tips(); ++i) { + for (size_t j = 0; j < tree.num_splits(); ++i) { + stream << (double) (extra_info->extra_taxa_table[j][i]) / extra_info->num_bs_trees; + if (j < tree.num_splits() - 1) { + stream << "\t"; + } + } + stream << "\n"; } - else - { - assert(pll_errno); - libpll_check_error("Failed to generate Newick"); - }*/ return stream; } From 641c26e0c16d542bfe072abaa4c944002ce039a7 Mon Sep 17 00:00:00 2001 From: Sarah Lutteropp Date: Wed, 12 Jun 2019 15:32:49 +0200 Subject: [PATCH 06/31] adapted to this weird cutoff value from booster --- libs/pll-modules | 2 +- src/Options.hpp | 4 ++-- src/bootstrap/TransferBootstrapTree.cpp | 8 ++++++-- src/bootstrap/TransferBootstrapTree.hpp | 3 ++- src/io/TBEExtraTreeStream.cpp | 1 + 5 files changed, 12 insertions(+), 6 deletions(-) diff --git a/libs/pll-modules b/libs/pll-modules index 8c3f3283..ec3f0552 160000 --- a/libs/pll-modules +++ b/libs/pll-modules @@ -1 +1 @@ -Subproject commit 8c3f328393587c24440e5a25eefbd3cc90a9a5fa +Subproject commit ec3f0552f47511e316f3b3ba1da64275c8e6d603 diff --git a/src/Options.hpp b/src/Options.hpp index 69f59b9d..91040935 100644 --- a/src/Options.hpp +++ b/src/Options.hpp @@ -43,7 +43,7 @@ class Options spr_cutoff(1.0), brlen_linkage(PLLMOD_COMMON_BRLEN_SCALED), brlen_opt_method(PLLMOD_OPT_BLO_NEWTON_FAST), brlen_min(RAXML_BRLEN_MIN), brlen_max(RAXML_BRLEN_MAX), - tbe_extra_cutoff(0), tbe_extra_table(false), tbe_extra_array(false), tbe_extra_tree(false), + tbe_extra_cutoff(0.3), tbe_extra_table(false), tbe_extra_array(false), tbe_extra_tree(false), num_searches(1), terrace_maxsize(100), num_bootstraps(1000), bootstop_criterion(BootstopCriterion::none), bootstop_cutoff(0.03), bootstop_interval(RAXML_BOOTSTOP_INTERVAL), bootstop_permutations(RAXML_BOOTSTOP_PERMUTES), @@ -86,7 +86,7 @@ class Options int brlen_opt_method; double brlen_min; double brlen_max; - unsigned int tbe_extra_cutoff; + double tbe_extra_cutoff; bool tbe_extra_table; bool tbe_extra_array; bool tbe_extra_tree; diff --git a/src/bootstrap/TransferBootstrapTree.cpp b/src/bootstrap/TransferBootstrapTree.cpp index 0be0e81f..6fa0e2d8 100644 --- a/src/bootstrap/TransferBootstrapTree.cpp +++ b/src/bootstrap/TransferBootstrapTree.cpp @@ -11,7 +11,7 @@ TransferBootstrapTree bstree(tree, true, 1., TBE_DO_TABLE | TBE_DO_OTHER); TransferBootstrapTree bstree(tree, true, 1., false, true, false); */ -TransferBootstrapTree::TransferBootstrapTree(const Tree& tree, bool naive, unsigned int d, bool doTable, bool doArray, bool doTree) : +TransferBootstrapTree::TransferBootstrapTree(const Tree& tree, bool naive, double tbe_cutoff, bool doTable, bool doArray, bool doTree) : SupportTree (tree), _split_info(nullptr), _naive_method(naive) { assert(num_splits() > 0); @@ -25,7 +25,7 @@ TransferBootstrapTree::TransferBootstrapTree(const Tree& tree, bool naive, unsig _split_info = pllmod_utree_tbe_nature_init((pll_unode_t*) &pll_utree_root(), _num_tips, (const pll_unode_t**) _split_node_map.data()); if (doTable || doArray || doTree) { - _extra_info = pllmod_tbe_extra_info_create(num_splits(), _num_tips, doTable, doArray, doTree); + _extra_info = pllmod_tbe_extra_info_create(num_splits(), _num_tips, tbe_cutoff, doTable, doArray, doTree); } } } @@ -38,6 +38,10 @@ pllmod_tbe_extra_info_t* TransferBootstrapTree::get_extra_info() const { return _extra_info; } +pllmod_tbe_split_info_t* TransferBootstrapTree::get_split_info() const { + return _split_info; +} + /* void TransferBootstrapTree::collect_support() { SupportTree::collect_support(); diff --git a/src/bootstrap/TransferBootstrapTree.hpp b/src/bootstrap/TransferBootstrapTree.hpp index 525dc706..eeba2c08 100644 --- a/src/bootstrap/TransferBootstrapTree.hpp +++ b/src/bootstrap/TransferBootstrapTree.hpp @@ -6,12 +6,13 @@ class TransferBootstrapTree : public SupportTree { public: - TransferBootstrapTree(const Tree& tree, bool naive = false, unsigned int d = 0, bool doTable = false, bool doArray = false, bool doTree = false); + TransferBootstrapTree(const Tree& tree, bool naive = false, double tbe_cutoff = 0.3, bool doTable = false, bool doArray = false, bool doTree = false); virtual ~TransferBootstrapTree(); void postprocess_extra(); //... pllmod_tbe_extra_info_t* get_extra_info() const; const std::vector get_split_node_map() const; + pllmod_tbe_split_info_t* get_split_info() const; protected: virtual void add_tree(const pll_unode_t& root); diff --git a/src/io/TBEExtraTreeStream.cpp b/src/io/TBEExtraTreeStream.cpp index 9619a826..7f0b9d02 100644 --- a/src/io/TBEExtraTreeStream.cpp +++ b/src/io/TBEExtraTreeStream.cpp @@ -7,6 +7,7 @@ TBEExtraTreeStream& operator<<(TBEExtraTreeStream& stream, const TransferBootstr { pllmod_tbe_extra_info_t* extra_info = tree.get_extra_info(); const std::vector split_node_map = tree.get_split_node_map(); + pllmod_tbe_split_info_t* split_info = tree.get_split_info(); //... tree.pll_utree(); From 64a5810b9659be1ccaf57db33af2d867581382e8 Mon Sep 17 00:00:00 2001 From: Sarah Lutteropp Date: Wed, 12 Jun 2019 15:33:32 +0200 Subject: [PATCH 07/31] uncommented some code --- src/main.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index dd1df69f..f19cc96d 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1813,7 +1813,7 @@ void print_final_output(const RaxmlInstance& instance, const Checkpoint& checkp) TBEExtraTableStream tbeExtraTable(extra_table_file); tbeExtraTable << *dynamic_cast(it.second.get()); } - /*if (opts.tbe_extra_array) { + if (opts.tbe_extra_array) { auto extra_array_file = opts.tbe_extra_array_file(); TBEExtraArrayStream tbeExtraArray(extra_array_file); tbeExtraArray << dynamic_cast(it.second); @@ -1822,7 +1822,7 @@ void print_final_output(const RaxmlInstance& instance, const Checkpoint& checkp) auto extra_tree_file = opts.tbe_extra_tree_file(); TBEExtraTreeStream tbeExtraTree(extra_tree_file); tbeExtraTree << dynamic_cast(*it.second); - }*/ + } } } } From 674a3105551303e43d6d1ef55023f88f80b71eab Mon Sep 17 00:00:00 2001 From: Sarah Lutteropp Date: Wed, 12 Jun 2019 15:34:23 +0200 Subject: [PATCH 08/31] fixed dynamic casts --- src/main.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index f19cc96d..8d4eb682 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1816,12 +1816,12 @@ void print_final_output(const RaxmlInstance& instance, const Checkpoint& checkp) if (opts.tbe_extra_array) { auto extra_array_file = opts.tbe_extra_array_file(); TBEExtraArrayStream tbeExtraArray(extra_array_file); - tbeExtraArray << dynamic_cast(it.second); + tbeExtraArray << *dynamic_cast(it.second.get()); } if (opts.tbe_extra_tree) { auto extra_tree_file = opts.tbe_extra_tree_file(); TBEExtraTreeStream tbeExtraTree(extra_tree_file); - tbeExtraTree << dynamic_cast(*it.second); + tbeExtraTree << *dynamic_cast(it.second.get()); } } } From 160f2d2ffad0aa88f0bacae50a45fdbac5e3459a Mon Sep 17 00:00:00 2001 From: Sarah Lutteropp Date: Wed, 12 Jun 2019 15:56:42 +0200 Subject: [PATCH 09/31] added dirty TBE extra tree output --- src/io/TBEExtraTreeStream.cpp | 149 ++++++++++++++++++++++++++++++++-- 1 file changed, 144 insertions(+), 5 deletions(-) diff --git a/src/io/TBEExtraTreeStream.cpp b/src/io/TBEExtraTreeStream.cpp index 7f0b9d02..bdaf743e 100644 --- a/src/io/TBEExtraTreeStream.cpp +++ b/src/io/TBEExtraTreeStream.cpp @@ -2,18 +2,157 @@ using namespace std; +char * newick_utree_recurse(const pll_unode_t * root, int level, + pllmod_tbe_extra_info_t* extra_info, + pllmod_tbe_split_info_t* split_info, + const std::vector& node_split_map + ) +{ + char * newick; + int size_alloced = 0; + assert(root != NULL); + if (!root->next) // leaf node + { + size_alloced = asprintf(&newick, "%s:%f", root->label, root->length); + } + else + { + const pll_unode_t * start = root->next; + const pll_unode_t * snode = start; + char * cur_newick; + do + { + char * subtree = newick_utree_recurse(snode->back, level+1, extra_info, split_info, node_split_map); + if (subtree == NULL) + { + pll_errno = PLL_ERROR_MEM_ALLOC; + snprintf(pll_errmsg, 200, "Unable to allocate enough memory."); + return NULL; + } + + if (snode == start) + { + cur_newick = subtree; + } + else + { + char * temp = cur_newick; + size_alloced = asprintf(&cur_newick, + "%s,%s", + temp, + subtree); + free(temp); + free(subtree); + } + snode = snode->next; + } + while(snode != root); + + if (level > 0) + { + unsigned int id = node_split_map[root->clv_index]; + double avg_dist = extra_info->extra_avg_dist_array[id] / (double) extra_info->num_bs_trees; + unsigned int depth = split_info[id].p; + + size_alloced = asprintf(&newick, + "(%s)%d|%f|%d:%f", + cur_newick, + id, + avg_dist, + depth, + root->length); + free(cur_newick); + } + else + newick = cur_newick; + } + + if (size_alloced < 0) + { + pll_errno = PLL_ERROR_MEM_ALLOC; + snprintf(pll_errmsg, 200, "memory allocation during newick export failed"); + return NULL; + } + + return newick; +} + +char * utree_export_newick(const pll_unode_t * root, + int export_rooted, + double root_brlen, + pllmod_tbe_extra_info_t* extra_info, + pllmod_tbe_split_info_t* split_info, + const std::vector& node_split_map + ) +{ + char * newick; + char * subtree1; + char * subtree2; + int size_alloced; + + if (!root) return NULL; + + if (!root->next) root = root->back; + + unsigned int id = node_split_map[root->clv_index]; + double avg_dist = extra_info->extra_avg_dist_array[id] / (double) extra_info->num_bs_trees; + unsigned int depth = split_info[id].p; + + if (export_rooted) + { + subtree1 = newick_utree_recurse(root->back, 1, extra_info, split_info, node_split_map); + subtree2 = newick_utree_recurse(root, 0, extra_info, split_info, node_split_map); + + size_alloced = asprintf(&newick, + "(%s,(%s)%d|%f|%d:%f):0.0;", + subtree1, + subtree2, + id, + avg_dist, + depth, + root_brlen); + } + else + { + subtree1 = newick_utree_recurse(root->back, 1, extra_info, split_info, node_split_map); + subtree2 = newick_utree_recurse(root, 0, extra_info, split_info, node_split_map); + + size_alloced = asprintf(&newick, + "(%s,%s)%d|%f|%d:0.0;", + subtree1, + subtree2, + id, + avg_dist, + depth); + } + + free(subtree1); + free(subtree2); + + if (size_alloced < 0) + { + pll_errno = PLL_ERROR_MEM_ALLOC; + snprintf(pll_errmsg, 200, "memory allocation during newick export failed"); + return NULL; + } + +// printf("newick: %s\n", newick); + + return (newick); +} TBEExtraTreeStream& operator<<(TBEExtraTreeStream& stream, const TransferBootstrapTree& tree) { pllmod_tbe_extra_info_t* extra_info = tree.get_extra_info(); const std::vector split_node_map = tree.get_split_node_map(); pllmod_tbe_split_info_t* split_info = tree.get_split_info(); - //... - + std::vector node_split_map(split_node_map.size()); + for (size_t i = 0; i < split_node_map.size(); ++i) { + node_split_map[split_node_map[i]->clv_index] = i; + } tree.pll_utree(); - /*auto print_cb = stream.brlens() ? newick_print_cb : newick_name_cb; - char * newick_str = pll_utree_export_newick(&root, print_cb); + char * newick_str = utree_export_newick(&tree.pll_utree_root(), 0, 0, extra_info, split_info, node_split_map); if (newick_str) { stream << newick_str << std::endl; @@ -23,7 +162,7 @@ TBEExtraTreeStream& operator<<(TBEExtraTreeStream& stream, const TransferBootstr { assert(pll_errno); libpll_check_error("Failed to generate Newick"); - }*/ + } return stream; } From c48a749ffcbcdde19956bf426248d7a6b067c527 Mon Sep 17 00:00:00 2001 From: Sarah Lutteropp Date: Wed, 12 Jun 2019 16:48:45 +0200 Subject: [PATCH 10/31] fixed extra table output and tbe computation call --- src/CommandLineParser.cpp | 1 - src/bootstrap/TransferBootstrapTree.cpp | 4 ++-- src/io/TBEExtraTableStream.cpp | 13 ++++++++---- src/main.cpp | 27 ++++++++++++++++--------- 4 files changed, 29 insertions(+), 16 deletions(-) diff --git a/src/CommandLineParser.cpp b/src/CommandLineParser.cpp index 234d7dc5..72488bc9 100644 --- a/src/CommandLineParser.cpp +++ b/src/CommandLineParser.cpp @@ -745,7 +745,6 @@ void CommandLineParser::parse_options(int argc, char** argv, Options &opts) opts.tbe_extra_array = true; else if (eopt == "tbe_extra_tree") opts.tbe_extra_tree = true; - // TODO: put TBE bool flags here else throw InvalidOptionValueException("Unknown extra option: " + string(optarg)); } diff --git a/src/bootstrap/TransferBootstrapTree.cpp b/src/bootstrap/TransferBootstrapTree.cpp index 6fa0e2d8..96bb93aa 100644 --- a/src/bootstrap/TransferBootstrapTree.cpp +++ b/src/bootstrap/TransferBootstrapTree.cpp @@ -79,8 +79,8 @@ void TransferBootstrapTree::add_tree(const pll_unode_t& root) pllmod_utree_tbe_naive(_ref_splits.get(), splits.get(), _num_tips, support.data()); else { - pllmod_utree_tbe_nature(_ref_splits.get(), splits.get(), (pll_unode_t*) &root, - _num_tips, support.data(), _split_info); + pllmod_utree_tbe_nature_extra(_ref_splits.get(), splits.get(), (pll_unode_t*) &root, + _num_tips, support.data(), _split_info, _extra_info); } add_splits_to_hashtable(_ref_splits, support, 1); diff --git a/src/io/TBEExtraTableStream.cpp b/src/io/TBEExtraTableStream.cpp index 450a5321..e7019aee 100644 --- a/src/io/TBEExtraTableStream.cpp +++ b/src/io/TBEExtraTableStream.cpp @@ -6,9 +6,16 @@ using namespace std; TBEExtraTableStream& operator<<(TBEExtraTableStream& stream, const TransferBootstrapTree& tree) { pllmod_tbe_extra_info_t* extra_info = tree.get_extra_info(); + if (!extra_info) { + throw std::runtime_error("Extra info is null"); + } + if (!extra_info->extra_taxa_table) { + throw std::runtime_error("Extra taxa table is null"); + } + double divideBy = extra_info->num_bs_trees * tree.num_splits(); for (size_t i = 0; i < tree.num_tips(); ++i) { - for (size_t j = 0; j < tree.num_splits(); ++i) { - stream << (double) (extra_info->extra_taxa_table[j][i]) / extra_info->num_bs_trees; + for (size_t j = 0; j < tree.num_splits(); ++j) { + stream << fixed << std::setprecision(10) << (double) (extra_info->extra_taxa_table[j][i]) / divideBy; if (j < tree.num_splits() - 1) { stream << "\t"; } @@ -17,5 +24,3 @@ TBEExtraTableStream& operator<<(TBEExtraTableStream& stream, const TransferBoots } return stream; } - - diff --git a/src/main.cpp b/src/main.cpp index 8d4eb682..7094c607 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1350,7 +1350,7 @@ void draw_bootstrap_support(RaxmlInstance& instance, Tree& ref_tree, const TreeC } else if (metric == BranchSupportMetric::tbe) { - sup_tree = make_shared(ref_tree, instance.opts.tbe_naive); + sup_tree = make_shared(ref_tree, instance.opts.tbe_naive, instance.opts.tbe_extra_cutoff, instance.opts.tbe_extra_table, instance.opts.tbe_extra_array, instance.opts.tbe_extra_tree); support_in_pct = false; } else @@ -1808,20 +1808,29 @@ void print_final_output(const RaxmlInstance& instance, const Checkpoint& checkp) if (it.first == BranchSupportMetric::tbe) { - if (opts.tbe_extra_table) { - auto extra_table_file = opts.tbe_extra_table_file(); - TBEExtraTableStream tbeExtraTable(extra_table_file); - tbeExtraTable << *dynamic_cast(it.second.get()); - } if (opts.tbe_extra_array) { auto extra_array_file = opts.tbe_extra_array_file(); TBEExtraArrayStream tbeExtraArray(extra_array_file); tbeExtraArray << *dynamic_cast(it.second.get()); + + LOG_INFO << "TBE extra array saved to: " << + sysutil_realpath(extra_array_file) << endl; } + if (opts.tbe_extra_table) { + auto extra_table_file = opts.tbe_extra_table_file(); + TBEExtraTableStream tbeExtraTable(extra_table_file); + tbeExtraTable << *dynamic_cast(it.second.get()); + + LOG_INFO << "TBE extra table saved to: " << + sysutil_realpath(extra_table_file) << endl; + } if (opts.tbe_extra_tree) { - auto extra_tree_file = opts.tbe_extra_tree_file(); - TBEExtraTreeStream tbeExtraTree(extra_tree_file); - tbeExtraTree << *dynamic_cast(it.second.get()); + auto extra_tree_file = opts.tbe_extra_tree_file(); + TBEExtraTreeStream tbeExtraTree(extra_tree_file); + tbeExtraTree << *dynamic_cast(it.second.get()); + + LOG_INFO << "TBE extra tree saved to: " << + sysutil_realpath(extra_tree_file) << endl; } } } From 7ff200071c0238ba01993bdf88504e9d249b7bc3 Mon Sep 17 00:00:00 2001 From: Sarah Lutteropp Date: Wed, 12 Jun 2019 16:50:34 +0200 Subject: [PATCH 11/31] fixed tbe extra tree output --- src/io/TBEExtraTreeStream.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/io/TBEExtraTreeStream.cpp b/src/io/TBEExtraTreeStream.cpp index bdaf743e..b8bd917f 100644 --- a/src/io/TBEExtraTreeStream.cpp +++ b/src/io/TBEExtraTreeStream.cpp @@ -146,11 +146,10 @@ TBEExtraTreeStream& operator<<(TBEExtraTreeStream& stream, const TransferBootstr pllmod_tbe_extra_info_t* extra_info = tree.get_extra_info(); const std::vector split_node_map = tree.get_split_node_map(); pllmod_tbe_split_info_t* split_info = tree.get_split_info(); - std::vector node_split_map(split_node_map.size()); + std::vector node_split_map(tree.num_nodes()); for (size_t i = 0; i < split_node_map.size(); ++i) { node_split_map[split_node_map[i]->clv_index] = i; } - tree.pll_utree(); char * newick_str = utree_export_newick(&tree.pll_utree_root(), 0, 0, extra_info, split_info, node_split_map); if (newick_str) From b87c1369d8b16c5609e370d6db613467338c84c6 Mon Sep 17 00:00:00 2001 From: Sarah Lutteropp Date: Wed, 12 Jun 2019 18:17:54 +0200 Subject: [PATCH 12/31] changed extra taxa table --- libs/pll-modules | 2 +- src/io/TBEExtraArrayStream.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/libs/pll-modules b/libs/pll-modules index ec3f0552..96629b49 160000 --- a/libs/pll-modules +++ b/libs/pll-modules @@ -1 +1 @@ -Subproject commit ec3f0552f47511e316f3b3ba1da64275c8e6d603 +Subproject commit 96629b49b5834a9707af69c7e56469a5a2598965 diff --git a/src/io/TBEExtraArrayStream.cpp b/src/io/TBEExtraArrayStream.cpp index 7268671a..46563268 100644 --- a/src/io/TBEExtraArrayStream.cpp +++ b/src/io/TBEExtraArrayStream.cpp @@ -6,9 +6,9 @@ using namespace std; TBEExtraArrayStream& operator<<(TBEExtraArrayStream& stream, const TransferBootstrapTree& tree) { pllmod_tbe_extra_info_t* extra_info = tree.get_extra_info(); - stream << "taxon_id;taxon_transfer_stat\n"; + stream << "taxon_label;taxon_transfer_stat\n"; for (size_t i = 0; i < tree.num_tips(); ++i) { - stream << i << ";" << (double) (extra_info->extra_taxa_array[i]) / extra_info->num_close_enough_branches << "\n"; + stream << tree.tip_labels_list()[i] << ";" << (double) (extra_info->extra_taxa_array[i]) / (double) extra_info->num_bs_trees << "\n"; } return stream; } From 56b988b7993584396e69a14898b9d6562a7039ca Mon Sep 17 00:00:00 2001 From: Sarah Lutteropp Date: Mon, 17 Jun 2019 16:32:14 +0200 Subject: [PATCH 13/31] updated submodule --- libs/pll-modules | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/pll-modules b/libs/pll-modules index 96629b49..3a150aaf 160000 --- a/libs/pll-modules +++ b/libs/pll-modules @@ -1 +1 @@ -Subproject commit 96629b49b5834a9707af69c7e56469a5a2598965 +Subproject commit 3a150aaf9ff93e3f089a5131e7a412697ddf9a6b From a974b0a615c6fc9059a25e07bd959845c66528fc Mon Sep 17 00:00:00 2001 From: Sarah Lutteropp Date: Mon, 17 Jun 2019 18:08:32 +0200 Subject: [PATCH 14/31] updated submodule and fixed tbe extra outputs --- libs/pll-modules | 2 +- src/io/TBEExtraArrayStream.cpp | 2 +- src/io/TBEExtraTableStream.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/libs/pll-modules b/libs/pll-modules index 3a150aaf..5b40e2d5 160000 --- a/libs/pll-modules +++ b/libs/pll-modules @@ -1 +1 @@ -Subproject commit 3a150aaf9ff93e3f089a5131e7a412697ddf9a6b +Subproject commit 5b40e2d58f08fff8e781927af100a919817c1cb5 diff --git a/src/io/TBEExtraArrayStream.cpp b/src/io/TBEExtraArrayStream.cpp index 46563268..71b6163b 100644 --- a/src/io/TBEExtraArrayStream.cpp +++ b/src/io/TBEExtraArrayStream.cpp @@ -8,7 +8,7 @@ TBEExtraArrayStream& operator<<(TBEExtraArrayStream& stream, const TransferBoots pllmod_tbe_extra_info_t* extra_info = tree.get_extra_info(); stream << "taxon_label;taxon_transfer_stat\n"; for (size_t i = 0; i < tree.num_tips(); ++i) { - stream << tree.tip_labels_list()[i] << ";" << (double) (extra_info->extra_taxa_array[i]) / (double) extra_info->num_bs_trees << "\n"; + stream << tree.tip_labels_list()[i] << ";" << (double) (extra_info->extra_taxa_array[i] * 100) / (double) extra_info->num_bs_trees << "\n"; } return stream; } diff --git a/src/io/TBEExtraTableStream.cpp b/src/io/TBEExtraTableStream.cpp index e7019aee..234921bf 100644 --- a/src/io/TBEExtraTableStream.cpp +++ b/src/io/TBEExtraTableStream.cpp @@ -15,7 +15,7 @@ TBEExtraTableStream& operator<<(TBEExtraTableStream& stream, const TransferBoots double divideBy = extra_info->num_bs_trees * tree.num_splits(); for (size_t i = 0; i < tree.num_tips(); ++i) { for (size_t j = 0; j < tree.num_splits(); ++j) { - stream << fixed << std::setprecision(10) << (double) (extra_info->extra_taxa_table[j][i]) / divideBy; + stream << fixed << std::setprecision(6) << (double) (extra_info->extra_taxa_table[j][i]) / divideBy; if (j < tree.num_splits() - 1) { stream << "\t"; } From f9ba4f9eeacd5bbafa05d3fc609637925b428490 Mon Sep 17 00:00:00 2001 From: Sarah Lutteropp Date: Mon, 17 Jun 2019 18:37:18 +0200 Subject: [PATCH 15/31] made tbe extra table output more like in booster --- src/io/TBEExtraArrayStream.cpp | 4 ++-- src/io/TBEExtraTableStream.cpp | 16 +++++++++++++--- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/io/TBEExtraArrayStream.cpp b/src/io/TBEExtraArrayStream.cpp index 71b6163b..3e0660c7 100644 --- a/src/io/TBEExtraArrayStream.cpp +++ b/src/io/TBEExtraArrayStream.cpp @@ -6,9 +6,9 @@ using namespace std; TBEExtraArrayStream& operator<<(TBEExtraArrayStream& stream, const TransferBootstrapTree& tree) { pllmod_tbe_extra_info_t* extra_info = tree.get_extra_info(); - stream << "taxon_label;taxon_transfer_stat\n"; + stream << "Taxon\ttIndex\n"; for (size_t i = 0; i < tree.num_tips(); ++i) { - stream << tree.tip_labels_list()[i] << ";" << (double) (extra_info->extra_taxa_array[i] * 100) / (double) extra_info->num_bs_trees << "\n"; + stream << tree.tip_labels_list()[i] << "\t" << (double) (extra_info->extra_taxa_array[i] * 100) / (double) extra_info->num_bs_trees << "\n"; } return stream; } diff --git a/src/io/TBEExtraTableStream.cpp b/src/io/TBEExtraTableStream.cpp index 234921bf..bea5edfe 100644 --- a/src/io/TBEExtraTableStream.cpp +++ b/src/io/TBEExtraTableStream.cpp @@ -13,10 +13,20 @@ TBEExtraTableStream& operator<<(TBEExtraTableStream& stream, const TransferBoots throw std::runtime_error("Extra taxa table is null"); } double divideBy = extra_info->num_bs_trees * tree.num_splits(); + stream << "Edge\tSupport\t"; for (size_t i = 0; i < tree.num_tips(); ++i) { - for (size_t j = 0; j < tree.num_splits(); ++j) { - stream << fixed << std::setprecision(6) << (double) (extra_info->extra_taxa_table[j][i]) / divideBy; - if (j < tree.num_splits() - 1) { + stream << tree.tip_labels_list()[i]; + if (i < tree.num_tips() - 1) { + stream << "\t"; + } else { + stream << "\n"; + } + } + for (size_t i = 0; i < tree.num_splits(); ++i) { + stream << tree.get_split_node_map()[i]->clv_index << "\t" << "???" << "\t"; + for (size_t j = 0; j < tree.num_tips(); ++j) { + stream << fixed << std::setprecision(6) << (double) (extra_info->extra_taxa_table[i][j]) / divideBy; + if (j < tree.num_tips() - 1) { stream << "\t"; } } From 537e7bb7bac0e559df62aa36ebaca36570e775e1 Mon Sep 17 00:00:00 2001 From: Sarah Lutteropp Date: Tue, 18 Jun 2019 15:29:57 +0200 Subject: [PATCH 16/31] tbe extra table output now also prints support values --- src/bootstrap/SupportTree.cpp | 4 ++++ src/bootstrap/SupportTree.hpp | 2 ++ src/io/TBEExtraTableStream.cpp | 4 +++- 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/bootstrap/SupportTree.cpp b/src/bootstrap/SupportTree.cpp index 3df90a6a..962fcc8a 100644 --- a/src/bootstrap/SupportTree.cpp +++ b/src/bootstrap/SupportTree.cpp @@ -127,3 +127,7 @@ void SupportTree::draw_support(bool support_in_pct) LOG_DEBUG_TS << "Done!" << endl << endl; } + +const doubleVector& SupportTree::get_support() const { + return _support; +} diff --git a/src/bootstrap/SupportTree.hpp b/src/bootstrap/SupportTree.hpp index a0cca24c..7306898a 100644 --- a/src/bootstrap/SupportTree.hpp +++ b/src/bootstrap/SupportTree.hpp @@ -18,6 +18,8 @@ class SupportTree : public Tree void draw_support(bool support_in_pct = true); + const doubleVector& get_support() const; + protected: PllSplitSharedPtr extract_splits_from_tree(const pll_unode_t& root, pll_unode_t ** node_split_map); diff --git a/src/io/TBEExtraTableStream.cpp b/src/io/TBEExtraTableStream.cpp index bea5edfe..be4ea302 100644 --- a/src/io/TBEExtraTableStream.cpp +++ b/src/io/TBEExtraTableStream.cpp @@ -22,8 +22,10 @@ TBEExtraTableStream& operator<<(TBEExtraTableStream& stream, const TransferBoots stream << "\n"; } } + + auto support = tree.get_support(); for (size_t i = 0; i < tree.num_splits(); ++i) { - stream << tree.get_split_node_map()[i]->clv_index << "\t" << "???" << "\t"; + stream << tree.get_split_node_map()[i]->clv_index << "\t" << fixed << std::setprecision(6) << support[i] << "\t"; for (size_t j = 0; j < tree.num_tips(); ++j) { stream << fixed << std::setprecision(6) << (double) (extra_info->extra_taxa_table[i][j]) / divideBy; if (j < tree.num_tips() - 1) { From 7ae199f848590c3033cd9b606b8f669c811fc033 Mon Sep 17 00:00:00 2001 From: Sarah Lutteropp Date: Tue, 18 Jun 2019 15:32:26 +0200 Subject: [PATCH 17/31] updated submodule --- libs/pll-modules | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/pll-modules b/libs/pll-modules index 5b40e2d5..2dbe97bd 160000 --- a/libs/pll-modules +++ b/libs/pll-modules @@ -1 +1 @@ -Subproject commit 5b40e2d58f08fff8e781927af100a919817c1cb5 +Subproject commit 2dbe97bd7d000717fbcfdc36488e01ce1dc49d0a From cfce8961c41259df92c474b52059ed8ce2a40b97 Mon Sep 17 00:00:00 2001 From: Sarah Lutteropp Date: Tue, 18 Jun 2019 15:33:47 +0200 Subject: [PATCH 18/31] updated submodule --- libs/pll-modules | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/pll-modules b/libs/pll-modules index 2dbe97bd..703c1439 160000 --- a/libs/pll-modules +++ b/libs/pll-modules @@ -1 +1 @@ -Subproject commit 2dbe97bd7d000717fbcfdc36488e01ce1dc49d0a +Subproject commit 703c14394b9801a380826a9122e97df003ecdc2a From 318c1d2f0c3543575ab5e1018dbcd7f77558e90c Mon Sep 17 00:00:00 2001 From: Sarah Lutteropp Date: Fri, 21 Jun 2019 11:54:58 +0200 Subject: [PATCH 19/31] updated submoudle --- libs/pll-modules | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/pll-modules b/libs/pll-modules index 703c1439..c4011bc8 160000 --- a/libs/pll-modules +++ b/libs/pll-modules @@ -1 +1 @@ -Subproject commit 703c14394b9801a380826a9122e97df003ecdc2a +Subproject commit c4011bc8af260be9d009062a4577d1ccd8b18fc6 From 2f5ad4b3598441b3a420232af020bf3a2f925d20 Mon Sep 17 00:00:00 2001 From: Sarah Lutteropp Date: Mon, 1 Jul 2019 15:53:29 +0200 Subject: [PATCH 20/31] updated submodule, added OpenMP support --- CMakeLists.txt | 8 ++++---- libs/pll-modules | 2 +- src/ParallelContext.hpp | 11 +++++++++++ 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9854d9c6..a22bcccf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -39,10 +39,10 @@ endif() #set(CMAKE_CXX_EXTENSIONS OFF) # set these flags globally for all subprojects (libpll etc.) -set (CMAKE_CXX_FLAGS_DEBUG "-O3 -g" CACHE INTERNAL "") -set (CMAKE_CXX_FLAGS_RELEASE "-O3" CACHE INTERNAL "") -set (CMAKE_C_FLAGS_DEBUG "-O3 -g" CACHE INTERNAL "") -set (CMAKE_C_FLAGS_RELEASE "-O3" CACHE INTERNAL "") +set (CMAKE_CXX_FLAGS_DEBUG "-O3 -g -fopenmp" CACHE INTERNAL "") +set (CMAKE_CXX_FLAGS_RELEASE "-O3 -fopenmp" CACHE INTERNAL "") +set (CMAKE_C_FLAGS_DEBUG "-O3 -g -fopenmp" CACHE INTERNAL "") +set (CMAKE_C_FLAGS_RELEASE "-O3 -fopenmp" CACHE INTERNAL "") project (raxml-ng C CXX) diff --git a/libs/pll-modules b/libs/pll-modules index c4011bc8..22449937 160000 --- a/libs/pll-modules +++ b/libs/pll-modules @@ -1 +1 @@ -Subproject commit c4011bc8af260be9d009062a4577d1ccd8b18fc6 +Subproject commit 224499378c3e12e2efde0de2599fedcf83009905 diff --git a/src/ParallelContext.hpp b/src/ParallelContext.hpp index 9ee917c3..4ec6cd5f 100644 --- a/src/ParallelContext.hpp +++ b/src/ParallelContext.hpp @@ -51,6 +51,17 @@ class ParallelContext static void mpi_gather_custom(std::function prepare_send_cb, std::function process_recv_cb); + // WARNING: This function is like a private parking lot. Only the transfer bootstrap computation is allowed to use it. Wrongdoers will be punished. PLEASE REFACTOR ME. + static void pll_lock(bool b) + { + static std::mutex mtx; + if (b) { + mtx.lock(); + } else { + mtx.unlock(); + } + } + static bool master() { return proc_id() == 0; } static bool master_rank() { return _rank_id == 0; } static bool master_thread() { return _thread_id == 0; } From 15c6fadab2e2bd8e8473db273cb5c0adc611472b Mon Sep 17 00:00:00 2001 From: Sarah Lutteropp Date: Mon, 1 Jul 2019 16:34:36 +0200 Subject: [PATCH 21/31] updated submodule --- libs/pll-modules | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/pll-modules b/libs/pll-modules index 22449937..7aeb7138 160000 --- a/libs/pll-modules +++ b/libs/pll-modules @@ -1 +1 @@ -Subproject commit 224499378c3e12e2efde0de2599fedcf83009905 +Subproject commit 7aeb7138470502c5b4181c1d9aedf75df2811fa5 From 0243b312949015cc6d007cd45e0bd408b1687707 Mon Sep 17 00:00:00 2001 From: Sarah Lutteropp Date: Thu, 4 Jul 2019 17:02:39 +0200 Subject: [PATCH 22/31] added setting number of OpenMP threads with --threads option --- src/CommandLineParser.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/CommandLineParser.cpp b/src/CommandLineParser.cpp index 72488bc9..e4a52ef6 100644 --- a/src/CommandLineParser.cpp +++ b/src/CommandLineParser.cpp @@ -6,6 +6,10 @@ #include #endif +#if defined(_OPENMP) +#include +#endif + using namespace std; static struct option long_options[] = @@ -847,6 +851,10 @@ void CommandLineParser::parse_options(int argc, char** argv, Options &opts) } } +#if defined(_OPENMP) + omp_set_num_threads(opts.num_threads); +#endif + if (c != -1) exit(EXIT_FAILURE); From b5d64dd2322709386e367fcff522867a4a072d3b Mon Sep 17 00:00:00 2001 From: Sarah Lutteropp Date: Mon, 8 Jul 2019 13:25:35 +0200 Subject: [PATCH 23/31] added missing initialization of extra_info --- src/bootstrap/TransferBootstrapTree.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bootstrap/TransferBootstrapTree.cpp b/src/bootstrap/TransferBootstrapTree.cpp index 96bb93aa..769d935c 100644 --- a/src/bootstrap/TransferBootstrapTree.cpp +++ b/src/bootstrap/TransferBootstrapTree.cpp @@ -12,7 +12,7 @@ TransferBootstrapTree bstree(tree, true, 1., false, true, false); */ TransferBootstrapTree::TransferBootstrapTree(const Tree& tree, bool naive, double tbe_cutoff, bool doTable, bool doArray, bool doTree) : - SupportTree (tree), _split_info(nullptr), _naive_method(naive) + SupportTree (tree), _split_info(nullptr), _extra_info(nullptr), _naive_method(naive) { assert(num_splits() > 0); _split_node_map.resize(num_splits()); From fb57023ca637b6225272f3d1bde2ecf44aaff93d Mon Sep 17 00:00:00 2001 From: Sarah Lutteropp Date: Mon, 8 Jul 2019 13:25:52 +0200 Subject: [PATCH 24/31] updated submodule --- libs/pll-modules | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/pll-modules b/libs/pll-modules index 7aeb7138..e518b63a 160000 --- a/libs/pll-modules +++ b/libs/pll-modules @@ -1 +1 @@ -Subproject commit 7aeb7138470502c5b4181c1d9aedf75df2811fa5 +Subproject commit e518b63a23c9702310778cf5cd23a514dd44cc8e From 6b4e18163375f2368f85c7fbc0292f1b536cace4 Mon Sep 17 00:00:00 2001 From: Sarah Lutteropp Date: Mon, 8 Jul 2019 13:47:32 +0200 Subject: [PATCH 25/31] slightly faster table output --- src/io/TBEExtraTableStream.cpp | 37 +++++++++++++++++++--------------- 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/src/io/TBEExtraTableStream.cpp b/src/io/TBEExtraTableStream.cpp index be4ea302..1ff45858 100644 --- a/src/io/TBEExtraTableStream.cpp +++ b/src/io/TBEExtraTableStream.cpp @@ -7,32 +7,37 @@ TBEExtraTableStream& operator<<(TBEExtraTableStream& stream, const TransferBoots { pllmod_tbe_extra_info_t* extra_info = tree.get_extra_info(); if (!extra_info) { - throw std::runtime_error("Extra info is null"); + throw std::runtime_error("Extra info is null"); } if (!extra_info->extra_taxa_table) { - throw std::runtime_error("Extra taxa table is null"); + throw std::runtime_error("Extra taxa table is null"); } double divideBy = extra_info->num_bs_trees * tree.num_splits(); stream << "Edge\tSupport\t"; for (size_t i = 0; i < tree.num_tips(); ++i) { - stream << tree.tip_labels_list()[i]; - if (i < tree.num_tips() - 1) { - stream << "\t"; - } else { - stream << "\n"; - } + stream << tree.tip_labels_list()[i]; + if (i < tree.num_tips() - 1) { + stream << "\t"; + } else { + stream << "\n"; + } } + auto bufsize = tree.num_tips() * 10; + char * buf = new char[bufsize]; auto support = tree.get_support(); for (size_t i = 0; i < tree.num_splits(); ++i) { - stream << tree.get_split_node_map()[i]->clv_index << "\t" << fixed << std::setprecision(6) << support[i] << "\t"; - for (size_t j = 0; j < tree.num_tips(); ++j) { - stream << fixed << std::setprecision(6) << (double) (extra_info->extra_taxa_table[i][j]) / divideBy; - if (j < tree.num_tips() - 1) { - stream << "\t"; - } - } - stream << "\n"; + stream << tree.get_split_node_map()[i]->clv_index << "\t" << fixed << std::setprecision(6) << support[i]; + + char * bufptr = buf; + for (size_t j = 0; j < tree.num_tips(); ++j) + { + double d = (double) (extra_info->extra_taxa_table[i][j]) / divideBy; + bufptr += sprintf(bufptr, "\t%.6lf", d); + } + *bufptr = 0; + stream << buf << "\n"; } + delete[] buf; return stream; } From 35d2af9af5ffba02d2a270155959f196c3f3a02e Mon Sep 17 00:00:00 2001 From: Sarah Lutteropp Date: Mon, 8 Jul 2019 14:46:39 +0200 Subject: [PATCH 26/31] updated submodule --- libs/pll-modules | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/pll-modules b/libs/pll-modules index e518b63a..6e812ef8 160000 --- a/libs/pll-modules +++ b/libs/pll-modules @@ -1 +1 @@ -Subproject commit e518b63a23c9702310778cf5cd23a514dd44cc8e +Subproject commit 6e812ef87e9254c02142a939516890166471e7d6 From b3ed82526197fa5679c879a5f89e1b6f78f90be2 Mon Sep 17 00:00:00 2001 From: Sarah Lutteropp Date: Tue, 9 Jul 2019 14:49:05 +0200 Subject: [PATCH 27/31] removed unneccessary rebuilds of tip_label_list in output of tbe extra information --- src/io/TBEExtraArrayStream.cpp | 3 ++- src/io/TBEExtraTableStream.cpp | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/io/TBEExtraArrayStream.cpp b/src/io/TBEExtraArrayStream.cpp index 3e0660c7..544918f3 100644 --- a/src/io/TBEExtraArrayStream.cpp +++ b/src/io/TBEExtraArrayStream.cpp @@ -7,8 +7,9 @@ TBEExtraArrayStream& operator<<(TBEExtraArrayStream& stream, const TransferBoots { pllmod_tbe_extra_info_t* extra_info = tree.get_extra_info(); stream << "Taxon\ttIndex\n"; + auto tip_labels_list = tree.tip_labels_list(); for (size_t i = 0; i < tree.num_tips(); ++i) { - stream << tree.tip_labels_list()[i] << "\t" << (double) (extra_info->extra_taxa_array[i] * 100) / (double) extra_info->num_bs_trees << "\n"; + stream << tip_labels_list[i] << "\t" << (double) (extra_info->extra_taxa_array[i] * 100) / (double) extra_info->num_bs_trees << "\n"; } return stream; } diff --git a/src/io/TBEExtraTableStream.cpp b/src/io/TBEExtraTableStream.cpp index 1ff45858..fab33465 100644 --- a/src/io/TBEExtraTableStream.cpp +++ b/src/io/TBEExtraTableStream.cpp @@ -14,8 +14,9 @@ TBEExtraTableStream& operator<<(TBEExtraTableStream& stream, const TransferBoots } double divideBy = extra_info->num_bs_trees * tree.num_splits(); stream << "Edge\tSupport\t"; + auto tip_labels_list = tree.tip_labels_list(); for (size_t i = 0; i < tree.num_tips(); ++i) { - stream << tree.tip_labels_list()[i]; + stream << tip_labels_list[i]; if (i < tree.num_tips() - 1) { stream << "\t"; } else { From 757e9be44621723bf88de6c48673ebc71cf67a86 Mon Sep 17 00:00:00 2001 From: Sarah Lutteropp Date: Tue, 9 Jul 2019 15:17:17 +0200 Subject: [PATCH 28/31] faster output of zeros in tbe extra table --- src/io/TBEExtraTableStream.cpp | 39 ++++++++++++++++++++-------------- 1 file changed, 23 insertions(+), 16 deletions(-) diff --git a/src/io/TBEExtraTableStream.cpp b/src/io/TBEExtraTableStream.cpp index fab33465..8821e1a4 100644 --- a/src/io/TBEExtraTableStream.cpp +++ b/src/io/TBEExtraTableStream.cpp @@ -16,29 +16,36 @@ TBEExtraTableStream& operator<<(TBEExtraTableStream& stream, const TransferBoots stream << "Edge\tSupport\t"; auto tip_labels_list = tree.tip_labels_list(); for (size_t i = 0; i < tree.num_tips(); ++i) { - stream << tip_labels_list[i]; - if (i < tree.num_tips() - 1) { - stream << "\t"; - } else { - stream << "\n"; - } + stream << tip_labels_list[i]; + if (i < tree.num_tips() - 1) { + stream << "\t"; + } else { + stream << "\n"; + } } auto bufsize = tree.num_tips() * 10; char * buf = new char[bufsize]; auto support = tree.get_support(); for (size_t i = 0; i < tree.num_splits(); ++i) { - stream << tree.get_split_node_map()[i]->clv_index << "\t" << fixed << std::setprecision(6) << support[i]; + stream << tree.get_split_node_map()[i]->clv_index << "\t" << fixed << std::setprecision(6) << support[i]; - char * bufptr = buf; - for (size_t j = 0; j < tree.num_tips(); ++j) - { - double d = (double) (extra_info->extra_taxa_table[i][j]) / divideBy; - bufptr += sprintf(bufptr, "\t%.6lf", d); - } - *bufptr = 0; - stream << buf << "\n"; - } + char * bufptr = buf; + for (size_t j = 0; j < tree.num_tips(); ++j) + { + if (extra_info->extra_taxa_table[i][j] == 0) + { + bufptr += sprintf(bufptr, "\t0.000000"); + } + else + { + double d = (double) (extra_info->extra_taxa_table[i][j]) / divideBy; + bufptr += sprintf(bufptr, "\t%f", d); + } + } + *bufptr = 0; + stream << buf << "\n"; +} delete[] buf; return stream; } From b5411e1e936f8bd8c9c0796487d22d49a1c6eb1e Mon Sep 17 00:00:00 2001 From: Sarah Lutteropp Date: Fri, 26 Jul 2019 15:54:01 +0200 Subject: [PATCH 29/31] updated README --- README.md | 89 +++++-------------------------------------------------- 1 file changed, 8 insertions(+), 81 deletions(-) diff --git a/README.md b/README.md index 60e416d2..3daa45d7 100644 --- a/README.md +++ b/README.md @@ -1,17 +1,17 @@ -# RAxML Next Generation - -[![Build Status](https://www.travis-ci.org/amkozlov/raxml-ng.svg?branch=master)](https://www.travis-ci.org/amkozlov/raxml-ng) [![DOI](https://zenodo.org/badge/75947982.svg)](https://zenodo.org/badge/latestdoi/75947982) [![License](https://img.shields.io/badge/license-AGPL-blue.svg)](http://www.gnu.org/licenses/agpl-3.0.en.html) +# RAxML Next Generation with parallel computation of Transfer Bootstrap Expectation (TBE) scores and computation of TBE extra information ## Introduction -RAxML-NG is a phylogenetic tree inference tool which uses maximum-likelihood (ML) optimality criterion. Its search heuristic is based on iteratively performing a series of Subtree Pruning and Regrafting (SPR) moves, which allows to quickly navigate to the best-known ML tree. RAxML-NG is a successor of RAxML (Stamatakis 2014) and leverages the highly optimized likelihood computation implemented in [*libpll*](https://github.com/xflouris/libpll) (Flouri et al. 2014). +Greetings! If you are not here for parallel computation of TBE support or computation of the TBE extra information, we strongly advise you to use the most up-to-date version of RAxML-NG instead. It can be found here: https://github.com/amkozlov/raxml-ng -RAxML-NG offers improvements in speed, flexibility and user-friendliness over the previous RAxML versions. It also implements some of the features previously available in ExaML (Kozlov et al. 2015), including checkpointing and efficient load balancing for partitioned alignments (Kobert et al. 2014). +## Computing TBE support with extra information -RAxML-NG is currently under active development, and the mid-term goal is to have most functionality of RAxML 8.x covered. -You can see some of the planned features [here](https://github.com/amkozlov/raxml-ng/issues). +Here is one example call which computes TBE support scores as well as the extra table and the extra array. It uses the cutoff value 0.3 for that: +``` +./raxml-ng --support --tree REF.nw --bs-trees BS.nw --bs-metric TBE --extra tbe_extra_table,tbe_extra_array,tbe-cutoff{0.3} +``` -Documentation: [github wiki](https://github.com/amkozlov/raxml-ng/wiki) +If you don't understand what this is, please read our paper at (TODO: Insert DOI) and its supplementary text (TODO: Insert DOI). ## Installation instructions @@ -65,77 +65,4 @@ cmake -DSTATIC_BUILD=ON -DENABLE_RAXML_SIMD=OFF -DENABLE_PLLMOD_SIMD=OFF .. make ``` -## Documentation and Support - -Documentation can be found in the [github wiki](https://github.com/amkozlov/raxml-ng/wiki). -For a quick start, please check out the [hands-on tutorial](https://github.com/amkozlov/raxml-ng/wiki/Tutorial). - -Also please check the online help with `raxml-ng -h`. - -If still in doubt, please feel free to post to the [RAxML google group](https://groups.google.com/forum/#!forum/raxml). - -## Usage examples - - 1. Perform single tree inference on DNA alignment - (random starting tree, general time-reversible model, ML estimate of substitution rates and - nucleotide frequencies, discrete GAMMA model of rate heterogeneity with 4 categories): - - `./raxml-ng --msa testDNA.fa --model GTR+G` - - 2. Perform an all-in-one analysis (ML tree search + non-parametric bootstrap) - (10 randomized parsimony starting trees, fixed empirical substitution matrix (LG), - empirical aminoacid frequencies from alignment, 8 discrete GAMMA categories, - 200 bootstrap replicates): - - `./raxml-ng --all --msa testAA.fa --model LG+G8+F --tree pars{10} --bs-trees 200` - - - 3. Optimize branch lengths and free model parameters on a fixed topology - (using multiple partitions with proportional branch lengths) - - `./raxml-ng --evaluate --msa testAA.fa --model partitions.txt --tree test.tree --brlen scaled` - - 4. Map support values from existing set of replicate trees: - - `./raxml-ng --support --tree bestML.tree --bs-trees bootstraps.tree` - -## License and citation - -The code is currently licensed under the GNU Affero General Public License version 3. - -When using RAxML-NG, please cite [this preprint](https://www.biorxiv.org/content/early/2018/10/18/447110): - -Alexey M. Kozlov, Diego Darriba, Tomáš Flouri, Benoit Morel, and Alexandros Stamatakis (2018) -**RAxML-NG: A fast, scalable, and user-friendly tool for maximum likelihood phylogenetic inference.** -*bioRxiv.* -doi:[10.1101/447110](https://doi.org/10.1101/447110) - -## The team - -* Alexey Kozlov -* Alexandros Stamatakis -* Diego Darriba -* Tomáš Flouri -* Benoit Morel - -## References - -* Stamatakis A. (2014) -**RAxML version 8: a tool for phylogenetic analysis and post-analysis of large phylogenies.** -*Bioinformatics*, 30(9): 1312-1313. -doi:[10.1093/bioinformatics/btu033](http://dx.doi.org/10.1093/bioinformatics/btu033) - -* Flouri T., Izquierdo-Carrasco F., Darriba D., Aberer AJ, Nguyen LT, Minh BQ, von Haeseler A., Stamatakis A. (2014) -**The Phylogenetic Likelihood Library.** -*Systematic Biology*, 64(2): 356-362. -doi:[10.1093/sysbio/syu084](http://dx.doi.org/10.1093/sysbio/syu084) - -* Kozlov A.M., Aberer A.J., Stamatakis A. (2015) -**ExaML version 3: a tool for phylogenomic analyses on supercomputers.** -*Bioinformatics (2015) 31 (15): 2577-2579.* -doi:[10.1093/bioinformatics/btv184](https://doi.org/10.1093/bioinformatics/btv184) - -* Kobert K., Flouri T., Aberer A., Stamatakis A. (2014) -**The divisible load balance problem and its application to phylogenetic inference.** -*Brown D., Morgenstern B., editors. (eds.) Algorithms in Bioinformatics, Vol. 8701 of Lecture Notes in Computer Science. Springer, Berlin, pp. 204–216* From 980842fe6801c944f75b745e6d47bf8f5d30e5b5 Mon Sep 17 00:00:00 2001 From: Sarah Lutteropp Date: Fri, 26 Jul 2019 15:56:01 +0200 Subject: [PATCH 30/31] added number of threads --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 3daa45d7..aa2b11bb 100644 --- a/README.md +++ b/README.md @@ -6,9 +6,9 @@ Greetings! If you are not here for parallel computation of TBE support or comput ## Computing TBE support with extra information -Here is one example call which computes TBE support scores as well as the extra table and the extra array. It uses the cutoff value 0.3 for that: +Here is one example call which computes TBE support scores as well as the extra table and the extra array. It uses the cutoff value 0.3 for that. It uses 10 threads: ``` -./raxml-ng --support --tree REF.nw --bs-trees BS.nw --bs-metric TBE --extra tbe_extra_table,tbe_extra_array,tbe-cutoff{0.3} +./raxml-ng --support --tree REF.nw --bs-trees BS.nw --bs-metric TBE --extra tbe_extra_table,tbe_extra_array,tbe-cutoff{0.3} --threads 10 ``` If you don't understand what this is, please read our paper at (TODO: Insert DOI) and its supplementary text (TODO: Insert DOI). From d10450689bc1c3cf3338798bb2f6e4b508826c55 Mon Sep 17 00:00:00 2001 From: Sarah Lutteropp Date: Thu, 5 Sep 2019 09:56:36 +0200 Subject: [PATCH 31/31] Update README.md Added link to bioarxiv paper --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index aa2b11bb..8c09e001 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,8 @@ Here is one example call which computes TBE support scores as well as the extra ./raxml-ng --support --tree REF.nw --bs-trees BS.nw --bs-metric TBE --extra tbe_extra_table,tbe_extra_array,tbe-cutoff{0.3} --threads 10 ``` -If you don't understand what this is, please read our paper at (TODO: Insert DOI) and its supplementary text (TODO: Insert DOI). +If you don't understand what this is, please read our paper at https://www.biorxiv.org/content/10.1101/734848v2 + ## Installation instructions