Skip to content

Commit

Permalink
attempt on makeing R package
Browse files Browse the repository at this point in the history
modify .gitignore to untrack files

simulation core part was not called

update gitignore file

move around finalize function to public, now it can be called from hybridLambda build
  • Loading branch information
shajoezhu committed Nov 13, 2015
1 parent b87f5ba commit b575101
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 23 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Expand Up @@ -87,6 +87,8 @@ tests/caterpillar_test/*gt*
# unittest
unit_tests
unit_tests.trs
test-driver
compile

# gcov
*gcov
Expand Down
16 changes: 8 additions & 8 deletions src/node.hpp
Expand Up @@ -30,14 +30,14 @@

using namespace std;

//Unless compiled with options NDEBUG, we will produce a debug output using
//'dout' instead of cout and execute (expensive) assert statements.
#ifndef NDEBUG
#define dout std::cout
#else
#pragma GCC diagnostic ignored "-Wunused-value"
#define dout 0 && std::cout
#endif
////Unless compiled with options NDEBUG, we will produce a debug output using
////'dout' instead of cout and execute (expensive) assert statements.
//#ifndef NDEBUG
//#define dout std::cout
//#else
//#pragma GCC diagnostic ignored "-Wunused-value"
//#define dout 0 && std::cout
//#endif

#ifndef NODE
#define NODE
Expand Down
24 changes: 17 additions & 7 deletions src/sim_gt.cpp
Expand Up @@ -67,13 +67,8 @@ void SimulationParameters::finalize(){
my_para_net = new Net (para_string);
}


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

sim_num_gener_bool_ = this->simulation_jobs_->sim_num_gener_bool;
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) sim_num_gener_bool_ = true;

this->initialize_remaining_sp_node ( this->parameters_->my_Net );
Expand Down Expand Up @@ -134,6 +129,21 @@ simTree::simTree ( SimulationParameters* sim_param, action_board* simulation_job
this->finalize( this->parameters_->my_Net->tax_name.size() );
}


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): parameters_(sim_param), simulation_jobs_ (simulation_jobs) {
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
21 changes: 13 additions & 8 deletions src/sim_gt.hpp
Expand Up @@ -49,13 +49,18 @@ class SimulationParameters{
bool num_gener_bool;
bool sp_coal_unit_bool;

string net_str;
vector < int > sample_size;

Net * my_Net;
Net * my_pop_net;
Net * my_para_net;

string write_sp_string_in_coal_unit( string &sp_num_gener_string, string &pop_size_string );
string rewrite_pop_string_by_para_string( string para_string,string pop_size_string );

public:
string net_str;
void finalize();
SimulationParameters(){
this->mutation_rate=0.00005;
this->pop_bool=false;
Expand All @@ -74,10 +79,6 @@ class SimulationParameters{
if ( my_pop_net ) delete my_pop_net;
if ( my_para_net ) delete my_para_net;
};
string write_sp_string_in_coal_unit( string &sp_num_gener_string, string &pop_size_string );
string rewrite_pop_string_by_para_string( string para_string,string pop_size_string );

void finalize();
};


Expand All @@ -103,6 +104,7 @@ class action_board {
bool mono_bool;
bool Si_num_bool;

public:
action_board(){
this->sim_mut_unit_bool = false;
this->sim_num_gener_bool = false;
Expand All @@ -123,7 +125,6 @@ class simTree : public Tree {

action_board* simulation_jobs_;
SimulationParameters* parameters_;
string gt_string_coal_unit;
string gt_string_mut_num;
string gt_string_mut_unit;
string gt_string_gener_num;
Expand All @@ -137,8 +138,6 @@ class simTree : public Tree {
bool sim_num_gener_bool_;

simTree(){ this->parameters_ = NULL; this->simulation_jobs_ = NULL; };
simTree( SimulationParameters* sim_param, action_board *simulation_jobs, std::ofstream &Si_table );
~simTree(){};

void init(){ this->sim_num_gener_bool_ = false;}
void initialize_gt_tip_nodes( Net * my_Net );
Expand Down Expand Up @@ -210,6 +209,12 @@ class simTree : public Tree {
return k;
}

void core();
public:
string gt_string_coal_unit;
simTree( SimulationParameters* sim_param, action_board *simulation_jobs, std::ofstream &Si_table );
simTree( SimulationParameters* sim_param, action_board *simulation_jobs);
~simTree(){};
};

string write_para_into_tree(string sp_string, double para);
Expand Down

0 comments on commit b575101

Please sign in to comment.