Merge pull request #304 from broadinstitute/eb_rr_header_negative_fix_again

Fixing the 'header is negative' problem in Reduce Reads... again.
This commit is contained in:
Mark DePristo 2013-06-24 11:55:52 -07:00
commit ff76d0c877
2 changed files with 18 additions and 5 deletions

View File

@ -94,7 +94,7 @@ public class SlidingWindowUnitTest extends BaseTest {
////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////
@Test(enabled = true) @Test(enabled = true)
public void testLeadingClipThenInsertion() { public void testLeadingSoftClipThenInsertion() {
final GATKSAMRecord read = ArtificialSAMUtils.createArtificialRead(header, "foo", 0, 1, 10); final GATKSAMRecord read = ArtificialSAMUtils.createArtificialRead(header, "foo", 0, 1, 10);
read.setReadBases(Utils.dupBytes((byte) 'A', 10)); read.setReadBases(Utils.dupBytes((byte) 'A', 10));
@ -104,8 +104,21 @@ public class SlidingWindowUnitTest extends BaseTest {
final SlidingWindow slidingWindow = new SlidingWindow("1", 0, 1); final SlidingWindow slidingWindow = new SlidingWindow("1", 0, 1);
slidingWindow.addRead(read); slidingWindow.addRead(read);
Pair<ObjectSet<GATKSAMRecord>, CompressionStash> result = slidingWindow.close(null); slidingWindow.close(null);
}
@Test(enabled = true)
public void testLeadingHardClipThenInsertion() {
final GATKSAMRecord read = ArtificialSAMUtils.createArtificialRead(header, "foo", 0, 1, 8);
read.setReadBases(Utils.dupBytes((byte) 'A', 8));
read.setBaseQualities(Utils.dupBytes((byte)30, 8));
read.setMappingQuality(30);
read.setCigarString("2H2I6M");
final SlidingWindow slidingWindow = new SlidingWindow("1", 0, 10, header, new GATKSAMReadGroupRecord("test"), 0, 0.05, 0.05, 0.05, 20, 20, 100, ReduceReads.DownsampleStrategy.Normal, false);
slidingWindow.addRead(read);
slidingWindow.close(null);
} }
////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////

View File

@ -613,15 +613,15 @@ public class ReadUtils {
* Checks if a read starts with an insertion. * Checks if a read starts with an insertion.
* *
* @param cigarForRead the CIGAR to evaluate * @param cigarForRead the CIGAR to evaluate
* @param ignoreClipOps should we ignore S and H operators when evaluating whether an I operator is at the beginning? * @param ignoreSoftClipOps should we ignore S operators when evaluating whether an I operator is at the beginning? Note that H operators are always ignored.
* @return the element if it's a leading insertion or null otherwise * @return the element if it's a leading insertion or null otherwise
*/ */
public static CigarElement readStartsWithInsertion(final Cigar cigarForRead, final boolean ignoreClipOps) { public static CigarElement readStartsWithInsertion(final Cigar cigarForRead, final boolean ignoreSoftClipOps) {
for ( final CigarElement cigarElement : cigarForRead.getCigarElements() ) { for ( final CigarElement cigarElement : cigarForRead.getCigarElements() ) {
if ( cigarElement.getOperator() == CigarOperator.INSERTION ) if ( cigarElement.getOperator() == CigarOperator.INSERTION )
return cigarElement; return cigarElement;
else if ( !ignoreClipOps || (cigarElement.getOperator() != CigarOperator.HARD_CLIP && cigarElement.getOperator() != CigarOperator.SOFT_CLIP) ) else if ( cigarElement.getOperator() != CigarOperator.HARD_CLIP && ( !ignoreSoftClipOps || cigarElement.getOperator() != CigarOperator.SOFT_CLIP) )
break; break;
} }
return null; return null;