MCPcopy Create free account
hub / github.com/BirolLab/abyss / createConsensus

Function createConsensus

MergePaths/PathConsensus.cpp:352–372  ·  view source on GitHub ↗

Return a consensus sequence of a and b. * @return an empty string if a consensus could not be found */

Source from the content-addressed store, hash-verified

350 * @return an empty string if a consensus could not be found
351 */
352static string createConsensus(const Sequence& a, const Sequence& b)
353{
354 assert(a.length() == b.length());
355 if (a == b)
356 return a;
357 string s;
358 s.reserve(a.length());
359 for (string::const_iterator ita = a.begin(), itb = b.begin();
360 ita != a.end(); ++ita, ++itb) {
361 bool mask = islower(*ita) || islower(*itb);
362 char ca = toupper(*ita), cb = toupper(*itb);
363 char c = ca == cb ? ca
364 : ca == 'N' ? cb
365 : cb == 'N' ? ca
366 : 'x';
367 if (c == 'x')
368 return string("");
369 s += mask ? tolower(c) : c;
370 }
371 return s;
372}
373
374/** Merge the specified two contigs, default overlap is k-1,
375 * generate a consensus sequence of the overlapping region. The result

Callers 1

mergeContigsFunction · 0.70

Calls 3

lengthMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected