Assemble contigs. * @return the number of contigs and k-mer assembled */
| 1197 | * @return the number of contigs and k-mer assembled |
| 1198 | */ |
| 1199 | pair<size_t, size_t> NetworkSequenceCollection:: |
| 1200 | performNetworkAssembly(FastaWriter* fileWriter) |
| 1201 | { |
| 1202 | Timer timer("NetworkAssembly"); |
| 1203 | NetworkSequenceCollection* seqCollection = this; |
| 1204 | pair<size_t, size_t> numAssembled(0, 0); |
| 1205 | uint64_t branchGroupID = 0; |
| 1206 | assert(m_activeBranchGroups.empty()); |
| 1207 | |
| 1208 | for (iterator iter = seqCollection->begin(); |
| 1209 | iter != seqCollection->end(); ++iter) { |
| 1210 | if (iter->second.deleted()) |
| 1211 | continue; |
| 1212 | |
| 1213 | extDirection dir; |
| 1214 | // dir will be set to the assembly direction if the sequence |
| 1215 | // can be assembled. |
| 1216 | SeqContiguity status = AssemblyAlgorithms::checkSeqContiguity( |
| 1217 | *iter, dir, true); |
| 1218 | if (status == SC_CONTIGUOUS) |
| 1219 | continue; |
| 1220 | else if(status == SC_ISLAND) |
| 1221 | { |
| 1222 | // Output the singleton contig. |
| 1223 | BranchRecord currBranch(SENSE); |
| 1224 | currBranch.push_back(*iter); |
| 1225 | currBranch.terminate(BS_NOEXT); |
| 1226 | assembleContig(fileWriter, currBranch, |
| 1227 | m_numAssembled + numAssembled.first); |
| 1228 | numAssembled.first++; |
| 1229 | numAssembled.second += currBranch.size(); |
| 1230 | continue; |
| 1231 | } |
| 1232 | |
| 1233 | BranchGroup group(dir, 1, iter->first); |
| 1234 | group.addBranch(BranchRecord(dir)); |
| 1235 | pair<BranchGroupMap::iterator, bool> |
| 1236 | inserted = m_activeBranchGroups.insert( |
| 1237 | BranchGroupMap::value_type(branchGroupID, group)); |
| 1238 | assert(inserted.second); |
| 1239 | |
| 1240 | // Generate the first extension request |
| 1241 | BranchRecord& branch = inserted.first->second[0]; |
| 1242 | branch.push_back(*iter); |
| 1243 | V kmer = iter->first; |
| 1244 | AssemblyAlgorithms::extendBranch(branch, |
| 1245 | kmer, iter->second.getExtension(dir)); |
| 1246 | assert(branch.isActive()); |
| 1247 | generateExtensionRequest(branchGroupID++, 0, kmer); |
| 1248 | |
| 1249 | numAssembled += processBranchesAssembly( |
| 1250 | fileWriter, numAssembled.first); |
| 1251 | seqCollection->pumpNetwork(); |
| 1252 | |
| 1253 | if(m_activeBranchGroups.size() > MAX_ACTIVE) |
| 1254 | { |
| 1255 | while(m_activeBranchGroups.size() > LOW_ACTIVE) |
| 1256 | { |
nothing calls this directly
no test coverage detected