Bugfix for ReadClipper with ReducedReads
-- The previous version of the read clipping operations wouldn't modify the reduced reads counts, so hardClipToRegion would result in a read with, say, 50 bp of sequence and base qualities but 250 bp of reduced read counts. Updated the hardClip operation to handle reduce reads, and added a unit test to make sure this works properly. Also had to update GATKSAMRecord.emptyRead() to set the reduced count to new byte[0] if the template read is a reduced read -- Update md5s, where the new code recovers a TP variant with count 2 that was missed previously
This commit is contained in:
parent
5dd73ba2d1
commit
0387ea8df9
|
|
@ -188,7 +188,7 @@ public class HaplotypeCallerIntegrationTest extends WalkerTest {
|
||||||
public void HCTestReducedBam() {
|
public void HCTestReducedBam() {
|
||||||
WalkerTest.WalkerTestSpec spec = new WalkerTest.WalkerTestSpec(
|
WalkerTest.WalkerTestSpec spec = new WalkerTest.WalkerTestSpec(
|
||||||
"-T HaplotypeCaller --disableDithering -R " + b37KGReference + " --no_cmdline_in_header -I " + privateTestDir + "bamExample.ReducedRead.ADAnnotation.bam -o %s -L 1:67,225,396-67,288,518", 1,
|
"-T HaplotypeCaller --disableDithering -R " + b37KGReference + " --no_cmdline_in_header -I " + privateTestDir + "bamExample.ReducedRead.ADAnnotation.bam -o %s -L 1:67,225,396-67,288,518", 1,
|
||||||
Arrays.asList("3c87eb93ffe3a0166aca753050b981e1"));
|
Arrays.asList("0df626cd0d76aca8a05a545d0b36bf23"));
|
||||||
executeTest("HC calling on a ReducedRead BAM", spec);
|
executeTest("HC calling on a ReducedRead BAM", spec);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -379,6 +379,12 @@ public class ClippingOp {
|
||||||
hardClippedRead.setBaseQualities(newBaseDeletionQuals, EventType.BASE_DELETION);
|
hardClippedRead.setBaseQualities(newBaseDeletionQuals, EventType.BASE_DELETION);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (read.isReducedRead()) {
|
||||||
|
final byte[] reducedCounts = new byte[newLength];
|
||||||
|
System.arraycopy(read.getReducedReadCounts(), copyStart, reducedCounts, 0, newLength);
|
||||||
|
hardClippedRead.setReducedReadCounts(reducedCounts);
|
||||||
|
}
|
||||||
|
|
||||||
return hardClippedRead;
|
return hardClippedRead;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -393,6 +393,22 @@ public class GATKSAMRecord extends BAMRecord {
|
||||||
setAttribute(REDUCED_READ_CONSENSUS_TAG, counts);
|
setAttribute(REDUCED_READ_CONSENSUS_TAG, counts);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the reduced read counts tag for this record to counts
|
||||||
|
*
|
||||||
|
* Note that this function does not set the REDUCED_READ_CONSENSUS_TAG value, it's purely for manipulating
|
||||||
|
* the underlying reduced reads count
|
||||||
|
*
|
||||||
|
* TODO -- this function needs to be fixed when the RR spec is set to 2.0
|
||||||
|
*
|
||||||
|
* @param counts the count array
|
||||||
|
*/
|
||||||
|
public void setReducedReadCounts(final byte[] counts) {
|
||||||
|
if ( counts.length != getReadBases().length ) throw new IllegalArgumentException("Reduced counts length " + counts.length + " != bases length " + getReadBases().length);
|
||||||
|
retrievedReduceReadCounts = true;
|
||||||
|
reducedReadCounts = counts;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The number of bases corresponding the i'th base of the reduced read.
|
* The number of bases corresponding the i'th base of the reduced read.
|
||||||
*
|
*
|
||||||
|
|
@ -678,6 +694,7 @@ public class GATKSAMRecord extends BAMRecord {
|
||||||
emptyRead.setCigarString("");
|
emptyRead.setCigarString("");
|
||||||
emptyRead.setReadBases(new byte[0]);
|
emptyRead.setReadBases(new byte[0]);
|
||||||
emptyRead.setBaseQualities(new byte[0]);
|
emptyRead.setBaseQualities(new byte[0]);
|
||||||
|
if ( read.isReducedRead() ) emptyRead.setReducedReadCounts(new byte[0]);
|
||||||
|
|
||||||
SAMReadGroupRecord samRG = read.getReadGroup();
|
SAMReadGroupRecord samRG = read.getReadGroup();
|
||||||
emptyRead.clearAttributes();
|
emptyRead.clearAttributes();
|
||||||
|
|
|
||||||
|
|
@ -35,6 +35,7 @@ import org.testng.Assert;
|
||||||
import org.testng.annotations.BeforeClass;
|
import org.testng.annotations.BeforeClass;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
|
@ -348,4 +349,20 @@ public class ReadClipperUnitTest extends BaseTest {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test(enabled = true)
|
||||||
|
public void testHardClipReducedRead() {
|
||||||
|
GATKSAMRecord read = ReadClipperTestUtils.makeReadFromCigar("10M");
|
||||||
|
final byte[] counts = new byte[read.getReadLength()];
|
||||||
|
for ( int i = 0; i < counts.length; i++ ) counts[i] = (byte)i;
|
||||||
|
read.setReducedReadCounts(counts);
|
||||||
|
int alnStart = read.getAlignmentStart();
|
||||||
|
int alnEnd = read.getAlignmentEnd();
|
||||||
|
int readLength = read.getReadLength();
|
||||||
|
for (int i = 0; i < readLength / 2; i++) {
|
||||||
|
GATKSAMRecord clippedRead = ReadClipper.hardClipBothEndsByReferenceCoordinates(read, alnStart + i, alnEnd - i);
|
||||||
|
final byte[] expectedReducedCounts = Arrays.copyOfRange(counts, i + 1, readLength - i - 1);
|
||||||
|
Assert.assertEquals(clippedRead.getReducedReadCounts(), expectedReducedCounts);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue