Skip to content

Commit

Permalink
improve readCounts report to make categories mutually exclusive and t…
Browse files Browse the repository at this point in the history
…allyable
  • Loading branch information
tedsharpe committed Apr 18, 2019
1 parent f6b1b69 commit 724270b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@
*
* <h3>Input</h3>
* <ul>
* <li>A BAM file. Any combination of paired or unpaired reads can be presented. In paired mode, the default mode
* of operation of the program where overlapping pairs are combined bedore variant calling, the BAM must be
* <li>A BAM file. Any combination of paired or unpaired reads can be presented. In paired mode (the default mode
* of operation of the program where overlapping pairs are combined before variant calling), the BAM must be
* in unsorted or query-name sorted order (so that read pairs are adjacent). The BAM file should be
* aligned to the amplicon under scrutiny. You may also specify a text file listing several BAMs.</li>
* <li>A fasta-formatted reference file with the wild-type sequence of the gene as a single contig. It's best
Expand Down Expand Up @@ -169,7 +169,6 @@ public void onTraversalStart() {

@Override
public void traverse() {
final byte[] refSeq = reference.getRefSeq();

// ignore non-primary alignments
final Stream<GATKRead> reads = getTransformedReadStream(ReadFilterLibrary.PRIMARY_LINE);
Expand Down Expand Up @@ -534,7 +533,7 @@ private static void writeMoleculeCounts( final MoleculeCounts moleculeCounts,
final BufferedWriter writer )
throws IOException {
final long nInconsistentPairs = moleculeCounts.getNInconsistentPairs();
final long nInsufficientFlankMolecules = moleculeCounts.getnInsufficientFlank();
final long nInsufficientFlankMolecules = moleculeCounts.getNInsufficientFlank();
final long nWildTypeMolecules = moleculeCounts.getNWildType();
final long nLowQualityVariantMolecules = moleculeCounts.getNLowQualityVariant();
final long nCalledVariantMolecules = moleculeCounts.getCalledVariant();
Expand Down Expand Up @@ -686,7 +685,7 @@ private int updateCoverage( final List<Interval> refCoverageList ) {
public void bumpInconsistentPairs() { nInconsistentPairs += 1; }
public long getNInconsistentPairs() { return nInconsistentPairs; }
public void bumpInsufficientFlank() { nInsufficientFlank += 1; }
public long getnInsufficientFlank() { return nInsufficientFlank; }
public long getNInsufficientFlank() { return nInsufficientFlank; }
public void bumpNLowQualityVariant() { nLowQualityVariant += 1; }
public long getNLowQualityVariant() { return nLowQualityVariant; }
public void bumpCalledVariant() { nCalledVariant += 1; }
Expand Down Expand Up @@ -1567,7 +1566,7 @@ private static List<SNV> combineVariations( final ReadReport report1, final Read
return ReadReport.NULL_REPORT;
}

final Interval trim = calculateTrim(read.getBaseQualitiesNoCopy(), readCounts);
final Interval trim = calculateTrim(read.getBaseQualitiesNoCopy());
if ( trim.size() == 0 ) {
readCounts.bumpNLowQualityReads();
return ReadReport.NULL_REPORT;
Expand All @@ -1582,7 +1581,7 @@ private static List<SNV> combineVariations( final ReadReport report1, final Read
return readReport;
}

@VisibleForTesting static Interval calculateTrim( final byte[] quals, final ReadCounts readCounts ) {
@VisibleForTesting static Interval calculateTrim( final byte[] quals ) {
// find initial end-trim
int readStart = 0;
int hiQCount = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import htsjdk.samtools.SAMFileHeader;
import org.broadinstitute.hellbender.GATKBaseTest;
import org.broadinstitute.hellbender.tools.AnalyzeSaturationMutagenesis.*;
import org.broadinstitute.hellbender.tools.spark.utils.HopscotchMap;
import org.broadinstitute.hellbender.utils.read.ArtificialReadUtils;
import org.broadinstitute.hellbender.utils.read.GATKRead;
import org.testng.Assert;
Expand Down Expand Up @@ -517,23 +516,22 @@ public void testPairedApplication() {
public void testCalculateTrim() {
final byte BAD_Q = (byte)(minQ - 1);
final byte GOOD_Q = (byte)minQ;
final ReadCounts readCounts = new ReadCounts();
final byte[] quals = new byte[100];
Arrays.fill(quals, BAD_Q);
Assert.assertEquals(calculateTrim(quals, readCounts).size(), 0);
Assert.assertEquals(calculateTrim(quals).size(), 0);
Arrays.fill(quals, GOOD_Q);
Assert.assertEquals(calculateTrim(quals, readCounts), new Interval(0, 100));
Assert.assertEquals(calculateTrim(quals), new Interval(0, 100));
quals[minLength] = BAD_Q;
Assert.assertEquals(calculateTrim(quals, readCounts), new Interval(0, 100));
Assert.assertEquals(calculateTrim(quals), new Interval(0, 100));
quals[minLength - 1] = BAD_Q;
Assert.assertEquals(calculateTrim(quals, readCounts), new Interval(minLength + 1, 100));
Assert.assertEquals(calculateTrim(quals), new Interval(minLength + 1, 100));
quals[quals.length - minLength] = BAD_Q;
Assert.assertEquals(calculateTrim(quals, readCounts), new Interval(minLength + 1, quals.length - minLength));
Assert.assertEquals(calculateTrim(quals), new Interval(minLength + 1, quals.length - minLength));
Arrays.fill(quals, GOOD_Q);
for ( int idx = minLength - 1; idx < quals.length; idx += minLength ) {
quals[idx] = BAD_Q;
}
Assert.assertEquals(calculateTrim(quals, readCounts).size(), 0);
Assert.assertEquals(calculateTrim(quals).size(), 0);
}

@Test
Expand Down

0 comments on commit 724270b

Please sign in to comment.