1 | #include "muscle.h" |
---|
2 | #include "profile.h" |
---|
3 | #include "pwpath.h" |
---|
4 | |
---|
5 | SCORE FastScorePath2(const ProfPos *PA, unsigned uLengthA, |
---|
6 | const ProfPos *PB, unsigned uLengthB, const PWPath &Path) |
---|
7 | { |
---|
8 | const unsigned uEdgeCount = Path.GetEdgeCount(); |
---|
9 | Log("Edge SS PLA PLB Match Gap Total\n"); |
---|
10 | Log("---- -- --- --- ----- --- -----\n"); |
---|
11 | char cType = 'S'; |
---|
12 | SCORE scoreTotal = 0; |
---|
13 | for (unsigned uEdgeIndex = 0; uEdgeIndex < uEdgeCount; ++uEdgeIndex) |
---|
14 | { |
---|
15 | const PWEdge &Edge = Path.GetEdge(uEdgeIndex); |
---|
16 | const char cPrevType = cType; |
---|
17 | cType = Edge.cType; |
---|
18 | const unsigned uPrefixLengthA = Edge.uPrefixLengthA; |
---|
19 | const unsigned uPrefixLengthB = Edge.uPrefixLengthB; |
---|
20 | bool bGap = false; |
---|
21 | bool bMatch = false; |
---|
22 | SCORE scoreGap = 0; |
---|
23 | SCORE scoreMatch = 0; |
---|
24 | |
---|
25 | switch (cType) |
---|
26 | { |
---|
27 | case 'M': |
---|
28 | { |
---|
29 | if (0 == uPrefixLengthA || 0 == uPrefixLengthB) |
---|
30 | Quit("FastScorePath2, M zero length"); |
---|
31 | |
---|
32 | const ProfPos &PPA = PA[uPrefixLengthA - 1]; |
---|
33 | const ProfPos &PPB = PB[uPrefixLengthB - 1]; |
---|
34 | |
---|
35 | bMatch = true; |
---|
36 | scoreMatch = ScoreProfPos2(PPA, PPB); |
---|
37 | |
---|
38 | if ('D' == cPrevType) |
---|
39 | { |
---|
40 | bGap = true; |
---|
41 | assert(uPrefixLengthA > 1); |
---|
42 | scoreGap = PA[uPrefixLengthA-2].m_scoreGapClose; |
---|
43 | } |
---|
44 | else if ('I' == cPrevType) |
---|
45 | { |
---|
46 | bGap = true; |
---|
47 | assert(uPrefixLengthB > 1); |
---|
48 | scoreGap = PB[uPrefixLengthB-2].m_scoreGapClose; |
---|
49 | } |
---|
50 | break; |
---|
51 | } |
---|
52 | |
---|
53 | case 'D': |
---|
54 | { |
---|
55 | if (0 == uPrefixLengthA) |
---|
56 | Quit("FastScorePath2, D zero length"); |
---|
57 | |
---|
58 | const ProfPos &PPA = PA[uPrefixLengthA - 1]; |
---|
59 | bGap = true; |
---|
60 | switch (cPrevType) |
---|
61 | { |
---|
62 | case 'S': |
---|
63 | scoreGap = PPA.m_scoreGapOpen; |
---|
64 | break; |
---|
65 | case 'M': |
---|
66 | scoreGap = PPA.m_scoreGapOpen; |
---|
67 | break; |
---|
68 | case 'D': |
---|
69 | // scoreGap = g_scoreGapExtend; |
---|
70 | scoreGap = 0; |
---|
71 | break; |
---|
72 | case 'I': |
---|
73 | Quit("FastScorePath2 DI"); |
---|
74 | } |
---|
75 | break; |
---|
76 | } |
---|
77 | |
---|
78 | case 'I': |
---|
79 | { |
---|
80 | if (0 == uPrefixLengthB) |
---|
81 | Quit("FastScorePath2, I zero length"); |
---|
82 | |
---|
83 | const ProfPos &PPB = PB[uPrefixLengthB - 1]; |
---|
84 | bGap = true; |
---|
85 | switch (cPrevType) |
---|
86 | { |
---|
87 | case 'S': |
---|
88 | scoreGap = PPB.m_scoreGapOpen; |
---|
89 | break; |
---|
90 | case 'M': |
---|
91 | scoreGap = PPB.m_scoreGapOpen; |
---|
92 | break; |
---|
93 | case 'I': |
---|
94 | scoreGap = 0; |
---|
95 | // scoreGap = g_scoreGapExtend; |
---|
96 | break; |
---|
97 | case 'D': |
---|
98 | Quit("FastScorePath2 DI"); |
---|
99 | } |
---|
100 | break; |
---|
101 | } |
---|
102 | |
---|
103 | case 'U': |
---|
104 | { |
---|
105 | Quit("FastScorePath2 U"); |
---|
106 | } |
---|
107 | |
---|
108 | default: |
---|
109 | Quit("FastScorePath2: invalid type %c", cType); |
---|
110 | } |
---|
111 | |
---|
112 | Log("%4u %c%c %4u %4u ", uEdgeIndex, cPrevType, cType, |
---|
113 | uPrefixLengthA, uPrefixLengthB); |
---|
114 | if (bMatch) |
---|
115 | Log("%7.1f ", scoreMatch); |
---|
116 | else |
---|
117 | Log(" "); |
---|
118 | if (bGap) |
---|
119 | Log("%7.1f ", scoreGap); |
---|
120 | else |
---|
121 | Log(" "); |
---|
122 | SCORE scoreEdge = scoreMatch + scoreGap; |
---|
123 | scoreTotal += scoreEdge; |
---|
124 | Log("%7.1f %7.1f", scoreEdge, scoreTotal); |
---|
125 | Log("\n"); |
---|
126 | } |
---|
127 | |
---|
128 | SCORE scoreGap = 0; |
---|
129 | // if (!g_bTermGapsHalf) |
---|
130 | switch (cType) |
---|
131 | { |
---|
132 | case 'M': |
---|
133 | scoreGap = 0; |
---|
134 | break; |
---|
135 | |
---|
136 | case 'D': |
---|
137 | { |
---|
138 | const ProfPos &LastPPA = PA[uLengthA - 1]; |
---|
139 | scoreGap = LastPPA.m_scoreGapClose; |
---|
140 | break; |
---|
141 | } |
---|
142 | |
---|
143 | case 'I': |
---|
144 | { |
---|
145 | const ProfPos &LastPPB = PB[uLengthB - 1]; |
---|
146 | scoreGap = LastPPB.m_scoreGapClose; |
---|
147 | break; |
---|
148 | } |
---|
149 | |
---|
150 | case 'U': |
---|
151 | Quit("Unaligned regions not supported"); |
---|
152 | |
---|
153 | case 'S': |
---|
154 | break; |
---|
155 | |
---|
156 | default: |
---|
157 | Quit("Invalid type %c", cType); |
---|
158 | } |
---|
159 | |
---|
160 | Log(" %cE %4u %4u %7.1f\n", cType, uLengthA, uLengthB, scoreGap); |
---|
161 | scoreTotal += scoreGap; |
---|
162 | |
---|
163 | Log("Total = %g\n", scoreTotal); |
---|
164 | return scoreTotal; |
---|
165 | } |
---|