Generate distance estimates for the specified alignments. */
| 336 | |
| 337 | /** Generate distance estimates for the specified alignments. */ |
| 338 | static void writeEstimates(ostream& out, |
| 339 | const vector<SAMRecord>& pairs, |
| 340 | const vector<unsigned>& lengthVec, const PMF& pmf) |
| 341 | { |
| 342 | assert(!pairs.empty()); |
| 343 | ContigID id0(get(g_contigNames, pairs.front().rname)); |
| 344 | assert(id0 < lengthVec.size()); |
| 345 | unsigned len0 = lengthVec[id0]; |
| 346 | if (len0 < opt::seedLen) |
| 347 | return; // Skip contigs shorter than the seed length. |
| 348 | |
| 349 | ostringstream ss; |
| 350 | if (opt::format == DIST) |
| 351 | ss << pairs.front().rname; |
| 352 | |
| 353 | typedef map<ContigNode, Pairs> PairsMap; |
| 354 | PairsMap dataMap[2]; |
| 355 | for (Pairs::const_iterator it = pairs.begin(); |
| 356 | it != pairs.end(); ++it) |
| 357 | dataMap[it->isReverse()][find_vertex( |
| 358 | it->mrnm, it->isReverse() == it->isMateReverse(), |
| 359 | g_contigNames)] |
| 360 | .push_back(*it); |
| 361 | |
| 362 | for (int sense0 = false; sense0 <= true; sense0++) { |
| 363 | if (opt::format == DIST && sense0) |
| 364 | ss << " ;"; |
| 365 | const PairsMap& x = dataMap[sense0 ^ opt::rf]; |
| 366 | for (PairsMap::const_iterator it = x.begin(); |
| 367 | it != x.end(); ++it) |
| 368 | writeEstimate(opt::format == DIST ? ss : out, |
| 369 | ContigNode(id0, sense0), it->first, |
| 370 | len0, lengthVec[it->first.id()], |
| 371 | it->second, pmf); |
| 372 | } |
| 373 | if (opt::format == DIST) |
| 374 | #pragma omp critical(out) |
| 375 | out << ss.str() << '\n'; |
| 376 | assert(out.good()); |
| 377 | } |
| 378 | |
| 379 | /** Load a histogram from the specified file. */ |
| 380 | static Histogram loadHist(const string& path) |
no test coverage detected