diff --git a/libs/pll-modules b/libs/pll-modules index c06c712d..d35a18cd 160000 --- a/libs/pll-modules +++ b/libs/pll-modules @@ -1 +1 @@ -Subproject commit c06c712dc5faf5225d88e8d0f8e368b930dd0da2 +Subproject commit d35a18cd893c3564ba4b5ca51d24464e127a198c diff --git a/src/Tree.hpp b/src/Tree.hpp index 0528af3e..4c2a0259 100644 --- a/src/Tree.hpp +++ b/src/Tree.hpp @@ -32,6 +32,7 @@ class BasicTree size_t num_nodes() const { return _num_tips + _num_tips - 2; }; size_t num_subnodes() const { return _num_tips + num_inner() * 3; }; size_t num_branches() const { return _num_tips + _num_tips - 3; }; + size_t num_splits() const { return _num_tips - 3; }; protected: size_t _num_tips; diff --git a/src/TreeInfo.cpp b/src/TreeInfo.cpp index 3b026325..d857f24a 100644 --- a/src/TreeInfo.cpp +++ b/src/TreeInfo.cpp @@ -330,7 +330,7 @@ void build_clv(ProbVector::const_iterator probs, size_t sites, WeightVector::con } void set_partition_tips(const Options& opts, const MSA& msa, const PartitionRange& part_region, - pll_partition_t* partition) + pll_partition_t* partition, const unsigned int * charmap) { /* set pattern weights */ if (!msa.weights().empty()) @@ -358,13 +358,14 @@ void set_partition_tips(const Options& opts, const MSA& msa, const PartitionRang { for (size_t i = 0; i < msa.size(); ++i) { - pll_set_tip_states(partition, i, partition->map, msa.at(i).c_str() + part_region.start); + pll_set_tip_states(partition, i, charmap, msa.at(i).c_str() + part_region.start); } } } void set_partition_tips(const Options& opts, const MSA& msa, const PartitionRange& part_region, - pll_partition_t* partition, const WeightVector& weights) + pll_partition_t* partition, const unsigned int * charmap, + const WeightVector& weights) { assert(!weights.empty()); @@ -412,7 +413,7 @@ void set_partition_tips(const Options& opts, const MSA& msa, const PartitionRang } assert(pos == comp_weights.size()); - pll_set_tip_states(partition, i, partition->map, bs_seq.data()); + pll_set_tip_states(partition, i, charmap, bs_seq.data()); } } @@ -478,15 +479,13 @@ pll_partition_t* create_pll_partition(const Options& opts, const PartitionInfo& if (!partition) throw runtime_error("ERROR creating pll_partition: " + string(pll_errmsg)); - partition->map = model.charmap(); - if (part_region.master() && !model.ascbias_weights().empty()) pll_set_asc_state_weights(partition, model.ascbias_weights().data()); if (part_length == part_region.length) - set_partition_tips(opts, msa, part_region, partition); + set_partition_tips(opts, msa, part_region, partition, model.charmap()); else - set_partition_tips(opts, msa, part_region, partition, weights); + set_partition_tips(opts, msa, part_region, partition, model.charmap(), weights); assign(partition, model); diff --git a/src/bootstrap/BootstrapTree.cpp b/src/bootstrap/BootstrapTree.cpp index 0a40bd15..3d112c8c 100644 --- a/src/bootstrap/BootstrapTree.cpp +++ b/src/bootstrap/BootstrapTree.cpp @@ -4,9 +4,10 @@ using namespace std; -BootstrapTree::BootstrapTree (const Tree& tree) : Tree(tree), _num_bs_trees(0), _num_splits(0) +BootstrapTree::BootstrapTree (const Tree& tree) : Tree(tree), _num_bs_trees(0) { _pll_splits_hash = nullptr; + _node_split_map.resize(num_splits()); add_splits_to_hashtable(pll_utree_root(), true); } @@ -15,7 +16,6 @@ BootstrapTree::~BootstrapTree () { pll_utree_destroy(_pll_utree, nullptr); pllmod_utree_split_hashtable_destroy(_pll_splits_hash); - free(_node_split_map); } void BootstrapTree::add_bootstrap_tree(const Tree& tree) @@ -29,25 +29,21 @@ void BootstrapTree::add_bootstrap_tree(const Tree& tree) void BootstrapTree::add_splits_to_hashtable(const pll_unode_t& root, bool ref_tree) { - unsigned int n_splits; - int ** node_split_map = ref_tree ? &_node_split_map : nullptr; + pll_unode_t ** node_split_map = ref_tree ? _node_split_map.data() : nullptr; int update_only = ref_tree ? 0 : 1; pll_split_t * ref_splits = pllmod_utree_split_create((pll_unode_t*) &root, _num_tips, - &n_splits, node_split_map); _pll_splits_hash = pllmod_utree_split_hashtable_insert(_pll_splits_hash, ref_splits, _num_tips, - n_splits, + num_splits(), + nullptr, update_only); pllmod_utree_split_destroy(ref_splits); - - if (ref_tree) - _num_splits = n_splits; } void BootstrapTree::calc_support() @@ -70,36 +66,14 @@ void BootstrapTree::calc_support() // printf("node_id %d, split_id %d\n", i, _node_split_map[i]); // printf("\n\n"); - PllNodeVector inner(_pll_utree->nodes + _pll_utree->tip_count, - _pll_utree->nodes + _pll_utree->tip_count + _pll_utree->inner_count - 1); - - vector split_plotted(_num_splits); - for (auto node: inner) + for (size_t i = 0; i < _node_split_map.size(); ++i) { - assert(node->next); - - auto n = node; - do - { - if (pllmod_utree_is_tip(n->back)) - continue; - - auto node_id = n->node_index - _num_tips; - auto split_id = _node_split_map[node_id]; - assert(split_id >= 0); + auto node = _node_split_map[i]; - if (split_plotted[split_id]) - continue; - - n->label = n->next->label = n->next->next->label = - strdup(std::to_string(support[split_id]).c_str()); - - split_plotted[split_id].flip(); + /* this has to be an inner node! */ + assert(node->next); - break; - } - while ((n = n->next) != node); + node->label = node->next->label = node->next->next->label = + strdup(std::to_string(support[i]).c_str()); } } - - diff --git a/src/bootstrap/BootstrapTree.hpp b/src/bootstrap/BootstrapTree.hpp index b6669bb6..62220899 100644 --- a/src/bootstrap/BootstrapTree.hpp +++ b/src/bootstrap/BootstrapTree.hpp @@ -17,9 +17,8 @@ class BootstrapTree : public Tree private: size_t _num_bs_trees; - size_t _num_splits; bitv_hashtable_t* _pll_splits_hash; - int * _node_split_map; + std::vector _node_split_map; void add_splits_to_hashtable(const pll_unode_t& root, bool update_only); }; diff --git a/src/version.h b/src/version.h index 1a9ce540..afe4e0c3 100644 --- a/src/version.h +++ b/src/version.h @@ -1,2 +1,2 @@ -#define RAXML_VERSION "0.4.0 BETA" -#define RAXML_DATE "01.06.2017" +#define RAXML_VERSION "0.4.1 BETA" +#define RAXML_DATE "20.07.2017"