1
1
package org .broadinstitute .hellbender .cmdline .GATKPlugin ;
2
2
3
- import org .broadinstitute .barclay .argparser .ClassFinder ;
4
3
import htsjdk .variant .variantcontext .*;
5
4
import org .apache .commons .io .output .NullOutputStream ;
6
- import org .broadinstitute .barclay .argparser .CommandLineArgumentParser ;
7
- import org .broadinstitute .barclay .argparser .CommandLineException ;
8
- import org .broadinstitute .barclay .argparser .CommandLineParser ;
5
+ import org .broadinstitute .barclay .argparser .*;
9
6
import org .broadinstitute .hellbender .GATKBaseTest ;
7
+ import org .broadinstitute .hellbender .cmdline .GATKPlugin .testpluggables .TestAnnotation ;
10
8
import org .broadinstitute .hellbender .cmdline .StandardArgumentDefinitions ;
9
+ import org .broadinstitute .hellbender .cmdline .TestProgramGroup ;
11
10
import org .broadinstitute .hellbender .engine .FeatureContext ;
11
+ import org .broadinstitute .hellbender .engine .GATKTool ;
12
12
import org .broadinstitute .hellbender .engine .ReferenceContext ;
13
13
import org .broadinstitute .hellbender .exceptions .GATKException ;
14
+ import org .broadinstitute .hellbender .testutils .ArgumentsBuilder ;
14
15
import org .broadinstitute .hellbender .tools .walkers .annotator .*;
15
16
import org .broadinstitute .hellbender .tools .walkers .annotator .allelespecific .AS_RMSMappingQuality ;
16
17
import org .broadinstitute .hellbender .tools .walkers .annotator .allelespecific .AS_StandardAnnotation ;
18
+ import org .broadinstitute .hellbender .utils .config .GATKConfig ;
17
19
import org .broadinstitute .hellbender .utils .genotyper .ReadLikelihoods ;
18
20
import org .broadinstitute .hellbender .utils .variant .GATKVCFConstants ;
19
21
import org .mockito .internal .util .collections .Sets ;
22
+ import org .mockito .internal .util .io .IOUtil ;
20
23
import org .testng .Assert ;
21
24
import org .testng .annotations .DataProvider ;
22
25
import org .testng .annotations .Test ;
23
26
import org .testng .collections .Lists ;
24
27
28
+ import java .io .File ;
29
+ import java .io .IOException ;
25
30
import java .io .PrintStream ;
31
+ import java .nio .file .Files ;
26
32
import java .util .*;
27
33
import java .util .stream .Collectors ;
28
34
import java .util .stream .Stream ;
@@ -456,7 +462,7 @@ public void testUseAllAnnotations(){
456
462
List <Annotation > annots = instantiateAnnotations (clp );
457
463
458
464
ClassFinder finder = new ClassFinder ();
459
- finder .find (GATKAnnotationPluginDescriptor . pluginPackageName , Annotation .class );
465
+ finder .find (GATKConfig . DEFAULT_ANNOTATION_PACKAGES , Annotation .class );
460
466
461
467
Set <Class <?>> classes = finder .getConcreteClasses ();
462
468
Assert .assertFalse (classes .isEmpty ());
@@ -477,7 +483,7 @@ public void testUseAllAnnotationsDisableToolDefaultAnnotaiotns(){
477
483
List <Annotation > annots = instantiateAnnotations (clp );
478
484
479
485
ClassFinder finder = new ClassFinder ();
480
- finder .find (GATKAnnotationPluginDescriptor . pluginPackageName , Annotation .class );
486
+ finder .find (GATKConfig . DEFAULT_ANNOTATION_PACKAGES , Annotation .class );
481
487
482
488
Set <Class <?>> classes = finder .getConcreteClasses ();
483
489
Assert .assertFalse (classes .isEmpty ());
@@ -502,7 +508,7 @@ public void testIncludeAllExcludeIndividual(){
502
508
Assert .assertFalse (annots .stream ().anyMatch (a -> a .getClass ()==AS_StandardAnnotation .class ));
503
509
504
510
ClassFinder finder = new ClassFinder ();
505
- finder .find (GATKAnnotationPluginDescriptor . pluginPackageName , Annotation .class );
511
+ finder .find (GATKConfig . DEFAULT_ANNOTATION_PACKAGES , Annotation .class );
506
512
507
513
Set <Class <?>> classes = finder .getConcreteClasses ();
508
514
classes .remove (Coverage .class );
@@ -628,6 +634,7 @@ public List<String> getKeyNames() {
628
634
return Collections .singletonList ("Test" );
629
635
}
630
636
}
637
+
631
638
static class testParentAnnotation extends InfoFieldAnnotation implements ParentAnnotationGroup {
632
639
boolean dontAnnotate = false ;
633
640
@@ -651,4 +658,37 @@ public List<String> getKeyNames() {
651
658
}
652
659
}
653
660
661
+ @ CommandLineProgramProperties (summary ="test tool to check annotation loading" ,
662
+ oneLineSummary = "test tool to check annotation loading" ,
663
+ programGroup = TestProgramGroup .class ,
664
+ omitFromCommandLine = true )
665
+ public static class TestAnnotationsTool extends GATKTool {
666
+ @ Argument (fullName = StandardArgumentDefinitions .OUTPUT_LONG_NAME )
667
+ String output ;
668
+
669
+ @ Override
670
+ public boolean useVariantAnnotations (){
671
+ return true ;
672
+ }
673
+
674
+ @ Override
675
+ public void traverse () {
676
+ String annotations = makeVariantAnnotations ().stream ()
677
+ .map (a -> a .getClass ().getSimpleName ())
678
+ .collect (Collectors .joining ("\n " ));
679
+ IOUtil .writeText (annotations , new File (output ));
680
+ }
681
+ }
682
+
683
+ @ Test
684
+ public void testConfigFileControlsAnnotationPackages () throws IOException {
685
+ final File output = createTempFile ("annotations" , "txt" );
686
+ final File configFile = new File (packageRootTestDir + "cmdline/GATKPlugin/changePluginPackages.properties" );
687
+ ArgumentsBuilder args = new ArgumentsBuilder ();
688
+ args .addArgument (StandardArgumentDefinitions .ANNOTATION_LONG_NAME , TestAnnotation .class .getSimpleName ())
689
+ .addFileArgument (StandardArgumentDefinitions .GATK_CONFIG_FILE_OPTION , configFile )
690
+ .addOutput (output );
691
+ runToolInNewJVM ("TestAnnotationsTool" , args );
692
+ Assert .assertEquals (Files .readAllLines (output .toPath ()), Collections .singletonList (TestAnnotation .class .getSimpleName ()));
693
+ }
654
694
}
0 commit comments