1 package org.broadinstitute.hellbender.tools.walkers.varianteval; 2 3 import org.broadinstitute.barclay.argparser.CommandLineException; 4 import org.broadinstitute.hellbender.CommandLineProgramTest; 5 import org.broadinstitute.hellbender.cmdline.StandardArgumentDefinitions; 6 import org.broadinstitute.hellbender.exceptions.GATKException; 7 import org.broadinstitute.hellbender.exceptions.UserException; 8 import org.broadinstitute.hellbender.testutils.ArgumentsBuilder; 9 import org.broadinstitute.hellbender.testutils.IntegrationTestSpec; 10 import org.broadinstitute.hellbender.utils.SimpleInterval; 11 import org.testng.annotations.DataProvider; 12 import org.testng.annotations.Test; 13 14 import java.io.File; 15 import java.io.IOException; 16 import java.util.ArrayList; 17 import java.util.Arrays; 18 import java.util.List; 19 20 public class VariantEvalIntegrationTest extends CommandLineProgramTest { 21 22 private static String fundamentalTestVCF = "FundamentalsTest.annotated.db.subset.snps_and_indels.vcf"; 23 private static String fundamentalTestSNPsVCF = "FundamentalsTest.annotated.db.subset.final.vcf"; 24 private static String fundamentalTestSNPsWithMLEVCF = "FundamentalsTest.annotated.db.subset.final.withMLE.vcf"; 25 private static String fundamentalTestSNPsSplit1of2VCF = "FundamentalsTest.annotated.db.subset.final.split_1_of_2.vcf"; 26 private static String fundamentalTestSNPsSplit2of2VCF = "FundamentalsTest.annotated.db.subset.final.split_2_of_2.vcf"; 27 private static String fundamentalTestSNPsOneSampleVCF = "FundamentalsTest.annotated.db.subset.final.NA12045.vcf"; 28 private static String snpEffVcf = largeFileTestDir + "snpEff2.0.5.AFR.unfiltered.VariantAnnotator.output.vcf"; 29 getExpectedFile(String testName)30 private String getExpectedFile(String testName) { 31 return getToolTestDataDir() + "expected/" + testName + ".expected.txt"; 32 } 33 getTestFilePath(String fileName)34 protected String getTestFilePath(String fileName) { 35 return super.getTestFile(fileName).getPath(); 36 } 37 38 @Test testFunctionClassWithSnpeff()39 public void testFunctionClassWithSnpeff() throws IOException { 40 String name = "testFunctionClassWithSnpeff"; 41 42 IntegrationTestSpec spec = new IntegrationTestSpec( 43 " -R " + b37Reference + 44 " --dbsnp " + dbsnp_138_b37_1_65M_vcf + 45 " --eval " + snpEffVcf + 46 " -no-ev" + 47 " -EV TiTvVariantEvaluator" + 48 " -no-st" + 49 " -ST FunctionalClass" + 50 " -L " + snpEffVcf + 51 " -O %s" 52 , Arrays.asList(getExpectedFile(name))); 53 54 spec.executeTest(name, this); 55 } 56 57 @Test testStratifySamplesAndExcludeMonomorphicSites()58 public void testStratifySamplesAndExcludeMonomorphicSites() throws IOException { 59 String vcf = getTestFilePath("/CEU.trio.callsForVE.vcf"); 60 String name = "testStratifySamplesAndExcludeMonomorphicSites"; 61 IntegrationTestSpec spec = new IntegrationTestSpec( 62 " -R " + b37Reference + 63 " --dbsnp " + dbsnp_138_b37_1_65M_vcf+ 64 " --eval " + vcf + 65 " -no-ev" + 66 " -EV TiTvVariantEvaluator" + 67 " -ST Sample" + 68 " -L " + vcf + 69 " -O %s" 70 , Arrays.asList(getExpectedFile(name)) 71 ); 72 spec.executeTest(name, this); 73 } 74 75 @Test testFundamentalsCountVariantsSNPsAndIndels()76 public void testFundamentalsCountVariantsSNPsAndIndels() throws IOException { 77 String name = "testFundamentalsCountVariantsSNPsAndIndels"; 78 IntegrationTestSpec spec = new IntegrationTestSpec( 79 " -R " + b37_reference_20_21 + 80 " --dbsnp " + dbsnp_138_b37_20_21_vcf + 81 " --eval " + getTestFilePath(fundamentalTestVCF) + 82 " -no-ev" + 83 " -EV CountVariants" + 84 " -no-st" + 85 " -L " + getTestFilePath(fundamentalTestVCF) + 86 " -O %s", Arrays.asList(getExpectedFile(name)) 87 ); 88 spec.executeTest(name, this); 89 } 90 91 @Test testFundamentalsCountVariantsSNPsAndIndelsWithNovelty()92 public void testFundamentalsCountVariantsSNPsAndIndelsWithNovelty() throws IOException { 93 String name = "testFundamentalsCountVariantsSNPsAndIndelsWithNovelty"; 94 getTestFilePath(fundamentalTestVCF); 95 IntegrationTestSpec spec = new IntegrationTestSpec( 96 " -R " + b37_reference_20_21 + 97 " --dbsnp " + dbsnp_138_b37_20_21_vcf + 98 " --eval " + getTestFilePath(fundamentalTestVCF) + 99 " -no-ev" + 100 " -EV CountVariants" + 101 " -no-st" + 102 " -ST Novelty" + 103 " -L " + getTestFilePath(fundamentalTestVCF) + 104 " -O %s", 105 Arrays.asList(getExpectedFile(name)) 106 ); 107 spec.executeTest(name, this); 108 } 109 110 @Test testFundamentalsCountVariantsSNPsAndIndelsWithNoveltyAndFilter()111 public void testFundamentalsCountVariantsSNPsAndIndelsWithNoveltyAndFilter() throws IOException { 112 String name = "testFundamentalsCountVariantsSNPsAndIndelsWithNoveltyAndFilter"; 113 114 IntegrationTestSpec spec = new IntegrationTestSpec( 115 " -R " + b37_reference_20_21 + 116 " --dbsnp " + dbsnp_138_b37_20_21_vcf + 117 " --eval " + getTestFilePath(fundamentalTestVCF) + 118 " -no-ev" + 119 " -EV CountVariants" + 120 " -no-st" + 121 " -ST Novelty" + 122 " -ST Filter" + 123 " -L " + getTestFilePath(fundamentalTestVCF) + 124 " -O %s", 125 Arrays.asList(getExpectedFile(name)) 126 ); 127 spec.executeTest(name, this); 128 } 129 130 @Test testFundamentalsCountVariantsSNPsAndIndelsWithCpG()131 public void testFundamentalsCountVariantsSNPsAndIndelsWithCpG() throws IOException { 132 String name = "testFundamentalsCountVariantsSNPsAndIndelsWithCpG"; 133 134 IntegrationTestSpec spec = new IntegrationTestSpec( 135 " -R " + b37_reference_20_21 + 136 " --dbsnp " + dbsnp_138_b37_20_21_vcf + 137 " --eval " + getTestFilePath(fundamentalTestVCF) + 138 " -no-ev" + 139 " -EV CountVariants" + 140 " -no-st" + 141 " -ST CpG" + 142 " -L " + getTestFilePath(fundamentalTestVCF) + 143 " -O %s", 144 Arrays.asList(getExpectedFile(name)) 145 ); 146 spec.executeTest(name, this); 147 } 148 149 @Test testFundamentalsCountVariantsSNPsAndIndelsWithFunctionalClasses()150 public void testFundamentalsCountVariantsSNPsAndIndelsWithFunctionalClasses() throws IOException { 151 String name = "testFundamentalsCountVariantsSNPsAndIndelsWithFunctionalClass"; 152 153 IntegrationTestSpec spec = new IntegrationTestSpec( 154 " -R " + b37_reference_20_21 + 155 " --dbsnp " + dbsnp_138_b37_20_21_vcf + 156 " --eval " + getTestFilePath(fundamentalTestVCF) + 157 " -no-ev" + 158 " -EV CountVariants" + 159 " -no-st" + 160 " -ST FunctionalClass" + 161 " -L " + getTestFilePath(fundamentalTestVCF) + 162 " -O %s", 163 Arrays.asList(getExpectedFile(name)) 164 ); 165 spec.executeTest(name, this); 166 } 167 168 @Test testFundamentalsCountVariantsSNPsAndIndelsWithDegeneracy()169 public void testFundamentalsCountVariantsSNPsAndIndelsWithDegeneracy() throws IOException { 170 String name = "testFundamentalsCountVariantsSNPsAndIndelsWithDegeneracy"; 171 172 IntegrationTestSpec spec = new IntegrationTestSpec( 173 " -R " + b37_reference_20_21 + 174 " --dbsnp " + dbsnp_138_b37_20_21_vcf + 175 " --eval " + getTestFilePath(fundamentalTestVCF) + 176 " -no-ev" + 177 " -EV CountVariants" + 178 " -no-st" + 179 " -ST Degeneracy" + 180 " -L " + getTestFilePath(fundamentalTestVCF) + 181 " -O %s", 182 Arrays.asList(getExpectedFile(name)) 183 ); 184 spec.executeTest(name, this); 185 } 186 187 @Test testFundamentalsCountVariantsSNPsAndIndelsWithSample()188 public void testFundamentalsCountVariantsSNPsAndIndelsWithSample() throws IOException { 189 String name = "testFundamentalsCountVariantsSNPsAndIndelsWithSample"; 190 191 IntegrationTestSpec spec = new IntegrationTestSpec( 192 " -R " + b37_reference_20_21 + 193 " --dbsnp " + dbsnp_138_b37_20_21_vcf + 194 " --eval " + getTestFilePath(fundamentalTestVCF) + 195 " -no-ev" + 196 " -EV CountVariants" + 197 " -no-st" + 198 " -ST Sample" + 199 " -L " + getTestFilePath(fundamentalTestVCF) + 200 " -O %s", 201 Arrays.asList(getExpectedFile(name)) 202 ); 203 spec.executeTest(name, this); 204 } 205 206 @Test testFundamentalsCountVariantsSNPsAndIndelsWithJexlExpression()207 public void testFundamentalsCountVariantsSNPsAndIndelsWithJexlExpression() throws IOException { 208 String name = "testFundamentalsCountVariantsSNPsAndIndelsWithJexlExpression"; 209 210 IntegrationTestSpec spec = new IntegrationTestSpec( 211 " -R " + b37_reference_20_21 + 212 " --dbsnp " + dbsnp_138_b37_20_21_vcf + 213 " --eval " + getTestFilePath(fundamentalTestVCF) + 214 " -no-ev" + 215 " -EV CountVariants" + 216 " -no-st" + 217 " -ST JexlExpression" + 218 " -select 'DP < 20'" + 219 " -select-name DepthSelect" + 220 " -L " + getTestFilePath(fundamentalTestVCF) + 221 " -O %s", 222 Arrays.asList(getExpectedFile(name)) 223 ); 224 spec.executeTest(name, this); 225 } 226 227 @Test testFundamentalsCountVariantsSNPsAndIndelsWithMultipleJexlExpressions()228 public void testFundamentalsCountVariantsSNPsAndIndelsWithMultipleJexlExpressions() throws IOException { 229 String name = "testFundamentalsCountVariantsSNPsAndIndelsWithMultipleJexlExpressions"; 230 231 IntegrationTestSpec spec = new IntegrationTestSpec( 232 " -R " + b37_reference_20_21 + 233 " --dbsnp " + dbsnp_138_b37_20_21_vcf + 234 " --eval " + getTestFilePath(fundamentalTestVCF) + 235 " -no-ev" + 236 " -EV CountVariants" + 237 " -no-st" + 238 " -ST JexlExpression" + 239 " -select 'DP < 20'" + 240 " -select-name DepthLt20" + 241 " -select 'DP > 20'" + 242 " -select-name DepthGt20" + 243 " -L " + getTestFilePath(fundamentalTestVCF) + 244 " -O %s", 245 Arrays.asList(getExpectedFile(name)) 246 ); 247 spec.executeTest(name, this); 248 } 249 250 @Test testFundamentalsCountVariantsNoCompRod()251 public void testFundamentalsCountVariantsNoCompRod() throws IOException { 252 String name = "testFundamentalsCountVariantsNoCompRod"; 253 254 IntegrationTestSpec spec = new IntegrationTestSpec( 255 " -R " + b37_reference_20_21 + 256 " --eval " + getTestFilePath(fundamentalTestVCF) + 257 " -no-ev" + 258 " -EV CountVariants" + 259 " -no-st" + 260 " -L " + getTestFilePath(fundamentalTestVCF) + 261 " -O %s", 262 Arrays.asList(getExpectedFile(name)) 263 ); 264 spec.executeTest(name, this); 265 } 266 267 @Test testSelect1()268 public void testSelect1() throws IOException { 269 String name = "testSelect1"; 270 String vcf1 = getTestFilePath("yri.trio.gatk_glftrio.intersection.annotated.filtered.chr1.500.noheader.vcf"); 271 String vcf2 = getTestFilePath("yri.trio.gatk.ug.head.vcf"); 272 273 String tests = " -R " + b37Reference + 274 " --dbsnp " + dbsnp_138_b37_1_65M_vcf + 275 " --eval " + vcf1 + 276 " --comp:comp_genotypes " + vcf2; 277 IntegrationTestSpec spec = new IntegrationTestSpec(withSelect(tests, "DP < 50", "DP50") + " " + " -ST CpG -O %s", Arrays.asList(getExpectedFile(name))); 278 spec.executeTest(name, this); 279 } 280 281 @Test testVEMendelianViolationEvaluator()282 public void testVEMendelianViolationEvaluator() throws IOException { 283 String vcfFile = getTestFilePath("MendelianViolationEval.vcf"); 284 String pedFile = "MendelianViolationEval.ped"; 285 286 String name = "testVEMendelianViolationEvaluator"; 287 IntegrationTestSpec spec = new IntegrationTestSpec(" -R " + b37Reference + " --eval " + vcfFile + " -ped "+ getTestFilePath(pedFile) +" -no-ev -EV MendelianViolationEvaluator -L 1:10109-10315 -O %s -mvq 0 -no-st", 288 Arrays.asList(getExpectedFile(name))); 289 290 spec.executeTest(name, this); 291 } 292 293 @Test testMVEvalFamilyStrat()294 public void testMVEvalFamilyStrat() throws IOException { 295 String name = "testMVEvalFamilyStrat"; 296 String vcfFile = "PhaseByTransmission.IntegrationTest.TP.vcf"; 297 String pedFile = "PhaseByTransmission.IntegrationTest.goodFamilies.ped"; 298 299 IntegrationTestSpec spec = new IntegrationTestSpec(" -R " + b37Reference + " -ped " + getTestFilePath(pedFile) + " -eval " + getTestFilePath(vcfFile) + " -no-ev -no-st -ST Family -EV MendelianViolationEvaluator -O %s", 300 Arrays.asList(getExpectedFile(name))); 301 spec.executeTest(name, this); 302 } 303 304 withSelect(String cmd, String select, String name)305 private static String withSelect(String cmd, String select, String name) { 306 return String.format("%s -select '%s' -select-name %s", cmd, select, name); 307 } 308 309 @Test testCompOverlap()310 public void testCompOverlap() throws IOException { 311 String eval = getTestFilePath("pacbio.ts.recalibrated.vcf"); 312 String comp = largeFileTestDir + "genotypes_r27_nr.b37_fwd.subset.vcf"; 313 314 String name = "testCompOverlap"; 315 String extraArgs = " -R " + b37_reference_20_21 + " -L " + getTestFilePath("pacbio.hg19.intervals") + " --comp:comphapmap " + comp + " --eval " + eval + " -no-ev -EV CompOverlap -sn NA12878 -no-st -ST Novelty -O %s"; 316 IntegrationTestSpec spec = new IntegrationTestSpec(extraArgs,Arrays.asList(getExpectedFile(name))); 317 spec.executeTest(name,this); 318 } 319 320 @Test testEvalTrackWithoutGenotypes()321 public void testEvalTrackWithoutGenotypes() throws IOException { 322 String vcf = largeFileTestDir + "ALL.20100201.chr20.subset.bi.sites.vcf"; 323 String name = "testEvalTrackWithoutGenotypes"; 324 String extraArgs = " -R " + b37_reference_20_21 + 325 " -L 20" + 326 " --dbsnp " + dbsnp_138_b37_20_21_vcf + 327 " --eval:evalBI " + vcf + 328 " -no-st -ST Novelty -O %s"; 329 IntegrationTestSpec spec = new IntegrationTestSpec(extraArgs,Arrays.asList(getExpectedFile(name))); 330 spec.executeTest(name,this); 331 } 332 333 @Test testEvalTrackWithoutGenotypesWithSampleFields()334 public void testEvalTrackWithoutGenotypesWithSampleFields() throws IOException { 335 String name = "testEvalTrackWithoutGenotypesWithSampleFields"; 336 String vcf = getTestFilePath("noGenotypes.vcf"); 337 338 IntegrationTestSpec spec = new IntegrationTestSpec( 339 " -R " + b37_reference_20_21 + 340 " -eval " + vcf + 341 " -O %s", 342 Arrays.asList(getExpectedFile(name))); //There is no md5 because we only care that this completes without an exception. 343 spec.executeTest(name, this); 344 345 } 346 347 @Test testMultipleEvalTracksWithoutGenotypes()348 public void testMultipleEvalTracksWithoutGenotypes() throws IOException { 349 String name = "testMultipleEvalTracksWithoutGenotypes"; 350 String vcf1 = largeFileTestDir + "ALL.20100201.chr20.subset.bi.sites.vcf"; 351 String vcf2 = largeFileTestDir + "ALL.20100201.chr20.subset.bc.sites.vcf"; 352 353 String extraArgs = 354 " -R " + b37_reference_20_21 + 355 " -L 20" + 356 " --dbsnp " + dbsnp_138_b37_20_21_vcf + 357 " --eval:evalBI " + vcf1 + 358 " --eval:evalBC " + vcf2 + 359 " -no-st -ST Novelty -O %s"; 360 IntegrationTestSpec spec = new IntegrationTestSpec(extraArgs,Arrays.asList(getExpectedFile(name))); 361 spec.executeTest(name,this); 362 } 363 364 @Test testMultipleCompTracks()365 public void testMultipleCompTracks() throws IOException { 366 String vcf = largeFileTestDir + "1000G.phase3.broad.withGenotypes.chr20.10100000.vcf"; 367 String eval = getTestFilePath("NA12878.hg19.HiSeq.WGS.cleaned.ug.snpfiltered.indelfiltered.optimized.cut.subset.vcf"); 368 369 String extraArgs = " -R " + b37_reference_20_21 + 370 " --comp " + vcf + 371 " --eval " + eval + 372 " --dbsnp " + dbsnp_138_b37_20_21_vcf + 373 " -L 20:10000000-10100000" + 374 " -no-st -no-ev -ST Novelty -EV CompOverlap" + 375 " -O %s"; 376 377 String name = "testMultipleCompTracks"; 378 IntegrationTestSpec spec = new IntegrationTestSpec(extraArgs,Arrays.asList(getExpectedFile(name))); 379 spec.executeTest(name,this); 380 } 381 382 @Test testPerSampleAndSubsettedSampleHaveSameResults()383 public void testPerSampleAndSubsettedSampleHaveSameResults() throws IOException { 384 String name = "testPerSampleAndSubsettedSampleHaveSameResults-subset"; 385 IntegrationTestSpec spec = new IntegrationTestSpec( 386 " -R " + b37_reference_20_21 + 387 " --dbsnp " + dbsnp_138_b37_20_21_vcf + 388 " --eval " + getTestFilePath(fundamentalTestSNPsVCF) + 389 " -no-ev" + 390 " -EV CompOverlap" + 391 " -sn NA12045" + 392 " -no-st" + 393 " -L " + getTestFilePath(fundamentalTestSNPsVCF) + 394 " -O %s", 395 Arrays.asList(getExpectedFile(name)) 396 ); 397 spec.executeTest(name, this); 398 399 String name2 = "testPerSampleAndSubsettedSampleHaveSameResults-Onesample"; 400 IntegrationTestSpec spec2 = new IntegrationTestSpec( 401 " -R " + b37_reference_20_21 + 402 " --dbsnp " + dbsnp_138_b37_20_21_vcf + 403 " --eval " + getTestFilePath(fundamentalTestSNPsOneSampleVCF) + 404 " -no-ev" + 405 " -EV CompOverlap" + 406 " -no-st" + 407 " -L " + getTestFilePath(fundamentalTestSNPsOneSampleVCF) + 408 " -O %s", 409 Arrays.asList(getExpectedFile(name2)) 410 ); 411 spec2.executeTest(name2, this); 412 } 413 414 415 @Test testAlleleCountStrat()416 public void testAlleleCountStrat() throws IOException { 417 String name = "testAlleleCountStrat"; 418 IntegrationTestSpec spec = new IntegrationTestSpec( 419 " -R " + b37_reference_20_21 + 420 " --dbsnp " + dbsnp_138_b37_20_21_vcf + 421 " --eval " + getTestFilePath(fundamentalTestSNPsVCF) + 422 " -no-ev" + 423 " -EV CountVariants" + 424 " -no-st" + 425 " -ST AlleleCount" + 426 " -L " + getTestFilePath(fundamentalTestSNPsVCF) + 427 " -O %s", 428 Arrays.asList(getExpectedFile(name)) 429 ); 430 spec.executeTest(name, this); 431 } 432 433 @Test testAlleleCountStratWithMLE()434 public void testAlleleCountStratWithMLE() throws IOException { 435 String name = "testAlleleCountStratWithMLE"; 436 437 IntegrationTestSpec spec = new IntegrationTestSpec( 438 " -R " + b37_reference_20_21 + 439 " --dbsnp " + dbsnp_138_b37_20_21_vcf + 440 " --eval " + getTestFilePath(fundamentalTestSNPsWithMLEVCF) + 441 " -no-ev" + 442 " -EV CountVariants" + 443 " -no-st" + 444 " -ST AlleleCount" + 445 " -L " + getTestFilePath(fundamentalTestSNPsWithMLEVCF) + 446 " -O %s", 447 Arrays.asList(getExpectedFile(name)) 448 ); 449 spec.executeTest(name, this); 450 } 451 452 @Test testMultipleEvalTracksAlleleCountWithMerge()453 public void testMultipleEvalTracksAlleleCountWithMerge() throws IOException { 454 String name = "testMultipleEvalTracksAlleleCountWithMerge"; 455 456 IntegrationTestSpec spec = new IntegrationTestSpec( 457 " -R " + b37_reference_20_21 + 458 " --dbsnp " + dbsnp_138_b37_20_21_vcf + 459 " --eval " + getTestFilePath(fundamentalTestSNPsSplit1of2VCF) + 460 " --eval " + getTestFilePath(fundamentalTestSNPsSplit2of2VCF) + 461 " --merge-evals" + 462 " -no-ev" + 463 " -EV CountVariants" + 464 " -no-st" + 465 " -ST AlleleCount" + 466 " -L " + getTestFilePath(fundamentalTestSNPsVCF) + 467 " -O %s", 468 Arrays.asList(getExpectedFile(name)) 469 ); 470 spec.executeTest(name, this); 471 } 472 473 @Test testMultipleEvalTracksAlleleCountWithoutMerge()474 public void testMultipleEvalTracksAlleleCountWithoutMerge() throws IOException { 475 String name = "testMultipleEvalTracksAlleleCountWithoutMerge"; 476 IntegrationTestSpec spec = new IntegrationTestSpec( 477 " -R " + b37_reference_20_21 + 478 " --dbsnp " + dbsnp_138_b37_20_21_vcf + 479 " --eval " + getTestFilePath(fundamentalTestSNPsSplit1of2VCF) + 480 " --eval " + getTestFilePath(fundamentalTestSNPsSplit2of2VCF) + 481 //"--merge-evals" + No merge with AC strat ==> error 482 " -no-ev" + 483 " -EV CountVariants" + 484 " -no-st" + 485 " -ST AlleleCount" + 486 " -L " + getTestFilePath(fundamentalTestSNPsVCF) + 487 " -O %s", 488 1, 489 CommandLineException.BadArgumentValue.class 490 ); 491 spec.executeTest(name, this); 492 } 493 494 @Test testIntervalStrat()495 public void testIntervalStrat() throws IOException { 496 String name = "testIntervalStrat"; 497 String vcf = getTestFilePath("/withSymbolic.b37.vcf"); 498 String bed = getTestFilePath("/overlapTest.bed"); 499 500 IntegrationTestSpec spec = new IntegrationTestSpec( 501 " -R " + b37_reference_20_21 + 502 " -eval " + vcf + 503 " -no-ev" + 504 " -EV CountVariants" + 505 " -no-st" + 506 " -strat-intervals " + bed + 507 " -ST IntervalStratification" + 508 " -L 20" + 509 " -O %s", 510 Arrays.asList(getExpectedFile(name)) 511 ); 512 spec.executeTest(name, this); 513 } 514 515 @Test testModernVCFWithLargeIndels()516 public void testModernVCFWithLargeIndels() throws IOException { 517 String name = "testModernVCFWithLargeIndels"; 518 String vcf = largeFileTestDir + "/NA12878.HiSeq.WGS.b37_decoy.indel.recalibrated.chr20.vcf"; 519 IntegrationTestSpec spec = new IntegrationTestSpec( 520 " -R " + b37_reference_20_21 + 521 " -eval " + vcf + 522 " -L 20" + 523 " -D " + dbsnp_138_b37_20_21_vcf + 524 " -O %s", 525 Arrays.asList(getExpectedFile(name)) 526 ); 527 spec.executeTest(name, this); 528 } 529 530 @Test testStandardIndelEval()531 public void testStandardIndelEval() throws IOException { 532 String name = "testStandardIndelEval"; 533 String vcf = largeFileTestDir + "/NA12878.HiSeq.WGS.b37_decoy.indel.recalibrated.chr20.vcf"; 534 String gold = largeFileTestDir + "/Mills_and_1000G_gold_standard.indels.b37.sites.chr20.vcf"; 535 536 IntegrationTestSpec spec = new IntegrationTestSpec( 537 " -R " + b37_reference_20_21 + 538 " -eval " + vcf + 539 " -L 20" + 540 " -no-st -ST Sample -ST OneBPIndel -ST TandemRepeat" + 541 " -no-ev -EV IndelSummary -EV IndelLengthHistogram" + 542 " -gold " + gold + 543 " -D " + dbsnp_138_b37_20_21_vcf + 544 " -O %s", 545 Arrays.asList(getExpectedFile(name)) 546 ); 547 spec.executeTest(name, this); 548 } 549 550 @Test testBadACValue()551 public void testBadACValue() throws IOException { 552 String name = "testBadACValue"; 553 IntegrationTestSpec spec = new IntegrationTestSpec( 554 " -R " + b37_reference_20_21 + 555 " -eval " + getTestFilePath("vcfexample.withBadAC.vcf") + 556 " -no-st -ST AlleleCount" + 557 " -no-ev -EV VariantSummary" + 558 " -O %s", 559 1, 560 UserException.class); 561 spec.executeTest(name, this); 562 } 563 564 565 @Test() testIncompatibleEvalAndStrat()566 public void testIncompatibleEvalAndStrat() throws IOException { 567 String name = "testIncompatibleEvalAndStrat"; 568 String vcf = largeFileTestDir + "/NA12878.HiSeq.WGS.b37_decoy.indel.recalibrated.chr20.vcf"; 569 570 IntegrationTestSpec spec = new IntegrationTestSpec( 571 " -R " + b37_reference_20_21 + 572 " -eval " + vcf + 573 " -L 20 -no-st -ST AlleleCount -no-ev -EV VariantSummary -O %s", 574 1, 575 CommandLineException.BadArgumentValue.class); 576 spec.executeTest(name, this); 577 } 578 testIncludingAC0(boolean includeAC0)579 public void testIncludingAC0(boolean includeAC0) throws IOException { 580 String name = "testIncludingAC0 keep ac 0 = " + includeAC0; 581 String vcf = getTestFilePath("ac0.vcf"); 582 583 IntegrationTestSpec spec = new IntegrationTestSpec( 584 " -R " + b37_reference_20_21 + 585 " -eval " + vcf + 586 " -L 20:81006 -no-st -no-ev -EV VariantSummary -O %s" + (includeAC0 ? " -keep-ac0" : ""), 587 Arrays.asList(getExpectedFile(name))); 588 spec.executeTest(name, this); 589 } 590 testWithAC0()591 @Test public void testWithAC0() throws IOException { testIncludingAC0(true); } testWithoutAC0()592 @Test public void testWithoutAC0() throws IOException { testIncludingAC0(false); } 593 594 // 595 // Test validation report is doing the right thing with sites only and genotypes files 596 // where the validation comp has more genotypes than eval 597 // 598 @Test(dataProvider = "testValidationReportData") testValidationReport(final String suffix, final String eval, final String comp)599 public void testValidationReport(final String suffix, final String eval, final String comp) throws IOException { 600 String name = "testValidationReportData-" + suffix; 601 602 IntegrationTestSpec spec = new IntegrationTestSpec( 603 " -R " + b37_reference_20_21 + 604 " -eval " + eval + 605 " -comp " + comp + 606 " -L 20:10,000,000-10,000,010 -no-st -no-ev -EV ValidationReport -O %s", 607 Arrays.asList(getExpectedFile(name))); 608 spec.executeTest(name, this); 609 } 610 611 @DataProvider(name = "testValidationReportData") testValidationReportData()612 public Object[][] testValidationReportData() { 613 final String compGenotypes = getTestFilePath("validationReportComp.vcf"); 614 final String compSites = getTestFilePath("validationReportComp.noGenotypes.vcf"); 615 final String evalGenotypes = getTestFilePath("validationReportEval.vcf"); 616 final String evalSites = getTestFilePath("validationReportEval.noGenotypes.vcf"); 617 618 List<Object[]> tests = new ArrayList<>(); 619 tests.add(new Object[]{"sites-sites", evalSites, compSites}); 620 tests.add(new Object[]{"sites-genotypes", evalSites, compGenotypes}); 621 tests.add(new Object[]{"genotypes-sites", evalGenotypes, compSites}); 622 tests.add(new Object[]{"genotypes-genotypes", evalGenotypes, compGenotypes}); 623 return tests.toArray(new Object[][]{}); 624 } 625 626 627 @Test testPrintMissingComp()628 public void testPrintMissingComp() throws IOException { 629 String name = "testPrintMissingComp"; 630 String vcf1 = getTestFilePath("validationReportEval.noGenotypes.vcf"); 631 String vcf2 = getTestFilePath("validationReportComp.noGenotypes.vcf"); 632 633 IntegrationTestSpec spec = new IntegrationTestSpec( 634 " -R " + b37_reference_20_21 + 635 " -eval " + vcf1 + 636 " --comp " + vcf2 + 637 " -L 20" + 638 " -EV PrintMissingComp" + 639 " -O %s", 640 Arrays.asList(getExpectedFile(name))); // sato: make sure it doesn't throw a null pointer exception. 641 spec.executeTest(name, this); 642 643 } 644 645 @Test testOutputFileCreation()646 public void testOutputFileCreation() throws IOException { 647 // duplicate of "testPrintMissingComp", this time without using IntegrationTestSpec in order to force the 648 // tool to create the output file directly (tests fix for https://github.com/broadinstitute/gatk/issues/5674) 649 650 final String testName = "testOutputFileCreation"; 651 final File tmpDir = createTempDir(testName); 652 final File outputFile = new File(tmpDir, testName + ".txt"); 653 654 ArgumentsBuilder argBuilder= new ArgumentsBuilder(); 655 argBuilder.addReference(new File(b37_reference_20_21)); 656 argBuilder.add("eval", getTestFilePath("validationReportEval.noGenotypes.vcf")); 657 argBuilder.add(StandardArgumentDefinitions.COMPARISON_SHORT_NAME, getTestFilePath("validationReportComp.noGenotypes.vcf")); 658 argBuilder.addInterval(new SimpleInterval("20")); 659 argBuilder.add("EV", "PrintMissingComp"); 660 argBuilder.addOutput(outputFile); 661 662 runCommandLine(argBuilder); 663 664 IntegrationTestSpec.assertEqualTextFiles( 665 outputFile, 666 new File(getToolTestDataDir() + "expected/" + "testPrintMissingComp" + ".expected.txt")); 667 } 668 testForCrashWithGivenEvaluator(final String countVariants)669 private void testForCrashWithGivenEvaluator(final String countVariants) { 670 final String vcf = getTestFilePath("/CEU.trio.callsForVE.vcf"); 671 final ArgumentsBuilder args = new ArgumentsBuilder(); 672 args.addOutput( createTempFile("out",".stuff")) 673 .add("eval", vcf) 674 .addFlag("do-not-use-all-standard-modules") 675 .add("EV", countVariants); 676 677 runCommandLine(args); 678 } 679 680 @Test testWithoutRequiringAReference()681 public void testWithoutRequiringAReference() { 682 testForCrashWithGivenEvaluator("IndelSummary"); 683 } 684 685 @Test(expectedExceptions = UserException.class) testNoReferenceWithEvaluatorsThatRequireOne()686 public void testNoReferenceWithEvaluatorsThatRequireOne() { 687 testForCrashWithGivenEvaluator("CountVariants"); 688 } 689 690 @Test(expectedExceptions = GATKException.class) testIncorrectlyLabelledEvaluator()691 public void testIncorrectlyLabelledEvaluator(){ 692 testForCrashWithGivenEvaluator("TestEvaluatorWhichRequiresReferenceButDoesntSayItDoes"); 693 } 694 } 695