Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New data structures for nodes #21

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions alignment/seqregions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -644,6 +644,13 @@ void SeqRegions::mergeUpperLower(SeqRegions* &merged_regions,
{
merge_RACGT_ORACGT(*seq1_region, *seq2_region, total_blength_1, total_blength_2, upper_plength, end_pos, threshold_prob, model, aln, *merged_regions);
}

// NHANLT: LOGS FOR DEBUGGING
/*if (merged_regions->at(merged_regions->size()-1).type == TYPE_O)
{
SeqRegion::LHType lh = *merged_regions->at(merged_regions->size()-1).likelihood;
std::cout << "mergeUpLow " << pos << " " << std::setprecision(20) << lh[0] << " " << lh[1] << " " << lh[2] << " " << lh[3] << " " << std::endl;
}*/
}

// update pos
Expand Down Expand Up @@ -1011,6 +1018,13 @@ RealNumType SeqRegions::mergeTwoLowers(SeqRegions* &merged_regions, RealNumType
{
if (!merge_notN_notN_TwoLowers(*seq1_region, *seq2_region, plength1, plength2, end_pos, pos, aln, model, threshold_prob, log_lh, merged_regions, return_log_lh)) return MIN_NEGATIVE;
}

// NHANLT: LOGS FOR DEBUGGING
/*if (merged_regions->at(merged_regions->size()-1).type == TYPE_O)
{
SeqRegion::LHType lh = *merged_regions->at(merged_regions->size()-1).likelihood;
std::cout << "merge2Low " << pos << " " << std::setprecision(20) << lh[0] << " " << lh[1] << " " << lh[2] << " " << lh[3] << " " << std::endl;
}*/
// update pos
pos = end_pos + 1;
}
Expand Down
6 changes: 3 additions & 3 deletions maple/cmaple.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -295,14 +295,14 @@ void test()
std::cout << " Update partial_lh " << std::endl;
std::unique_ptr<SeqRegions> new_partial_lh = std::make_unique<SeqRegions>(SeqRegions());
new_partial_lh->emplace_back(0, 100);
phylonode1.setPartialLh(mini_index, std::move(new_partial_lh));
phylonode1.setPartialLh(mini_index, new_partial_lh);
std::cout << "- (size of) partial_lh: " << phylonode1.getPartialLh(mini_index)->size() << std::endl;

std::cout << " Update partial_lh 2nd time" << std::endl;
std::unique_ptr<SeqRegions> new_partial_lh2 = std::make_unique<SeqRegions>(SeqRegions());
new_partial_lh2->emplace_back(1, 200);
new_partial_lh2->emplace_back(2, 300);
phylonode1.setPartialLh(mini_index, std::move(new_partial_lh2));
phylonode1.setPartialLh(mini_index, new_partial_lh2);
std::cout << "- (size of) partial_lh: " << phylonode1.getPartialLh(mini_index)->size() << std::endl;

// test phylonode is an internal node
Expand All @@ -322,7 +322,7 @@ void test()
std::unique_ptr<SeqRegions> new_partial_lh1 = std::make_unique<SeqRegions>(SeqRegions());
new_partial_lh1->emplace_back(0, 100);
new_partial_lh1->emplace_back(1, 200);
phylonode2.setPartialLh(mini_index2, std::move(new_partial_lh1));
phylonode2.setPartialLh(mini_index2, new_partial_lh1);
std::cout << "- (size of) partial_lh at the left mininode: " << phylonode2.getPartialLh(mini_index2)->size() << std::endl;

// create a phylonode as an internal node
Expand Down
2 changes: 1 addition & 1 deletion tree/node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ std::unique_ptr<SeqRegions>& PhyloNode::getPartialLh(const MiniIndex mini_index)
return data_.leaf.partial_lh_;
}

void PhyloNode::setPartialLh(const MiniIndex mini_index, std::unique_ptr<SeqRegions>&& partial_lh)
void PhyloNode::setPartialLh(const MiniIndex mini_index, std::unique_ptr<SeqRegions>& partial_lh)
{
// if it's an internal node
if (is_internal_)
Expand Down
2 changes: 1 addition & 1 deletion tree/node.h
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ class PhyloNode
/**
Set partial_lh
*/
void setPartialLh(const MiniIndex mini_index, std::unique_ptr<SeqRegions>&& partial_lh);
void setPartialLh(const MiniIndex mini_index, std::unique_ptr<SeqRegions>& partial_lh);

/**
Get the index of the neighbor node
Expand Down
8 changes: 8 additions & 0 deletions tree/tree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1715,6 +1715,10 @@ void Tree::connectNewSample2Branch(SeqRegions* const sample, const std::string &
next_node_1->getPartialLhAtNode(aln, model, threshold_prob)->mergeUpperLower(new_sample_node->mid_branch_lh, half_branch_length, *sample, half_branch_length, aln, model, threshold_prob);
}

// NHANLT: LOGS FOR DEBUGGING
/*cout << "2Branch " << seq_name << " " << (best_blength > 0?new_sample_node->total_lh->size():0)<< " " << (best_blength > 0?new_sample_node->mid_branch_lh->size():0)<< " " << new_sample_node->partial_lh->size()<< " " << new_internal_node->total_lh->size()<< " " << new_internal_node->mid_branch_lh->size()<< " " << new_internal_node->partial_lh->size() << " " << next_node_1->partial_lh->size() << " " << next_node_2->partial_lh->size() << std::endl;
cout << std::setprecision(20) << new_internal_node->length << " " << sibling_node->length << " " << new_sample_node->length << std::endl;*/

// update pseudo_count
model.updatePesudoCount(aln, *next_node_1->getPartialLhAtNode(aln, model, threshold_prob), *sample);

Expand Down Expand Up @@ -1957,6 +1961,10 @@ void Tree::connectNewSample2Root(SeqRegions* const sample, const std::string &se
createFurtherMidNodes(new_root.children[1],new_root.probVectUpLeft)*/
}

// NHANLT: LOGS FOR DEBUGGING
/*cout << "2Root " << seq_name << " " << (best_length2 > 0 ?new_sample_node->total_lh->size():0)<< " " << (best_length2 > 0?new_sample_node->mid_branch_lh->size():0)<< " " << new_sample_node->partial_lh->size()<< " " << new_root->total_lh->size()<< " " << new_root->partial_lh->size() << " " << next_node_1->partial_lh->size() << " " << next_node_2->partial_lh->size() << std::endl;
cout << std::setprecision(20) << sibling_node->length << " " << new_sample_node->length << std::endl;*/

// update tree->root;
root = new_root;

Expand Down