Fix for badIndelLength() throwing NPE at non-indel sites. Added integration test.

This commit is contained in:
Christopher Hartl 2012-08-25 12:38:23 -07:00
parent b59948709f
commit db2e88c7cb
3 changed files with 17 additions and 1 deletions

View File

@ -579,6 +579,9 @@ public class SelectVariants extends RodWalker<Integer, Integer> implements TreeR
} }
private boolean badIndelSize(final VariantContext vc) { private boolean badIndelSize(final VariantContext vc) {
List<Integer> lengths = vc.getIndelLengths();
if ( lengths == null )
return false; // VC does not harbor indel
for ( Integer indelLength : vc.getIndelLengths() ) { for ( Integer indelLength : vc.getIndelLengths() ) {
if ( indelLength > maxIndelSize ) if ( indelLength > maxIndelSize )
return true; return true;

View File

@ -716,7 +716,7 @@ public class VariantContext implements Feature { // to enable tribble integratio
* @return a list of indel lengths ( null if not of type indel or mixed ) * @return a list of indel lengths ( null if not of type indel or mixed )
*/ */
public List<Integer> getIndelLengths() { public List<Integer> getIndelLengths() {
if ( getType() != Type.INDEL && getType() != Type.MIXED ) { if ( getType() != Type.INDEL && getType() != Type.MIXED && getType() != Type.STRUCTURAL_INDEL ) {
return null; return null;
} }

View File

@ -128,6 +128,19 @@ public class SelectVariantsIntegrationTest extends WalkerTest {
executeTest("testVariantTypeSelection--" + testFile, spec); executeTest("testVariantTypeSelection--" + testFile, spec);
} }
@Test
public void testIndelLengthSelection() {
String testFile = privateTestDir + "complexExample1.vcf";
WalkerTestSpec spec = new WalkerTestSpec(
"-T SelectVariants -R " + b36KGReference + " -selectType INDEL --variant " + testFile + " -o %s --no_cmdline_in_header --maxIndelSize 3",
1,
Arrays.asList("004589868ca5dc887e2dff876b4cc797")
);
executeTest("testIndelLengthSelection--" + testFile, spec);
}
@Test @Test
public void testUsingDbsnpName() { public void testUsingDbsnpName() {
String testFile = privateTestDir + "combine.3.vcf"; String testFile = privateTestDir + "combine.3.vcf";