| 306 | } |
| 307 | |
| 308 | static void |
| 309 | handleAlignmentPair(const ReadAlignMap::value_type& curr, const ReadAlignMap::value_type& pair) |
| 310 | { |
| 311 | const string& currID = curr.first; |
| 312 | const string& pairID = pair.first; |
| 313 | |
| 314 | // Both reads must align to a unique location. |
| 315 | // The reads are allowed to span more than one contig, but |
| 316 | // at least one of the two reads must span no more than |
| 317 | // two contigs. |
| 318 | const unsigned MAX_SPAN = 2; |
| 319 | if (curr.second.empty() && pair.second.empty()) { |
| 320 | stats.bothUnaligned++; |
| 321 | } else if (curr.second.empty() || pair.second.empty()) { |
| 322 | stats.oneUnaligned++; |
| 323 | } else if (!checkUniqueAlignments(curr.second) || !checkUniqueAlignments(pair.second)) { |
| 324 | stats.numMulti++; |
| 325 | } else if (curr.second.size() > MAX_SPAN && pair.second.size() > MAX_SPAN) { |
| 326 | stats.numSplit++; |
| 327 | } else { |
| 328 | // Iterate over the vectors, outputting the aligments |
| 329 | bool counted = false; |
| 330 | for (AlignmentVector::const_iterator refAlignIter = curr.second.begin(); |
| 331 | refAlignIter != curr.second.end(); |
| 332 | ++refAlignIter) { |
| 333 | for (AlignmentVector::const_iterator pairAlignIter = pair.second.begin(); |
| 334 | pairAlignIter != pair.second.end(); |
| 335 | ++pairAlignIter) { |
| 336 | const Alignment& a0 = flipAlignment(*refAlignIter, currID); |
| 337 | const Alignment& a1 = flipAlignment(*pairAlignIter, pairID); |
| 338 | |
| 339 | bool sameTarget = a0.contig == a1.contig; |
| 340 | if (sameTarget && curr.second.size() == 1 && pair.second.size() == 1) { |
| 341 | // Same target and the only alignment. |
| 342 | if (a0.isRC != a1.isRC) { |
| 343 | // Correctly oriented. Add this alignment to |
| 344 | // the distribution of fragment sizes. |
| 345 | int size = fragmentSize(a0, a1); |
| 346 | histogram.insert(size); |
| 347 | if (!opt::fragPath.empty()) { |
| 348 | fragFile << size << '\n'; |
| 349 | assert(fragFile.good()); |
| 350 | } |
| 351 | } else |
| 352 | stats.numFF++; |
| 353 | counted = true; |
| 354 | } |
| 355 | |
| 356 | bool outputSameTarget = opt::fragPath.empty() && opt::histPath.empty(); |
| 357 | if (!sameTarget || outputSameTarget) { |
| 358 | cout << SAMRecord(a0, a1) << '\n' << SAMRecord(a1, a0) << '\n'; |
| 359 | assert(cout.good()); |
| 360 | } |
| 361 | } |
| 362 | } |
| 363 | if (!counted) |
| 364 | stats.numDifferent++; |
| 365 | } |
no test coverage detected