| 243 | /** Collapse a bubble to a single path. */ |
| 244 | template <typename Graph> |
| 245 | void collapseJoinedBranches(Graph* collection, |
| 246 | BranchGroup& group) |
| 247 | { |
| 248 | typedef typename graph_traits<Graph>::vertex_descriptor V; |
| 249 | typedef typename vertex_bundle_type<Graph>::type VP; |
| 250 | typedef typename std::map<V, VP> Map; |
| 251 | |
| 252 | const BranchRecord& best = group[0]; |
| 253 | logger(5) << "Popping " << best.size() << ' ' |
| 254 | << best.front().first << '\n'; |
| 255 | |
| 256 | // Add the k-mer from the dead branches. |
| 257 | Map doomed; |
| 258 | for (BranchGroup::const_iterator branchIt = group.begin() + 1; |
| 259 | branchIt != group.end(); ++branchIt) { |
| 260 | const BranchRecord& branch = *branchIt; |
| 261 | for (BranchRecord::const_iterator it = branch.begin(); |
| 262 | it != branch.end(); ++it) |
| 263 | doomed.insert(*it); |
| 264 | } |
| 265 | |
| 266 | // Remove the k-mer that are in the good branch. |
| 267 | for (BranchRecord::const_iterator it = best.begin(); |
| 268 | it != best.end(); ++it) |
| 269 | doomed.erase(it->first); |
| 270 | |
| 271 | // Remove the dead k-mer from the assembly. |
| 272 | for (typename Map::const_iterator it = doomed.begin(); |
| 273 | it != doomed.end(); ++it) |
| 274 | removeSequenceAndExtensions(collection, *it); |
| 275 | } |
| 276 | |
| 277 | } // namespace AssemblyAlgorithms |
| 278 | |