Skip to content

Commit

Permalink
update libpll to v0.3.2 (several minor bugfixes)
Browse files Browse the repository at this point in the history
  • Loading branch information
amkozlov committed Jul 20, 2017
1 parent 805d036 commit b8bdd08
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 50 deletions.
1 change: 1 addition & 0 deletions src/Tree.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
15 changes: 7 additions & 8 deletions src/TreeInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down Expand Up @@ -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());

Expand Down Expand Up @@ -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());
}
}

Expand Down Expand Up @@ -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);

Expand Down
48 changes: 11 additions & 37 deletions src/bootstrap/BootstrapTree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -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)
Expand All @@ -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()
Expand All @@ -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<bool> 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());
}
}


3 changes: 1 addition & 2 deletions src/bootstrap/BootstrapTree.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<pll_unode_t*> _node_split_map;

void add_splits_to_hashtable(const pll_unode_t& root, bool update_only);
};
Expand Down
4 changes: 2 additions & 2 deletions src/version.h
Original file line number Diff line number Diff line change
@@ -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"

0 comments on commit b8bdd08

Please sign in to comment.