Skip to content

Commit

Permalink
output rtt distance and date in verbose mode
Browse files Browse the repository at this point in the history
  • Loading branch information
Thu-Hien To authored and Thu-Hien To committed Oct 9, 2020
1 parent 62ad74a commit 49846df
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 5 deletions.
Binary file modified bin/lsd2_mac
Binary file not shown.
16 changes: 15 additions & 1 deletion src/confidence_interval.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,21 @@ void output(double br,int y, InputOutputStream *io, Pr* pr,Node** nodes,ostream&
pr->resultMessage.push_back(oss.str());
}
}

//Write input trees out after all pre-process steps (collapse branches, remove outgroups, rooting, remove outliers etc)
if (pr->verbose){
std::ostringstream oss;
oss<<"- Evolution distance & date of each node:\n";
oss<<"Node Branch_length Branch_elapsed_time RttDistance NodeDate\n";
double* r2t = rtt(pr,nodes);
for (int i=0;i<=pr->nbBranches;i++){
if (i<pr->nbINodes) oss<<"node_"<<i<<" ";
else oss<<nodes[i]->L<<" ";
if (i==0) oss<<"NA NA ";
else oss<<nodes[i]->B<<" "<<pr->rho*(nodes[i]->D-nodes[nodes[i]->P]->D)<<" ";
oss<<r2t[i]<<" "<<nodes[i]->D<<"\n";
}
pr->resultMessage.push_back(oss.str());
}
//Replace branche length by time-scaled lengths
if (pr->ratePartition.size()==0){
for (int i=1;i<=pr->nbBranches;i++){
Expand Down
6 changes: 3 additions & 3 deletions src/options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Pr* getOptions( int argc, char** argv )

Pr* getCommandLine( int argc, char** argv)
{
const string VERSION="v.1.9.5";
const string VERSION="v.1.9.6";
Pr* opt = new Pr();
int c;
string s;
Expand Down Expand Up @@ -356,7 +356,7 @@ Pr* getInterface()

void printInterface(ostream& in, Pr* opt)
{
const string VERSION = "v.1.9.5";
const string VERSION = "v.1.9.6";

in<<"\nLEAST-SQUARE METHODS TO ESTIMATE RATES AND DATES - "<<VERSION<<" \n\n";
in<<"\nInput files:\n";
Expand Down Expand Up @@ -513,7 +513,7 @@ void printHelp( void )
const string BOLD = "\033[00;01m";
const string LINE = "\033[00;04m";
const string FLAT = "\033[00;00m";
const string VERSION = "v.1.9.5";
const string VERSION = "v.1.9.6";

cout<<BOLD<<"LSD: LEAST-SQUARES METHODS TO ESTIMATE RATES AND DATES - "<<VERSION<<"\n\n";
cout<<BOLD<<"DESCRIPTION\n"
Expand Down
2 changes: 1 addition & 1 deletion src/readData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ void extrait_outgroup(InputOutputStream *io, Pr* pr, bool useBootstrapTree){
w << newick(p_r, p_r,pr, nodes_new,nbTips).c_str();
}
if ((nbTips+outgroups.size()) != (pr->nbBranches+1 - pr->nbINodes)){
cerr<<"Error: The outgroups do not form a monophyletic in the tree "<<y+1<<endl;
cerr<<"The outgroups do not form a monophyletic in the tree "<<y+1<<endl;
exit(EXIT_FAILURE);
}
if (!pr->removeOutgroup) {
Expand Down
14 changes: 14 additions & 0 deletions src/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3305,3 +3305,17 @@ bool checkTopology(Pr* pr,Node** nodes1, Node** nodes2){
}
return true;
}*/

double* rtt(Pr* pr,Node** nodes){
double* r2t = new double[pr->nbBranches+1];
for (int i=0;i<=pr->nbBranches;i++){
double r=0;
int j=i;
while (j!=0){
r+=nodes[j]->B;
j=nodes[j]->P;
}
r2t[i]=r;
}
return r2t;
}
2 changes: 2 additions & 0 deletions src/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -322,4 +322,6 @@ void adjustDateToYM(Date*& date,int m1,int d1,int m2,int d2);

bool checkTopology(Pr* pr,Node** nodes1, Node** nodes2);

double* rtt(Pr* pr,Node** nodes);

#endif

0 comments on commit 49846df

Please sign in to comment.