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