/** Find every path that overlaps with the specified path. */ static void findOverlaps(const Graph& g, const Paths& paths, const SeedMap& seedMap, const Vertex& v, Overlaps& overlaps) { ContigPath rc; if (v.sense) { rc = paths[v.id]; reverseComplement(rc.begin(), rc.end()); } const ContigPath& path = v.sense ? rc : paths[v.id]; for (ContigPath::const_iterator it = path.begin(); it != path.end(); ++it) { if (it->ambiguous()) continue; pair<SeedMap::const_iterator, SeedMap::const_iterator> range = seedMap.equal_range(*it); for (SeedMap::const_iterator seed = range.first; seed != range.second; ++seed) { if (v == seed->second) continue; int distance = 0; unsigned overlap = findOverlap(g, paths, it, path.end(), seed->second, distance); if (overlap > 0) overlaps.push_back(Overlap(v, seed->second, overlap, distance)); } } }
/** Record the trimmed contigs. */ static void recordTrimmedContigs( ContigPath::const_iterator first, ContigPath::const_iterator last) { for (ContigPath::const_iterator it = first; it != last; ++it) if (!it->ambiguous()) s_trimmedContigs.push_back(it->contigIndex()); }
static void appendToMergeQ(deque<ContigNode>& mergeQ, set<ContigNode>& seen, const ContigPath& path) { for (ContigPath::const_iterator it = path.begin(); it != path.end(); ++it) if (!it->ambiguous() && seen.insert(*it).second) mergeQ.push_back(*it); }
/** Return a pivot suitable for aligning the two paths if one exists, * otherwise return false. */ static pair<ContigNode, bool> findPivot( const ContigPath& path1, const ContigPath& path2) { for (ContigPath::const_iterator it = path2.begin(); it != path2.end(); ++it) { if (it->ambiguous()) continue; if (count(path2.begin(), path2.end(), *it) == 1 && count(path1.begin(), path1.end(), *it) == 1) return make_pair(*it, true); } return make_pair(ContigNode(0), false); }
/** Return all contigs that are tandem repeats, identified as those * contigs that appear more than once in a single path. */ static set<ContigID> findRepeats(const ContigPathMap& paths) { set<ContigID> repeats; for (ContigPathMap::const_iterator pathIt = paths.begin(); pathIt != paths.end(); ++pathIt) { const ContigPath& path = pathIt->second; map<ContigID, unsigned> count; for (ContigPath::const_iterator it = path.begin(); it != path.end(); ++it) if (!it->ambiguous()) count[it->contigIndex()]++; for (map<ContigID, unsigned>::const_iterator it = count.begin(); it != count.end(); ++it) if (it->second > 1) repeats.insert(it->first); } return repeats; }
/** Merge the specified path. */ static Contig mergePath(const Graph& g, const Contigs& contigs, const ContigPath& path) { Sequence seq; unsigned coverage = 0; for (ContigPath::const_iterator it = path.begin(); it != path.end(); ++it) { if (!it->ambiguous()) coverage += g[*it].coverage; if (seq.empty()) { seq = sequence(contigs, *it); } else { assert(it != path.begin()); mergeContigs(g, contigs, *(it-1), *it, seq, path); } } ostringstream ss; ss << seq.size() << ' ' << coverage << ' '; pathToComment(ss, g, path); return Contig(ss.str(), seq); }