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

Function mergeContigs

MergePaths/MergeContigs.cpp:213–277  ·  view source on GitHub ↗

Append the sequence of contig v to seq. */

Source from the content-addressed store, hash-verified

211
212/** Append the sequence of contig v to seq. */
213static void
214mergeContigs(
215 const Graph& g,
216 const Contigs& contigs,
217 vertex_descriptor u,
218 vertex_descriptor v,
219 Sequence& seq,
220 const ContigPath& path)
221{
222 int d = get(edge_bundle, g, u, v).distance;
223 assert(d < 0);
224 unsigned overlap = -d;
225 const Sequence& s = sequence(contigs, v);
226 assert(s.length() >= overlap);
227 Sequence ao;
228 Sequence bo(s, 0, overlap);
229 Sequence o;
230 do {
231 assert(seq.length() >= overlap);
232 ao = seq.substr(seq.length() - overlap);
233 o = createConsensus(ao, bo);
234 if (!o.empty()) {
235 seq.resize(seq.length() - overlap);
236 seq += o;
237 seq += Sequence(s, overlap);
238 return;
239 }
240 } while (chomp(seq, 'n'));
241
242 // Try an overlap alignment.
243 if (opt::verbose > 2)
244 cerr << '\n';
245 vector<overlap_align> overlaps;
246 alignOverlap(ao, bo, 0, overlaps, false, opt::verbose > 2);
247 bool good = false;
248 if (!overlaps.empty()) {
249 assert(overlaps.size() == 1);
250 const overlap_align& o = overlaps.front();
251 unsigned matches = o.overlap_match;
252 const string& consensus = o.overlap_str;
253 float identity = (float)matches / consensus.size();
254 good = matches >= opt::minOverlap && identity >= opt::minIdentity;
255 if (opt::verbose > 2)
256 cerr << matches << " / " << consensus.size() << " = " << identity
257 << (matches < opt::minOverlap
258 ? " (too few)"
259 : identity < opt::minIdentity ? " (too low)" : " (good)")
260 << '\n';
261 }
262 if (good) {
263 assert(overlaps.size() == 1);
264 const overlap_align& o = overlaps.front();
265 seq.erase(seq.length() - overlap + o.overlap_t_pos);
266 seq += o.overlap_str;
267 seq += Sequence(s, o.overlap_h_pos + 1);
268 } else {
269 cerr << "warning: the head of " << get(vertex_name, g, v)
270 << " does not match the tail of the previous contig\n"

Callers 1

mergePathFunction · 0.70

Calls 11

chompFunction · 0.85
alignOverlapFunction · 0.85
resizeMethod · 0.80
eraseMethod · 0.80
getFunction · 0.70
sequenceFunction · 0.70
createConsensusFunction · 0.70
lengthMethod · 0.45
emptyMethod · 0.45
sizeMethod · 0.45
frontMethod · 0.45

Tested by

no test coverage detected