Skip to content

Commit

Permalink
fix bug regarding integrating calib constraints when reroot
Browse files Browse the repository at this point in the history
  • Loading branch information
tothuhien committed May 27, 2021
1 parent 4a354eb commit b526730
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 100 deletions.
Binary file modified bin/lsd2_mac
Binary file not shown.
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.9";
const string VERSION="v.1.10";
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.9";
const string VERSION = "v.1.10";

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.9";
const string VERSION = "v.1.10";

cout<<BOLD<<"LSD: LEAST-SQUARES METHODS TO ESTIMATE RATES AND DATES - "<<VERSION<<"\n\n";
cout<<BOLD<<"DESCRIPTION\n"
Expand Down
97 changes: 0 additions & 97 deletions src/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1625,99 +1625,6 @@ void desactiveLimit(Node* no){
if (upper(no)) no->status-=2+8;
}

bool integrateConstrainL(Date* d1,Node* n2){//n1 is an ancestor of n2
if (n2->type=='n') {
if (d1->type=='l' || d1->type=='b') {
n2->type='l';
n2->lower=d1->lower;
}
if (d1->type=='p') {
n2->type='l';
n2->lower=d1->date;
}
}
if (n2->type=='l' || n2->type=='b'){
if (d1->type=='l' || d1->type=='b') {
n2->lower=max(d1->lower,n2->lower);
}
if (d1->type=='p') {
n2->lower=max(n2->lower,d1->date);
}
}
if (n2->type=='u' || n2->type=='b'){
if (d1->type=='l' || d1->type=='b') {
if (d1->lower>n2->upper) {
return false;
}
n2->type='b';
n2->lower=d1->lower;
}
if (d1->type=='u' || d1->type=='b') {
n2->upper=min(d1->upper,n2->upper);
}
if (d1->type=='p') {
if (d1->date>n2->upper) {
return false;
}
n2->lower=d1->date;
n2->type='b';
}
}
return true;
}

bool integrateConstrainU(Date* d1,Node* n2){//n1 is a child of n2
if (n2->type=='n') {
if (d1->type=='u' || d1->type=='b') {
n2->type='u';
n2->upper=d1->upper;
}
if (d1->type=='p') {
n2->type='u';
n2->upper=d1->date;
}
}
if (n2->type=='u' || n2->type=='b'){
if (d1->type=='u' || d1->type=='b') {
n2->upper=min(d1->upper,n2->upper);
}
if (d1->type=='p') {
n2->upper=max(n2->upper,d1->date);
}
}
if (n2->type=='l' || n2->type=='b'){
if (d1->type=='u' || d1->type=='b') {
if (d1->upper<n2->lower) {
return false;
}
else if (d1->upper==n2->lower){
n2->type='p';
n2->D=n2->lower;
}
else{
n2->type='b';
n2->upper=d1->upper;
}
}
if (d1->type=='p') {
if (d1->date<n2->lower) {
return false;
}
else if (d1->date==n2->lower){
n2->type='p';
n2->D=n2->lower;
n2->status=8;
}
else{
n2->upper=d1->date;
n2->type='b';
}

}
}
return true;
}

bool initConstraintReRooted(Pr* pr,Node** nodes,int r,int p_r){
bool constraintConsistent=true;
for (int i=0;i<pr->nbINodes;i++){
Expand All @@ -1729,10 +1636,6 @@ bool initConstraintReRooted(Pr* pr,Node** nodes,int r,int p_r){
int k=-1;
if (no->mrca.size()==0){
k=no->id;
if (k==0){
if (!integrateConstrainL(no,nodes[r])) return false;//or swap r and p_r
if (!integrateConstrainU(no,nodes[p_r])) return false;
}
}
else{
k=mrca(nodes,(*iter)->mrca);
Expand Down
1 change: 1 addition & 0 deletions src/utils.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

#ifndef UTILS_H_
#define UTILS_H_

Expand Down

0 comments on commit b526730

Please sign in to comment.