Skip to content

Commit

Permalink
dbg
Browse files Browse the repository at this point in the history
  • Loading branch information
shajoezhu committed Feb 1, 2019
1 parent 936c1dc commit 007d4fe
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 56 deletions.
16 changes: 8 additions & 8 deletions src/debug/net_debug.cpp
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/*
* hybrid-Lambda is used to simulate gene trees given species network under
* hybrid-Lambda is used to simulate gene trees given species network under
* coalescent process.
*
*
* Copyright (C) 2010 -- 2014 Sha (Joe) Zhu
*
*
* This file is part of hybrid-Lambda.
*
*
* hybrid-Lambda is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
Expand All @@ -15,7 +15,7 @@
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
Expand All @@ -25,15 +25,15 @@
bool Tree::print_all_node_dout(){

if ( is_Net ) dout<<" label hybrid hyb_des non-tp parent1 height brchln1 parent2 brchln2 #child #dsndnt #id rank e_num Clade "<<endl;
else dout<<" label non-tp parent height brchln #child #dsndnt #id rank e_num Clade "<<endl;
else dout<<" label non-tp parent height brchln #child #dsndnt #id rank e_num Clade "<<endl;
for (size_t i=0;i<NodeContainer.size();i++){
//for (size_t j=0;j<descndnt[i].size();j++) dout<<setw(3)<<descndnt[i][j];

assert( this->NodeContainer[i].print_dout( this->is_Net_() ) );

dout<<" ";
for (size_t j=0;j<samples_below[i].size();j++) dout<<samples_below[i][j];

for (size_t j=0;j<samples_below[i].size();j++) dout<<samples_below[i][j];
dout<<endl;
}
return true;
Expand Down
12 changes: 6 additions & 6 deletions src/debug/node_debug.cpp
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/*
* hybrid-Lambda is used to simulate gene trees given species network under
* hybrid-Lambda is used to simulate gene trees given species network under
* coalescent process.
*
*
* Copyright (C) 2010 -- 2014 Sha (Joe) Zhu
*
*
* This file is part of hybrid-Lambda.
*
*
* hybrid-Lambda is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
Expand All @@ -15,7 +15,7 @@
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
Expand All @@ -31,7 +31,7 @@ bool Node::print_dout( bool is_Net ){
//else dout << " ";
if (this->parent1) dout << setw (11) << (parent1);
else dout << " ";
dout << setw (6) << this->height();
dout << setw (8) << this->height();
dout << setw (12) << this->brchlen1();
if (is_Net){
if (this->parent2) dout << setw (11) << (parent2->label);
Expand Down
91 changes: 49 additions & 42 deletions src/sim_gt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,24 @@ void SimulationParameters::finalize(){
my_para_net = new Net (para_string);
}




//simTree::simTree ( SimulationParameters* sim_param, action_board* simulation_jobs ): parameters_(sim_param), simulation_jobs_ (simulation_jobs) {
//this->init();
//dout<<" Starting simulating gene tree from "<< this->parameters_->sp_string_coal_unit<<endl;
//this->core();
//}


simTree::simTree ( SimulationParameters* sim_param, action_board* simulation_jobs, ofstream &Si_table, MersenneTwister *mt ): parameters_(sim_param), simulation_jobs_ (simulation_jobs) {
this->mt = mt;
this->init();
dout<<" Starting simulating gene tree from "<< this->parameters_->sp_string_coal_unit<<endl;
this->Si_table_ = &Si_table;
this->core();
}

void simTree::core (){
sim_num_gener_bool_ = this->simulation_jobs_->sim_num_gener_bool;
if ( this->simulation_jobs_->sim_mut_unit_bool || this->simulation_jobs_->sim_num_mut_bool) {
Expand All @@ -93,8 +111,11 @@ void simTree::core (){
dout << endl;

//here to choose go left or right for hybrid node.
if ( this->parameters_->my_Net->NodeContainer[node_i].hybrid() ) this->assign_lineages_at_sp_node ( this->parameters_->my_Net->NodeContainer[node_i] );
if ( this->parameters_->my_Net->NodeContainer[node_i].hybrid() ) {
this->assign_lineages_at_sp_node ( this->parameters_->my_Net->NodeContainer[node_i] );
}

//
double remaining_length = ( rank_i == this->parameters_->my_Net->max_rank ) ? 1.0/0.0 : this->parameters_->my_Net->NodeContainer[node_i].brchlen1();
double multi_merge_para = this->parameters_->my_para_net->NodeContainer[node_i].brchlen1();
double pop_size = this->parameters_->my_pop_net->NodeContainer[node_i].brchlen1();
Expand Down Expand Up @@ -143,21 +164,6 @@ void simTree::core (){
}


//simTree::simTree ( SimulationParameters* sim_param, action_board* simulation_jobs ): parameters_(sim_param), simulation_jobs_ (simulation_jobs) {
//this->init();
//dout<<" Starting simulating gene tree from "<< this->parameters_->sp_string_coal_unit<<endl;
//this->core();
//}


simTree::simTree ( SimulationParameters* sim_param, action_board* simulation_jobs, ofstream &Si_table, MersenneTwister *mt ): parameters_(sim_param), simulation_jobs_ (simulation_jobs) {
this->mt = mt;
this->init();
dout<<" Starting simulating gene tree from "<< this->parameters_->sp_string_coal_unit<<endl;
this->Si_table_ = &Si_table;
this->core();
}

void simTree::remove_unused_nodes(){
for ( size_t node_i = 0; node_i < this->NodeContainer.size(); ){
if ( this->NodeContainer[node_i].num_descndnt == 0 ){
Expand Down Expand Up @@ -639,22 +645,23 @@ void simTree::include_lineages_at_sp_node( Node & sp_node ){
dout << &this->NodeContainer[sp_node.Net_node_contains_gt_node1.back()] << ", ";
}
}
for ( size_t j = 0; j < sp_node.child[i]->Net_node_contains_gt_node2.size(); j++){
bool unique = true;
for (size_t check_i = 0; check_i < sp_node.Net_node_contains_gt_node1.size(); check_i++) {
if (sp_node.child[i]->Net_node_contains_gt_node2[j] == sp_node.Net_node_contains_gt_node1[check_i]){
unique = false;
break;
if (sp_node.child[i]->parent2 == &sp_node ){ // This is for looping case, 1 sp node has two path to a hybrid node
for ( size_t j = 0; j < sp_node.child[i]->Net_node_contains_gt_node2.size(); j++){
bool unique = true;
for (size_t check_i = 0; check_i < sp_node.Net_node_contains_gt_node1.size(); check_i++) {
if (sp_node.child[i]->Net_node_contains_gt_node2[j] == sp_node.Net_node_contains_gt_node1[check_i]){
unique = false;
break;
}
}
}

if (unique){
sp_node.Net_node_contains_gt_node1.push_back ( sp_node.child[i]->Net_node_contains_gt_node2[j]);
dout << &this->NodeContainer[sp_node.Net_node_contains_gt_node1.back()] << ", ";
if (unique){
sp_node.Net_node_contains_gt_node1.push_back ( sp_node.child[i]->Net_node_contains_gt_node2[j]);
dout << &this->NodeContainer[sp_node.Net_node_contains_gt_node1.back()] << ", ";
}
}
}
}
else if ( sp_node.child[i]->parent2 == &sp_node ){
} else if ( sp_node.child[i]->parent2 == &sp_node ){
assert ( sp_node.child[i]->parent2 == &sp_node );
for ( size_t j = 0; j < sp_node.child[i]->Net_node_contains_gt_node2.size(); j++){
bool unique = true;
Expand All @@ -669,28 +676,28 @@ void simTree::include_lineages_at_sp_node( Node & sp_node ){
dout << &this->NodeContainer[sp_node.Net_node_contains_gt_node1.back()] << ", ";
}
}
for ( size_t j = 0; j < sp_node.child[i]->Net_node_contains_gt_node2.size(); j++){
bool unique = true;
for (size_t check_i = 0; check_i < sp_node.Net_node_contains_gt_node1.size(); check_i++) {
if (sp_node.child[i]->Net_node_contains_gt_node2[j] == sp_node.Net_node_contains_gt_node1[check_i]){
unique = false;
break;
}
}
//for ( size_t j = 0; j < sp_node.child[i]->Net_node_contains_gt_node1.size(); j++){
//bool unique = true;
//for (size_t check_i = 0; check_i < sp_node.Net_node_contains_gt_node1.size(); check_i++) {
//if (sp_node.child[i]->Net_node_contains_gt_node1[j] == sp_node.Net_node_contains_gt_node1[check_i]){
//unique = false;
//break;
//}
//}

if (unique){
sp_node.Net_node_contains_gt_node1.push_back ( sp_node.child[i]->Net_node_contains_gt_node2[j]);
dout << &this->NodeContainer[sp_node.Net_node_contains_gt_node1.back()] << ", ";
}
}
//if (unique){
//sp_node.Net_node_contains_gt_node1.push_back ( sp_node.child[i]->Net_node_contains_gt_node1[j]);
//dout << &this->NodeContainer[sp_node.Net_node_contains_gt_node1.back()] << ", ";
//}
//}
}
else continue;
}
dout << sp_node.Net_node_contains_gt_node1.size() << " lineages in total" << endl;
}


void simTree::assign_lineages_at_sp_node ( Node &sp_node ){
void simTree::assign_lineages_at_sp_node(Node &sp_node){
dout<<"hybrid node"<<endl;
vector < size_t > index_container_tmp = sp_node.Net_node_contains_gt_node1;
sp_node.Net_node_contains_gt_node1.clear();
Expand Down

0 comments on commit 007d4fe

Please sign in to comment.