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

Function makeDistanceMap

SimpleGraph/SimpleGraph.cpp:413–442  ·  view source on GitHub ↗

Return a map of contig IDs to their distance along this path. * Repeat contigs, which would have more than one position, are not * represented in this map. */

Source from the content-addressed store, hash-verified

411 * represented in this map.
412 */
413map<ContigNode, int> makeDistanceMap(const Graph& g,
414 const ContigNode& origin, const ContigPath& path)
415{
416 map<ContigNode, int> distances;
417 int distance = 0;
418 for (ContigPath::const_iterator it = path.begin();
419 it != path.end(); ++it) {
420 vertex_descriptor u = it == path.begin() ? origin : *(it - 1);
421 vertex_descriptor v = *it;
422 distance += getDistance(g, u, v);
423
424 bool inserted = distances.insert(
425 make_pair(v, distance)).second;
426 if (!inserted) {
427 // Mark this contig as a repeat.
428 distances[v] = INT_MIN;
429 }
430
431 distance += g[v].length;
432 }
433
434 // Remove the repeats.
435 for (map<ContigNode, int>::iterator it = distances.begin();
436 it != distances.end();)
437 if (it->second == INT_MIN)
438 distances.erase(it++);
439 else
440 ++it;
441 return distances;
442}
443
444/** Print a distance map. */
445static void printDistanceMap(ostream& out, const Graph& g,

Callers 2

printDistanceMapFunction · 0.85
handleEstimateFunction · 0.85

Calls 5

eraseMethod · 0.80
getDistanceFunction · 0.70
beginMethod · 0.45
endMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected