Return the minimum number of matches. */
| 162 | |
| 163 | /** Return the minimum number of matches. */ |
| 164 | static unsigned countMatches(const alignment& o, |
| 165 | const string& consensus) |
| 166 | { |
| 167 | unsigned minMatches = consensus.size(); |
| 168 | const seq_col& scol = *o.scol; |
| 169 | vector<int> proc(scol.length, 0); |
| 170 | algn_pos **ap = o.algn; |
| 171 | for (int s = 0; s < scol.length; s++) { |
| 172 | unsigned matches = 0; |
| 173 | const seq& sq = scol.seqs[s]; |
| 174 | for (int j = 0; j < o.max_pos; j++) { |
| 175 | if (proc[s] < sq.length) { |
| 176 | const algn_pos& ap1 = *find_eqc(ap, s, proc[s]); |
| 177 | assert(j <= *ap1.eqcAlgnPos); |
| 178 | if (*ap1.eqcAlgnPos == j) { |
| 179 | char c = sq.data[proc[s]]; |
| 180 | if (toupper(c) == toupper(consensus[j])) |
| 181 | matches++; |
| 182 | proc[s]++; |
| 183 | } |
| 184 | } |
| 185 | } |
| 186 | minMatches = min(minMatches, matches); |
| 187 | } |
| 188 | return minMatches; |
| 189 | } |
| 190 | |
| 191 | static struct seq_col* read_seqs(const vector<string>& amb_seqs) |
| 192 | { |