1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
|
#include "muscle.h"
#include "msa.h"
#include "tree.h"
#include "profile.h"
#include <stdio.h>
void RefineTree(MSA &msa, Tree &tree)
{
const unsigned uSeqCount = msa.GetSeqCount();
if (tree.GetLeafCount() != uSeqCount)
Quit("Refine tree, tree has different number of nodes");
if (uSeqCount < 3)
return;
#if DEBUG
ValidateMuscleIds(msa);
ValidateMuscleIds(tree);
#endif
unsigned *IdToDiffsLeafNodeIndex = new unsigned[uSeqCount];
unsigned uDiffsCount = uSeqCount;
Tree Tree2;
for (unsigned uIter = 0; uIter < g_uMaxTreeRefineIters; ++uIter)
{
TreeFromMSA(msa, Tree2, g_Cluster2, g_Distance2, g_Root2, g_pstrDistMxFileName2);
#if DEBUG
ValidateMuscleIds(Tree2);
#endif
Tree Diffs;
DiffTrees(Tree2, tree, Diffs, IdToDiffsLeafNodeIndex);
tree.Copy(Tree2);
const unsigned uNewDiffsNodeCount = Diffs.GetNodeCount();
const unsigned uNewDiffsCount = (uNewDiffsNodeCount - 1)/2;
if (0 == uNewDiffsCount || uNewDiffsCount >= uDiffsCount)
{
ProgressStepsDone();
break;
}
uDiffsCount = uNewDiffsCount;
MSA msa2;
RealignDiffs(msa, Diffs, IdToDiffsLeafNodeIndex, msa2);
#if DEBUG
ValidateMuscleIds(msa2);
#endif
msa.Copy(msa2);
SetCurrentAlignment(msa);
}
delete[] IdToDiffsLeafNodeIndex;
}
|