1 | #include "muscle.h" |
---|
2 | #include "msa.h" |
---|
3 | #include "seqvect.h" |
---|
4 | #include "msa.h" |
---|
5 | #include "tree.h" |
---|
6 | #include "profile.h" |
---|
7 | |
---|
8 | void MUSCLE(SeqVect &v, MSA &msaOut) |
---|
9 | { |
---|
10 | const unsigned uSeqCount = v.Length(); |
---|
11 | |
---|
12 | if (0 == uSeqCount) |
---|
13 | Quit("No sequences in input file"); |
---|
14 | |
---|
15 | ALPHA Alpha = ALPHA_Undefined; |
---|
16 | switch (g_SeqType) |
---|
17 | { |
---|
18 | case SEQTYPE_Auto: |
---|
19 | Alpha = v.GuessAlpha(); |
---|
20 | break; |
---|
21 | |
---|
22 | case SEQTYPE_Protein: |
---|
23 | Alpha = ALPHA_Amino; |
---|
24 | break; |
---|
25 | |
---|
26 | case SEQTYPE_RNA: |
---|
27 | Alpha = ALPHA_RNA; |
---|
28 | break; |
---|
29 | |
---|
30 | case SEQTYPE_DNA: |
---|
31 | Alpha = ALPHA_DNA; |
---|
32 | break; |
---|
33 | |
---|
34 | default: |
---|
35 | Quit("Invalid seq type"); |
---|
36 | } |
---|
37 | SetAlpha(Alpha); |
---|
38 | v.FixAlpha(); |
---|
39 | |
---|
40 | if (ALPHA_DNA == Alpha || ALPHA_RNA == Alpha) |
---|
41 | { |
---|
42 | SetPPScore(PPSCORE_SPN); |
---|
43 | g_Distance1 = DISTANCE_Kmer4_6; |
---|
44 | } |
---|
45 | |
---|
46 | unsigned uMaxL = 0; |
---|
47 | unsigned uTotL = 0; |
---|
48 | for (unsigned uSeqIndex = 0; uSeqIndex < uSeqCount; ++uSeqIndex) |
---|
49 | { |
---|
50 | unsigned L = v.GetSeq(uSeqIndex).Length(); |
---|
51 | uTotL += L; |
---|
52 | if (L > uMaxL) |
---|
53 | uMaxL = L; |
---|
54 | } |
---|
55 | |
---|
56 | SetIter(1); |
---|
57 | g_bDiags = g_bDiags1; |
---|
58 | SetSeqStats(uSeqCount, uMaxL, uTotL/uSeqCount); |
---|
59 | |
---|
60 | MSA::SetIdCount(uSeqCount); |
---|
61 | |
---|
62 | //// Initialize sequence ids. |
---|
63 | //// From this point on, ids must somehow propogate from here. |
---|
64 | // for (unsigned uSeqIndex = 0; uSeqIndex < uSeqCount; ++uSeqIndex) |
---|
65 | // v.SetSeqId(uSeqIndex, uSeqIndex); |
---|
66 | |
---|
67 | if (uSeqCount > 1) |
---|
68 | MHackStart(v); |
---|
69 | |
---|
70 | if (0 == uSeqCount) |
---|
71 | { |
---|
72 | msaOut.Clear(); |
---|
73 | return; |
---|
74 | } |
---|
75 | |
---|
76 | if (1 == uSeqCount && ALPHA_Amino == Alpha) |
---|
77 | { |
---|
78 | const Seq &s = v.GetSeq(0); |
---|
79 | msaOut.FromSeq(s); |
---|
80 | return; |
---|
81 | } |
---|
82 | |
---|
83 | // First iteration |
---|
84 | Tree GuideTree; |
---|
85 | TreeFromSeqVect(v, GuideTree, g_Cluster1, g_Distance1, g_Root1); |
---|
86 | |
---|
87 | SetMuscleTree(GuideTree); |
---|
88 | |
---|
89 | ProgNode *ProgNodes = 0; |
---|
90 | if (g_bLow) |
---|
91 | ProgNodes = ProgressiveAlignE(v, GuideTree, msaOut); |
---|
92 | else |
---|
93 | ProgressiveAlign(v, GuideTree, msaOut); |
---|
94 | SetCurrentAlignment(msaOut); |
---|
95 | |
---|
96 | if (1 == g_uMaxIters || 2 == uSeqCount) |
---|
97 | { |
---|
98 | MHackEnd(msaOut); |
---|
99 | return; |
---|
100 | } |
---|
101 | |
---|
102 | g_bDiags = g_bDiags2; |
---|
103 | SetIter(2); |
---|
104 | |
---|
105 | if (g_bLow) |
---|
106 | { |
---|
107 | if (0 != g_uMaxTreeRefineIters) |
---|
108 | RefineTreeE(msaOut, v, GuideTree, ProgNodes); |
---|
109 | } |
---|
110 | else |
---|
111 | RefineTree(msaOut, GuideTree); |
---|
112 | |
---|
113 | extern void DeleteProgNode(ProgNode &Node); |
---|
114 | const unsigned uNodeCount = GuideTree.GetNodeCount(); |
---|
115 | for (unsigned uNodeIndex = 0; uNodeIndex < uNodeCount; ++uNodeIndex) |
---|
116 | DeleteProgNode(ProgNodes[uNodeIndex]); |
---|
117 | |
---|
118 | delete[] ProgNodes; |
---|
119 | ProgNodes = 0; |
---|
120 | |
---|
121 | SetSeqWeightMethod(g_SeqWeight2); |
---|
122 | SetMuscleTree(GuideTree); |
---|
123 | |
---|
124 | if (g_bAnchors) |
---|
125 | RefineVert(msaOut, GuideTree, g_uMaxIters - 2); |
---|
126 | else |
---|
127 | RefineHoriz(msaOut, GuideTree, g_uMaxIters - 2, false, false); |
---|
128 | |
---|
129 | MHackEnd(msaOut); |
---|
130 | } |
---|