Return a consensus sequence of a and b. * @return an empty string if a consensus could not be found */
| 174 | * @return an empty string if a consensus could not be found |
| 175 | */ |
| 176 | static string |
| 177 | createConsensus(const Sequence& a, const Sequence& b) |
| 178 | { |
| 179 | assert(a.length() == b.length()); |
| 180 | if (a == b) |
| 181 | return a; |
| 182 | string s; |
| 183 | s.reserve(a.length()); |
| 184 | for (string::const_iterator ita = a.begin(), itb = b.begin(); ita != a.end(); ++ita, ++itb) { |
| 185 | bool mask = islower(*ita) || islower(*itb); |
| 186 | char ca = toupper(*ita), cb = toupper(*itb); |
| 187 | char c = ca == cb |
| 188 | ? ca |
| 189 | : ca == 'N' |
| 190 | ? cb |
| 191 | : cb == 'N' ? ca : ambiguityIsSubset(ca, cb) ? ambiguityOr(ca, cb) : 'x'; |
| 192 | if (c == 'x') |
| 193 | return string(""); |
| 194 | s += mask ? tolower(c) : c; |
| 195 | } |
| 196 | return s; |
| 197 | } |
| 198 | |
| 199 | typedef ContigGraph<DirectedGraph<ContigProperties, Distance>> Graph; |
| 200 | typedef graph_traits<Graph>::vertex_descriptor vertex_descriptor; |
no test coverage detected