Permalink
Browse files

-bug fix in AUTO prot model optimization

  • Loading branch information...
1 parent e7db2f5 commit 126d3a4c30b8274b00af8782727a9121791ad92a @stamatak committed May 7, 2013
Showing with 39 additions and 39 deletions.
  1. +38 −38 optimizeModel.c
  2. +1 −1 topologies.c
View
76 optimizeModel.c
@@ -3530,15 +3530,8 @@ static void optScaler(tree *tr, double modelEpsilon, linkageList *ll)
static void autoProtein(tree *tr)
{
int
- countAutos = 0,
- i,
- model;
-
- topolRELL_LIST
- *rl = (topolRELL_LIST *)rax_malloc(sizeof(topolRELL_LIST));
-
- initTL(rl, tr, 1);
- saveTL(rl, tr, 0);
+ countAutos = 0,
+ model;
for(model = 0; model < tr->NumberOfModels; model++)
if(tr->partitionData[model].protModels == AUTO)
@@ -3547,6 +3540,7 @@ static void autoProtein(tree *tr)
if(countAutos > 0)
{
int
+ i,
numProteinModels = AUTO,
*bestIndex = (int*)rax_malloc(sizeof(int) * tr->NumberOfModels),
*oldIndex = (int*)rax_malloc(sizeof(int) * tr->NumberOfModels);
@@ -3555,6 +3549,12 @@ static void autoProtein(tree *tr)
startLH,
*bestScores = (double*)rax_malloc(sizeof(double) * tr->NumberOfModels);
+ topolRELL_LIST
+ *rl = (topolRELL_LIST *)rax_malloc(sizeof(topolRELL_LIST));
+
+ initTL(rl, tr, 1);
+ saveTL(rl, tr, 0);
+
evaluateGenericInitrav(tr, tr->start);
startLH = tr->likelihood;
@@ -3616,37 +3616,37 @@ static void autoProtein(tree *tr)
masterBarrier(THREAD_COPY_RATES, tr);
#endif
- resetBranches(tr);
- evaluateGenericInitrav(tr, tr->start);
- treeEvaluate(tr, 2.0);
-
- if(tr->likelihood < startLH)
- {
- for(model = 0; model < tr->NumberOfModels; model++)
- {
- if(tr->partitionData[model].protModels == AUTO)
- {
- tr->partitionData[model].autoProtModels = oldIndex[model];
- initReversibleGTR(tr, model);
- }
- }
-
+ resetBranches(tr);
+ evaluateGenericInitrav(tr, tr->start);
+ treeEvaluate(tr, 2.0);
+
+ if(tr->likelihood < startLH)
+ {
+ for(model = 0; model < tr->NumberOfModels; model++)
+ {
+ if(tr->partitionData[model].protModels == AUTO)
+ {
+ tr->partitionData[model].autoProtModels = oldIndex[model];
+ initReversibleGTR(tr, model);
+ }
+ }
+
#ifdef _USE_PTHREADS
- masterBarrier(THREAD_COPY_RATES, tr);
+ masterBarrier(THREAD_COPY_RATES, tr);
#endif
- restoreTL(rl, tr, 0);
- evaluateGenericInitrav(tr, tr->start);
- }
-
- assert(tr->likelihood >= startLH);
-
- freeTL(rl);
- rax_free(rl);
-
- rax_free(oldIndex);
- rax_free(bestIndex);
- rax_free(bestScores);
- }
+ restoreTL(rl, tr, 0);
+ evaluateGenericInitrav(tr, tr->start);
+ }
+
+ assert(tr->likelihood >= startLH);
+
+ freeTL(rl);
+ rax_free(rl);
+
+ rax_free(oldIndex);
+ rax_free(bestIndex);
+ rax_free(bestScores);
+ }
}
View
2 topologies.c
@@ -102,7 +102,7 @@ static void saveTopolRELL(tree *tr, topolRELL *tpl)
saveTopolRELLRec(tr, p->back, tpl, &i, tr->rdta->numsp, tr->numBranches);
- assert(i == 2 * tr->mxtips - 3);
+ assert(i == 2 * tr->ntips - 3);
}

0 comments on commit 126d3a4

Please sign in to comment.