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

Function constructAmbiguousPath

SimpleGraph/SimpleGraph.cpp:327–407  ·  view source on GitHub ↗

Return an ambiguous path that agrees with all the given paths. */

Source from the content-addressed store, hash-verified

325
326/** Return an ambiguous path that agrees with all the given paths. */
327static ContigPath constructAmbiguousPath(const Graph &g,
328 const ContigNode& origin, const ContigPaths& paths)
329{
330 assert(!paths.empty());
331
332 // Find the size of the smallest path.
333 const ContigPath& firstSol = paths.front();
334 size_t min_len = firstSol.size();
335 for (ContigPaths::const_iterator it = paths.begin() + 1;
336 it != paths.end(); ++it)
337 min_len = min(min_len, it->size());
338
339 // Find the longest prefix.
340 ContigPath vppath;
341 size_t longestPrefix;
342 bool commonPrefix = true;
343 for (longestPrefix = 0;
344 longestPrefix < min_len; longestPrefix++) {
345 const ContigNode& common_path_node = firstSol[longestPrefix];
346 for (ContigPaths::const_iterator solIter = paths.begin();
347 solIter != paths.end(); ++solIter) {
348 const ContigNode& pathnode = (*solIter)[longestPrefix];
349 if (pathnode != common_path_node) {
350 // Found the longest prefix.
351 commonPrefix = false;
352 break;
353 }
354 }
355 if (!commonPrefix)
356 break;
357 vppath.push_back(common_path_node);
358 }
359
360 // Find the longest suffix.
361 ContigPath vspath;
362 size_t longestSuffix;
363 bool commonSuffix = true;
364 for (longestSuffix = 0;
365 longestSuffix < min_len-longestPrefix; longestSuffix++) {
366 const ContigNode& common_path_node
367 = firstSol[firstSol.size()-longestSuffix-1];
368 for (ContigPaths::const_iterator solIter = paths.begin();
369 solIter != paths.end(); ++solIter) {
370 const ContigNode& pathnode
371 = (*solIter)[solIter->size()-longestSuffix-1];
372 if (pathnode != common_path_node) {
373 // Found the longest suffix.
374 commonSuffix = false;
375 break;
376 }
377 }
378 if (!commonSuffix)
379 break;
380 vspath.push_back(common_path_node);
381 }
382
383 ContigPath out;
384 out.reserve(vppath.size() + 1 + vspath.size());

Callers 1

handleEstimateFunction · 0.85

Calls 10

calculatePathLengthFunction · 0.85
ContigNodeClass · 0.85
getDistanceFunction · 0.70
emptyMethod · 0.45
frontMethod · 0.45
sizeMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
push_backMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected