| 503 | } |
| 504 | |
| 505 | static void* alignReadsToDB(void*) |
| 506 | { |
| 507 | opt::chastityFilter = false; |
| 508 | opt::trimMasked = false; |
| 509 | static timeval start, end; |
| 510 | |
| 511 | pthread_mutex_lock(&g_mutexCerr); |
| 512 | gettimeofday(&start, NULL); |
| 513 | pthread_mutex_unlock(&g_mutexCerr); |
| 514 | |
| 515 | for (pair<FastaRecord, size_t> recPair = g_pipeMux.nextValue(); |
| 516 | recPair.second > 0; recPair = g_pipeMux.nextValue()) { |
| 517 | const FastaRecord& rec = recPair.first; |
| 518 | const Sequence& seq = rec.seq; |
| 519 | ostringstream output; |
| 520 | if (seq.find_first_not_of("ACGT0123") == string::npos) { |
| 521 | if (opt::colourSpace) |
| 522 | assert(isdigit(seq[0])); |
| 523 | else |
| 524 | assert(isalpha(seq[0])); |
| 525 | } |
| 526 | |
| 527 | switch (opt::format) { |
| 528 | case KALIGNER: |
| 529 | if (opt::multimap == opt::MULTIMAP) |
| 530 | g_aligner_m->alignRead(rec.id, seq, |
| 531 | affix_ostream_iterator<Alignment>( |
| 532 | output, "\t")); |
| 533 | else |
| 534 | g_aligner_u->alignRead(rec.id, seq, |
| 535 | affix_ostream_iterator<Alignment>( |
| 536 | output, "\t")); |
| 537 | break; |
| 538 | case SAM: |
| 539 | if (opt::multimap == opt::MULTIMAP) |
| 540 | g_aligner_m->alignRead(rec.id, seq, |
| 541 | ostream_iterator<SAMRecord>(output, "\n")); |
| 542 | else |
| 543 | g_aligner_u->alignRead(rec.id, seq, |
| 544 | ostream_iterator<SAMRecord>(output, "\n")); |
| 545 | break; |
| 546 | } |
| 547 | |
| 548 | ostringstream out; |
| 549 | string s = output.str(); |
| 550 | switch (opt::format) { |
| 551 | case KALIGNER: |
| 552 | out << rec.id; |
| 553 | if (opt::printSeq) { |
| 554 | out << ' '; |
| 555 | if (opt::colourSpace) |
| 556 | out << rec.anchor; |
| 557 | out << seq; |
| 558 | } |
| 559 | out << s << '\n'; |
| 560 | break; |
| 561 | case SAM: |
| 562 | out << s; |