Skip to content

Commit

Permalink
fixed fasta and bam too
Browse files Browse the repository at this point in the history
  • Loading branch information
gf777 committed Dec 26, 2024
1 parent ddd6f33 commit 6112f14
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions src/reads.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -761,10 +761,14 @@ void InReads::writeToStream() {

case 1: { // fasta[.gz]

for (std::pair<std::vector<InRead*>,uint32_t> inReads : readBatchesCpy) {
for (std::vector<std::pair<std::vector<InRead*>,uint32_t>>::iterator it = readBatchesCpy.begin(); it != readBatchesCpy.end();) {

auto &inReads = *it;

if (inReads.second != batchCounter)
if (inReads.second != batchCounter) {
++it;
continue;
}

lg.verbose("Writing read batch " + std::to_string(inReads.second) + " to file (" + std::to_string(inReads.first.size()) + ")");

Expand All @@ -773,6 +777,7 @@ void InReads::writeToStream() {
*outputStream.stream << '>' << read->seqHeader << '\n' << *read->inSequence << '\n';
delete read;
}
it = readBatchesCpy.erase(it);
++batchCounter;
}
break;
Expand Down Expand Up @@ -802,10 +807,14 @@ void InReads::writeToStream() {
}
case 3: { // bam&cram

for (std::pair<std::vector<InRead*>,uint32_t> inReads : readBatchesCpy) {
for (std::vector<std::pair<std::vector<InRead*>,uint32_t>>::iterator it = readBatchesCpy.begin(); it != readBatchesCpy.end();) {

auto &inReads = *it;

if (inReads.second != batchCounter)
if (inReads.second != batchCounter) {
++it;
continue;
}

lg.verbose("Writing read batch " + std::to_string(inReads.second) + " to file (" + std::to_string(inReads.first.size()) + ")");

Expand Down Expand Up @@ -847,6 +856,7 @@ void InReads::writeToStream() {
if (read->inSequenceQuality != NULL)
delete quality;
}
it = readBatchesCpy.erase(it);
++batchCounter;
}
break;
Expand Down

0 comments on commit 6112f14

Please sign in to comment.