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. */
| 411 | * represented in this map. |
| 412 | */ |
| 413 | map<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. */ |
| 445 | static void printDistanceMap(ostream& out, const Graph& g, |
no test coverage detected