Skip to content

Commit

Permalink
more cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesemery committed Jun 24, 2024
1 parent 2bd562e commit 985ba41
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,6 @@ public final class SoftClippedReadFilter extends ReadFilter {
static final long serialVersionUID = 1L;
private final Logger logger = LogManager.getLogger(this.getClass());

// @VisibleForTesting
// @Argument(fullName = ReadFilterArgumentDefinitions.INVERT_SOFT_CLIP_RATIO_FILTER,
// doc = "Inverts the results from this filter, causing all variants that would pass to fail and visa-versa.",
// optional = true
// )
// boolean doInvertFilter = false;

@VisibleForTesting
@Argument(fullName = ReadFilterArgumentDefinitions.SOFT_CLIPPED_RATIO_THRESHOLD,
doc = "Threshold ratio of soft clipped bases (anywhere in the cigar string) to total bases in read for read to be filtered.",
Expand Down Expand Up @@ -61,15 +54,15 @@ private boolean testMinSoftClippedRatio(final GATKRead read) {
totalLength += element.getLength();
}

final double softClipRatio = ((double)numSoftClippedBases / (double)totalLength);
final double softClipRatio = totalLength != 0 ? ((double)numSoftClippedBases / (double)totalLength) : 0.0;

return softClipRatio < maximumSoftClippedRatio;
return softClipRatio <= maximumSoftClippedRatio;
}

private boolean testMinLeadingTrailingSoftClippedRatio(final GATKRead read) {

if ( read.getCigarElements().size() < 1 ) {
return false;
return true; //NOTE: in this edge case that the read should pass this filter as there are no cigar elements to have edge soft-clipping.
}

// Get the index of the last cigar element:
Expand All @@ -90,9 +83,9 @@ private boolean testMinLeadingTrailingSoftClippedRatio(final GATKRead read) {
.sum();

// Calculate the ratio:
final double softClipRatio = ((double)numLeadingTrailingSoftClippedBases / (double)totalLength);
final double softClipRatio = totalLength != 0 ? ((double)numLeadingTrailingSoftClippedBases / (double)totalLength) : 0.0;

return softClipRatio < maximumLeadingTrailingSoftClippedRatio;
return softClipRatio <= maximumLeadingTrailingSoftClippedRatio;
}

@Override
Expand All @@ -119,10 +112,6 @@ else if ( maximumLeadingTrailingSoftClippedRatio != null ) {
);
}

// Check for if we want to invert our results:
if ( doInvertFilter ) {
return !result;
}
return result;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,6 @@ public void testOverclippedSoftClipRatioFilter(final String cigarString,

final GATKRead read = buildSAMRead(cigarString);
Assert.assertEquals(filter.test(read), expectedResult, cigarString);

// filter.doInvertFilter = true;
// Assert.assertEquals(filter.test(read), !expectedResult, "Inverted case: " + cigarString);
}

@Test(dataProvider= "SoftClippedLeadingTrailingRatioDataProvider")
Expand All @@ -56,9 +53,6 @@ public void testSoftClippedLeadingTrailingRatioFilter(final String cigarString,

final GATKRead read = buildSAMRead(cigarString);
Assert.assertEquals(filter.test(read), expectedResult, cigarString);

// filter.doInvertFilter = true;
// Assert.assertEquals(filter.test(read), !expectedResult, "Inverted case: " + cigarString);
}

@DataProvider(name = "SoftClipRatioDataProvider")
Expand Down

0 comments on commit 985ba41

Please sign in to comment.