Skip to content

Commit

Permalink
Fix issue caused by unpaired reads. Reads that are neither the 1st no…
Browse files Browse the repository at this point in the history
…r the 2nd read caused an adapter trimming assertion to fail
  • Loading branch information
Thomas Willems committed Apr 16, 2020
1 parent 63fe4df commit 12e989b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/adapter_trimmer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ void AdapterTrimmer::trim_adapters(BamAlignment& aln){

double start_time = clock(); // Start the clock
int64_t num_trim;
if (aln.IsFirstMate()){
if (aln.IsFirstMate() || (!aln.IsPaired())){
if (aln.IsReverseStrand())
num_trim = trim_five_prime(aln, r1_rc_adapters_);
else
Expand All @@ -168,8 +168,11 @@ void AdapterTrimmer::trim_adapters(BamAlignment& aln){
locus_r2_trimmed_reads_ += (num_trim > 0 ? 1 : 0);
locus_r2_total_reads_++;
}
else
else {
printErrorAndDie(aln.Name());
assert(false);
}

locus_trimming_time_ += (clock() - start_time)/CLOCKS_PER_SEC; // Turn off the clock
}

Expand Down
4 changes: 4 additions & 0 deletions src/bam_processor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,10 @@ void BamProcessor::read_and_filter_reads(BamCramMultiReader& reader, const std::
std::string file_label = "0_";

while (reader.GetNextAlignment(alignment)){
// Discard reads where the 1st/2nd mate info isn't clear
if (alignment.IsPaired() && (!alignment.IsFirstMate() && !alignment.IsSecondMate()))
continue;

// Discard reads that don't overlap the STR region and whose mate pair has no chance of overlapping the region
if (alignment.Position() > region_group.stop() || alignment.GetEndPosition() < region_group.start()){
if (!alignment.IsPaired() || alignment.MatePosition() == alignment.Position())
Expand Down

0 comments on commit 12e989b

Please sign in to comment.