diff --git a/java/src/org/broadinstitute/sting/gatk/walkers/annotator/VariantAnnotator.java b/java/src/org/broadinstitute/sting/gatk/walkers/annotator/VariantAnnotator.java index 2afc513bb..f53e5ee80 100755 --- a/java/src/org/broadinstitute/sting/gatk/walkers/annotator/VariantAnnotator.java +++ b/java/src/org/broadinstitute/sting/gatk/walkers/annotator/VariantAnnotator.java @@ -43,6 +43,7 @@ import org.broadinstitute.sting.utils.BaseUtils; import org.broadinstitute.sting.utils.classloader.PackageUtils; import org.broadinstitute.sting.utils.SampleUtils; import org.broadinstitute.sting.commandline.Argument; +import org.broadinstitute.sting.commandline.CommandLineUtils; import org.broadinstitute.sting.utils.genotype.vcf.VCFUtils; import org.broadinstitute.sting.utils.genotype.vcf.VCFWriter; @@ -62,10 +63,10 @@ public class VariantAnnotator extends RodWalker { protected String sampleName = null; @Argument(fullName="annotation", shortName="A", doc="One or more specific annotations to apply to variant calls", required=false) - protected String[] annotationsToUse = {}; + protected List annotationsToUse = new ArrayList(); @Argument(fullName="group", shortName="G", doc="One or more classes/groups of annotations to apply to variant calls", required=false) - protected String[] annotationGroupsToUse = {}; + protected List annotationGroupsToUse = new ArrayList(); @Argument(fullName="useAllAnnotations", shortName="all", doc="Use all possible annotations (not for the faint of heart)", required=false) protected Boolean USE_ALL_ANNOTATIONS = false; @@ -79,6 +80,9 @@ public class VariantAnnotator extends RodWalker { @Argument(fullName="vcfContainsOnlyIndels", shortName="dels",doc="Use if you are annotating an indel vcf, currently VERY experimental", required = false) protected boolean indelsOnly = false; + @Argument(fullName = "NO_HEADER", shortName = "NO_HEADER", doc = "Don't output the usual VCF header tag with the command line. FOR DEBUGGING PURPOSES ONLY. This option is required in order to pass integration tests.", required = false) + protected Boolean NO_VCF_HEADER_LINE = false; + private VCFWriter vcfWriter; private HashMap nonVCFsampleName = new HashMap(); @@ -139,11 +143,15 @@ public class VariantAnnotator extends RodWalker { // note that if any of the definitions conflict with our new ones, then we want to overwrite the old ones Set hInfo = new HashSet(); hInfo.addAll(engine.getVCFAnnotationDescriptions()); - hInfo.add(new VCFHeaderLine("source", "VariantAnnotator")); for ( VCFHeaderLine line : VCFUtils.getHeaderFields(getToolkit(), Arrays.asList("variant")) ) { if ( isUniqueHeaderLine(line, hInfo) ) hInfo.add(line); } + if ( !NO_VCF_HEADER_LINE ) { + Set args = new HashSet(); + args.add(this); + hInfo.add(new VCFHeaderLine("VariantAnnotator", "\"" + CommandLineUtils.createApproximateCommandLineArgumentString(getToolkit(), args, getClass()) + "\"")); + } vcfWriter = new VCFWriter(out); VCFHeader vcfHeader = new VCFHeader(hInfo, samples); diff --git a/java/src/org/broadinstitute/sting/gatk/walkers/annotator/VariantAnnotatorEngine.java b/java/src/org/broadinstitute/sting/gatk/walkers/annotator/VariantAnnotatorEngine.java index eb7ee719c..b5f0a8001 100755 --- a/java/src/org/broadinstitute/sting/gatk/walkers/annotator/VariantAnnotatorEngine.java +++ b/java/src/org/broadinstitute/sting/gatk/walkers/annotator/VariantAnnotatorEngine.java @@ -88,7 +88,7 @@ public class VariantAnnotatorEngine { } // use this constructor if you want to select specific annotations (and/or interfaces) - public VariantAnnotatorEngine(GenomeAnalysisEngine engine, String[] annotationGroupsToUse, String[] annotationsToUse) { + public VariantAnnotatorEngine(GenomeAnalysisEngine engine, List annotationGroupsToUse, List annotationsToUse) { // create a map for all annotation classes which implement our top-level interfaces HashMap classMap = new HashMap(); diff --git a/java/src/org/broadinstitute/sting/gatk/walkers/filters/VariantFiltrationWalker.java b/java/src/org/broadinstitute/sting/gatk/walkers/filters/VariantFiltrationWalker.java index d6aaf5f3a..ecd229bdd 100755 --- a/java/src/org/broadinstitute/sting/gatk/walkers/filters/VariantFiltrationWalker.java +++ b/java/src/org/broadinstitute/sting/gatk/walkers/filters/VariantFiltrationWalker.java @@ -37,6 +37,7 @@ import org.broadinstitute.sting.gatk.refdata.ReferenceOrderedDatum; import org.broadinstitute.sting.gatk.refdata.VariantContextAdaptors; import org.broadinstitute.sting.gatk.walkers.*; import org.broadinstitute.sting.commandline.Argument; +import org.broadinstitute.sting.commandline.CommandLineUtils; import org.broadinstitute.sting.utils.genotype.vcf.*; import org.broadinstitute.sting.utils.genotype.vcf.VCFWriter; @@ -51,14 +52,14 @@ import java.util.*; public class VariantFiltrationWalker extends RodWalker { @Argument(fullName="filterExpression", shortName="filter", doc="One or more expression used with INFO fields to filter (see wiki docs for more info)", required=false) - protected String[] FILTER_EXPS = new String[]{}; + protected ArrayList FILTER_EXPS = new ArrayList(); @Argument(fullName="filterName", shortName="filterName", doc="Names to use for the list of filters (must be a 1-to-1 mapping); this name is put in the FILTER field for variants that get filtered", required=false) - protected String[] FILTER_NAMES = new String[]{}; + protected ArrayList FILTER_NAMES = new ArrayList(); @Argument(fullName="genotypeFilterExpression", shortName="G_filter", doc="One or more expression used with FORMAT (sample/genotype-level) fields to filter (see wiki docs for more info)", required=false) - protected String[] GENOTYPE_FILTER_EXPS = new String[]{}; + protected ArrayList GENOTYPE_FILTER_EXPS = new ArrayList(); @Argument(fullName="genotypeFilterName", shortName="G_filterName", doc="Names to use for the list of sample/genotype filters (must be a 1-to-1 mapping); this name is put in the FILTER field for variants that get filtered", required=false) - protected String[] GENOTYPE_FILTER_NAMES = new String[]{}; + protected ArrayList GENOTYPE_FILTER_NAMES = new ArrayList(); @Argument(fullName="clusterSize", shortName="cluster", doc="The number of SNPs which make up a cluster (see also --clusterWindowSize); [default:3]", required=false) protected Integer clusterSize = 3; @@ -68,6 +69,9 @@ public class VariantFiltrationWalker extends RodWalker { @Argument(fullName="maskName", shortName="mask", doc="The text to put in the FILTER field if a 'mask' rod is provided and overlaps with a variant call; [default:'Mask']", required=false) protected String MASK_NAME = "Mask"; + @Argument(fullName = "NO_HEADER", shortName = "NO_HEADER", doc = "Don't output the usual VCF header tag with the command line. FOR DEBUGGING PURPOSES ONLY. This option is required in order to pass integration tests.", required = false) + protected Boolean NO_VCF_HEADER_LINE = false; + // JEXL expressions for the filters List filterExps; List genotypeFilterExps; @@ -88,8 +92,6 @@ public class VariantFiltrationWalker extends RodWalker { // setup the header fields Set hInfo = new HashSet(); hInfo.addAll(VCFUtils.getHeaderFields(getToolkit())); - hInfo.add(new VCFHeaderLine("source", "VariantFiltration")); - hInfo.add(new VCFHeaderLine("reference", getToolkit().getArguments().referenceFile.getName())); if ( clusterWindow > 0 ) hInfo.add(new VCFFilterHeaderLine(CLUSTERED_SNP_FILTER_NAME, "SNPs found in clusters")); @@ -110,6 +112,12 @@ public class VariantFiltrationWalker extends RodWalker { } } + if ( !NO_VCF_HEADER_LINE ) { + Set args = new HashSet(); + args.add(this); + hInfo.add(new VCFHeaderLine("VariantFiltration", "\"" + CommandLineUtils.createApproximateCommandLineArgumentString(getToolkit(), args, getClass()) + "\"")); + } + writer = new VCFWriter(out); writer.writeHeader(new VCFHeader(hInfo, new TreeSet(vc.getSampleNames()))); } diff --git a/java/src/org/broadinstitute/sting/gatk/walkers/genotyper/UnifiedGenotyper.java b/java/src/org/broadinstitute/sting/gatk/walkers/genotyper/UnifiedGenotyper.java index 858853f60..09951cff2 100755 --- a/java/src/org/broadinstitute/sting/gatk/walkers/genotyper/UnifiedGenotyper.java +++ b/java/src/org/broadinstitute/sting/gatk/walkers/genotyper/UnifiedGenotyper.java @@ -61,7 +61,7 @@ public class UnifiedGenotyper extends LocusWalker annotationsToUse = new ArrayList(); @Argument(fullName="group", shortName="G", doc="One or more classes/groups of annotations to apply to variant calls", required=false) protected String[] annotationClassesToUse = { "Standard" }; @@ -112,7 +112,7 @@ public class UnifiedGenotyper extends LocusWalker 20.0' -filterName foo -B variant,VCF," + validationDataLocation + "vcfexample2.vcf -L 1:10,020,000-10,021,000", 1, - Arrays.asList("fa110840f477b238c0b30ed4fae5ab72")); + Arrays.asList("b0b9110aeff967dd87cd0ec273d20791")); executeTest("test filter #1", spec); } @@ -48,7 +48,7 @@ public class VariantFiltrationIntegrationTest extends WalkerTest { public void testFilter2() { WalkerTestSpec spec = new WalkerTestSpec( baseTestString() + " -filter 'AlleleBalance < 70.0 && FisherStrand == 1.4' -filterName bar -B variant,VCF," + validationDataLocation + "vcfexample2.vcf -L 1:10,020,000-10,021,000", 1, - Arrays.asList("9a30dd4c67ddbfadc9e153e0345b46d4")); + Arrays.asList("8405a7ef69792c239d903d13832a1ea7")); executeTest("test filter #2", spec); } @@ -56,7 +56,7 @@ public class VariantFiltrationIntegrationTest extends WalkerTest { public void testFilterWithSeparateNames() { WalkerTestSpec spec = new WalkerTestSpec( baseTestString() + " --filterName ABF -filter 'AlleleBalance < 70.0' --filterName FSF -filter 'FisherStrand == 1.4' -B variant,VCF," + validationDataLocation + "vcfexample2.vcf -L 1:10,020,000-10,021,000", 1, - Arrays.asList("7052fca252754e7a92ddb1f27123c7c8")); + Arrays.asList("8266b9eb2ba35d77ab1cecb395322f31")); executeTest("test filter with separate names #2", spec); } @@ -64,7 +64,7 @@ public class VariantFiltrationIntegrationTest extends WalkerTest { public void testGenotypeFilter1() { WalkerTestSpec spec = new WalkerTestSpec( baseTestString() + " -G_filter 'GQ == 0.60' -G_filterName foo -B variant,VCF," + validationDataLocation + "vcfexample2.vcf -L 1:10,020,000-10,021,000", 1, - Arrays.asList("e22ecae2f992fb9d5a91c286f9ac3e40")); + Arrays.asList("99d8a47623cba215ee7d803c514ef116")); executeTest("test genotype filter #1", spec); } @@ -72,7 +72,7 @@ public class VariantFiltrationIntegrationTest extends WalkerTest { public void testGenotypeFilter2() { WalkerTestSpec spec = new WalkerTestSpec( baseTestString() + " -G_filter 'AF == 0.04 && isHomVar == 1' -G_filterName foo -B variant,VCF," + validationDataLocation + "vcfexample2.vcf -L 1:10,020,000-10,021,000", 1, - Arrays.asList("b7e7e7abbf5b03d773f82cced33497a4")); + Arrays.asList("c58ea74c32290c9b4e8ae3dd1d0250e1")); executeTest("test genotype filter #2", spec); } } \ No newline at end of file