From 86afe878a7ccfff5878432e8795130ba40068f31 Mon Sep 17 00:00:00 2001 From: Mark DePristo Date: Tue, 9 Aug 2011 20:55:15 -0400 Subject: [PATCH 04/19] ReducedRead optimization: single pass likelihood calculation -- Low level add() now takes a nObs argument and rather than += likelihood now does += nObs * likelihood --- .../DiploidSNPGenotypeLikelihoods.java | 26 +++++++++---------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/public/java/src/org/broadinstitute/sting/gatk/walkers/genotyper/DiploidSNPGenotypeLikelihoods.java b/public/java/src/org/broadinstitute/sting/gatk/walkers/genotyper/DiploidSNPGenotypeLikelihoods.java index 2014801e4..5f6865d04 100755 --- a/public/java/src/org/broadinstitute/sting/gatk/walkers/genotyper/DiploidSNPGenotypeLikelihoods.java +++ b/public/java/src/org/broadinstitute/sting/gatk/walkers/genotyper/DiploidSNPGenotypeLikelihoods.java @@ -276,13 +276,11 @@ public class DiploidSNPGenotypeLikelihoods implements Cloneable { if ( elt.isReducedRead() ) { // reduced read representation byte qual = elt.getReducedQual(); - for ( int i = 0; i < elt.getReducedCount(); i++ ) { - add(obsBase, qual, (byte)0, (byte)0); - } - return elt.getQual(); + add(obsBase, qual, (byte)0, (byte)0, elt.getReducedCount()); // fast calculation of n identical likelihoods + return elt.getReducedCount(); // we added nObs bases here } else { byte qual = qualToUse(elt, ignoreBadBases, capBaseQualsAtMappingQual, minBaseQual); - return qual > 0 ? add(obsBase, qual, (byte)0, (byte)0) : 0; + return qual > 0 ? add(obsBase, qual, (byte)0, (byte)0, 1) : 0; } } @@ -309,9 +307,11 @@ public class DiploidSNPGenotypeLikelihoods implements Cloneable { * @param qual1 * @param obsBase2 * @param qual2 can be 0, indicating no second base was observed for this fragment + * @param nObs The number of times this quad of values was seen. Generally 1, but reduced reads + * can have nObs > 1 for synthetic reads * @return */ - private int add(byte obsBase1, byte qual1, byte obsBase2, byte qual2) { + private int add(byte obsBase1, byte qual1, byte obsBase2, byte qual2, int nObs) { // TODO-- Right now we assume that there are at most 2 reads per fragment. This assumption is fine // TODO-- given the current state of next-gen sequencing, but may need to be fixed in the future. // TODO-- However, when that happens, we'll need to be a lot smarter about the caching we do here. @@ -332,19 +332,17 @@ public class DiploidSNPGenotypeLikelihoods implements Cloneable { for ( DiploidGenotype g : DiploidGenotype.values() ) { double likelihood = likelihoods[g.ordinal()]; - - //if ( VERBOSE ) { - // System.out.printf(" L(%c | G=%s, Q=%d, S=%s) = %f / %f%n", - // observedBase, g, qualityScore, pow(10,likelihood) * 100, likelihood); - //} - - log10Likelihoods[g.ordinal()] += likelihood; - log10Posteriors[g.ordinal()] += likelihood; + log10Likelihoods[g.ordinal()] += likelihood * nObs; + log10Posteriors[g.ordinal()] += likelihood * nObs; } return 1; } + private int add(byte obsBase1, byte qual1, byte obsBase2, byte qual2) { + return add(obsBase1, qual1, obsBase2, qual2, 1); + } + // ------------------------------------------------------------------------------------- // // Dealing with the cache routines From 08631546c8f3593e06dcc32e5c2e1f5fbb60f730 Mon Sep 17 00:00:00 2001 From: Eric Banks Date: Tue, 9 Aug 2011 23:19:40 -0400 Subject: [PATCH 05/19] Partial commit for David so he can see what I want to do with the VariantAnnotator. Added a DbsnpArgumentCollection that people can use in their walkers to ensure that we have a standard syntax whenever allowing dbsnp rods. Added it to UG, but didn't hook it up. Maybe we should do the same for the 'variant' rod? --- .../arguments/DbsnpArgumentCollection.java | 48 +++++++++++++++++++ .../walkers/annotator/VariantAnnotator.java | 19 ++++++++ .../walkers/genotyper/UnifiedGenotyper.java | 8 ++++ 3 files changed, 75 insertions(+) create mode 100644 public/java/src/org/broadinstitute/sting/gatk/arguments/DbsnpArgumentCollection.java diff --git a/public/java/src/org/broadinstitute/sting/gatk/arguments/DbsnpArgumentCollection.java b/public/java/src/org/broadinstitute/sting/gatk/arguments/DbsnpArgumentCollection.java new file mode 100644 index 000000000..b77b175bc --- /dev/null +++ b/public/java/src/org/broadinstitute/sting/gatk/arguments/DbsnpArgumentCollection.java @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2010 The Broad Institute + * + * Permission is hereby granted, free of charge, to any person + * obtaining a copy of this software and associated documentation + * files (the "Software"), to deal in the Software without + * restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following + * conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES + * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR + * THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +package org.broadinstitute.sting.gatk.arguments; + + +import org.broadinstitute.sting.commandline.Input; +import org.broadinstitute.sting.commandline.RodBinding; +import org.broadinstitute.sting.utils.variantcontext.VariantContext; +import org.simpleframework.xml.*; + +/** + * @author ebanks + * @version 1.0 + */ +@Root +public class DbsnpArgumentCollection { + + /** + * A dbSNP VCF file. + */ + @Input(fullName="dbsnp", shortName = "D", doc="dbSNP file", required=false) + public RodBinding dbsnp = RodBinding.makeUnbound(VariantContext.class); + +} + diff --git a/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/VariantAnnotator.java b/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/VariantAnnotator.java index ec7d51043..594216d53 100755 --- a/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/VariantAnnotator.java +++ b/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/VariantAnnotator.java @@ -26,6 +26,7 @@ package org.broadinstitute.sting.gatk.walkers.annotator; import org.broadinstitute.sting.commandline.*; +import org.broadinstitute.sting.gatk.arguments.DbsnpArgumentCollection; import org.broadinstitute.sting.gatk.contexts.AlignmentContext; import org.broadinstitute.sting.gatk.contexts.AlignmentContextUtils; import org.broadinstitute.sting.gatk.contexts.ReferenceContext; @@ -34,6 +35,7 @@ import org.broadinstitute.sting.gatk.walkers.*; import org.broadinstitute.sting.gatk.walkers.annotator.interfaces.AnnotationType; import org.broadinstitute.sting.gatk.walkers.annotator.interfaces.GenotypeAnnotation; import org.broadinstitute.sting.gatk.walkers.annotator.interfaces.InfoFieldAnnotation; +import org.broadinstitute.sting.gatk.walkers.genotyper.UnifiedArgumentCollection; import org.broadinstitute.sting.utils.BaseUtils; import org.broadinstitute.sting.utils.SampleUtils; import org.broadinstitute.sting.utils.classloader.PluginManager; @@ -60,6 +62,23 @@ public class VariantAnnotator extends RodWalker { @Input(fullName="snpEffFile", shortName = "snpEffFile", doc="SnpEff file", required=false) public RodBinding snpEffFile; + /** + * A dbSNP VCF file from which to annotate. + * + * rsIDs from this file are used to populate the ID column of the output. Also, the DB INFO flag will be set when appropriate. + */ + @ArgumentCollection protected DbsnpArgumentCollection dbsnp = new DbsnpArgumentCollection(); + + /** + * A comparisons VCF file from which to annotate. + * + * If a record in the 'variant' track overlaps with a record from the provided comp track, the INFO field will be annotated + * as such in the output with the track name (e.g. -comp:FOO will have 'FOO' in the INFO field). Records that are filtered in the comp track will be ignored. + * Note that 'dbSNP' has been special-cased (see the --dbsnp argument). + */ + @Input(fullName="comp", shortName = "comp", doc="comparison VCF file", required=false) + public RodBinding comps = RodBinding.makeUnbound(VariantContext.class); + @Output(doc="File to which variants should be written",required=true) protected VCFWriter vcfWriter = null; diff --git a/public/java/src/org/broadinstitute/sting/gatk/walkers/genotyper/UnifiedGenotyper.java b/public/java/src/org/broadinstitute/sting/gatk/walkers/genotyper/UnifiedGenotyper.java index 812511322..6836b14fc 100755 --- a/public/java/src/org/broadinstitute/sting/gatk/walkers/genotyper/UnifiedGenotyper.java +++ b/public/java/src/org/broadinstitute/sting/gatk/walkers/genotyper/UnifiedGenotyper.java @@ -29,6 +29,7 @@ import org.broadinstitute.sting.commandline.Argument; import org.broadinstitute.sting.commandline.ArgumentCollection; import org.broadinstitute.sting.commandline.Output; import org.broadinstitute.sting.gatk.DownsampleType; +import org.broadinstitute.sting.gatk.arguments.DbsnpArgumentCollection; import org.broadinstitute.sting.gatk.contexts.AlignmentContext; import org.broadinstitute.sting.gatk.contexts.ReferenceContext; import org.broadinstitute.sting.gatk.datasources.rmd.ReferenceOrderedDataSource; @@ -59,6 +60,13 @@ public class UnifiedGenotyper extends LocusWalker Date: Tue, 9 Aug 2011 23:21:17 -0400 Subject: [PATCH 06/19] Bringing Indel Realigner up to speed with the new rod binding syntax; now use -known to specify the known indels track. --- .../sting/gatk/walkers/indels/IndelRealigner.java | 12 ++++++------ .../indels/IndelRealignerIntegrationTest.java | 6 +++--- .../indels/IndelRealignerPerformanceTest.java | 4 ++-- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/public/java/src/org/broadinstitute/sting/gatk/walkers/indels/IndelRealigner.java b/public/java/src/org/broadinstitute/sting/gatk/walkers/indels/IndelRealigner.java index 61f21c488..cb7627888 100755 --- a/public/java/src/org/broadinstitute/sting/gatk/walkers/indels/IndelRealigner.java +++ b/public/java/src/org/broadinstitute/sting/gatk/walkers/indels/IndelRealigner.java @@ -30,10 +30,7 @@ import net.sf.samtools.*; import net.sf.samtools.util.RuntimeIOException; import net.sf.samtools.util.SequenceUtil; import net.sf.samtools.util.StringUtil; -import org.broadinstitute.sting.commandline.Argument; -import org.broadinstitute.sting.commandline.Hidden; -import org.broadinstitute.sting.commandline.Input; -import org.broadinstitute.sting.commandline.Output; +import org.broadinstitute.sting.commandline.*; import org.broadinstitute.sting.gatk.GenomeAnalysisEngine; import org.broadinstitute.sting.gatk.arguments.ValidationExclusion; import org.broadinstitute.sting.gatk.contexts.ReferenceContext; @@ -86,6 +83,9 @@ public class IndelRealigner extends ReadWalker { USE_SW } + @Input(fullName="known", shortName = "known", doc="Input VCF file with known indels", required=false) + public RodBinding known = RodBinding.makeUnbound(VariantContext.class); + @Input(fullName="targetIntervals", shortName="targetIntervals", doc="intervals file output from RealignerTargetCreator", required=true) protected String intervalsFile = null; @@ -558,8 +558,8 @@ public class IndelRealigner extends ReadWalker { if ( indelRodsSeen.contains(rod) ) continue; indelRodsSeen.add(rod); - if ( VariantContextAdaptors.canBeConvertedToVariantContext(rod)) - knownIndelsToTry.add(VariantContextAdaptors.toVariantContext("", rod, ref)); + if ( rod instanceof VariantContext ) + knownIndelsToTry.add((VariantContext)rod); } } } diff --git a/public/java/test/org/broadinstitute/sting/gatk/walkers/indels/IndelRealignerIntegrationTest.java b/public/java/test/org/broadinstitute/sting/gatk/walkers/indels/IndelRealignerIntegrationTest.java index 19dc99682..28e5a15de 100755 --- a/public/java/test/org/broadinstitute/sting/gatk/walkers/indels/IndelRealignerIntegrationTest.java +++ b/public/java/test/org/broadinstitute/sting/gatk/walkers/indels/IndelRealignerIntegrationTest.java @@ -28,7 +28,7 @@ public class IndelRealignerIntegrationTest extends WalkerTest { executeTest("test realigner defaults", spec1); WalkerTestSpec spec2 = new WalkerTestSpec( - baseCommand + "-B:indels,vcf " + knownIndels, + baseCommand + "-known " + knownIndels, 1, Arrays.asList(base_md5_with_SW_or_VCF)); executeTest("test realigner defaults with VCF", spec2); @@ -37,7 +37,7 @@ public class IndelRealignerIntegrationTest extends WalkerTest { @Test public void testKnownsOnly() { WalkerTestSpec spec1 = new WalkerTestSpec( - baseCommand + "--consensusDeterminationModel KNOWNS_ONLY -B:indels,vcf " + knownIndels, + baseCommand + "--consensusDeterminationModel KNOWNS_ONLY -known " + knownIndels, 1, Arrays.asList("3dd5d2c9931b375455af0bff1a2c4888")); executeTest("realigner known indels only from VCF", spec1); @@ -46,7 +46,7 @@ public class IndelRealignerIntegrationTest extends WalkerTest { @Test public void testUseSW() { WalkerTestSpec spec1 = new WalkerTestSpec( - baseCommand + "--consensusDeterminationModel USE_SW -B:indels,vcf " + knownIndels, + baseCommand + "--consensusDeterminationModel USE_SW -known " + knownIndels, 1, Arrays.asList(base_md5_with_SW_or_VCF)); executeTest("realigner use SW from VCF", spec1); diff --git a/public/java/test/org/broadinstitute/sting/gatk/walkers/indels/IndelRealignerPerformanceTest.java b/public/java/test/org/broadinstitute/sting/gatk/walkers/indels/IndelRealignerPerformanceTest.java index 200b9b5a7..77675b0f4 100755 --- a/public/java/test/org/broadinstitute/sting/gatk/walkers/indels/IndelRealignerPerformanceTest.java +++ b/public/java/test/org/broadinstitute/sting/gatk/walkers/indels/IndelRealignerPerformanceTest.java @@ -30,7 +30,7 @@ public class IndelRealignerPerformanceTest extends WalkerTest { " -LOD 5" + " -maxConsensuses 100" + " -greedy 100" + - " -dbsnp:vcf " + GATKDataLocation + "dbsnp_132.hg18.vcf" + + " -known " + GATKDataLocation + "dbsnp_132.hg18.vcf" + " -o /dev/null" + " -I " + evaluationDataLocation + "NA12878.GAII.chr1.50MB.bam" + " -L chr1:1-5,650,000" + @@ -45,7 +45,7 @@ public class IndelRealignerPerformanceTest extends WalkerTest { " -LOD 5" + " -maxConsensuses 100" + " -greedy 100" + - " -dbsnp:vcf " + GATKDataLocation + "dbsnp_132.hg18.vcf" + + " -known " + GATKDataLocation + "dbsnp_132.hg18.vcf" + " -o /dev/null" + " -I " + evaluationDataLocation + "NA12878.ESP.WEx.chr1.bam" + " -L chr1:1-150,000,000" + From 1ea5ec276bea63c485ff2b8cd4cf31265682ba25 Mon Sep 17 00:00:00 2001 From: Eric Banks Date: Tue, 9 Aug 2011 23:28:59 -0400 Subject: [PATCH 07/19] Minor cleanup --- .../gatk/walkers/indels/IndelRealigner.java | 16 ---------------- .../indels/IndelRealignerIntegrationTest.java | 1 - 2 files changed, 17 deletions(-) diff --git a/public/java/src/org/broadinstitute/sting/gatk/walkers/indels/IndelRealigner.java b/public/java/src/org/broadinstitute/sting/gatk/walkers/indels/IndelRealigner.java index cb7627888..dcd4f5dec 100755 --- a/public/java/src/org/broadinstitute/sting/gatk/walkers/indels/IndelRealigner.java +++ b/public/java/src/org/broadinstitute/sting/gatk/walkers/indels/IndelRealigner.java @@ -36,7 +36,6 @@ import org.broadinstitute.sting.gatk.arguments.ValidationExclusion; import org.broadinstitute.sting.gatk.contexts.ReferenceContext; import org.broadinstitute.sting.gatk.io.StingSAMFileWriter; import org.broadinstitute.sting.gatk.refdata.ReadMetaDataTracker; -import org.broadinstitute.sting.gatk.refdata.VariantContextAdaptors; import org.broadinstitute.sting.gatk.refdata.utils.GATKFeature; import org.broadinstitute.sting.gatk.walkers.BAQMode; import org.broadinstitute.sting.gatk.walkers.ReadWalker; @@ -159,21 +158,6 @@ public class IndelRealigner extends ReadWalker { protected boolean CHECKEARLY = false; - // DEPRECATED - - @Deprecated - @Argument(fullName="sortInCoordinateOrderEvenThoughItIsHighlyUnsafe", doc="This argument is no longer used.", required=false) - protected boolean DEPRECATED_SORT_IN_COORDINATE_ORDER = false; - - @Deprecated - @Argument(fullName="realignReadsWithBadMates", doc="This argument is no longer used.", required=false) - protected boolean DEPRECATED_REALIGN_MATES = false; - - @Deprecated - @Argument(fullName="useOnlyKnownIndels", shortName="knownsOnly", doc="This argument is no longer used. See --consensusDeterminationModel instead.", required=false) - protected boolean DEPRECATED_KNOWNS_ONLY = false; - - // DEBUGGING OPTIONS FOLLOW @Hidden diff --git a/public/java/test/org/broadinstitute/sting/gatk/walkers/indels/IndelRealignerIntegrationTest.java b/public/java/test/org/broadinstitute/sting/gatk/walkers/indels/IndelRealignerIntegrationTest.java index 28e5a15de..0ff6fc244 100755 --- a/public/java/test/org/broadinstitute/sting/gatk/walkers/indels/IndelRealignerIntegrationTest.java +++ b/public/java/test/org/broadinstitute/sting/gatk/walkers/indels/IndelRealignerIntegrationTest.java @@ -1,7 +1,6 @@ package org.broadinstitute.sting.gatk.walkers.indels; import org.broadinstitute.sting.WalkerTest; -import org.broadinstitute.sting.utils.exceptions.UserException; import org.testng.annotations.Test; import java.util.Arrays; From 9e53fd688034da583dd4fad78b2cc6946ae91a3f Mon Sep 17 00:00:00 2001 From: Mark DePristo Date: Wed, 10 Aug 2011 07:28:35 -0400 Subject: [PATCH 08/19] Fixed VCFGatherFunction to not provide incorrect rod_priority_list -- simply don't provide one, since you are just 'cating' the files together and genotypes never overlap --- .../sting/queue/extensions/gatk/VcfGatherFunction.scala | 1 - 1 file changed, 1 deletion(-) diff --git a/public/scala/src/org/broadinstitute/sting/queue/extensions/gatk/VcfGatherFunction.scala b/public/scala/src/org/broadinstitute/sting/queue/extensions/gatk/VcfGatherFunction.scala index f8a6cb2cb..d70022147 100644 --- a/public/scala/src/org/broadinstitute/sting/queue/extensions/gatk/VcfGatherFunction.scala +++ b/public/scala/src/org/broadinstitute/sting/queue/extensions/gatk/VcfGatherFunction.scala @@ -44,7 +44,6 @@ class VcfGatherFunction extends CombineVariants with GatherFunction { this.intervalsString = this.originalGATK.intervalsString this.variant = this.gatherParts.zipWithIndex map { case (input, index) => new TaggedFile(input, "input"+index) } - this.rod_priority_list = (0 until this.gatherParts.size).map("input"+_).mkString(",") this.out = this.originalOutput this.assumeIdenticalSamples = true From c60cf52f73d436bd7159957159d1e9356cb05fd1 Mon Sep 17 00:00:00 2001 From: Ryan Poplin Date: Wed, 10 Aug 2011 10:20:37 -0400 Subject: [PATCH 10/19] Updating VQSR for new RodBinding syntax. Cleaning up indel specific parts of VQSR. --- .../ApplyRecalibration.java | 22 ++-- .../VariantDataManager.java | 93 ++++++++-------- .../VariantRecalibrator.java | 105 ++++++++++++------ ...ntRecalibrationWalkersIntegrationTest.java | 12 +- 4 files changed, 129 insertions(+), 103 deletions(-) diff --git a/public/java/src/org/broadinstitute/sting/gatk/walkers/variantrecalibration/ApplyRecalibration.java b/public/java/src/org/broadinstitute/sting/gatk/walkers/variantrecalibration/ApplyRecalibration.java index 74b7b8e7d..abe27e483 100755 --- a/public/java/src/org/broadinstitute/sting/gatk/walkers/variantrecalibration/ApplyRecalibration.java +++ b/public/java/src/org/broadinstitute/sting/gatk/walkers/variantrecalibration/ApplyRecalibration.java @@ -28,9 +28,9 @@ package org.broadinstitute.sting.gatk.walkers.variantrecalibration; import org.broadinstitute.sting.commandline.Argument; import org.broadinstitute.sting.commandline.Input; import org.broadinstitute.sting.commandline.Output; +import org.broadinstitute.sting.commandline.RodBinding; import org.broadinstitute.sting.gatk.contexts.AlignmentContext; import org.broadinstitute.sting.gatk.contexts.ReferenceContext; -import org.broadinstitute.sting.gatk.datasources.rmd.ReferenceOrderedDataSource; import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker; import org.broadinstitute.sting.gatk.walkers.RodWalker; import org.broadinstitute.sting.utils.SampleUtils; @@ -56,6 +56,11 @@ public class ApplyRecalibration extends RodWalker { ///////////////////////////// // Inputs ///////////////////////////// + /** + * The raw input variants to be recalibrated. + */ + @Input(fullName="input", shortName = "input", doc="The raw input variants to be recalibrated", required=true) + public List> input; @Input(fullName="recal_file", shortName="recalFile", doc="The output recal file used by ApplyRecalibration", required=true) private File RECAL_FILE; @Input(fullName="tranches_file", shortName="tranchesFile", doc="The input tranches file describing where to cut the data", required=true) @@ -101,17 +106,8 @@ public class ApplyRecalibration extends RodWalker { } Collections.reverse(tranches); // this algorithm wants the tranches ordered from best (lowest truth sensitivity) to worst (highest truth sensitivity) - for( final ReferenceOrderedDataSource d : this.getToolkit().getRodDataSources() ) { - if( d.getName().startsWith("input") ) { - inputNames.add(d.getName()); - logger.info("Found input variant track with name " + d.getName()); - } else { - logger.info("Not evaluating ROD binding " + d.getName()); - } - } - - if( inputNames.size() == 0 ) { - throw new UserException.BadInput( "No input variant tracks found. Input variant binding names must begin with 'input'." ); + for( final RodBinding rod : input ) { + inputNames.add( rod.getName() ); } if( IGNORE_INPUT_FILTERS != null ) { @@ -168,7 +164,7 @@ public class ApplyRecalibration extends RodWalker { return 1; } - for( VariantContext vc : tracker.getValues(VariantContext.class, inputNames, context.getLocation()) ) { + for( VariantContext vc : tracker.getValues(input, context.getLocation()) ) { if( vc != null ) { if( VariantRecalibrator.checkRecalibrationMode( vc, MODE ) && (vc.isNotFiltered() || ignoreInputFilterSet.containsAll(vc.getFilters())) ) { String filterString = null; diff --git a/public/java/src/org/broadinstitute/sting/gatk/walkers/variantrecalibration/VariantDataManager.java b/public/java/src/org/broadinstitute/sting/gatk/walkers/variantrecalibration/VariantDataManager.java index 8687b5796..08026a45e 100755 --- a/public/java/src/org/broadinstitute/sting/gatk/walkers/variantrecalibration/VariantDataManager.java +++ b/public/java/src/org/broadinstitute/sting/gatk/walkers/variantrecalibration/VariantDataManager.java @@ -26,10 +26,10 @@ package org.broadinstitute.sting.gatk.walkers.variantrecalibration; import org.apache.log4j.Logger; +import org.broadinstitute.sting.commandline.RodBinding; import org.broadinstitute.sting.gatk.GenomeAnalysisEngine; -import org.broadinstitute.sting.gatk.contexts.AlignmentContext; -import org.broadinstitute.sting.gatk.contexts.ReferenceContext; import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker; +import org.broadinstitute.sting.utils.GenomeLoc; import org.broadinstitute.sting.utils.MathUtils; import org.broadinstitute.sting.utils.collections.ExpandingArrayList; import org.broadinstitute.sting.utils.exceptions.UserException; @@ -38,6 +38,7 @@ import org.broadinstitute.sting.utils.variantcontext.VariantContext; import java.io.PrintStream; import java.util.ArrayList; import java.util.Collections; +import java.util.HashMap; import java.util.List; /** @@ -105,31 +106,6 @@ public class VariantDataManager { } } - public void addTrainingSet( final TrainingSet trainingSet ) { - trainingSets.add( trainingSet ); - } - - public boolean checkHasTrainingSet() { - for( final TrainingSet trainingSet : trainingSets ) { - if( trainingSet.isTraining ) { return true; } - } - return false; - } - - public boolean checkHasTruthSet() { - for( final TrainingSet trainingSet : trainingSets ) { - if( trainingSet.isTruth ) { return true; } - } - return false; - } - - public boolean checkHasKnownSet() { - for( final TrainingSet trainingSet : trainingSets ) { - if( trainingSet.isKnown ) { return true; } - } - return false; - } - public ExpandingArrayList getTrainingData() { final ExpandingArrayList trainingData = new ExpandingArrayList(); for( final VariantDatum datum : data ) { @@ -240,13 +216,14 @@ public class VariantDataManager { if( jitter && annotationKey.equalsIgnoreCase("HRUN") ) { // Integer valued annotations must be jittered a bit to work in this GMM value += -0.25 + 0.5 * GenomeAnalysisEngine.getRandomGenerator().nextDouble(); } - if (vc.isIndel() && annotationKey.equalsIgnoreCase("QD")) { - // normalize QD by event length for indel case - int eventLength = Math.abs(vc.getAlternateAllele(0).getBaseString().length() - vc.getReference().getBaseString().length()); // ignore multi-allelic complication here for now - if (eventLength > 0) // sanity check - value /= (double)eventLength; - } + if (vc.isIndel() && annotationKey.equalsIgnoreCase("QD")) { + // normalize QD by event length for indel case + int eventLength = Math.abs(vc.getAlternateAllele(0).getBaseString().length() - vc.getReference().getBaseString().length()); // ignore multi-allelic complication here for now + if (eventLength > 0) { // sanity check + value /= (double)eventLength; + } + } if( jitter && annotationKey.equalsIgnoreCase("HaplotypeScore") && MathUtils.compareDoubles(value, 0.0, 0.0001) == 0 ) { value = -0.2 + 0.4*GenomeAnalysisEngine.getRandomGenerator().nextDouble(); } if( jitter && annotationKey.equalsIgnoreCase("FS") && MathUtils.compareDoubles(value, 0.0, 0.001) == 0 ) { value = -0.2 + 0.4*GenomeAnalysisEngine.getRandomGenerator().nextDouble(); } @@ -257,30 +234,44 @@ public class VariantDataManager { return value; } - public void parseTrainingSets( final RefMetaDataTracker tracker, final ReferenceContext ref, final AlignmentContext context, final VariantContext evalVC, final VariantDatum datum, final boolean TRUST_ALL_POLYMORPHIC ) { + public void parseTrainingSets( final RefMetaDataTracker tracker, final GenomeLoc genomeLoc, final VariantContext evalVC, final VariantDatum datum, final boolean TRUST_ALL_POLYMORPHIC, final HashMap rodToPriorMap, + final List> training, final List> truth, final List> known, final List> badSites) { datum.isKnown = false; datum.atTruthSite = false; datum.atTrainingSite = false; datum.atAntiTrainingSite = false; datum.prior = 2.0; - datum.consensusCount = 0; - for( final TrainingSet trainingSet : trainingSets ) { - for( final VariantContext trainVC : tracker.getValues(VariantContext.class, trainingSet.name, ref.getLocus()) ) { - if( trainVC != null && trainVC.isNotFiltered() && trainVC.isVariant() && - ((evalVC.isSNP() && trainVC.isSNP()) || ((evalVC.isIndel()||evalVC.isMixed()) && (trainVC.isIndel()||trainVC.isMixed()))) && - (TRUST_ALL_POLYMORPHIC || !trainVC.hasGenotypes() || trainVC.isPolymorphic()) ) { - - datum.isKnown = datum.isKnown || trainingSet.isKnown; - datum.atTruthSite = datum.atTruthSite || trainingSet.isTruth; - datum.atTrainingSite = datum.atTrainingSite || trainingSet.isTraining; - datum.prior = Math.max( datum.prior, trainingSet.prior ); - datum.consensusCount += ( trainingSet.isConsensus ? 1 : 0 ); + for( final RodBinding rod : training ) { + for( final VariantContext trainVC : tracker.getValues(rod, genomeLoc) ) { + if( isValidVariant( evalVC, trainVC, TRUST_ALL_POLYMORPHIC ) ) { + datum.atTrainingSite = true; + datum.prior = Math.max( datum.prior, (rodToPriorMap.containsKey(rod.getName()) ? rodToPriorMap.get(rod.getName()) : 0.0) ); } + } + } + for( final RodBinding rod : truth ) { + for( final VariantContext trainVC : tracker.getValues(rod, genomeLoc) ) { + if( isValidVariant( evalVC, trainVC, TRUST_ALL_POLYMORPHIC ) ) { + datum.atTruthSite = true; + datum.prior = Math.max( datum.prior, (rodToPriorMap.containsKey(rod.getName()) ? rodToPriorMap.get(rod.getName()) : 0.0) ); + } + } + } + for( final RodBinding rod : known ) { + for( final VariantContext trainVC : tracker.getValues(rod, genomeLoc) ) { + if( isValidVariant( evalVC, trainVC, TRUST_ALL_POLYMORPHIC ) ) { + datum.isKnown = true; + datum.prior = Math.max( datum.prior, (rodToPriorMap.containsKey(rod.getName()) ? rodToPriorMap.get(rod.getName()) : 0.0) ); + } + } + } + for( final RodBinding rod : badSites ) { + for( final VariantContext trainVC : tracker.getValues(rod, genomeLoc) ) { if( trainVC != null ) { - datum.atAntiTrainingSite = datum.atAntiTrainingSite || trainingSet.isAntiTraining; + datum.atAntiTrainingSite = true; + datum.prior = Math.max( datum.prior, (rodToPriorMap.containsKey(rod.getName()) ? rodToPriorMap.get(rod.getName()) : 0.0) ); } - } } } @@ -292,4 +283,10 @@ public class VariantDataManager { (datum.worstAnnotation != -1 ? annotationKeys.get(datum.worstAnnotation) : "NULL"))); } } + + private boolean isValidVariant( final VariantContext evalVC, final VariantContext trainVC, final boolean TRUST_ALL_POLYMORPHIC) { + return trainVC != null && trainVC.isNotFiltered() && trainVC.isVariant() && + ((evalVC.isSNP() && trainVC.isSNP()) || ((evalVC.isIndel()||evalVC.isMixed()) && (trainVC.isIndel()||trainVC.isMixed()))) && + (TRUST_ALL_POLYMORPHIC || !trainVC.hasGenotypes() || trainVC.isPolymorphic()); + } } diff --git a/public/java/src/org/broadinstitute/sting/gatk/walkers/variantrecalibration/VariantRecalibrator.java b/public/java/src/org/broadinstitute/sting/gatk/walkers/variantrecalibration/VariantRecalibrator.java index 7bd7ea46d..da9da936b 100755 --- a/public/java/src/org/broadinstitute/sting/gatk/walkers/variantrecalibration/VariantRecalibrator.java +++ b/public/java/src/org/broadinstitute/sting/gatk/walkers/variantrecalibration/VariantRecalibrator.java @@ -25,13 +25,9 @@ package org.broadinstitute.sting.gatk.walkers.variantrecalibration; -import org.broadinstitute.sting.commandline.Argument; -import org.broadinstitute.sting.commandline.ArgumentCollection; -import org.broadinstitute.sting.commandline.Hidden; -import org.broadinstitute.sting.commandline.Output; +import org.broadinstitute.sting.commandline.*; import org.broadinstitute.sting.gatk.contexts.AlignmentContext; import org.broadinstitute.sting.gatk.contexts.ReferenceContext; -import org.broadinstitute.sting.gatk.datasources.rmd.ReferenceOrderedDataSource; import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker; import org.broadinstitute.sting.gatk.walkers.RodWalker; import org.broadinstitute.sting.gatk.walkers.TreeReducible; @@ -57,11 +53,51 @@ import java.util.*; public class VariantRecalibrator extends RodWalker, ExpandingArrayList> implements TreeReducible> { - public static final String VQS_LOD_KEY = "VQSLOD"; - public static final String CULPRIT_KEY = "culprit"; + public static final String VQS_LOD_KEY = "VQSLOD"; // Log odds ratio of being a true variant versus being false under the trained gaussian mixture model + public static final String CULPRIT_KEY = "culprit"; // The annotation which was the worst performing in the Gaussian mixture model, likely the reason why the variant was filtered out @ArgumentCollection private VariantRecalibratorArgumentCollection VRAC = new VariantRecalibratorArgumentCollection(); + ///////////////////////////// + // Inputs + ///////////////////////////// + /** + * The raw input variants to be recalibrated. + */ + @Input(fullName="input", shortName = "input", doc="The raw input variants to be recalibrated", required=true) + public List> input; + /** + * A list of training variants used to train the Gaussian mixture model. + * + * Input variants which are found to overlap with these training sites are used to build the Gaussian mixture model. + */ + @Input(fullName="training", shortName = "training", doc="A list of training variants used to train the Gaussian mixture model", required=true) + public List> training; + /** + * A list of true variants to be used when deciding the truth sensitivity cut of the final callset. + * + * When deciding where to set the cutoff in VQSLOD sensitivity to these truth sites is used. + * Typically one might want to say I dropped my threshold until I got back 99% of HapMap sites, for example. + */ + @Input(fullName="truth", shortName = "truth", doc="A list of true variants to be used when deciding the truth sensitivity cut of the final callset", required=true) + public List> truth; + /** + * A list of known variants to be used for metric comparison purposes. + * + * The known / novel status of a variant isn't used by the algorithm itself and is only used for reporting / display purposes. + * The output metrics are stratified by known status in order to aid in comparisons with other call sets. + */ + @Input(fullName="known", shortName = "known", doc="A list of known variants to be used for metric comparison purposes", required=false) + public List> known = Collections.emptyList(); + /** + * A list of known bad variants used to supplement training the negative model. + * + * In addition to using the worst 3% of variants as compared to the Gaussian mixture model, we can also supplement the list + * with a database of known bad variants. Maybe these are loci which are frequently filtered out in many projects (centromere, for example). + */ + @Input(fullName="badSites", shortName = "badSites", doc="A list of known bad variants used to supplement training the negative model", required=false) + public List> badSites = Collections.emptyList(); + ///////////////////////////// // Outputs ///////////////////////////// @@ -96,9 +132,9 @@ public class VariantRecalibrator extends RodWalker ignoreInputFilterSet = new TreeSet(); - private final Set inputNames = new HashSet(); private final VariantRecalibratorEngine engine = new VariantRecalibratorEngine( VRAC ); + private final HashMap rodToPriorMap = new HashMap(); //--------------------------------------------------------------------------------------------------------------- // @@ -123,31 +159,24 @@ public class VariantRecalibrator extends RodWalker> allInputBindings = new ArrayList>(); + allInputBindings.addAll(truth); + allInputBindings.addAll(training); + allInputBindings.addAll(known); + allInputBindings.addAll(badSites); + for( final RodBinding rod : allInputBindings ) { + try { + rodToPriorMap.put(rod.getName(), (rod.getTags().containsKey("prior") ? Double.parseDouble(rod.getTags().getValue("prior")) : 0.0) ); + } catch( NumberFormatException e ) { + throw new UserException.BadInput("Bad rod binding syntax. Prior key-value tag detected but isn't parsable. Expecting something like -training:prior=12.0 my.set.vcf"); + } + } } //--------------------------------------------------------------------------------------------------------------- @@ -163,10 +192,12 @@ public class VariantRecalibrator extends RodWalker Date: Wed, 10 Aug 2011 10:23:33 -0400 Subject: [PATCH 11/19] TrainingSets class is obsolete now. --- .../variantrecalibration/TrainingSet.java | 71 ------------------- .../VariantDataManager.java | 2 - 2 files changed, 73 deletions(-) delete mode 100755 public/java/src/org/broadinstitute/sting/gatk/walkers/variantrecalibration/TrainingSet.java diff --git a/public/java/src/org/broadinstitute/sting/gatk/walkers/variantrecalibration/TrainingSet.java b/public/java/src/org/broadinstitute/sting/gatk/walkers/variantrecalibration/TrainingSet.java deleted file mode 100755 index 6c1a7ddbc..000000000 --- a/public/java/src/org/broadinstitute/sting/gatk/walkers/variantrecalibration/TrainingSet.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright (c) 2011 The Broad Institute - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, - * copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following - * conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES - * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT - * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, - * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR - * THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -package org.broadinstitute.sting.gatk.walkers.variantrecalibration; - -import org.apache.log4j.Logger; -import org.broadinstitute.sting.commandline.Tags; - -/** - * Created by IntelliJ IDEA. - * User: rpoplin - * Date: 3/12/11 - */ - -public class TrainingSet { - - public String name; - public boolean isKnown = false; - public boolean isTraining = false; - public boolean isAntiTraining = false; - public boolean isTruth = false; - public boolean isConsensus = false; - public double prior = 0.0; - - protected final static Logger logger = Logger.getLogger(TrainingSet.class); - - public TrainingSet( final String name, final Tags tags ) { - this.name = name; - - // Parse the tags to decide which tracks have which properties - if( tags != null ) { - isKnown = tags.containsKey("known") && tags.getValue("known").equals("true"); - isTraining = tags.containsKey("training") && tags.getValue("training").equals("true"); - isAntiTraining = tags.containsKey("bad") && tags.getValue("bad").equals("true"); - isTruth = tags.containsKey("truth") && tags.getValue("truth").equals("true"); - isConsensus = tags.containsKey("consensus") && tags.getValue("consensus").equals("true"); - prior = ( tags.containsKey("prior") ? Double.parseDouble(tags.getValue("prior")) : prior ); - } - - // Report back to the user which tracks were found and the properties that were detected - if( !isConsensus && !isAntiTraining ) { - logger.info( String.format( "Found %s track: \tKnown = %s \tTraining = %s \tTruth = %s \tPrior = Q%.1f", this.name, isKnown, isTraining, isTruth, prior) ); - } else if( isConsensus ) { - logger.info( String.format( "Found consensus track: %s", this.name) ); - } else { - logger.info( String.format( "Found bad sites training track: %s", this.name) ); - } - } -} diff --git a/public/java/src/org/broadinstitute/sting/gatk/walkers/variantrecalibration/VariantDataManager.java b/public/java/src/org/broadinstitute/sting/gatk/walkers/variantrecalibration/VariantDataManager.java index 08026a45e..cb4d94332 100755 --- a/public/java/src/org/broadinstitute/sting/gatk/walkers/variantrecalibration/VariantDataManager.java +++ b/public/java/src/org/broadinstitute/sting/gatk/walkers/variantrecalibration/VariantDataManager.java @@ -52,7 +52,6 @@ public class VariantDataManager { private final double[] meanVector; private final double[] varianceVector; // this is really the standard deviation public final ArrayList annotationKeys; - private final ExpandingArrayList trainingSets; private final VariantRecalibratorArgumentCollection VRAC; protected final static Logger logger = Logger.getLogger(VariantDataManager.class); @@ -63,7 +62,6 @@ public class VariantDataManager { this.VRAC = VRAC; meanVector = new double[this.annotationKeys.size()]; varianceVector = new double[this.annotationKeys.size()]; - trainingSets = new ExpandingArrayList(); } public void setData( final ExpandingArrayList data ) { From 06cdc4d5f948e813b22aacd61b066c08dfe36a9a Mon Sep 17 00:00:00 2001 From: Eric Banks Date: Wed, 10 Aug 2011 12:00:56 -0400 Subject: [PATCH 12/19] Added a StandardVariantContextInputArgumentCollection that is now used for consistency by many of the core tools. --- ...VariantContextInputArgumentCollection.java | 55 +++++++++++++++++++ .../walkers/annotator/VariantAnnotator.java | 11 ++-- .../beagle/BeagleOutputToVCFWalker.java | 15 +++-- .../beagle/ProduceBeagleInputWalker.java | 9 +-- .../filters/VariantFiltrationWalker.java | 15 ++--- .../phasing/ReadBackedPhasingWalker.java | 13 +++-- .../walkers/variantutils/CombineVariants.java | 7 +-- .../variantutils/LeftAlignVariants.java | 18 +++--- .../variantutils/LiftoverVariants.java | 22 ++++---- .../walkers/variantutils/SelectVariants.java | 8 +-- .../variantutils/ValidateVariants.java | 15 ++--- .../walkers/variantutils/VariantsToTable.java | 12 ++-- 12 files changed, 124 insertions(+), 76 deletions(-) create mode 100644 public/java/src/org/broadinstitute/sting/gatk/arguments/StandardVariantContextInputArgumentCollection.java diff --git a/public/java/src/org/broadinstitute/sting/gatk/arguments/StandardVariantContextInputArgumentCollection.java b/public/java/src/org/broadinstitute/sting/gatk/arguments/StandardVariantContextInputArgumentCollection.java new file mode 100644 index 000000000..dd5f628c1 --- /dev/null +++ b/public/java/src/org/broadinstitute/sting/gatk/arguments/StandardVariantContextInputArgumentCollection.java @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2010 The Broad Institute + * + * Permission is hereby granted, free of charge, to any person + * obtaining a copy of this software and associated documentation + * files (the "Software"), to deal in the Software without + * restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following + * conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES + * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR + * THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +package org.broadinstitute.sting.gatk.arguments; + + +import org.broadinstitute.sting.commandline.Input; +import org.broadinstitute.sting.commandline.RodBinding; +import org.broadinstitute.sting.utils.variantcontext.VariantContext; +import org.simpleframework.xml.Root; + +/** + * @author ebanks + * @version 1.0 + */ +@Root +public class StandardVariantContextInputArgumentCollection { + + /** + * The VCF input file(s) + * + * The variant track can take any number of arguments on the command line. Each -V argument + * will be included as an input to the tool. If no explicit name is provided, + * the -V arguments will be named using the default algorithm: variant, variant2, variant3, etc. + * The user can override this by providing an explicit name -V:name,vcf for each -V argument, + * and each named argument will be labeled as such in the output (i.e., set=name rather than + * set=variant2). The order of arguments does not matter except for the naming. + */ + @Input(fullName="variant", shortName = "V", doc="Input VCF file", required=true) + public RodBinding variants; + +} + diff --git a/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/VariantAnnotator.java b/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/VariantAnnotator.java index 594216d53..9bf70017a 100755 --- a/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/VariantAnnotator.java +++ b/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/VariantAnnotator.java @@ -27,6 +27,7 @@ package org.broadinstitute.sting.gatk.walkers.annotator; import org.broadinstitute.sting.commandline.*; import org.broadinstitute.sting.gatk.arguments.DbsnpArgumentCollection; +import org.broadinstitute.sting.gatk.arguments.StandardVariantContextInputArgumentCollection; import org.broadinstitute.sting.gatk.contexts.AlignmentContext; import org.broadinstitute.sting.gatk.contexts.AlignmentContextUtils; import org.broadinstitute.sting.gatk.contexts.ReferenceContext; @@ -35,7 +36,6 @@ import org.broadinstitute.sting.gatk.walkers.*; import org.broadinstitute.sting.gatk.walkers.annotator.interfaces.AnnotationType; import org.broadinstitute.sting.gatk.walkers.annotator.interfaces.GenotypeAnnotation; import org.broadinstitute.sting.gatk.walkers.annotator.interfaces.InfoFieldAnnotation; -import org.broadinstitute.sting.gatk.walkers.genotyper.UnifiedArgumentCollection; import org.broadinstitute.sting.utils.BaseUtils; import org.broadinstitute.sting.utils.SampleUtils; import org.broadinstitute.sting.utils.classloader.PluginManager; @@ -56,8 +56,7 @@ import java.util.*; @By(DataSource.REFERENCE) public class VariantAnnotator extends RodWalker { - @Input(fullName="variant", shortName = "V", doc="Input VCF file", required=true) - public RodBinding variants; + @ArgumentCollection protected StandardVariantContextInputArgumentCollection variantCollection = new StandardVariantContextInputArgumentCollection(); @Input(fullName="snpEffFile", shortName = "snpEffFile", doc="SnpEff file", required=false) public RodBinding snpEffFile; @@ -142,7 +141,7 @@ public class VariantAnnotator extends RodWalker { listAnnotationsAndExit(); // get the list of all sample names from the variant VCF input rod, if applicable - List rodName = Arrays.asList(variants.getName()); + List rodName = Arrays.asList(variantCollection.variants.getName()); Set samples = SampleUtils.getUniqueSamplesFromRods(getToolkit(), rodName); // add the non-VCF sample from the command-line, if applicable @@ -166,7 +165,7 @@ 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()); - for ( VCFHeaderLine line : VCFUtils.getHeaderFields(getToolkit(), Arrays.asList(variants.getName())) ) { + for ( VCFHeaderLine line : VCFUtils.getHeaderFields(getToolkit(), Arrays.asList(variantCollection.variants.getName())) ) { if ( isUniqueHeaderLine(line, hInfo) ) hInfo.add(line); } @@ -225,7 +224,7 @@ public class VariantAnnotator extends RodWalker { if ( tracker == null ) return 0; - Collection VCs = tracker.getValues(variants, context.getLocation()); + Collection VCs = tracker.getValues(variantCollection.variants, context.getLocation()); if ( VCs.size() == 0 ) return 0; diff --git a/public/java/src/org/broadinstitute/sting/gatk/walkers/beagle/BeagleOutputToVCFWalker.java b/public/java/src/org/broadinstitute/sting/gatk/walkers/beagle/BeagleOutputToVCFWalker.java index a34dfd080..221861062 100755 --- a/public/java/src/org/broadinstitute/sting/gatk/walkers/beagle/BeagleOutputToVCFWalker.java +++ b/public/java/src/org/broadinstitute/sting/gatk/walkers/beagle/BeagleOutputToVCFWalker.java @@ -25,10 +25,8 @@ package org.broadinstitute.sting.gatk.walkers.beagle; -import org.broadinstitute.sting.commandline.Argument; -import org.broadinstitute.sting.commandline.Input; -import org.broadinstitute.sting.commandline.Output; -import org.broadinstitute.sting.commandline.RodBinding; +import org.broadinstitute.sting.commandline.*; +import org.broadinstitute.sting.gatk.arguments.StandardVariantContextInputArgumentCollection; import org.broadinstitute.sting.gatk.contexts.AlignmentContext; import org.broadinstitute.sting.gatk.contexts.ReferenceContext; import org.broadinstitute.sting.gatk.datasources.rmd.ReferenceOrderedDataSource; @@ -54,8 +52,9 @@ import static java.lang.Math.log10; */ @Requires(value={}) public class BeagleOutputToVCFWalker extends RodWalker { - @Input(fullName="variant", shortName = "V", doc="Input VCF file", required=true) - public RodBinding variants; + + @ArgumentCollection + protected StandardVariantContextInputArgumentCollection variantCollection = new StandardVariantContextInputArgumentCollection(); @Input(fullName="comp", shortName = "comp", doc="Comparison VCF file", required=false) public RodBinding comp = RodBinding.makeUnbound(VariantContext.class); @@ -111,7 +110,7 @@ public class BeagleOutputToVCFWalker extends RodWalker { hInfo.add(new VCFInfoHeaderLine("AFH", 1, VCFHeaderLineType.Float, "Allele Number from Comparison ROD at this site")); } - Set samples = SampleUtils.getSampleListWithVCFHeader(getToolkit(), Arrays.asList(variants.getName())); + Set samples = SampleUtils.getSampleListWithVCFHeader(getToolkit(), Arrays.asList(variantCollection.variants.getName())); final VCFHeader vcfHeader = new VCFHeader(hInfo, samples); vcfWriter.writeHeader(vcfHeader); @@ -123,7 +122,7 @@ public class BeagleOutputToVCFWalker extends RodWalker { return 0; GenomeLoc loc = context.getLocation(); - VariantContext vc_input = tracker.getFirstValue(variants, loc); + VariantContext vc_input = tracker.getFirstValue(variantCollection.variants, loc); VariantContext vc_comp = tracker.getFirstValue(comp, loc); diff --git a/public/java/src/org/broadinstitute/sting/gatk/walkers/beagle/ProduceBeagleInputWalker.java b/public/java/src/org/broadinstitute/sting/gatk/walkers/beagle/ProduceBeagleInputWalker.java index 88b976e7e..4837aa54d 100755 --- a/public/java/src/org/broadinstitute/sting/gatk/walkers/beagle/ProduceBeagleInputWalker.java +++ b/public/java/src/org/broadinstitute/sting/gatk/walkers/beagle/ProduceBeagleInputWalker.java @@ -27,6 +27,7 @@ package org.broadinstitute.sting.gatk.walkers.beagle; import org.broadinstitute.sting.commandline.*; import org.broadinstitute.sting.gatk.GenomeAnalysisEngine; +import org.broadinstitute.sting.gatk.arguments.StandardVariantContextInputArgumentCollection; import org.broadinstitute.sting.gatk.contexts.AlignmentContext; import org.broadinstitute.sting.gatk.contexts.ReferenceContext; import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker; @@ -52,8 +53,8 @@ import java.util.*; */ @Requires(value={}) public class ProduceBeagleInputWalker extends RodWalker { - @Input(fullName="variant", shortName = "V", doc="Input VCF file", required=true) - public RodBinding variants; + + @ArgumentCollection protected StandardVariantContextInputArgumentCollection variantCollection = new StandardVariantContextInputArgumentCollection(); @Input(fullName="validation", shortName = "validation", doc="Input VCF file", required=false) public RodBinding validation = RodBinding.makeUnbound(VariantContext.class); @@ -98,7 +99,7 @@ public class ProduceBeagleInputWalker extends RodWalker { public void initialize() { - samples = SampleUtils.getSampleListWithVCFHeader(getToolkit(), Arrays.asList(variants.getName())); + samples = SampleUtils.getSampleListWithVCFHeader(getToolkit(), Arrays.asList(variantCollection.variants.getName())); beagleWriter.print("marker alleleA alleleB"); for ( String sample : samples ) @@ -120,7 +121,7 @@ public class ProduceBeagleInputWalker extends RodWalker { public Integer map( RefMetaDataTracker tracker, ReferenceContext ref, AlignmentContext context ) { if( tracker != null ) { GenomeLoc loc = context.getLocation(); - VariantContext variant_eval = tracker.getFirstValue(variants, loc); + VariantContext variant_eval = tracker.getFirstValue(variantCollection.variants, loc); VariantContext validation_eval = tracker.getFirstValue(validation, loc); if ( goodSite(variant_eval,validation_eval) ) { diff --git a/public/java/src/org/broadinstitute/sting/gatk/walkers/filters/VariantFiltrationWalker.java b/public/java/src/org/broadinstitute/sting/gatk/walkers/filters/VariantFiltrationWalker.java index e0bd58aea..e5968692b 100755 --- a/public/java/src/org/broadinstitute/sting/gatk/walkers/filters/VariantFiltrationWalker.java +++ b/public/java/src/org/broadinstitute/sting/gatk/walkers/filters/VariantFiltrationWalker.java @@ -26,13 +26,10 @@ package org.broadinstitute.sting.gatk.walkers.filters; import org.broad.tribble.Feature; -import org.broadinstitute.sting.commandline.Argument; -import org.broadinstitute.sting.commandline.Input; -import org.broadinstitute.sting.commandline.Output; -import org.broadinstitute.sting.commandline.RodBinding; +import org.broadinstitute.sting.commandline.*; +import org.broadinstitute.sting.gatk.arguments.StandardVariantContextInputArgumentCollection; import org.broadinstitute.sting.gatk.contexts.AlignmentContext; import org.broadinstitute.sting.gatk.contexts.ReferenceContext; -import org.broadinstitute.sting.gatk.datasources.rmd.ReferenceOrderedDataSource; import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker; import org.broadinstitute.sting.gatk.walkers.*; import org.broadinstitute.sting.utils.GenomeLoc; @@ -53,8 +50,8 @@ import java.util.*; @Reference(window=@Window(start=-50,stop=50)) public class VariantFiltrationWalker extends RodWalker { - @Input(fullName="variant", shortName = "V", doc="Input VCF file", required=true) - public RodBinding variants; + @ArgumentCollection + protected StandardVariantContextInputArgumentCollection variantCollection = new StandardVariantContextInputArgumentCollection(); @Input(fullName="mask", doc="Input ROD mask", required=false) public RodBinding mask = RodBinding.makeUnbound(Feature.class); @@ -100,7 +97,7 @@ public class VariantFiltrationWalker extends RodWalker { private void initializeVcfWriter() { - final List inputNames = Arrays.asList(variants.getName()); + final List inputNames = Arrays.asList(variantCollection.variants.getName()); // setup the header fields Set hInfo = new HashSet(); @@ -152,7 +149,7 @@ public class VariantFiltrationWalker extends RodWalker { if ( tracker == null ) return 0; - Collection VCs = tracker.getValues(variants, context.getLocation()); + Collection VCs = tracker.getValues(variantCollection.variants, context.getLocation()); // is there a SNP mask present? boolean hasMask = tracker.hasValues(mask); diff --git a/public/java/src/org/broadinstitute/sting/gatk/walkers/phasing/ReadBackedPhasingWalker.java b/public/java/src/org/broadinstitute/sting/gatk/walkers/phasing/ReadBackedPhasingWalker.java index f81dec2ac..ac4fba4b4 100755 --- a/public/java/src/org/broadinstitute/sting/gatk/walkers/phasing/ReadBackedPhasingWalker.java +++ b/public/java/src/org/broadinstitute/sting/gatk/walkers/phasing/ReadBackedPhasingWalker.java @@ -24,12 +24,12 @@ package org.broadinstitute.sting.gatk.walkers.phasing; import org.broadinstitute.sting.commandline.*; +import org.broadinstitute.sting.gatk.arguments.StandardVariantContextInputArgumentCollection; import org.broadinstitute.sting.gatk.contexts.AlignmentContext; import org.broadinstitute.sting.gatk.contexts.ReferenceContext; import org.broadinstitute.sting.gatk.datasources.sample.Sample; import org.broadinstitute.sting.gatk.filters.MappingQualityZeroReadFilter; import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker; -import org.broadinstitute.sting.gatk.refdata.ReferenceOrderedDatum; import org.broadinstitute.sting.gatk.walkers.*; import org.broadinstitute.sting.utils.BaseUtils; import org.broadinstitute.sting.utils.DisjointSet; @@ -67,8 +67,8 @@ public class ReadBackedPhasingWalker extends RodWalker variants; + @ArgumentCollection + protected StandardVariantContextInputArgumentCollection variantCollection = new StandardVariantContextInputArgumentCollection(); @Output(doc = "File to which variants should be written", required = true) protected VCFWriter writer = null; @@ -175,8 +175,9 @@ public class ReadBackedPhasingWalker extends RodWalker rodNameToHeader = getVCFHeadersFromRods(getToolkit(), Arrays.asList(variants.getName())); - Set samples = new TreeSet(samplesToPhase == null ? rodNameToHeader.get(variants.getName()).getGenotypeSamples() : samplesToPhase); + String trackName = variantCollection.variants.getName(); + Map rodNameToHeader = getVCFHeadersFromRods(getToolkit(), Arrays.asList(trackName)); + Set samples = new TreeSet(samplesToPhase == null ? rodNameToHeader.get(trackName).getGenotypeSamples() : samplesToPhase); writer.writeHeader(new VCFHeader(hInfo, samples)); } @@ -207,7 +208,7 @@ public class ReadBackedPhasingWalker extends RodWalker unprocessedList = new LinkedList(); - for (VariantContext vc : tracker.getValues(variants, context.getLocation())) { + for (VariantContext vc : tracker.getValues(variantCollection.variants, context.getLocation())) { if (samplesToPhase != null) vc = reduceVCToSamples(vc, samplesToPhase); if (ReadBackedPhasingWalker.processVariantInPhasing(vc)) { diff --git a/public/java/src/org/broadinstitute/sting/gatk/walkers/variantutils/CombineVariants.java b/public/java/src/org/broadinstitute/sting/gatk/walkers/variantutils/CombineVariants.java index f24d7a211..fb172e1b7 100755 --- a/public/java/src/org/broadinstitute/sting/gatk/walkers/variantutils/CombineVariants.java +++ b/public/java/src/org/broadinstitute/sting/gatk/walkers/variantutils/CombineVariants.java @@ -31,7 +31,6 @@ import org.broadinstitute.sting.gatk.contexts.ReferenceContext; import org.broadinstitute.sting.gatk.io.stubs.VCFWriterStub; import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker; import org.broadinstitute.sting.gatk.walkers.Reference; -import org.broadinstitute.sting.gatk.walkers.Requires; import org.broadinstitute.sting.gatk.walkers.RodWalker; import org.broadinstitute.sting.gatk.walkers.Window; import org.broadinstitute.sting.utils.SampleUtils; @@ -64,8 +63,8 @@ public class CombineVariants extends RodWalker { * are techincally order dependent. It is strongly recommended to provide explicit names when * a rod priority list is provided. */ - @Input(fullName = "variant", shortName = "V", doc="The VCF files to merge together", required=true) - public List> variantsToMerge; + @Input(fullName="variant", shortName = "V", doc="Input VCF file", required=true) + public List> variants; @Output(doc="File to which variants should be written",required=true) protected VCFWriter vcfWriter = null; @@ -157,7 +156,7 @@ public class CombineVariants extends RodWalker { // get all of the vcf rods at this locus // Need to provide reference bases to simpleMerge starting at current locus - Collection vcs = tracker.getValues(variantsToMerge, context.getLocation()); + Collection vcs = tracker.getValues(variants, context.getLocation()); if ( sitesOnlyVCF ) { vcs = VariantContextUtils.sitesOnlyVariantContexts(vcs); diff --git a/public/java/src/org/broadinstitute/sting/gatk/walkers/variantutils/LeftAlignVariants.java b/public/java/src/org/broadinstitute/sting/gatk/walkers/variantutils/LeftAlignVariants.java index 52b633cdf..f88810aed 100755 --- a/public/java/src/org/broadinstitute/sting/gatk/walkers/variantutils/LeftAlignVariants.java +++ b/public/java/src/org/broadinstitute/sting/gatk/walkers/variantutils/LeftAlignVariants.java @@ -28,9 +28,9 @@ package org.broadinstitute.sting.gatk.walkers.variantutils; import net.sf.samtools.Cigar; import net.sf.samtools.CigarElement; import net.sf.samtools.CigarOperator; -import org.broadinstitute.sting.commandline.Input; +import org.broadinstitute.sting.commandline.ArgumentCollection; import org.broadinstitute.sting.commandline.Output; -import org.broadinstitute.sting.commandline.RodBinding; +import org.broadinstitute.sting.gatk.arguments.StandardVariantContextInputArgumentCollection; import org.broadinstitute.sting.gatk.contexts.AlignmentContext; import org.broadinstitute.sting.gatk.contexts.ReferenceContext; import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker; @@ -50,8 +50,9 @@ import java.util.*; @Reference(window=@Window(start=-200,stop=200)) @Requires(value={}) public class LeftAlignVariants extends RodWalker { - @Input(fullName="variant", shortName = "V", doc="Input VCF file", required=true) - public RodBinding variants; + + @ArgumentCollection + protected StandardVariantContextInputArgumentCollection variantCollection = new StandardVariantContextInputArgumentCollection(); @Output(doc="File to which variants should be written",required=true) protected VCFWriter baseWriter = null; @@ -59,10 +60,11 @@ public class LeftAlignVariants extends RodWalker { private SortingVCFWriter writer; public void initialize() { - Set samples = SampleUtils.getSampleListWithVCFHeader(getToolkit(), Arrays.asList(variants.getName())); - Map vcfHeaders = VCFUtils.getVCFHeadersFromRods(getToolkit(), Arrays.asList(variants.getName())); + String trackName = variantCollection.variants.getName(); + Set samples = SampleUtils.getSampleListWithVCFHeader(getToolkit(), Arrays.asList(trackName)); + Map vcfHeaders = VCFUtils.getVCFHeadersFromRods(getToolkit(), Arrays.asList(trackName)); - Set headerLines = vcfHeaders.get(variants.getName()).getMetaData(); + Set headerLines = vcfHeaders.get(trackName).getMetaData(); baseWriter.writeHeader(new VCFHeader(headerLines, samples)); writer = new SortingVCFWriter(baseWriter, 200); @@ -72,7 +74,7 @@ public class LeftAlignVariants extends RodWalker { if ( tracker == null ) return 0; - Collection VCs = tracker.getValues(variants, context.getLocation()); + Collection VCs = tracker.getValues(variantCollection.variants, context.getLocation()); int changedSites = 0; for ( VariantContext vc : VCs ) diff --git a/public/java/src/org/broadinstitute/sting/gatk/walkers/variantutils/LiftoverVariants.java b/public/java/src/org/broadinstitute/sting/gatk/walkers/variantutils/LiftoverVariants.java index 7edb4d52c..f93fb84e3 100755 --- a/public/java/src/org/broadinstitute/sting/gatk/walkers/variantutils/LiftoverVariants.java +++ b/public/java/src/org/broadinstitute/sting/gatk/walkers/variantutils/LiftoverVariants.java @@ -29,10 +29,8 @@ import net.sf.picard.liftover.LiftOver; import net.sf.picard.util.Interval; import net.sf.samtools.SAMFileHeader; import net.sf.samtools.SAMFileReader; -import org.broadinstitute.sting.commandline.Argument; -import org.broadinstitute.sting.commandline.Input; -import org.broadinstitute.sting.commandline.Output; -import org.broadinstitute.sting.commandline.RodBinding; +import org.broadinstitute.sting.commandline.*; +import org.broadinstitute.sting.gatk.arguments.StandardVariantContextInputArgumentCollection; import org.broadinstitute.sting.gatk.contexts.AlignmentContext; import org.broadinstitute.sting.gatk.contexts.ReferenceContext; import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker; @@ -52,8 +50,9 @@ import java.util.*; */ @Requires(value={}) public class LiftoverVariants extends RodWalker { - @Input(fullName="variant", shortName = "V", doc="Input VCF file", required=true) - public RodBinding variants; + + @ArgumentCollection + protected StandardVariantContextInputArgumentCollection variantCollection = new StandardVariantContextInputArgumentCollection(); @Output(doc="File to which variants should be written",required=true) protected File file = null; @@ -88,12 +87,13 @@ public class LiftoverVariants extends RodWalker { throw new UserException.BadInput("the chain file you are using is not compatible with the reference you are trying to lift over to; please use the appropriate chain file for the given reference"); } - Set samples = SampleUtils.getSampleListWithVCFHeader(getToolkit(), Arrays.asList(variants.getName())); - Map vcfHeaders = VCFUtils.getVCFHeadersFromRods(getToolkit(), Arrays.asList(variants.getName())); + String trackName = variantCollection.variants.getName(); + Set samples = SampleUtils.getSampleListWithVCFHeader(getToolkit(), Arrays.asList(trackName)); + Map vcfHeaders = VCFUtils.getVCFHeadersFromRods(getToolkit(), Arrays.asList(trackName)); Set metaData = new HashSet(); - if ( vcfHeaders.containsKey(variants.getName()) ) - metaData.addAll(vcfHeaders.get(variants.getName()).getMetaData()); + if ( vcfHeaders.containsKey(trackName) ) + metaData.addAll(vcfHeaders.get(trackName).getMetaData()); if ( RECORD_ORIGINAL_LOCATION ) { metaData.add(new VCFInfoHeaderLine("OriginalChr", 1, VCFHeaderLineType.String, "Original contig name for the record")); metaData.add(new VCFInfoHeaderLine("OriginalStart", 1, VCFHeaderLineType.Integer, "Original start position for the record")); @@ -146,7 +146,7 @@ public class LiftoverVariants extends RodWalker { if ( tracker == null ) return 0; - Collection VCs = tracker.getValues(variants, context.getLocation()); + Collection VCs = tracker.getValues(variantCollection.variants, context.getLocation()); for ( VariantContext vc : VCs ) convertAndWrite(vc, ref); diff --git a/public/java/src/org/broadinstitute/sting/gatk/walkers/variantutils/SelectVariants.java b/public/java/src/org/broadinstitute/sting/gatk/walkers/variantutils/SelectVariants.java index 7179956c1..e254fe61f 100755 --- a/public/java/src/org/broadinstitute/sting/gatk/walkers/variantutils/SelectVariants.java +++ b/public/java/src/org/broadinstitute/sting/gatk/walkers/variantutils/SelectVariants.java @@ -25,6 +25,7 @@ package org.broadinstitute.sting.gatk.walkers.variantutils; import org.broadinstitute.sting.commandline.*; +import org.broadinstitute.sting.gatk.arguments.StandardVariantContextInputArgumentCollection; import org.broadinstitute.sting.utils.MathUtils; import org.broadinstitute.sting.utils.codecs.vcf.*; import org.broadinstitute.sting.utils.exceptions.UserException; @@ -61,8 +62,7 @@ public class SelectVariants extends RodWalker { * Variants from this file are sent through the filtering and modifying routines as directed * by the arguments to SelectVariants, and finally are emitted. */ - @Input(fullName="variant", shortName = "V", doc="Select variants from this VCF file", required=true) - public RodBinding variants; + @ArgumentCollection protected StandardVariantContextInputArgumentCollection variantCollection = new StandardVariantContextInputArgumentCollection(); /** * If provided, we will filter out variants that are "discordant" to the variants in this file @@ -194,7 +194,7 @@ public class SelectVariants extends RodWalker { */ public void initialize() { // Get list of samples to include in the output - List rodNames = Arrays.asList(variants.getName()); + List rodNames = Arrays.asList(variantCollection.variants.getName()); Map vcfRods = VCFUtils.getVCFHeadersFromRods(getToolkit(), rodNames); TreeSet vcfSamples = new TreeSet(SampleUtils.getSampleList(vcfRods, VariantContextUtils.GenotypeMergeType.REQUIRE_UNIQUE)); @@ -318,7 +318,7 @@ public class SelectVariants extends RodWalker { if ( tracker == null ) return 0; - Collection vcs = tracker.getValues(variants, context.getLocation()); + Collection vcs = tracker.getValues(variantCollection.variants, context.getLocation()); if ( vcs == null || vcs.size() == 0) { return 0; diff --git a/public/java/src/org/broadinstitute/sting/gatk/walkers/variantutils/ValidateVariants.java b/public/java/src/org/broadinstitute/sting/gatk/walkers/variantutils/ValidateVariants.java index 9f64e0ca4..cc7854f12 100755 --- a/public/java/src/org/broadinstitute/sting/gatk/walkers/variantutils/ValidateVariants.java +++ b/public/java/src/org/broadinstitute/sting/gatk/walkers/variantutils/ValidateVariants.java @@ -28,13 +28,10 @@ package org.broadinstitute.sting.gatk.walkers.variantutils; import org.broad.tribble.Feature; import org.broad.tribble.TribbleException; import org.broad.tribble.dbsnp.DbSNPFeature; -import org.broadinstitute.sting.commandline.Argument; -import org.broadinstitute.sting.commandline.Hidden; -import org.broadinstitute.sting.commandline.Input; -import org.broadinstitute.sting.commandline.RodBinding; +import org.broadinstitute.sting.commandline.*; +import org.broadinstitute.sting.gatk.arguments.StandardVariantContextInputArgumentCollection; import org.broadinstitute.sting.gatk.contexts.AlignmentContext; import org.broadinstitute.sting.gatk.contexts.ReferenceContext; -import org.broadinstitute.sting.gatk.datasources.rmd.ReferenceOrderedDataSource; import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker; import org.broadinstitute.sting.gatk.refdata.features.DbSNPHelper; import org.broadinstitute.sting.gatk.walkers.*; @@ -56,8 +53,8 @@ import java.util.Set; @Requires(value={}) public class ValidateVariants extends RodWalker { - @Input(fullName="variant", shortName = "V", doc="Input VCF file", required=true) - public RodBinding variants; + @ArgumentCollection + protected StandardVariantContextInputArgumentCollection variantCollection = new StandardVariantContextInputArgumentCollection(); public enum ValidationType { ALL, REF, IDS, ALLELES, CHR_COUNTS @@ -78,14 +75,14 @@ public class ValidateVariants extends RodWalker { private File file = null; public void initialize() { - file = new File(variants.getSource()); + file = new File(variantCollection.variants.getSource()); } public Integer map(RefMetaDataTracker tracker, ReferenceContext ref, AlignmentContext context) { if ( tracker == null ) return 0; - Collection VCs = tracker.getValues(variants, context.getLocation()); + Collection VCs = tracker.getValues(variantCollection.variants, context.getLocation()); for ( VariantContext vc : VCs ) validate(vc, tracker, ref); diff --git a/public/java/src/org/broadinstitute/sting/gatk/walkers/variantutils/VariantsToTable.java b/public/java/src/org/broadinstitute/sting/gatk/walkers/variantutils/VariantsToTable.java index f999f25c0..fa25b0191 100755 --- a/public/java/src/org/broadinstitute/sting/gatk/walkers/variantutils/VariantsToTable.java +++ b/public/java/src/org/broadinstitute/sting/gatk/walkers/variantutils/VariantsToTable.java @@ -24,12 +24,10 @@ package org.broadinstitute.sting.gatk.walkers.variantutils; -import org.broadinstitute.sting.commandline.Input; -import org.broadinstitute.sting.commandline.RodBinding; +import org.broadinstitute.sting.commandline.*; +import org.broadinstitute.sting.gatk.arguments.StandardVariantContextInputArgumentCollection; import org.broadinstitute.sting.utils.MathUtils; import org.broadinstitute.sting.utils.variantcontext.VariantContext; -import org.broadinstitute.sting.commandline.Argument; -import org.broadinstitute.sting.commandline.Output; import org.broadinstitute.sting.gatk.contexts.AlignmentContext; import org.broadinstitute.sting.gatk.contexts.ReferenceContext; import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker; @@ -48,8 +46,8 @@ import java.util.*; @Requires(value={}) public class VariantsToTable extends RodWalker { - @Input(fullName="variant", shortName = "V", doc="Input VCF file", required=true) - public RodBinding variants; + @ArgumentCollection + protected StandardVariantContextInputArgumentCollection variantCollection = new StandardVariantContextInputArgumentCollection(); @Output(doc="File to which results should be written",required=true) protected PrintStream out; @@ -138,7 +136,7 @@ public class VariantsToTable extends RodWalker { return 0; if ( ++nRecords < MAX_RECORDS || MAX_RECORDS == -1 ) { - for ( VariantContext vc : tracker.getValues(variants, context.getLocation())) { + for ( VariantContext vc : tracker.getValues(variantCollection.variants, context.getLocation())) { if ( (keepMultiAllelic || vc.isBiallelic()) && ( showFiltered || vc.isNotFiltered() ) ) { List vals = extractFields(vc, fieldsToTake, ALLOW_MISSING_DATA); out.println(Utils.join("\t", vals)); From c884b6bf1f01d9d6c2a59898ece5113830c567ac Mon Sep 17 00:00:00 2001 From: Eric Banks Date: Wed, 10 Aug 2011 12:07:43 -0400 Subject: [PATCH 13/19] Fixed comment --- .../StandardVariantContextInputArgumentCollection.java | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/public/java/src/org/broadinstitute/sting/gatk/arguments/StandardVariantContextInputArgumentCollection.java b/public/java/src/org/broadinstitute/sting/gatk/arguments/StandardVariantContextInputArgumentCollection.java index dd5f628c1..847120414 100644 --- a/public/java/src/org/broadinstitute/sting/gatk/arguments/StandardVariantContextInputArgumentCollection.java +++ b/public/java/src/org/broadinstitute/sting/gatk/arguments/StandardVariantContextInputArgumentCollection.java @@ -39,14 +39,9 @@ import org.simpleframework.xml.Root; public class StandardVariantContextInputArgumentCollection { /** - * The VCF input file(s) + * The VCF file we are using. * - * The variant track can take any number of arguments on the command line. Each -V argument - * will be included as an input to the tool. If no explicit name is provided, - * the -V arguments will be named using the default algorithm: variant, variant2, variant3, etc. - * The user can override this by providing an explicit name -V:name,vcf for each -V argument, - * and each named argument will be labeled as such in the output (i.e., set=name rather than - * set=variant2). The order of arguments does not matter except for the naming. + * Variants from this file are used by this tool as input. */ @Input(fullName="variant", shortName = "V", doc="Input VCF file", required=true) public RodBinding variants; From a42f90db1104d918019a1d3cead1bd6fbdd730d2 Mon Sep 17 00:00:00 2001 From: Eric Banks Date: Wed, 10 Aug 2011 12:20:18 -0400 Subject: [PATCH 14/19] Moving more tools over to use the standard VC arg collection. Also, while I'm in there, I removed all of the empty references to @Requires given that it's no longer relevant. --- .../walkers/annotator/VariantAnnotator.java | 1 - .../beagle/BeagleOutputToVCFWalker.java | 2 -- .../beagle/ProduceBeagleInputWalker.java | 2 -- .../VariantsToBeagleUnphasedWalker.java | 2 -- .../walkers/diffengine/DiffObjectsWalker.java | 2 -- .../filters/VariantFiltrationWalker.java | 1 - .../walkers/genotyper/UGCalcLikelihoods.java | 1 - .../variantutils/FilterLiftedVariants.java | 19 ++++++++++--------- .../variantutils/LeftAlignVariants.java | 1 - .../variantutils/LiftoverVariants.java | 2 -- .../variantutils/RandomlySplitVariants.java | 17 +++++++---------- .../walkers/variantutils/SelectVariants.java | 2 -- .../variantutils/ValidateVariants.java | 1 - .../VariantValidationAssessor.java | 2 -- .../walkers/variantutils/VariantsToTable.java | 2 -- .../walkers/variantutils/VariantsToVCF.java | 1 - .../sting/gatk/WalkerManagerUnitTest.java | 2 -- 17 files changed, 17 insertions(+), 43 deletions(-) diff --git a/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/VariantAnnotator.java b/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/VariantAnnotator.java index 9bf70017a..efa40d9a8 100755 --- a/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/VariantAnnotator.java +++ b/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/VariantAnnotator.java @@ -50,7 +50,6 @@ import java.util.*; /** * Annotates variant calls with context information. Users can specify which of the available annotations to use. */ -@Requires(value={}) @Allows(value={DataSource.READS, DataSource.REFERENCE}) @Reference(window=@Window(start=-50,stop=50)) @By(DataSource.REFERENCE) diff --git a/public/java/src/org/broadinstitute/sting/gatk/walkers/beagle/BeagleOutputToVCFWalker.java b/public/java/src/org/broadinstitute/sting/gatk/walkers/beagle/BeagleOutputToVCFWalker.java index 221861062..ee2e4853b 100755 --- a/public/java/src/org/broadinstitute/sting/gatk/walkers/beagle/BeagleOutputToVCFWalker.java +++ b/public/java/src/org/broadinstitute/sting/gatk/walkers/beagle/BeagleOutputToVCFWalker.java @@ -32,7 +32,6 @@ import org.broadinstitute.sting.gatk.contexts.ReferenceContext; import org.broadinstitute.sting.gatk.datasources.rmd.ReferenceOrderedDataSource; import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker; import org.broadinstitute.sting.gatk.refdata.features.beagle.BeagleFeature; -import org.broadinstitute.sting.gatk.walkers.Requires; import org.broadinstitute.sting.gatk.walkers.RodWalker; import org.broadinstitute.sting.utils.GenomeLoc; import org.broadinstitute.sting.utils.SampleUtils; @@ -50,7 +49,6 @@ import static java.lang.Math.log10; /** * Takes files produced by Beagle imputation engine and creates a vcf with modified annotations. */ -@Requires(value={}) public class BeagleOutputToVCFWalker extends RodWalker { @ArgumentCollection diff --git a/public/java/src/org/broadinstitute/sting/gatk/walkers/beagle/ProduceBeagleInputWalker.java b/public/java/src/org/broadinstitute/sting/gatk/walkers/beagle/ProduceBeagleInputWalker.java index 4837aa54d..a46ec8b48 100755 --- a/public/java/src/org/broadinstitute/sting/gatk/walkers/beagle/ProduceBeagleInputWalker.java +++ b/public/java/src/org/broadinstitute/sting/gatk/walkers/beagle/ProduceBeagleInputWalker.java @@ -31,7 +31,6 @@ import org.broadinstitute.sting.gatk.arguments.StandardVariantContextInputArgume import org.broadinstitute.sting.gatk.contexts.AlignmentContext; import org.broadinstitute.sting.gatk.contexts.ReferenceContext; import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker; -import org.broadinstitute.sting.gatk.walkers.Requires; import org.broadinstitute.sting.gatk.walkers.RodWalker; import org.broadinstitute.sting.gatk.walkers.variantrecalibration.VQSRCalibrationCurve; import org.broadinstitute.sting.utils.GenomeLoc; @@ -51,7 +50,6 @@ import java.util.*; /** * Produces an input file to Beagle imputation engine, listing genotype likelihoods for each sample in input variant file */ -@Requires(value={}) public class ProduceBeagleInputWalker extends RodWalker { @ArgumentCollection protected StandardVariantContextInputArgumentCollection variantCollection = new StandardVariantContextInputArgumentCollection(); diff --git a/public/java/src/org/broadinstitute/sting/gatk/walkers/beagle/VariantsToBeagleUnphasedWalker.java b/public/java/src/org/broadinstitute/sting/gatk/walkers/beagle/VariantsToBeagleUnphasedWalker.java index d26bfeca4..22c39d794 100755 --- a/public/java/src/org/broadinstitute/sting/gatk/walkers/beagle/VariantsToBeagleUnphasedWalker.java +++ b/public/java/src/org/broadinstitute/sting/gatk/walkers/beagle/VariantsToBeagleUnphasedWalker.java @@ -32,7 +32,6 @@ import org.broadinstitute.sting.commandline.RodBinding; import org.broadinstitute.sting.gatk.contexts.AlignmentContext; import org.broadinstitute.sting.gatk.contexts.ReferenceContext; import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker; -import org.broadinstitute.sting.gatk.walkers.Requires; import org.broadinstitute.sting.gatk.walkers.RodWalker; import org.broadinstitute.sting.utils.GenomeLoc; import org.broadinstitute.sting.utils.SampleUtils; @@ -55,7 +54,6 @@ import java.util.Set; * in input variant file. Will additional hold back a fraction of the sites for evaluation, marking the * genotypes at that sites as missing, and writing the truth of these sites to a second VCF file */ -@Requires(value={}) public class VariantsToBeagleUnphasedWalker extends RodWalker { @Input(fullName="variants", shortName = "V", doc="Input VCF file", required=true) public RodBinding variants; diff --git a/public/java/src/org/broadinstitute/sting/gatk/walkers/diffengine/DiffObjectsWalker.java b/public/java/src/org/broadinstitute/sting/gatk/walkers/diffengine/DiffObjectsWalker.java index f43d1342d..5889d19e5 100644 --- a/public/java/src/org/broadinstitute/sting/gatk/walkers/diffengine/DiffObjectsWalker.java +++ b/public/java/src/org/broadinstitute/sting/gatk/walkers/diffengine/DiffObjectsWalker.java @@ -29,7 +29,6 @@ import org.broadinstitute.sting.commandline.Output; import org.broadinstitute.sting.gatk.contexts.AlignmentContext; import org.broadinstitute.sting.gatk.contexts.ReferenceContext; import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker; -import org.broadinstitute.sting.gatk.walkers.Requires; import org.broadinstitute.sting.gatk.walkers.RodWalker; import java.io.File; @@ -131,7 +130,6 @@ import java.util.List; * @author Mark DePristo * @since 7/4/11 */ -@Requires(value={}) public class DiffObjectsWalker extends RodWalker { /** * Writes out a file of the DiffEngine format: diff --git a/public/java/src/org/broadinstitute/sting/gatk/walkers/filters/VariantFiltrationWalker.java b/public/java/src/org/broadinstitute/sting/gatk/walkers/filters/VariantFiltrationWalker.java index e5968692b..8ee1e3a89 100755 --- a/public/java/src/org/broadinstitute/sting/gatk/walkers/filters/VariantFiltrationWalker.java +++ b/public/java/src/org/broadinstitute/sting/gatk/walkers/filters/VariantFiltrationWalker.java @@ -46,7 +46,6 @@ import java.util.*; /** * Filters variant calls using a number of user-selectable, parameterizable criteria. */ -@Requires(value={}) @Reference(window=@Window(start=-50,stop=50)) public class VariantFiltrationWalker extends RodWalker { diff --git a/public/java/src/org/broadinstitute/sting/gatk/walkers/genotyper/UGCalcLikelihoods.java b/public/java/src/org/broadinstitute/sting/gatk/walkers/genotyper/UGCalcLikelihoods.java index 4f78fab36..503d87cbe 100755 --- a/public/java/src/org/broadinstitute/sting/gatk/walkers/genotyper/UGCalcLikelihoods.java +++ b/public/java/src/org/broadinstitute/sting/gatk/walkers/genotyper/UGCalcLikelihoods.java @@ -49,7 +49,6 @@ import java.util.TreeSet; * the name 'allele' so we know which alternate allele to use at each site. */ @BAQMode(QualityMode = BAQ.QualityMode.ADD_TAG, ApplicationTime = BAQ.ApplicationTime.ON_INPUT) -@Requires(value={}) @Reference(window=@Window(start=-200,stop=200)) @By(DataSource.READS) @Downsample(by=DownsampleType.BY_SAMPLE, toCoverage=250) diff --git a/public/java/src/org/broadinstitute/sting/gatk/walkers/variantutils/FilterLiftedVariants.java b/public/java/src/org/broadinstitute/sting/gatk/walkers/variantutils/FilterLiftedVariants.java index 751633f9d..4c2222f3a 100755 --- a/public/java/src/org/broadinstitute/sting/gatk/walkers/variantutils/FilterLiftedVariants.java +++ b/public/java/src/org/broadinstitute/sting/gatk/walkers/variantutils/FilterLiftedVariants.java @@ -24,9 +24,9 @@ package org.broadinstitute.sting.gatk.walkers.variantutils; -import org.broadinstitute.sting.commandline.Input; +import org.broadinstitute.sting.commandline.ArgumentCollection; import org.broadinstitute.sting.commandline.Output; -import org.broadinstitute.sting.commandline.RodBinding; +import org.broadinstitute.sting.gatk.arguments.StandardVariantContextInputArgumentCollection; import org.broadinstitute.sting.gatk.contexts.AlignmentContext; import org.broadinstitute.sting.gatk.contexts.ReferenceContext; import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker; @@ -46,10 +46,10 @@ import java.util.Set; * Filters a lifted-over VCF file for ref bases that have been changed. */ @Reference(window=@Window(start=0,stop=100)) -@Requires(value={}) public class FilterLiftedVariants extends RodWalker { - @Input(fullName="variants", shortName = "V", doc="Input VCF file", required=true) - public RodBinding variants; + + @ArgumentCollection + protected StandardVariantContextInputArgumentCollection variantCollection = new StandardVariantContextInputArgumentCollection(); private static final int MAX_VARIANT_SIZE = 100; @@ -59,10 +59,11 @@ public class FilterLiftedVariants extends RodWalker { private long failedLocs = 0, totalLocs = 0; public void initialize() { - Set samples = SampleUtils.getSampleListWithVCFHeader(getToolkit(), Arrays.asList(variants.getName())); - Map vcfHeaders = VCFUtils.getVCFHeadersFromRods(getToolkit(), Arrays.asList(variants.getName())); + String trackName = variantCollection.variants.getName(); + Set samples = SampleUtils.getSampleListWithVCFHeader(getToolkit(), Arrays.asList(trackName)); + Map vcfHeaders = VCFUtils.getVCFHeadersFromRods(getToolkit(), Arrays.asList(trackName)); - final VCFHeader vcfHeader = new VCFHeader(vcfHeaders.containsKey(variants.getName()) ? vcfHeaders.get(variants.getName()).getMetaData() : null, samples); + final VCFHeader vcfHeader = new VCFHeader(vcfHeaders.containsKey(trackName) ? vcfHeaders.get(trackName).getMetaData() : null, samples); writer.writeHeader(vcfHeader); } @@ -89,7 +90,7 @@ public class FilterLiftedVariants extends RodWalker { if ( tracker == null ) return 0; - Collection VCs = tracker.getValues(variants, context.getLocation()); + Collection VCs = tracker.getValues(variantCollection.variants, context.getLocation()); for ( VariantContext vc : VCs ) filterAndWrite(ref.getBases(), vc); diff --git a/public/java/src/org/broadinstitute/sting/gatk/walkers/variantutils/LeftAlignVariants.java b/public/java/src/org/broadinstitute/sting/gatk/walkers/variantutils/LeftAlignVariants.java index f88810aed..c47a015c6 100755 --- a/public/java/src/org/broadinstitute/sting/gatk/walkers/variantutils/LeftAlignVariants.java +++ b/public/java/src/org/broadinstitute/sting/gatk/walkers/variantutils/LeftAlignVariants.java @@ -48,7 +48,6 @@ import java.util.*; * Left-aligns indels from a variants file. */ @Reference(window=@Window(start=-200,stop=200)) -@Requires(value={}) public class LeftAlignVariants extends RodWalker { @ArgumentCollection diff --git a/public/java/src/org/broadinstitute/sting/gatk/walkers/variantutils/LiftoverVariants.java b/public/java/src/org/broadinstitute/sting/gatk/walkers/variantutils/LiftoverVariants.java index f93fb84e3..1c76a21ea 100755 --- a/public/java/src/org/broadinstitute/sting/gatk/walkers/variantutils/LiftoverVariants.java +++ b/public/java/src/org/broadinstitute/sting/gatk/walkers/variantutils/LiftoverVariants.java @@ -34,7 +34,6 @@ import org.broadinstitute.sting.gatk.arguments.StandardVariantContextInputArgume import org.broadinstitute.sting.gatk.contexts.AlignmentContext; import org.broadinstitute.sting.gatk.contexts.ReferenceContext; import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker; -import org.broadinstitute.sting.gatk.walkers.Requires; import org.broadinstitute.sting.gatk.walkers.RodWalker; import org.broadinstitute.sting.utils.SampleUtils; import org.broadinstitute.sting.utils.codecs.vcf.*; @@ -48,7 +47,6 @@ import java.util.*; /** * Lifts a VCF file over from one build to another. Note that the resulting VCF could be mis-sorted. */ -@Requires(value={}) public class LiftoverVariants extends RodWalker { @ArgumentCollection diff --git a/public/java/src/org/broadinstitute/sting/gatk/walkers/variantutils/RandomlySplitVariants.java b/public/java/src/org/broadinstitute/sting/gatk/walkers/variantutils/RandomlySplitVariants.java index 5f5c9547b..1fefd20fc 100755 --- a/public/java/src/org/broadinstitute/sting/gatk/walkers/variantutils/RandomlySplitVariants.java +++ b/public/java/src/org/broadinstitute/sting/gatk/walkers/variantutils/RandomlySplitVariants.java @@ -24,15 +24,12 @@ package org.broadinstitute.sting.gatk.walkers.variantutils; -import org.broadinstitute.sting.commandline.Argument; -import org.broadinstitute.sting.commandline.Input; -import org.broadinstitute.sting.commandline.Output; -import org.broadinstitute.sting.commandline.RodBinding; +import org.broadinstitute.sting.commandline.*; import org.broadinstitute.sting.gatk.GenomeAnalysisEngine; +import org.broadinstitute.sting.gatk.arguments.StandardVariantContextInputArgumentCollection; import org.broadinstitute.sting.gatk.contexts.AlignmentContext; import org.broadinstitute.sting.gatk.contexts.ReferenceContext; import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker; -import org.broadinstitute.sting.gatk.walkers.Requires; import org.broadinstitute.sting.gatk.walkers.RodWalker; import org.broadinstitute.sting.utils.SampleUtils; import org.broadinstitute.sting.utils.codecs.vcf.*; @@ -45,10 +42,10 @@ import java.util.*; /** * Takes a VCF file, randomly splits variants into two different sets, and outputs 2 new VCFs with the results. */ -@Requires(value={}) public class RandomlySplitVariants extends RodWalker { - @Input(fullName="variants", shortName = "V", doc="Input VCF file", required=true) - public RodBinding variants; + + @ArgumentCollection + protected StandardVariantContextInputArgumentCollection variantCollection = new StandardVariantContextInputArgumentCollection(); @Output(fullName="out1", shortName="o1", doc="File #1 to which variants should be written", required=true) protected VCFWriter vcfWriter1 = null; @@ -72,7 +69,7 @@ public class RandomlySplitVariants extends RodWalker { iFraction = (int)(fraction * 1000.0); // setup the header info - final List inputNames = Arrays.asList(variants.getName()); + final List inputNames = Arrays.asList(variantCollection.variants.getName()); Set samples = SampleUtils.getUniqueSamplesFromRods(getToolkit(), inputNames); Set hInfo = new HashSet(); hInfo.addAll(VCFUtils.getHeaderFields(getToolkit(), inputNames)); @@ -94,7 +91,7 @@ public class RandomlySplitVariants extends RodWalker { if ( tracker == null ) return 0; - Collection vcs = tracker.getValues(variants, context.getLocation()); + Collection vcs = tracker.getValues(variantCollection.variants, context.getLocation()); for ( VariantContext vc : vcs ) { int random = GenomeAnalysisEngine.getRandomGenerator().nextInt(1000); if ( random < iFraction ) diff --git a/public/java/src/org/broadinstitute/sting/gatk/walkers/variantutils/SelectVariants.java b/public/java/src/org/broadinstitute/sting/gatk/walkers/variantutils/SelectVariants.java index e254fe61f..c45ff280b 100755 --- a/public/java/src/org/broadinstitute/sting/gatk/walkers/variantutils/SelectVariants.java +++ b/public/java/src/org/broadinstitute/sting/gatk/walkers/variantutils/SelectVariants.java @@ -38,7 +38,6 @@ import org.broadinstitute.sting.commandline.Output; import org.broadinstitute.sting.gatk.contexts.AlignmentContext; import org.broadinstitute.sting.gatk.contexts.ReferenceContext; import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker; -import org.broadinstitute.sting.gatk.walkers.Requires; import org.broadinstitute.sting.gatk.walkers.RodWalker; import org.broadinstitute.sting.utils.SampleUtils; import org.broadinstitute.sting.utils.variantcontext.Allele; @@ -54,7 +53,6 @@ import java.util.*; * Takes a VCF file, selects variants based on sample(s) in which it was found and/or on various annotation criteria, * recompute the value of certain annotations based on the new sample set, and output a new VCF with the results. */ -@Requires(value={}) public class SelectVariants extends RodWalker { /** * The VCF file we are selecting variants from. diff --git a/public/java/src/org/broadinstitute/sting/gatk/walkers/variantutils/ValidateVariants.java b/public/java/src/org/broadinstitute/sting/gatk/walkers/variantutils/ValidateVariants.java index cc7854f12..c3e7dbe0c 100755 --- a/public/java/src/org/broadinstitute/sting/gatk/walkers/variantutils/ValidateVariants.java +++ b/public/java/src/org/broadinstitute/sting/gatk/walkers/variantutils/ValidateVariants.java @@ -50,7 +50,6 @@ import java.util.Set; * Validates a variants file. */ @Reference(window=@Window(start=0,stop=100)) -@Requires(value={}) public class ValidateVariants extends RodWalker { @ArgumentCollection diff --git a/public/java/src/org/broadinstitute/sting/gatk/walkers/variantutils/VariantValidationAssessor.java b/public/java/src/org/broadinstitute/sting/gatk/walkers/variantutils/VariantValidationAssessor.java index 218f5377e..6ed0bbd16 100644 --- a/public/java/src/org/broadinstitute/sting/gatk/walkers/variantutils/VariantValidationAssessor.java +++ b/public/java/src/org/broadinstitute/sting/gatk/walkers/variantutils/VariantValidationAssessor.java @@ -36,7 +36,6 @@ import org.broadinstitute.sting.gatk.walkers.*; import org.broadinstitute.sting.utils.QualityUtils; import org.broadinstitute.sting.utils.SampleUtils; import org.broadinstitute.sting.utils.codecs.vcf.*; -import org.broadinstitute.sting.utils.collections.Pair; import org.broadinstitute.sting.utils.variantcontext.Allele; import org.broadinstitute.sting.utils.variantcontext.VariantContext; import org.broadinstitute.sting.utils.variantcontext.VariantContextUtils; @@ -47,7 +46,6 @@ import java.util.*; * Converts Sequenom files to a VCF annotated with QC metrics (HW-equilibrium, % failed probes) */ @Reference(window=@Window(start=0,stop=40)) -@Requires(value={}) public class VariantValidationAssessor extends RodWalker { @Input(fullName="variants", shortName = "V", doc="Input VCF file", required=true) public RodBinding variants; diff --git a/public/java/src/org/broadinstitute/sting/gatk/walkers/variantutils/VariantsToTable.java b/public/java/src/org/broadinstitute/sting/gatk/walkers/variantutils/VariantsToTable.java index fa25b0191..af3593ce4 100755 --- a/public/java/src/org/broadinstitute/sting/gatk/walkers/variantutils/VariantsToTable.java +++ b/public/java/src/org/broadinstitute/sting/gatk/walkers/variantutils/VariantsToTable.java @@ -31,7 +31,6 @@ import org.broadinstitute.sting.utils.variantcontext.VariantContext; import org.broadinstitute.sting.gatk.contexts.AlignmentContext; import org.broadinstitute.sting.gatk.contexts.ReferenceContext; import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker; -import org.broadinstitute.sting.gatk.walkers.Requires; import org.broadinstitute.sting.gatk.walkers.RodWalker; import org.broadinstitute.sting.utils.Utils; import org.broadinstitute.sting.utils.exceptions.UserException; @@ -43,7 +42,6 @@ import java.util.*; /** * Emits specific fields as dictated by the user from one or more VCF files. */ -@Requires(value={}) public class VariantsToTable extends RodWalker { @ArgumentCollection diff --git a/public/java/src/org/broadinstitute/sting/gatk/walkers/variantutils/VariantsToVCF.java b/public/java/src/org/broadinstitute/sting/gatk/walkers/variantutils/VariantsToVCF.java index 497d98b99..f9e9562ca 100755 --- a/public/java/src/org/broadinstitute/sting/gatk/walkers/variantutils/VariantsToVCF.java +++ b/public/java/src/org/broadinstitute/sting/gatk/walkers/variantutils/VariantsToVCF.java @@ -56,7 +56,6 @@ import java.util.*; /** * Converts variants from other file formats to VCF format. */ -@Requires(value={}) @Reference(window=@Window(start=-40,stop=40)) public class VariantsToVCF extends RodWalker { diff --git a/public/java/test/org/broadinstitute/sting/gatk/WalkerManagerUnitTest.java b/public/java/test/org/broadinstitute/sting/gatk/WalkerManagerUnitTest.java index cd43927a4..6149a1e51 100644 --- a/public/java/test/org/broadinstitute/sting/gatk/WalkerManagerUnitTest.java +++ b/public/java/test/org/broadinstitute/sting/gatk/WalkerManagerUnitTest.java @@ -26,7 +26,6 @@ package org.broadinstitute.sting.gatk; import org.testng.Assert; import org.broadinstitute.sting.commandline.Hidden; -import org.broadinstitute.sting.gatk.walkers.Requires; import org.broadinstitute.sting.gatk.walkers.Walker; import org.broadinstitute.sting.gatk.walkers.qc.CountLociWalker; import org.broadinstitute.sting.utils.exceptions.DynamicClassResolutionException; @@ -64,7 +63,6 @@ public class WalkerManagerUnitTest { } @Hidden -@Requires(value={}) class UninstantiableWalker extends Walker { // Private constructor will generate uninstantiable message private UninstantiableWalker() {} From 480e7a798476ac577d7e059ab592a38d5298f1d2 Mon Sep 17 00:00:00 2001 From: David Roazen Date: Tue, 9 Aug 2011 16:30:08 -0400 Subject: [PATCH 15/19] Correctly initialize the optional SnpEff rod binding in VariantAnnotator using RodBinding.makeUnbound() --- .../sting/gatk/walkers/annotator/VariantAnnotator.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/VariantAnnotator.java b/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/VariantAnnotator.java index efa40d9a8..54231e9b4 100755 --- a/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/VariantAnnotator.java +++ b/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/VariantAnnotator.java @@ -58,7 +58,7 @@ public class VariantAnnotator extends RodWalker { @ArgumentCollection protected StandardVariantContextInputArgumentCollection variantCollection = new StandardVariantContextInputArgumentCollection(); @Input(fullName="snpEffFile", shortName = "snpEffFile", doc="SnpEff file", required=false) - public RodBinding snpEffFile; + public RodBinding snpEffFile = RodBinding.makeUnbound(SnpEffFeature.class); /** * A dbSNP VCF file from which to annotate. From 577f861f69779361e8b2248e8fa3f37bf26ac897 Mon Sep 17 00:00:00 2001 From: David Roazen Date: Wed, 10 Aug 2011 11:39:41 -0400 Subject: [PATCH 16/19] Pass the rodBindings into the VariantAnnotator engine, and from there to the annotation classes themselves. --- .../gatk/walkers/annotator/AlleleBalance.java | 4 +++- .../annotator/AlleleBalanceBySample.java | 4 +++- .../gatk/walkers/annotator/BaseCounts.java | 4 +++- .../walkers/annotator/ChromosomeCounts.java | 4 +++- .../walkers/annotator/DepthOfCoverage.java | 4 +++- .../annotator/DepthPerAlleleBySample.java | 4 +++- .../gatk/walkers/annotator/FisherStrand.java | 4 +++- .../gatk/walkers/annotator/GCContent.java | 4 +++- .../sting/gatk/walkers/annotator/GLstats.java | 4 +++- .../walkers/annotator/HaplotypeScore.java | 4 +++- .../gatk/walkers/annotator/HardyWeinberg.java | 4 +++- .../walkers/annotator/HomopolymerRun.java | 4 +++- .../gatk/walkers/annotator/IndelType.java | 4 +++- .../sting/gatk/walkers/annotator/LowMQ.java | 4 +++- .../walkers/annotator/MappingQualityZero.java | 4 +++- .../annotator/MappingQualityZeroBySample.java | 6 +++-- .../annotator/MappingQualityZeroFraction.java | 4 +++- .../gatk/walkers/annotator/NBaseCount.java | 4 +++- .../gatk/walkers/annotator/QualByDepth.java | 4 +++- .../walkers/annotator/RMSMappingQuality.java | 4 +++- .../gatk/walkers/annotator/RankSumTest.java | 4 +++- .../ReadDepthAndAllelicFractionBySample.java | 4 +++- .../gatk/walkers/annotator/SBByDepth.java | 4 +++- .../gatk/walkers/annotator/SampleList.java | 4 +++- .../sting/gatk/walkers/annotator/SnpEff.java | 22 +++++++++---------- .../walkers/annotator/SpanningDeletions.java | 4 +++- .../annotator/TechnologyComposition.java | 4 +++- .../walkers/annotator/VariantAnnotator.java | 22 +++++++++++++++++-- .../annotator/VariantAnnotatorEngine.java | 13 ++++++----- .../interfaces/GenotypeAnnotation.java | 5 ++++- .../interfaces/InfoFieldAnnotation.java | 7 +++--- .../walkers/genotyper/UnifiedGenotyper.java | 5 ++++- 32 files changed, 130 insertions(+), 50 deletions(-) diff --git a/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/AlleleBalance.java b/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/AlleleBalance.java index 784927ab4..219ccbc0c 100755 --- a/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/AlleleBalance.java +++ b/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/AlleleBalance.java @@ -25,6 +25,8 @@ package org.broadinstitute.sting.gatk.walkers.annotator; +import org.broad.tribble.Feature; +import org.broadinstitute.sting.commandline.RodBinding; import org.broadinstitute.sting.gatk.contexts.AlignmentContext; import org.broadinstitute.sting.gatk.contexts.ReferenceContext; import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker; @@ -44,7 +46,7 @@ import java.util.Map; public class AlleleBalance extends InfoFieldAnnotation { - public Map annotate(RefMetaDataTracker tracker, ReferenceContext ref, Map stratifiedContexts, VariantContext vc) { + public Map annotate(RefMetaDataTracker tracker, Map> rodBindings, ReferenceContext ref, Map stratifiedContexts, VariantContext vc) { if ( stratifiedContexts.size() == 0 ) return null; diff --git a/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/AlleleBalanceBySample.java b/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/AlleleBalanceBySample.java index f70a87dc5..df9890d64 100755 --- a/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/AlleleBalanceBySample.java +++ b/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/AlleleBalanceBySample.java @@ -1,5 +1,7 @@ package org.broadinstitute.sting.gatk.walkers.annotator; +import org.broad.tribble.Feature; +import org.broadinstitute.sting.commandline.RodBinding; import org.broadinstitute.sting.gatk.contexts.AlignmentContext; import org.broadinstitute.sting.gatk.contexts.ReferenceContext; import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker; @@ -17,7 +19,7 @@ import java.util.*; public class AlleleBalanceBySample extends GenotypeAnnotation implements ExperimentalAnnotation { - public Map annotate(RefMetaDataTracker tracker, ReferenceContext ref, AlignmentContext stratifiedContext, VariantContext vc, Genotype g) { + public Map annotate(RefMetaDataTracker tracker, Map> rodBindings, ReferenceContext ref, AlignmentContext stratifiedContext, VariantContext vc, Genotype g) { Double ratio = annotateSNP(stratifiedContext, vc, g); if (ratio == null) return null; diff --git a/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/BaseCounts.java b/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/BaseCounts.java index 7cd159c5d..76daaa06b 100755 --- a/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/BaseCounts.java +++ b/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/BaseCounts.java @@ -31,6 +31,8 @@ package org.broadinstitute.sting.gatk.walkers.annotator; +import org.broad.tribble.Feature; +import org.broadinstitute.sting.commandline.RodBinding; import org.broadinstitute.sting.gatk.contexts.AlignmentContext; import org.broadinstitute.sting.gatk.contexts.ReferenceContext; import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker; @@ -48,7 +50,7 @@ import java.util.Map; public class BaseCounts extends InfoFieldAnnotation { - public Map annotate(RefMetaDataTracker tracker, ReferenceContext ref, Map stratifiedContexts, VariantContext vc) { + public Map annotate(RefMetaDataTracker tracker, Map> rodBindings, ReferenceContext ref, Map stratifiedContexts, VariantContext vc) { if ( stratifiedContexts.size() == 0 ) return null; diff --git a/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/ChromosomeCounts.java b/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/ChromosomeCounts.java index 9b30079d0..b2a3e6a26 100755 --- a/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/ChromosomeCounts.java +++ b/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/ChromosomeCounts.java @@ -25,6 +25,8 @@ package org.broadinstitute.sting.gatk.walkers.annotator; +import org.broad.tribble.Feature; +import org.broadinstitute.sting.commandline.RodBinding; import org.broadinstitute.sting.gatk.contexts.AlignmentContext; import org.broadinstitute.sting.gatk.contexts.ReferenceContext; import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker; @@ -50,7 +52,7 @@ public class ChromosomeCounts extends InfoFieldAnnotation implements StandardAnn new VCFInfoHeaderLine(VCFConstants.ALLELE_COUNT_KEY, VCFHeaderLineCount.A, VCFHeaderLineType.Integer, "Allele count in genotypes, for each ALT allele, in the same order as listed"), new VCFInfoHeaderLine(VCFConstants.ALLELE_NUMBER_KEY, 1, VCFHeaderLineType.Integer, "Total number of alleles in called genotypes") }; - public Map annotate(RefMetaDataTracker tracker, ReferenceContext ref, Map stratifiedContexts, VariantContext vc) { + public Map annotate(RefMetaDataTracker tracker, Map> rodBindings, ReferenceContext ref, Map stratifiedContexts, VariantContext vc) { if ( ! vc.hasGenotypes() ) return null; diff --git a/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/DepthOfCoverage.java b/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/DepthOfCoverage.java index d8907c57f..f2abbc5b8 100755 --- a/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/DepthOfCoverage.java +++ b/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/DepthOfCoverage.java @@ -1,5 +1,7 @@ package org.broadinstitute.sting.gatk.walkers.annotator; +import org.broad.tribble.Feature; +import org.broadinstitute.sting.commandline.RodBinding; import org.broadinstitute.sting.gatk.contexts.AlignmentContext; import org.broadinstitute.sting.gatk.contexts.ReferenceContext; import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker; @@ -18,7 +20,7 @@ import java.util.Map; public class DepthOfCoverage extends InfoFieldAnnotation implements StandardAnnotation { - public Map annotate(RefMetaDataTracker tracker, ReferenceContext ref, Map stratifiedContexts, VariantContext vc) { + public Map annotate(RefMetaDataTracker tracker, Map> rodBindings, ReferenceContext ref, Map stratifiedContexts, VariantContext vc) { if ( stratifiedContexts.size() == 0 ) return null; diff --git a/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/DepthPerAlleleBySample.java b/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/DepthPerAlleleBySample.java index 20513421d..958075a92 100755 --- a/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/DepthPerAlleleBySample.java +++ b/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/DepthPerAlleleBySample.java @@ -1,5 +1,7 @@ package org.broadinstitute.sting.gatk.walkers.annotator; +import org.broad.tribble.Feature; +import org.broadinstitute.sting.commandline.RodBinding; import org.broadinstitute.sting.gatk.contexts.AlignmentContext; import org.broadinstitute.sting.gatk.contexts.ReferenceContext; import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker; @@ -28,7 +30,7 @@ public class DepthPerAlleleBySample extends GenotypeAnnotation implements Standa private static String DEL = "DEL"; // constant, for speed: no need to create a key string for deletion allele every time - public Map annotate(RefMetaDataTracker tracker, ReferenceContext ref, AlignmentContext stratifiedContext, VariantContext vc, Genotype g) { + public Map annotate(RefMetaDataTracker tracker, Map> rodBindings, ReferenceContext ref, AlignmentContext stratifiedContext, VariantContext vc, Genotype g) { if ( g == null || !g.isCalled() ) return null; diff --git a/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/FisherStrand.java b/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/FisherStrand.java index e71febece..0ad643a4e 100755 --- a/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/FisherStrand.java +++ b/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/FisherStrand.java @@ -25,6 +25,8 @@ package org.broadinstitute.sting.gatk.walkers.annotator; import cern.jet.math.Arithmetic; +import org.broad.tribble.Feature; +import org.broadinstitute.sting.commandline.RodBinding; import org.broadinstitute.sting.gatk.contexts.AlignmentContext; import org.broadinstitute.sting.gatk.contexts.ReferenceContext; import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker; @@ -46,7 +48,7 @@ public class FisherStrand extends InfoFieldAnnotation implements StandardAnnotat private static final String FS = "FS"; private static final double MIN_PVALUE = 1E-320; - public Map annotate(RefMetaDataTracker tracker, ReferenceContext ref, Map stratifiedContexts, VariantContext vc) { + public Map annotate(RefMetaDataTracker tracker, Map> rodBindings, ReferenceContext ref, Map stratifiedContexts, VariantContext vc) { if ( ! vc.isVariant() || vc.isFiltered() ) return null; diff --git a/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/GCContent.java b/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/GCContent.java index 588d3e98a..f8e422e23 100755 --- a/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/GCContent.java +++ b/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/GCContent.java @@ -1,5 +1,7 @@ package org.broadinstitute.sting.gatk.walkers.annotator; +import org.broad.tribble.Feature; +import org.broadinstitute.sting.commandline.RodBinding; import org.broadinstitute.sting.gatk.contexts.AlignmentContext; import org.broadinstitute.sting.gatk.contexts.ReferenceContext; import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker; @@ -18,7 +20,7 @@ import java.util.Map; public class GCContent extends InfoFieldAnnotation implements ExperimentalAnnotation { - public Map annotate(RefMetaDataTracker tracker, ReferenceContext ref, Map stratifiedContexts, VariantContext vc) { + public Map annotate(RefMetaDataTracker tracker, Map> rodBindings, ReferenceContext ref, Map stratifiedContexts, VariantContext vc) { double content = computeGCContent(ref); Map map = new HashMap(); map.put(getKeyNames().get(0), String.format("%.2f", content)); diff --git a/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/GLstats.java b/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/GLstats.java index 862e12f7d..8fde3a20f 100755 --- a/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/GLstats.java +++ b/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/GLstats.java @@ -1,5 +1,7 @@ package org.broadinstitute.sting.gatk.walkers.annotator; +import org.broad.tribble.Feature; +import org.broadinstitute.sting.commandline.RodBinding; import org.broadinstitute.sting.gatk.contexts.AlignmentContext; import org.broadinstitute.sting.gatk.contexts.ReferenceContext; import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker; @@ -27,7 +29,7 @@ public class GLstats extends InfoFieldAnnotation implements StandardAnnotation { private static final int MIN_SAMPLES = 10; - public Map annotate(RefMetaDataTracker tracker, ReferenceContext ref, Map stratifiedContexts, VariantContext vc) { + public Map annotate(RefMetaDataTracker tracker, Map> rodBindings, ReferenceContext ref, Map stratifiedContexts, VariantContext vc) { final Map genotypes = vc.getGenotypes(); if ( genotypes == null || genotypes.size() < MIN_SAMPLES ) diff --git a/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/HaplotypeScore.java b/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/HaplotypeScore.java index 2196de389..24571aee1 100644 --- a/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/HaplotypeScore.java +++ b/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/HaplotypeScore.java @@ -25,6 +25,8 @@ package org.broadinstitute.sting.gatk.walkers.annotator; import net.sf.samtools.SAMRecord; +import org.broad.tribble.Feature; +import org.broadinstitute.sting.commandline.RodBinding; import org.broadinstitute.sting.gatk.contexts.AlignmentContext; import org.broadinstitute.sting.gatk.contexts.AlignmentContextUtils; import org.broadinstitute.sting.gatk.contexts.ReferenceContext; @@ -54,7 +56,7 @@ public class HaplotypeScore extends InfoFieldAnnotation implements StandardAnnot private final static int MAX_CONSENSUS_HAPLOTYPES_TO_CONSIDER = 50; private final static char REGEXP_WILDCARD = '.'; - public Map annotate(RefMetaDataTracker tracker, ReferenceContext ref, Map stratifiedContexts, VariantContext vc) { + public Map annotate(RefMetaDataTracker tracker, Map> rodBindings, ReferenceContext ref, Map stratifiedContexts, VariantContext vc) { if (stratifiedContexts.size() == 0 ) // size 0 means that call was made by someone else and we have no data here return null; diff --git a/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/HardyWeinberg.java b/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/HardyWeinberg.java index 2d9424e98..292a6c5e5 100755 --- a/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/HardyWeinberg.java +++ b/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/HardyWeinberg.java @@ -1,6 +1,8 @@ package org.broadinstitute.sting.gatk.walkers.annotator; +import org.broad.tribble.Feature; import org.broad.tribble.util.popgen.HardyWeinbergCalculation; +import org.broadinstitute.sting.commandline.RodBinding; import org.broadinstitute.sting.gatk.contexts.AlignmentContext; import org.broadinstitute.sting.gatk.contexts.ReferenceContext; import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker; @@ -24,7 +26,7 @@ public class HardyWeinberg extends InfoFieldAnnotation implements WorkInProgress private static final int MIN_GENOTYPE_QUALITY = 10; private static final int MIN_NEG_LOG10_PERROR = MIN_GENOTYPE_QUALITY / 10; - public Map annotate(RefMetaDataTracker tracker, ReferenceContext ref, Map stratifiedContexts, VariantContext vc) { + public Map annotate(RefMetaDataTracker tracker, Map> rodBindings, ReferenceContext ref, Map stratifiedContexts, VariantContext vc) { final Map genotypes = vc.getGenotypes(); if ( genotypes == null || genotypes.size() < MIN_SAMPLES ) diff --git a/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/HomopolymerRun.java b/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/HomopolymerRun.java index 870e9992b..97ac3ab6d 100755 --- a/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/HomopolymerRun.java +++ b/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/HomopolymerRun.java @@ -1,5 +1,7 @@ package org.broadinstitute.sting.gatk.walkers.annotator; +import org.broad.tribble.Feature; +import org.broadinstitute.sting.commandline.RodBinding; import org.broadinstitute.sting.gatk.contexts.AlignmentContext; import org.broadinstitute.sting.gatk.contexts.ReferenceContext; import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker; @@ -20,7 +22,7 @@ public class HomopolymerRun extends InfoFieldAnnotation implements StandardAnnot private boolean ANNOTATE_INDELS = true; - public Map annotate(RefMetaDataTracker tracker, ReferenceContext ref, Map stratifiedContexts, VariantContext vc) { + public Map annotate(RefMetaDataTracker tracker, Map> rodBindings, ReferenceContext ref, Map stratifiedContexts, VariantContext vc) { if ( !vc.isBiallelic() ) return null; diff --git a/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/IndelType.java b/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/IndelType.java index b1c16ba0d..7308f7f25 100755 --- a/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/IndelType.java +++ b/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/IndelType.java @@ -1,5 +1,7 @@ package org.broadinstitute.sting.gatk.walkers.annotator; +import org.broad.tribble.Feature; +import org.broadinstitute.sting.commandline.RodBinding; import org.broadinstitute.sting.gatk.contexts.AlignmentContext; import org.broadinstitute.sting.gatk.contexts.ReferenceContext; import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker; @@ -21,7 +23,7 @@ import java.util.*; */ public class IndelType extends InfoFieldAnnotation implements ExperimentalAnnotation { - public Map annotate(RefMetaDataTracker tracker, ReferenceContext ref, Map stratifiedContexts, VariantContext vc) { + public Map annotate(RefMetaDataTracker tracker, Map> rodBindings, ReferenceContext ref, Map stratifiedContexts, VariantContext vc) { int run; if (vc.isMixed()) { diff --git a/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/LowMQ.java b/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/LowMQ.java index 5de9aaa3b..492578839 100755 --- a/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/LowMQ.java +++ b/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/LowMQ.java @@ -1,5 +1,7 @@ package org.broadinstitute.sting.gatk.walkers.annotator; +import org.broad.tribble.Feature; +import org.broadinstitute.sting.commandline.RodBinding; import org.broadinstitute.sting.gatk.contexts.AlignmentContext; import org.broadinstitute.sting.gatk.contexts.ReferenceContext; import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker; @@ -18,7 +20,7 @@ import java.util.Map; public class LowMQ extends InfoFieldAnnotation { - public Map annotate(RefMetaDataTracker tracker, ReferenceContext ref, Map stratifiedContexts, VariantContext vc) { + public Map annotate(RefMetaDataTracker tracker, Map> rodBindings, ReferenceContext ref, Map stratifiedContexts, VariantContext vc) { if ( stratifiedContexts.size() == 0 ) return null; diff --git a/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/MappingQualityZero.java b/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/MappingQualityZero.java index 60bfe945f..2c5314822 100755 --- a/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/MappingQualityZero.java +++ b/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/MappingQualityZero.java @@ -1,5 +1,7 @@ package org.broadinstitute.sting.gatk.walkers.annotator; +import org.broad.tribble.Feature; +import org.broadinstitute.sting.commandline.RodBinding; import org.broadinstitute.sting.gatk.contexts.AlignmentContext; import org.broadinstitute.sting.gatk.contexts.ReferenceContext; import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker; @@ -20,7 +22,7 @@ import java.util.Map; public class MappingQualityZero extends InfoFieldAnnotation implements StandardAnnotation { - public Map annotate(RefMetaDataTracker tracker, ReferenceContext ref, Map stratifiedContexts, VariantContext vc) { + public Map annotate(RefMetaDataTracker tracker, Map> rodBindings, ReferenceContext ref, Map stratifiedContexts, VariantContext vc) { if ( stratifiedContexts.size() == 0 ) return null; diff --git a/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/MappingQualityZeroBySample.java b/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/MappingQualityZeroBySample.java index f2b7b72b9..f4d80f554 100644 --- a/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/MappingQualityZeroBySample.java +++ b/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/MappingQualityZeroBySample.java @@ -25,6 +25,8 @@ package org.broadinstitute.sting.gatk.walkers.annotator; +import org.broad.tribble.Feature; +import org.broadinstitute.sting.commandline.RodBinding; import org.broadinstitute.sting.gatk.contexts.AlignmentContext; import org.broadinstitute.sting.gatk.contexts.ReferenceContext; import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker; @@ -50,8 +52,8 @@ import java.util.Map; * To change this template use File | Settings | File Templates. */ public class MappingQualityZeroBySample extends GenotypeAnnotation { - public Map annotate(RefMetaDataTracker tracker, ReferenceContext ref, - AlignmentContext context, VariantContext vc, Genotype g) { + public Map annotate(RefMetaDataTracker tracker, Map> rodBindings, + ReferenceContext ref, AlignmentContext context, VariantContext vc, Genotype g) { if ( g == null || !g.isCalled() ) return null; diff --git a/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/MappingQualityZeroFraction.java b/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/MappingQualityZeroFraction.java index 3a6c9dce9..2b8296778 100755 --- a/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/MappingQualityZeroFraction.java +++ b/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/MappingQualityZeroFraction.java @@ -1,5 +1,7 @@ package org.broadinstitute.sting.gatk.walkers.annotator; +import org.broad.tribble.Feature; +import org.broadinstitute.sting.commandline.RodBinding; import org.broadinstitute.sting.gatk.contexts.AlignmentContext; import org.broadinstitute.sting.gatk.contexts.ReferenceContext; import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker; @@ -20,7 +22,7 @@ import java.util.Map; public class MappingQualityZeroFraction extends InfoFieldAnnotation implements ExperimentalAnnotation { - public Map annotate(RefMetaDataTracker tracker, ReferenceContext ref, Map stratifiedContexts, VariantContext vc) { + public Map annotate(RefMetaDataTracker tracker, Map> rodBindings, ReferenceContext ref, Map stratifiedContexts, VariantContext vc) { if ( stratifiedContexts.size() == 0 ) return null; diff --git a/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/NBaseCount.java b/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/NBaseCount.java index 9f67acf65..3ce01bc2a 100755 --- a/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/NBaseCount.java +++ b/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/NBaseCount.java @@ -1,5 +1,7 @@ package org.broadinstitute.sting.gatk.walkers.annotator; +import org.broad.tribble.Feature; +import org.broadinstitute.sting.commandline.RodBinding; import org.broadinstitute.sting.gatk.contexts.AlignmentContext; import org.broadinstitute.sting.gatk.contexts.ReferenceContext; import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker; @@ -22,7 +24,7 @@ import java.util.Map; */ public class NBaseCount extends InfoFieldAnnotation { - public Map annotate(RefMetaDataTracker tracker, ReferenceContext ref, Map stratifiedContexts, VariantContext vc) { + public Map annotate(RefMetaDataTracker tracker, Map> rodBindings, ReferenceContext ref, Map stratifiedContexts, VariantContext vc) { if( stratifiedContexts.size() == 0 ) return null; diff --git a/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/QualByDepth.java b/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/QualByDepth.java index 20bee9008..7b97a9c38 100755 --- a/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/QualByDepth.java +++ b/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/QualByDepth.java @@ -1,5 +1,7 @@ package org.broadinstitute.sting.gatk.walkers.annotator; +import org.broad.tribble.Feature; +import org.broadinstitute.sting.commandline.RodBinding; import org.broadinstitute.sting.gatk.contexts.AlignmentContext; import org.broadinstitute.sting.gatk.contexts.ReferenceContext; import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker; @@ -18,7 +20,7 @@ import java.util.Map; public class QualByDepth extends AnnotationByDepth implements StandardAnnotation { - public Map annotate(RefMetaDataTracker tracker, ReferenceContext ref, Map stratifiedContexts, VariantContext vc) { + public Map annotate(RefMetaDataTracker tracker, Map> rodBindings, ReferenceContext ref, Map stratifiedContexts, VariantContext vc) { if ( stratifiedContexts.size() == 0 ) return null; diff --git a/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/RMSMappingQuality.java b/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/RMSMappingQuality.java index d1d9871e7..38345a1c4 100755 --- a/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/RMSMappingQuality.java +++ b/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/RMSMappingQuality.java @@ -1,5 +1,7 @@ package org.broadinstitute.sting.gatk.walkers.annotator; +import org.broad.tribble.Feature; +import org.broadinstitute.sting.commandline.RodBinding; import org.broadinstitute.sting.gatk.contexts.AlignmentContext; import org.broadinstitute.sting.gatk.contexts.ReferenceContext; import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker; @@ -22,7 +24,7 @@ import java.util.Map; public class RMSMappingQuality extends InfoFieldAnnotation implements StandardAnnotation { - public Map annotate(RefMetaDataTracker tracker, ReferenceContext ref, Map stratifiedContexts, VariantContext vc) { + public Map annotate(RefMetaDataTracker tracker, Map> rodBindings, ReferenceContext ref, Map stratifiedContexts, VariantContext vc) { if ( stratifiedContexts.size() == 0 ) return null; diff --git a/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/RankSumTest.java b/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/RankSumTest.java index 643056c1d..cad10c77d 100644 --- a/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/RankSumTest.java +++ b/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/RankSumTest.java @@ -1,5 +1,7 @@ package org.broadinstitute.sting.gatk.walkers.annotator; +import org.broad.tribble.Feature; +import org.broadinstitute.sting.commandline.RodBinding; import org.broadinstitute.sting.gatk.contexts.AlignmentContext; import org.broadinstitute.sting.gatk.contexts.ReferenceContext; import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker; @@ -25,7 +27,7 @@ public abstract class RankSumTest extends InfoFieldAnnotation implements Standar static final double INDEL_LIKELIHOOD_THRESH = 0.1; static final boolean DEBUG = false; - public Map annotate(RefMetaDataTracker tracker, ReferenceContext ref, Map stratifiedContexts, VariantContext vc) { + public Map annotate(RefMetaDataTracker tracker, Map> rodBindings, ReferenceContext ref, Map stratifiedContexts, VariantContext vc) { if ( stratifiedContexts.size() == 0 ) return null; diff --git a/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/ReadDepthAndAllelicFractionBySample.java b/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/ReadDepthAndAllelicFractionBySample.java index f3e99235a..68cc86478 100644 --- a/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/ReadDepthAndAllelicFractionBySample.java +++ b/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/ReadDepthAndAllelicFractionBySample.java @@ -25,6 +25,8 @@ package org.broadinstitute.sting.gatk.walkers.annotator; +import org.broad.tribble.Feature; +import org.broadinstitute.sting.commandline.RodBinding; import org.broadinstitute.sting.gatk.contexts.AlignmentContext; import org.broadinstitute.sting.gatk.contexts.ReferenceContext; import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker; @@ -58,7 +60,7 @@ public class ReadDepthAndAllelicFractionBySample extends GenotypeAnnotation { private static String DEL = "DEL"; // constant, for speed: no need to create a key string for deletion allele every time - public Map annotate(RefMetaDataTracker tracker, ReferenceContext ref, + public Map annotate(RefMetaDataTracker tracker, Map> rodBindings, ReferenceContext ref, AlignmentContext stratifiedContext, VariantContext vc, Genotype g) { if ( g == null || !g.isCalled() ) return null; diff --git a/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/SBByDepth.java b/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/SBByDepth.java index a5ebd8db2..662b5cdce 100755 --- a/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/SBByDepth.java +++ b/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/SBByDepth.java @@ -1,5 +1,7 @@ package org.broadinstitute.sting.gatk.walkers.annotator; +import org.broad.tribble.Feature; +import org.broadinstitute.sting.commandline.RodBinding; import org.broadinstitute.sting.gatk.contexts.AlignmentContext; import org.broadinstitute.sting.gatk.contexts.ReferenceContext; import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker; @@ -18,7 +20,7 @@ import java.util.Map; public class SBByDepth extends AnnotationByDepth { - public Map annotate(RefMetaDataTracker tracker, ReferenceContext ref, Map stratifiedContexts, VariantContext vc) { + public Map annotate(RefMetaDataTracker tracker, Map> rodBindings, ReferenceContext ref, Map stratifiedContexts, VariantContext vc) { if ( stratifiedContexts.size() == 0 ) return null; diff --git a/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/SampleList.java b/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/SampleList.java index 3712ca8ae..0977a041f 100755 --- a/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/SampleList.java +++ b/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/SampleList.java @@ -25,6 +25,8 @@ package org.broadinstitute.sting.gatk.walkers.annotator; +import org.broad.tribble.Feature; +import org.broadinstitute.sting.commandline.RodBinding; import org.broadinstitute.sting.gatk.contexts.AlignmentContext; import org.broadinstitute.sting.gatk.contexts.ReferenceContext; import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker; @@ -43,7 +45,7 @@ import java.util.Map; public class SampleList extends InfoFieldAnnotation { - public Map annotate(RefMetaDataTracker tracker, ReferenceContext ref, Map stratifiedContexts, VariantContext vc) { + public Map annotate(RefMetaDataTracker tracker, Map> rodBindings, ReferenceContext ref, Map stratifiedContexts, VariantContext vc) { if ( vc.isMonomorphic() || !vc.hasGenotypes() ) return null; diff --git a/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/SnpEff.java b/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/SnpEff.java index cac59c8bb..26a9b2edd 100644 --- a/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/SnpEff.java +++ b/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/SnpEff.java @@ -25,6 +25,7 @@ package org.broadinstitute.sting.gatk.walkers.annotator; import org.broad.tribble.Feature; +import org.broadinstitute.sting.commandline.RodBinding; import org.broadinstitute.sting.gatk.contexts.AlignmentContext; import org.broadinstitute.sting.gatk.contexts.ReferenceContext; import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker; @@ -69,8 +70,11 @@ public class SnpEff extends InfoFieldAnnotation implements ExperimentalAnnotatio public static final String CODON_NUM_KEY = "CODON_NUM"; public static final String CDS_SIZE_KEY = "CDS_SIZE"; - public Map annotate ( RefMetaDataTracker tracker, ReferenceContext ref, Map stratifiedContexts, VariantContext vc ) { - List features = tracker.getValues(Feature.class); + public static final String SNPEFF_ROD_NAME = "snpEffFile"; + + public Map annotate ( RefMetaDataTracker tracker, Map> rodBindings, ReferenceContext ref, Map stratifiedContexts, VariantContext vc ) { + RodBinding snpEffRodBinding = (RodBinding)rodBindings.get(SNPEFF_ROD_NAME); + List features = tracker.getValues(snpEffRodBinding); // Add only annotations for one of the most biologically-significant effects as defined in // the SnpEffConstants class: @@ -83,18 +87,14 @@ public class SnpEff extends InfoFieldAnnotation implements ExperimentalAnnotatio return generateAnnotations(mostSignificantEffect); } - private SnpEffFeature getMostSignificantEffect ( List features ) { + private SnpEffFeature getMostSignificantEffect ( List snpEffFeatures ) { SnpEffFeature mostSignificantEffect = null; - for ( Feature feature : features ) { - if ( feature instanceof SnpEffFeature ) { - SnpEffFeature snpEffFeature = (SnpEffFeature)feature; + for ( SnpEffFeature snpEffFeature : snpEffFeatures ) { + if ( mostSignificantEffect == null || + snpEffFeature.isHigherImpactThan(mostSignificantEffect) ) { - if ( mostSignificantEffect == null || - snpEffFeature.isHigherImpactThan(mostSignificantEffect) ) { - - mostSignificantEffect = snpEffFeature; - } + mostSignificantEffect = snpEffFeature; } } diff --git a/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/SpanningDeletions.java b/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/SpanningDeletions.java index 332b0226b..c11634c94 100755 --- a/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/SpanningDeletions.java +++ b/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/SpanningDeletions.java @@ -1,5 +1,7 @@ package org.broadinstitute.sting.gatk.walkers.annotator; +import org.broad.tribble.Feature; +import org.broadinstitute.sting.commandline.RodBinding; import org.broadinstitute.sting.gatk.contexts.AlignmentContext; import org.broadinstitute.sting.gatk.contexts.ReferenceContext; import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker; @@ -18,7 +20,7 @@ import java.util.Map; public class SpanningDeletions extends InfoFieldAnnotation implements StandardAnnotation { - public Map annotate(RefMetaDataTracker tracker, ReferenceContext ref, Map stratifiedContexts, VariantContext vc) { + public Map annotate(RefMetaDataTracker tracker, Map> rodBindings, ReferenceContext ref, Map stratifiedContexts, VariantContext vc) { if ( stratifiedContexts.size() == 0 ) return null; diff --git a/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/TechnologyComposition.java b/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/TechnologyComposition.java index 626142cd2..12e7259a9 100755 --- a/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/TechnologyComposition.java +++ b/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/TechnologyComposition.java @@ -1,5 +1,7 @@ package org.broadinstitute.sting.gatk.walkers.annotator; +import org.broad.tribble.Feature; +import org.broadinstitute.sting.commandline.RodBinding; import org.broadinstitute.sting.gatk.contexts.AlignmentContext; import org.broadinstitute.sting.gatk.contexts.ReferenceContext; import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker; @@ -29,7 +31,7 @@ public class TechnologyComposition extends InfoFieldAnnotation implements Experi private String n454 ="Num454"; private String nSolid = "NumSOLiD"; private String nOther = "NumOther"; - public Map annotate(RefMetaDataTracker tracker, ReferenceContext ref, Map stratifiedContexts, VariantContext vc) { + public Map annotate(RefMetaDataTracker tracker, Map> rodBindings, ReferenceContext ref, Map stratifiedContexts, VariantContext vc) { if ( stratifiedContexts.size() == 0 ) return null; diff --git a/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/VariantAnnotator.java b/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/VariantAnnotator.java index 54231e9b4..a72c483e3 100755 --- a/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/VariantAnnotator.java +++ b/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/VariantAnnotator.java @@ -25,6 +25,7 @@ package org.broadinstitute.sting.gatk.walkers.annotator; +import org.broad.tribble.Feature; import org.broadinstitute.sting.commandline.*; import org.broadinstitute.sting.gatk.arguments.DbsnpArgumentCollection; import org.broadinstitute.sting.gatk.arguments.StandardVariantContextInputArgumentCollection; @@ -57,6 +58,12 @@ public class VariantAnnotator extends RodWalker { @ArgumentCollection protected StandardVariantContextInputArgumentCollection variantCollection = new StandardVariantContextInputArgumentCollection(); + /** + * A SnpEff output file from which to add annotations. + * + * The INFO field will be annotated with information on the most biologically-significant effect + * listed in the SnpEff output file for each variant. + */ @Input(fullName="snpEffFile", shortName = "snpEffFile", doc="SnpEff file", required=false) public RodBinding snpEffFile = RodBinding.makeUnbound(SnpEffFeature.class); @@ -112,6 +119,8 @@ public class VariantAnnotator extends RodWalker { private Collection indelBufferContext; + private Map> rodBindings = new HashMap>(); + private void listAnnotationsAndExit() { List> infoAnnotationClasses = new PluginManager(InfoFieldAnnotation.class).getPlugins(); @@ -154,10 +163,12 @@ public class VariantAnnotator extends RodWalker { logger.warn("There are no samples input at all; use the --sampleName argument to specify one if desired."); } + initializeRodBindingMap(); + if ( USE_ALL_ANNOTATIONS ) - engine = new VariantAnnotatorEngine(getToolkit()); + engine = new VariantAnnotatorEngine(getToolkit(), rodBindings); else - engine = new VariantAnnotatorEngine(getToolkit(), annotationGroupsToUse, annotationsToUse); + engine = new VariantAnnotatorEngine(getToolkit(), annotationGroupsToUse, annotationsToUse, rodBindings); engine.initializeExpressions(expressionsToUse); // setup the header fields @@ -177,6 +188,13 @@ public class VariantAnnotator extends RodWalker { } } + private void initializeRodBindingMap() { + rodBindings.put(variantCollection.variants.getName(), variantCollection.variants); + rodBindings.put(snpEffFile.getName(), snpEffFile); + rodBindings.put(dbsnp.dbsnp.getName(), dbsnp.dbsnp); + rodBindings.put(comps.getName(), comps); + } + public static boolean isUniqueHeaderLine(VCFHeaderLine line, Set currentSet) { if ( !(line instanceof VCFCompoundHeaderLine) ) return true; diff --git a/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/VariantAnnotatorEngine.java b/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/VariantAnnotatorEngine.java index 78207cb86..cae9ab00c 100755 --- a/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/VariantAnnotatorEngine.java +++ b/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/VariantAnnotatorEngine.java @@ -26,6 +26,7 @@ package org.broadinstitute.sting.gatk.walkers.annotator; import org.broad.tribble.Feature; +import org.broadinstitute.sting.commandline.RodBinding; import org.broadinstitute.sting.gatk.GenomeAnalysisEngine; import org.broadinstitute.sting.gatk.contexts.AlignmentContext; import org.broadinstitute.sting.gatk.contexts.ReferenceContext; @@ -55,7 +56,7 @@ public class VariantAnnotatorEngine { private List requestedExpressions = new ArrayList(); private HashMap dbAnnotations = new HashMap(); - + private Map> rodBindings; private static class VAExpression { public String fullName, bindingName, fieldName; @@ -72,16 +73,18 @@ public class VariantAnnotatorEngine { } // use this constructor if you want all possible annotations - public VariantAnnotatorEngine(GenomeAnalysisEngine engine) { + public VariantAnnotatorEngine(GenomeAnalysisEngine engine, Map> rodBindings) { requestedInfoAnnotations = AnnotationInterfaceManager.createAllInfoFieldAnnotations(); requestedGenotypeAnnotations = AnnotationInterfaceManager.createAllGenotypeAnnotations(); initializeDBs(engine); + this.rodBindings = rodBindings; } // use this constructor if you want to select specific annotations (and/or interfaces) - public VariantAnnotatorEngine(GenomeAnalysisEngine engine, List annotationGroupsToUse, List annotationsToUse) { + public VariantAnnotatorEngine(GenomeAnalysisEngine engine, List annotationGroupsToUse, List annotationsToUse, Map> rodBindings) { initializeAnnotations(annotationGroupsToUse, annotationsToUse); initializeDBs(engine); + this.rodBindings = rodBindings; } // select specific expressions to use @@ -137,7 +140,7 @@ public class VariantAnnotatorEngine { // go through all the requested info annotationTypes for ( InfoFieldAnnotation annotationType : requestedInfoAnnotations ) { - Map annotationsFromCurrentType = annotationType.annotate(tracker, ref, stratifiedContexts, vc); + Map annotationsFromCurrentType = annotationType.annotate(tracker, rodBindings, ref, stratifiedContexts, vc); if ( annotationsFromCurrentType != null ) infoAnnotations.putAll(annotationsFromCurrentType); } @@ -202,7 +205,7 @@ public class VariantAnnotatorEngine { Map genotypeAnnotations = new HashMap(genotype.getAttributes()); for ( GenotypeAnnotation annotation : requestedGenotypeAnnotations ) { - Map result = annotation.annotate(tracker, ref, context, vc, genotype); + Map result = annotation.annotate(tracker, rodBindings, ref, context, vc, genotype); if ( result != null ) genotypeAnnotations.putAll(result); } diff --git a/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/interfaces/GenotypeAnnotation.java b/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/interfaces/GenotypeAnnotation.java index e982582ee..29d90b5bf 100755 --- a/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/interfaces/GenotypeAnnotation.java +++ b/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/interfaces/GenotypeAnnotation.java @@ -1,5 +1,7 @@ package org.broadinstitute.sting.gatk.walkers.annotator.interfaces; +import org.broad.tribble.Feature; +import org.broadinstitute.sting.commandline.RodBinding; import org.broadinstitute.sting.gatk.contexts.AlignmentContext; import org.broadinstitute.sting.gatk.contexts.ReferenceContext; import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker; @@ -13,7 +15,8 @@ import java.util.Map; public abstract class GenotypeAnnotation extends VariantAnnotatorAnnotation { // return annotations for the given contexts/genotype split by sample - public abstract Map annotate(RefMetaDataTracker tracker, ReferenceContext ref, AlignmentContext stratifiedContext, VariantContext vc, Genotype g); + public abstract Map annotate(RefMetaDataTracker tracker, Map> rodBindings, + ReferenceContext ref, AlignmentContext stratifiedContext, VariantContext vc, Genotype g); // return the descriptions used for the VCF FORMAT meta field public abstract List getDescriptions(); diff --git a/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/interfaces/InfoFieldAnnotation.java b/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/interfaces/InfoFieldAnnotation.java index 84438ccd8..63dea93d2 100755 --- a/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/interfaces/InfoFieldAnnotation.java +++ b/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/interfaces/InfoFieldAnnotation.java @@ -1,11 +1,11 @@ package org.broadinstitute.sting.gatk.walkers.annotator.interfaces; +import org.broad.tribble.Feature; +import org.broadinstitute.sting.commandline.RodBinding; import org.broadinstitute.sting.gatk.contexts.AlignmentContext; import org.broadinstitute.sting.gatk.contexts.ReferenceContext; import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker; -import org.broadinstitute.sting.gatk.walkers.annotator.VariantAnnotator; import org.broadinstitute.sting.utils.codecs.vcf.VCFInfoHeaderLine; -import org.broadinstitute.sting.utils.help.DocumentedGATKFeature; import org.broadinstitute.sting.utils.variantcontext.VariantContext; import java.util.List; @@ -13,7 +13,8 @@ import java.util.Map; public abstract class InfoFieldAnnotation extends VariantAnnotatorAnnotation { // return annotations for the given contexts split by sample - public abstract Map annotate(RefMetaDataTracker tracker, ReferenceContext ref, Map stratifiedContexts, VariantContext vc); + public abstract Map annotate(RefMetaDataTracker tracker, Map> rodBindings, + ReferenceContext ref, Map stratifiedContexts, VariantContext vc); // return the descriptions used for the VCF INFO meta field public abstract List getDescriptions(); diff --git a/public/java/src/org/broadinstitute/sting/gatk/walkers/genotyper/UnifiedGenotyper.java b/public/java/src/org/broadinstitute/sting/gatk/walkers/genotyper/UnifiedGenotyper.java index 6836b14fc..07ba27639 100755 --- a/public/java/src/org/broadinstitute/sting/gatk/walkers/genotyper/UnifiedGenotyper.java +++ b/public/java/src/org/broadinstitute/sting/gatk/walkers/genotyper/UnifiedGenotyper.java @@ -25,9 +25,11 @@ package org.broadinstitute.sting.gatk.walkers.genotyper; +import org.broad.tribble.Feature; import org.broadinstitute.sting.commandline.Argument; import org.broadinstitute.sting.commandline.ArgumentCollection; import org.broadinstitute.sting.commandline.Output; +import org.broadinstitute.sting.commandline.RodBinding; import org.broadinstitute.sting.gatk.DownsampleType; import org.broadinstitute.sting.gatk.arguments.DbsnpArgumentCollection; import org.broadinstitute.sting.gatk.contexts.AlignmentContext; @@ -138,7 +140,8 @@ public class UnifiedGenotyper extends LocusWalker>()); UG_engine = new UnifiedGenotyperEngine(getToolkit(), UAC, logger, verboseWriter, annotationEngine, samples); // initialize the header From 0497170bc94f0d3c3df49ea2da3d1bd1b7ae562f Mon Sep 17 00:00:00 2001 From: David Roazen Date: Wed, 10 Aug 2011 12:56:31 -0400 Subject: [PATCH 17/19] SnpEffCodec now implements SelfScopingFeatureCodec so that we no longer have to specify the codec name on the command line for SnpEff files. --- .../utils/codecs/snpEff/SnpEffCodec.java | 19 ++++++++++++++++++- .../VariantAnnotatorIntegrationTest.java | 4 ++-- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/public/java/src/org/broadinstitute/sting/utils/codecs/snpEff/SnpEffCodec.java b/public/java/src/org/broadinstitute/sting/utils/codecs/snpEff/SnpEffCodec.java index 827df16bb..eada8521f 100644 --- a/public/java/src/org/broadinstitute/sting/utils/codecs/snpEff/SnpEffCodec.java +++ b/public/java/src/org/broadinstitute/sting/utils/codecs/snpEff/SnpEffCodec.java @@ -27,11 +27,16 @@ package org.broadinstitute.sting.utils.codecs.snpEff; import org.broad.tribble.Feature; import org.broad.tribble.FeatureCodec; import org.broad.tribble.TribbleException; +import org.broad.tribble.readers.AsciiLineReader; import org.broad.tribble.readers.LineReader; +import org.broadinstitute.sting.gatk.refdata.SelfScopingFeatureCodec; + import static org.broadinstitute.sting.utils.codecs.snpEff.SnpEffConstants.EffectType; import static org.broadinstitute.sting.utils.codecs.snpEff.SnpEffConstants.ChangeType; import static org.broadinstitute.sting.utils.codecs.snpEff.SnpEffConstants.Zygosity; +import java.io.File; +import java.io.FileInputStream; import java.io.IOException; /** @@ -68,7 +73,7 @@ import java.io.IOException; * * @author David Roazen */ -public class SnpEffCodec implements FeatureCodec { +public class SnpEffCodec implements FeatureCodec, SelfScopingFeatureCodec { public static final int EXPECTED_NUMBER_OF_FIELDS = 23; public static final String FIELD_DELIMITER_PATTERN = "\\t"; @@ -255,4 +260,16 @@ public class SnpEffCodec implements FeatureCodec { } } } + + public boolean canDecode ( final File potentialInput ) { + try { + LineReader reader = new AsciiLineReader(new FileInputStream(potentialInput)); + readHeader(reader); + } + catch ( Exception e ) { + return false; + } + + return true; + } } diff --git a/public/java/test/org/broadinstitute/sting/gatk/walkers/annotator/VariantAnnotatorIntegrationTest.java b/public/java/test/org/broadinstitute/sting/gatk/walkers/annotator/VariantAnnotatorIntegrationTest.java index 596ac5c36..af29bd01f 100755 --- a/public/java/test/org/broadinstitute/sting/gatk/walkers/annotator/VariantAnnotatorIntegrationTest.java +++ b/public/java/test/org/broadinstitute/sting/gatk/walkers/annotator/VariantAnnotatorIntegrationTest.java @@ -129,8 +129,8 @@ public class VariantAnnotatorIntegrationTest extends WalkerTest { @Test public void testSnpEffAnnotations() { WalkerTestSpec spec = new WalkerTestSpec( - "-T VariantAnnotator -R " + b37KGReference + " -NO_HEADER -o %s -A SnpEff --variant:VCF " + - validationDataLocation + "1000G.exomes.vcf --snpEffFile:SnpEff " + validationDataLocation + + "-T VariantAnnotator -R " + b37KGReference + " -NO_HEADER -o %s -A SnpEff --variant " + + validationDataLocation + "1000G.exomes.vcf --snpEffFile " + validationDataLocation + "snpEff_1.9.6_1000G.exomes.vcf_hg37.61.out -L 1:26,000,000-26,500,000", 1, Arrays.asList("c08648a078368c80530bff004b3157f1") From 749c8bfbcd8b8e42a951bb1c6bcff69321d9eb53 Mon Sep 17 00:00:00 2001 From: Eric Banks Date: Wed, 10 Aug 2011 13:42:35 -0400 Subject: [PATCH 18/19] Moving more tools over to the new rod system --- .../walkers/annotator/VariantAnnotator.java | 7 +++-- .../coverage/CompareCallableLociWalker.java | 29 ++++++++++--------- .../gatk/walkers/indels/IndelRealigner.java | 2 +- .../indels/RealignerTargetCreator.java | 10 ++++++- .../phasing/MergeAndMatchHaplotypes.java | 14 +++++++-- .../walkers/phasing/PhaseByTransmission.java | 11 +++++-- ...pareCallableLociWalkerIntegrationTest.java | 2 +- .../UnifiedGenotyperPerformanceTest.java | 6 ++-- ...RealignerTargetCreatorIntegrationTest.java | 4 +-- ...RealignerTargetCreatorPerformanceTest.java | 4 +-- ...ergeAndMatchHaplotypesIntegrationTest.java | 4 +-- .../PhaseByTransmissionIntegrationTest.java | 2 +- 12 files changed, 60 insertions(+), 35 deletions(-) diff --git a/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/VariantAnnotator.java b/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/VariantAnnotator.java index efa40d9a8..d26a81a06 100755 --- a/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/VariantAnnotator.java +++ b/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/VariantAnnotator.java @@ -50,12 +50,14 @@ import java.util.*; /** * Annotates variant calls with context information. Users can specify which of the available annotations to use. */ +@Requires(value={}) @Allows(value={DataSource.READS, DataSource.REFERENCE}) @Reference(window=@Window(start=-50,stop=50)) @By(DataSource.REFERENCE) public class VariantAnnotator extends RodWalker { - @ArgumentCollection protected StandardVariantContextInputArgumentCollection variantCollection = new StandardVariantContextInputArgumentCollection(); + @ArgumentCollection + protected StandardVariantContextInputArgumentCollection variantCollection = new StandardVariantContextInputArgumentCollection(); @Input(fullName="snpEffFile", shortName = "snpEffFile", doc="SnpEff file", required=false) public RodBinding snpEffFile; @@ -65,7 +67,8 @@ public class VariantAnnotator extends RodWalker { * * rsIDs from this file are used to populate the ID column of the output. Also, the DB INFO flag will be set when appropriate. */ - @ArgumentCollection protected DbsnpArgumentCollection dbsnp = new DbsnpArgumentCollection(); + @ArgumentCollection + protected DbsnpArgumentCollection dbsnp = new DbsnpArgumentCollection(); /** * A comparisons VCF file from which to annotate. diff --git a/public/java/src/org/broadinstitute/sting/gatk/walkers/coverage/CompareCallableLociWalker.java b/public/java/src/org/broadinstitute/sting/gatk/walkers/coverage/CompareCallableLociWalker.java index becbbeedf..cd5fdc505 100755 --- a/public/java/src/org/broadinstitute/sting/gatk/walkers/coverage/CompareCallableLociWalker.java +++ b/public/java/src/org/broadinstitute/sting/gatk/walkers/coverage/CompareCallableLociWalker.java @@ -22,10 +22,11 @@ package org.broadinstitute.sting.gatk.walkers.coverage; -import org.broad.tribble.Feature; -import org.broad.tribble.bed.FullBEDFeature; +import org.broad.tribble.bed.BEDFeature; import org.broadinstitute.sting.commandline.Argument; +import org.broadinstitute.sting.commandline.Input; import org.broadinstitute.sting.commandline.Output; +import org.broadinstitute.sting.commandline.RodBinding; import org.broadinstitute.sting.gatk.contexts.AlignmentContext; import org.broadinstitute.sting.gatk.contexts.ReferenceContext; import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker; @@ -44,11 +45,11 @@ public class CompareCallableLociWalker extends RodWalker compTrack1; - @Argument(shortName="comp2", doc="First comparison track name", required=false) - protected String COMP2 = "comp2"; + @Input(fullName="comp2", shortName = "comp2", doc="Second comparison track name", required=true) + public RodBinding compTrack2; @Argument(shortName="printState", doc="If provided, prints sites satisfying this state pair", required=false) protected String printState = null; @@ -78,8 +79,8 @@ public class CompareCallableLociWalker extends RodWalker map(RefMetaDataTracker tracker, ReferenceContext ref, AlignmentContext context) { if ( tracker != null ) { - CallableLociWalker.CallableBaseState comp1 = getCallableBaseState(tracker, COMP1); - CallableLociWalker.CallableBaseState comp2 = getCallableBaseState(tracker, COMP2); + CallableLociWalker.CallableBaseState comp1 = getCallableBaseState(tracker, compTrack1); + CallableLociWalker.CallableBaseState comp2 = getCallableBaseState(tracker, compTrack2); if ( printState != null && comp1.getState() == printState1 && comp2.getState() == printState2 ) { out.printf("%s %s %s %s%n", comp1.getLocation(), comp1.getState(), comp2.getLocation(), comp2.getState()); @@ -91,14 +92,14 @@ public class CompareCallableLociWalker extends RodWalker rodBinding) { //System.out.printf("tracker %s%n", tracker); - List bindings = tracker.getValues(Feature.class, track); - if ( bindings.size() != 1 || ! (bindings.get(0) instanceof FullBEDFeature)) { - throw new UserException.MalformedFile(String.format("%s track isn't a properly formated CallableBases object!", track)); + List bindings = tracker.getValues(rodBinding); + if ( bindings.size() != 1 ) { + throw new UserException.MalformedFile(String.format("%s track isn't a properly formated CallableBases object!", rodBinding.getName())); } - FullBEDFeature bed = (FullBEDFeature)bindings.get(0); + BEDFeature bed = bindings.get(0); GenomeLoc loc = getToolkit().getGenomeLocParser().createGenomeLoc(bed.getChr(), bed.getStart(), bed.getEnd()); CallableLociWalker.CalledState state = CallableLociWalker.CalledState.valueOf(bed.getName()); return new CallableLociWalker.CallableBaseState(getToolkit().getGenomeLocParser(),loc, state); @@ -128,7 +129,7 @@ public class CompareCallableLociWalker extends RodWalker { } @Input(fullName="known", shortName = "known", doc="Input VCF file with known indels", required=false) - public RodBinding known = RodBinding.makeUnbound(VariantContext.class); + public List> known = Collections.emptyList(); @Input(fullName="targetIntervals", shortName="targetIntervals", doc="intervals file output from RealignerTargetCreator", required=true) protected String intervalsFile = null; diff --git a/public/java/src/org/broadinstitute/sting/gatk/walkers/indels/RealignerTargetCreator.java b/public/java/src/org/broadinstitute/sting/gatk/walkers/indels/RealignerTargetCreator.java index 22a10144f..fbb62f17e 100755 --- a/public/java/src/org/broadinstitute/sting/gatk/walkers/indels/RealignerTargetCreator.java +++ b/public/java/src/org/broadinstitute/sting/gatk/walkers/indels/RealignerTargetCreator.java @@ -26,7 +26,9 @@ package org.broadinstitute.sting.gatk.walkers.indels; import org.broadinstitute.sting.commandline.Argument; +import org.broadinstitute.sting.commandline.Input; import org.broadinstitute.sting.commandline.Output; +import org.broadinstitute.sting.commandline.RodBinding; import org.broadinstitute.sting.gatk.contexts.AlignmentContext; import org.broadinstitute.sting.gatk.contexts.ReferenceContext; import org.broadinstitute.sting.gatk.filters.BadCigarFilter; @@ -46,6 +48,8 @@ import org.broadinstitute.sting.utils.variantcontext.VariantContext; import java.io.PrintStream; import java.util.ArrayList; +import java.util.Collections; +import java.util.List; /** * Emits intervals for the Local Indel Realigner to target for cleaning. Ignores 454 reads, MQ0 reads, and reads with consecutive indel operators in the CIGAR string. @@ -56,9 +60,13 @@ import java.util.ArrayList; @By(DataSource.REFERENCE) @BAQMode(ApplicationTime = BAQ.ApplicationTime.FORBIDDEN) public class RealignerTargetCreator extends RodWalker { + @Output protected PrintStream out; + @Input(fullName="known", shortName = "known", doc="Input VCF file with known indels", required=false) + public List> known = Collections.emptyList(); + // mismatch/entropy/SNP arguments @Argument(fullName="windowSize", shortName="window", doc="window size for calculating entropy or SNP clusters", required=false) protected int windowSize = 10; @@ -110,7 +118,7 @@ public class RealignerTargetCreator extends RodWalker { @Output protected VCFWriter vcfWriter = null; + @Input(fullName="pbt", shortName = "pbt", doc="Input VCF truth file", required=true) + public RodBinding pbtTrack; + + @Input(fullName="rbp", shortName = "rbp", doc="Input VCF truth file", required=true) + public RodBinding rbpTrack; + private Map pbtCache = new HashMap(); private Map rbpCache = new HashMap(); @@ -31,7 +39,7 @@ public class MergeAndMatchHaplotypes extends RodWalker { public void initialize() { ArrayList rodNames = new ArrayList(); - rodNames.add("pbt"); + rodNames.add(pbtTrack.getName()); Map vcfRods = VCFUtils.getVCFHeadersFromRods(getToolkit(), rodNames); Set vcfSamples = SampleUtils.getSampleList(vcfRods, VariantContextUtils.GenotypeMergeType.REQUIRE_UNIQUE); @@ -44,8 +52,8 @@ public class MergeAndMatchHaplotypes extends RodWalker { @Override public Integer map(RefMetaDataTracker tracker, ReferenceContext ref, AlignmentContext context) { if (tracker != null) { - Collection pbts = tracker.getValues(VariantContext.class, "pbt", ref.getLocus()); - Collection rbps = tracker.getValues(VariantContext.class, "rbp", ref.getLocus()); + Collection pbts = tracker.getValues(pbtTrack, ref.getLocus()); + Collection rbps = tracker.getValues(rbpTrack, ref.getLocus()); VariantContext pbt = pbts.iterator().hasNext() ? pbts.iterator().next() : null; VariantContext rbp = rbps.iterator().hasNext() ? rbps.iterator().next() : null; diff --git a/public/java/src/org/broadinstitute/sting/gatk/walkers/phasing/PhaseByTransmission.java b/public/java/src/org/broadinstitute/sting/gatk/walkers/phasing/PhaseByTransmission.java index 0178cdfaf..3eedc2a28 100755 --- a/public/java/src/org/broadinstitute/sting/gatk/walkers/phasing/PhaseByTransmission.java +++ b/public/java/src/org/broadinstitute/sting/gatk/walkers/phasing/PhaseByTransmission.java @@ -1,7 +1,9 @@ package org.broadinstitute.sting.gatk.walkers.phasing; import org.broadinstitute.sting.commandline.Argument; +import org.broadinstitute.sting.commandline.ArgumentCollection; import org.broadinstitute.sting.commandline.Output; +import org.broadinstitute.sting.gatk.arguments.StandardVariantContextInputArgumentCollection; import org.broadinstitute.sting.gatk.contexts.AlignmentContext; import org.broadinstitute.sting.gatk.contexts.ReferenceContext; import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker; @@ -31,13 +33,16 @@ import java.util.*; * begin. */ public class PhaseByTransmission extends RodWalker { + + @ArgumentCollection + protected StandardVariantContextInputArgumentCollection variantCollection = new StandardVariantContextInputArgumentCollection(); + @Argument(shortName="f", fullName="familySpec", required=true, doc="Patterns for the family structure (usage: mom+dad=child). Specify several trios by supplying this argument many times and/or a file containing many patterns.") public ArrayList familySpecs = null; @Output protected VCFWriter vcfWriter = null; - private final String ROD_NAME = "variant"; private final String TRANSMISSION_PROBABILITY_TAG_NAME = "TP"; private final String SOURCE_NAME = "PhaseByTransmission"; @@ -102,7 +107,7 @@ public class PhaseByTransmission extends RodWalker { trios = getFamilySpecsFromCommandLineInput(familySpecs); ArrayList rodNames = new ArrayList(); - rodNames.add(ROD_NAME); + rodNames.add(variantCollection.variants.getName()); Map vcfRods = VCFUtils.getVCFHeadersFromRods(getToolkit(), rodNames); Set vcfSamples = SampleUtils.getSampleList(vcfRods, VariantContextUtils.GenotypeMergeType.REQUIRE_UNIQUE); @@ -289,7 +294,7 @@ public class PhaseByTransmission extends RodWalker { @Override public Integer map(RefMetaDataTracker tracker, ReferenceContext ref, AlignmentContext context) { if (tracker != null) { - VariantContext vc = tracker.getFirstValue(VariantContext.class, ROD_NAME, context.getLocation()); + VariantContext vc = tracker.getFirstValue(variantCollection.variants, context.getLocation()); Map genotypeMap = vc.getGenotypes(); diff --git a/public/java/test/org/broadinstitute/sting/gatk/walkers/coverage/CompareCallableLociWalkerIntegrationTest.java b/public/java/test/org/broadinstitute/sting/gatk/walkers/coverage/CompareCallableLociWalkerIntegrationTest.java index 4a32d6701..1ba7a5e85 100755 --- a/public/java/test/org/broadinstitute/sting/gatk/walkers/coverage/CompareCallableLociWalkerIntegrationTest.java +++ b/public/java/test/org/broadinstitute/sting/gatk/walkers/coverage/CompareCallableLociWalkerIntegrationTest.java @@ -30,7 +30,7 @@ import org.testng.annotations.Test; import java.util.Arrays; public class CompareCallableLociWalkerIntegrationTest extends WalkerTest { - final static String commonArgs = "-R " + hg18Reference + " -T CompareCallableLoci -B:comp1,Bed " + validationDataLocation + "1kg_slx.chr1_10mb.callable.bed -B:comp2,Bed " + validationDataLocation + "ga2_slx.chr1_10mb.callable.bed -o %s"; + final static String commonArgs = "-R " + hg18Reference + " -T CompareCallableLoci --comp1:Bed " + validationDataLocation + "1kg_slx.chr1_10mb.callable.bed --comp2:Bed " + validationDataLocation + "ga2_slx.chr1_10mb.callable.bed -o %s"; @Test public void testCompareCallableLociWalker1() { diff --git a/public/java/test/org/broadinstitute/sting/gatk/walkers/genotyper/UnifiedGenotyperPerformanceTest.java b/public/java/test/org/broadinstitute/sting/gatk/walkers/genotyper/UnifiedGenotyperPerformanceTest.java index 86f8b14f1..fb7e84d22 100755 --- a/public/java/test/org/broadinstitute/sting/gatk/walkers/genotyper/UnifiedGenotyperPerformanceTest.java +++ b/public/java/test/org/broadinstitute/sting/gatk/walkers/genotyper/UnifiedGenotyperPerformanceTest.java @@ -15,7 +15,7 @@ public class UnifiedGenotyperPerformanceTest extends WalkerTest { " -glm BOTH" + " -I " + evaluationDataLocation + "NA12878.GAII.chr1.50MB.bam" + " -L chr1:1-50,000,000" + - " -dbsnp:VCF " + b36dbSNP129 + + " --dbsnp:VCF " + b36dbSNP129 + " -o /dev/null", 0, new ArrayList(0)); @@ -30,7 +30,7 @@ public class UnifiedGenotyperPerformanceTest extends WalkerTest { " -glm BOTH" + " -I " + evaluationDataLocation + "NA12878.ESP.WEx.chr1.bam" + " -L " + evaluationDataLocation + "whole_exome_agilent_designed_120.targets.chr1.interval_list" + - " -dbsnp:vcf " + b36dbSNP129 + + " --dbsnp:vcf " + b36dbSNP129 + " -o /dev/null", 0, new ArrayList(0)); @@ -46,7 +46,7 @@ public class UnifiedGenotyperPerformanceTest extends WalkerTest { " -glm BOTH" + " -L chr1:1-50,000,000" + " -nt 10" + - " -dbsnp:vcf " + b36dbSNP129 + + " --dbsnp:vcf " + b36dbSNP129 + " -o /dev/null", 0, new ArrayList(0)); diff --git a/public/java/test/org/broadinstitute/sting/gatk/walkers/indels/RealignerTargetCreatorIntegrationTest.java b/public/java/test/org/broadinstitute/sting/gatk/walkers/indels/RealignerTargetCreatorIntegrationTest.java index aabf01415..1873ccbe2 100755 --- a/public/java/test/org/broadinstitute/sting/gatk/walkers/indels/RealignerTargetCreatorIntegrationTest.java +++ b/public/java/test/org/broadinstitute/sting/gatk/walkers/indels/RealignerTargetCreatorIntegrationTest.java @@ -17,13 +17,13 @@ public class RealignerTargetCreatorIntegrationTest extends WalkerTest { executeTest("test standard", spec1); WalkerTest.WalkerTestSpec spec2 = new WalkerTest.WalkerTestSpec( - "-T RealignerTargetCreator -B:dbsnp,vcf " + b36dbSNP129 + " -R " + b36KGReference + " -I " + validationDataLocation + "NA12878.1kg.p2.chr1_10mb_11_mb.SLX.bam -L 1:10,000,000-10,050,000 -o %s", + "-T RealignerTargetCreator --known " + b36dbSNP129 + " -R " + b36KGReference + " -I " + validationDataLocation + "NA12878.1kg.p2.chr1_10mb_11_mb.SLX.bam -L 1:10,000,000-10,050,000 -o %s", 1, Arrays.asList("0367d39a122c8ac0899fb868a82ef728")); executeTest("test dbsnp", spec2); WalkerTest.WalkerTestSpec spec3 = new WalkerTest.WalkerTestSpec( - "-T RealignerTargetCreator -R " + b36KGReference + " -B:indels,VCF " + validationDataLocation + "NA12878.chr1_10mb_11mb.slx.indels.vcf4 -BTI indels -o %s", + "-T RealignerTargetCreator -R " + b36KGReference + " --known " + validationDataLocation + "NA12878.chr1_10mb_11mb.slx.indels.vcf4 -BTI known -o %s", 1, Arrays.asList("5206cee6c01b299417bf2feeb8b3dc96")); executeTest("test rods only", spec3); diff --git a/public/java/test/org/broadinstitute/sting/gatk/walkers/indels/RealignerTargetCreatorPerformanceTest.java b/public/java/test/org/broadinstitute/sting/gatk/walkers/indels/RealignerTargetCreatorPerformanceTest.java index 9490206c8..cc37cc191 100755 --- a/public/java/test/org/broadinstitute/sting/gatk/walkers/indels/RealignerTargetCreatorPerformanceTest.java +++ b/public/java/test/org/broadinstitute/sting/gatk/walkers/indels/RealignerTargetCreatorPerformanceTest.java @@ -12,7 +12,7 @@ public class RealignerTargetCreatorPerformanceTest extends WalkerTest { WalkerTestSpec spec1 = new WalkerTestSpec( "-R " + hg18Reference + " -T RealignerTargetCreator" + - " -B:dbsnp,vcf " + GATKDataLocation + "dbsnp_132.hg18.vcf" + + " --known " + GATKDataLocation + "dbsnp_132.hg18.vcf" + " -I " + evaluationDataLocation + "NA12878.GAII.chr1.50MB.bam" + " -L chr1:1-50,000,000" + " -o /dev/null", @@ -23,7 +23,7 @@ public class RealignerTargetCreatorPerformanceTest extends WalkerTest { WalkerTestSpec spec2 = new WalkerTestSpec( "-R " + hg18Reference + " -T RealignerTargetCreator" + - " -B:dbsnp,vcf " + GATKDataLocation + "dbsnp_132.hg18.vcf" + + " --known " + GATKDataLocation + "dbsnp_132.hg18.vcf" + " -I " + evaluationDataLocation + "NA12878.ESP.WEx.chr1.bam" + " -L " + evaluationDataLocation + "whole_exome_agilent_designed_120.targets.chr1.interval_list" + " -o /dev/null", diff --git a/public/java/test/org/broadinstitute/sting/gatk/walkers/phasing/MergeAndMatchHaplotypesIntegrationTest.java b/public/java/test/org/broadinstitute/sting/gatk/walkers/phasing/MergeAndMatchHaplotypesIntegrationTest.java index 21435dd7d..cf6b4e581 100644 --- a/public/java/test/org/broadinstitute/sting/gatk/walkers/phasing/MergeAndMatchHaplotypesIntegrationTest.java +++ b/public/java/test/org/broadinstitute/sting/gatk/walkers/phasing/MergeAndMatchHaplotypesIntegrationTest.java @@ -16,8 +16,8 @@ public class MergeAndMatchHaplotypesIntegrationTest extends WalkerTest { buildCommandLine( "-T MergeAndMatchHaplotypes", "-R " + b37KGReference, - "-B:pbt,VCF " + fundamentalTestPBTVCF, - "-B:rbp,VCF " + fundamentalTestRBPVCF, + "--pbt " + fundamentalTestPBTVCF, + "--rbp " + fundamentalTestRBPVCF, "-o %s" ), 1, diff --git a/public/java/test/org/broadinstitute/sting/gatk/walkers/phasing/PhaseByTransmissionIntegrationTest.java b/public/java/test/org/broadinstitute/sting/gatk/walkers/phasing/PhaseByTransmissionIntegrationTest.java index 59750e18f..c663c1dd7 100644 --- a/public/java/test/org/broadinstitute/sting/gatk/walkers/phasing/PhaseByTransmissionIntegrationTest.java +++ b/public/java/test/org/broadinstitute/sting/gatk/walkers/phasing/PhaseByTransmissionIntegrationTest.java @@ -16,7 +16,7 @@ public class PhaseByTransmissionIntegrationTest extends WalkerTest { "-T PhaseByTransmission", "-NO_HEADER", "-R " + b37KGReference, - "-B:variant,VCF " + fundamentalTestVCF, + "--variant " + fundamentalTestVCF, "-f NA12892+NA12891=NA12878", "-o %s" ), From 07ad8c78a9014d9fd4e652904974d6f975def6fe Mon Sep 17 00:00:00 2001 From: Eric Banks Date: Wed, 10 Aug 2011 14:24:40 -0400 Subject: [PATCH 19/19] More tools moved over. Fixed the VariantContextIntegrationTest which was not useful because the md5s were all removed. In the future, instead of removing md5s (putting it in 'parameterization' mode), you should instead use @Test{enabled=false} since it's easier to track. --- .../walkers/genotyper/UGCallVariants.java | 20 +++++++--------- .../walkers/qc/RodSystemValidationWalker.java | 7 +++++- .../variantutils/ValidateVariants.java | 8 +++++-- .../SelectVariantsIntegrationTest.java | 4 ++-- .../ValidateVariantsIntegrationTest.java | 2 +- .../VariantContextIntegrationTest.java | 23 +++++++++---------- 6 files changed, 34 insertions(+), 30 deletions(-) diff --git a/public/java/src/org/broadinstitute/sting/gatk/walkers/genotyper/UGCallVariants.java b/public/java/src/org/broadinstitute/sting/gatk/walkers/genotyper/UGCallVariants.java index d91f8d2e4..500b11360 100755 --- a/public/java/src/org/broadinstitute/sting/gatk/walkers/genotyper/UGCallVariants.java +++ b/public/java/src/org/broadinstitute/sting/gatk/walkers/genotyper/UGCallVariants.java @@ -25,7 +25,9 @@ package org.broadinstitute.sting.gatk.walkers.genotyper; import org.broadinstitute.sting.commandline.ArgumentCollection; +import org.broadinstitute.sting.commandline.Input; import org.broadinstitute.sting.commandline.Output; +import org.broadinstitute.sting.commandline.RodBinding; import org.broadinstitute.sting.gatk.contexts.AlignmentContext; import org.broadinstitute.sting.gatk.contexts.ReferenceContext; import org.broadinstitute.sting.gatk.datasources.rmd.ReferenceOrderedDataSource; @@ -51,6 +53,9 @@ public class UGCallVariants extends RodWalker { @ArgumentCollection private UnifiedArgumentCollection UAC = new UnifiedArgumentCollection(); + @Input(fullName="variant", shortName = "V", doc="Input VCF file", required=true) + public List> variants; + // control the output @Output(doc="File to which variants should be written",required=true) protected VCFWriter writer = null; @@ -63,13 +68,8 @@ public class UGCallVariants extends RodWalker { public void initialize() { - for ( ReferenceOrderedDataSource d : getToolkit().getRodDataSources() ) { - if ( d.getName().startsWith("variant") ) - trackNames.add(d.getName()); - } - if ( trackNames.size() == 0 ) - throw new UserException("At least one track bound to a name beginning with 'variant' must be provided."); - + for ( RodBinding rb : variants ) + trackNames.add(rb.getName()); Set samples = SampleUtils.getSampleListWithVCFHeader(getToolkit(), trackNames); UG_engine = new UnifiedGenotyperEngine(getToolkit(), UAC, logger, null, null, samples); @@ -93,11 +93,7 @@ public class UGCallVariants extends RodWalker { if ( tracker == null ) return null; - List VCs = new ArrayList(); - for ( String name : trackNames ) { - VariantContext vc = tracker.getFirstValue(VariantContext.class, name, context.getLocation()); - VCs.add(vc); - } + List VCs = tracker.getValues(variants, context.getLocation()); VariantContext mergedVC = mergeVCsWithGLs(VCs); if ( mergedVC == null ) diff --git a/public/java/src/org/broadinstitute/sting/gatk/walkers/qc/RodSystemValidationWalker.java b/public/java/src/org/broadinstitute/sting/gatk/walkers/qc/RodSystemValidationWalker.java index edfaea768..1c24f3879 100644 --- a/public/java/src/org/broadinstitute/sting/gatk/walkers/qc/RodSystemValidationWalker.java +++ b/public/java/src/org/broadinstitute/sting/gatk/walkers/qc/RodSystemValidationWalker.java @@ -25,7 +25,9 @@ package org.broadinstitute.sting.gatk.walkers.qc; import org.broadinstitute.sting.commandline.Argument; +import org.broadinstitute.sting.commandline.Input; import org.broadinstitute.sting.commandline.Output; +import org.broadinstitute.sting.commandline.RodBinding; import org.broadinstitute.sting.gatk.contexts.AlignmentContext; import org.broadinstitute.sting.gatk.contexts.ReferenceContext; import org.broadinstitute.sting.gatk.datasources.rmd.ReferenceOrderedDataSource; @@ -54,6 +56,9 @@ public class RodSystemValidationWalker extends RodWalker { // the divider to use in some of the text output private static final String DIVIDER = ","; + @Input(fullName="eval", shortName = "eval", doc="Input VCF eval file", required=true) + public List> eval; + @Output public PrintStream out; @@ -108,7 +113,7 @@ public class RodSystemValidationWalker extends RodWalker { // if the argument was set, check for equivalence if (allRecordsVariantContextEquivalent && tracker != null) { - Collection col = tracker.getValues(VariantContext.class); + Collection col = tracker.getValues(eval); VariantContext con = null; for (VariantContext contextInList : col) if (con == null) con = contextInList; diff --git a/public/java/src/org/broadinstitute/sting/gatk/walkers/variantutils/ValidateVariants.java b/public/java/src/org/broadinstitute/sting/gatk/walkers/variantutils/ValidateVariants.java index c3e7dbe0c..5c7fb268c 100755 --- a/public/java/src/org/broadinstitute/sting/gatk/walkers/variantutils/ValidateVariants.java +++ b/public/java/src/org/broadinstitute/sting/gatk/walkers/variantutils/ValidateVariants.java @@ -29,6 +29,7 @@ import org.broad.tribble.Feature; import org.broad.tribble.TribbleException; import org.broad.tribble.dbsnp.DbSNPFeature; import org.broadinstitute.sting.commandline.*; +import org.broadinstitute.sting.gatk.arguments.DbsnpArgumentCollection; import org.broadinstitute.sting.gatk.arguments.StandardVariantContextInputArgumentCollection; import org.broadinstitute.sting.gatk.contexts.AlignmentContext; import org.broadinstitute.sting.gatk.contexts.ReferenceContext; @@ -55,6 +56,9 @@ public class ValidateVariants extends RodWalker { @ArgumentCollection protected StandardVariantContextInputArgumentCollection variantCollection = new StandardVariantContextInputArgumentCollection(); + @ArgumentCollection + protected DbsnpArgumentCollection dbsnp = new DbsnpArgumentCollection(); + public enum ValidationType { ALL, REF, IDS, ALLELES, CHR_COUNTS } @@ -137,8 +141,8 @@ public class ValidateVariants extends RodWalker { // get the RS IDs Set rsIDs = null; - if ( tracker.hasValues(DbSNPHelper.STANDARD_DBSNP_TRACK_NAME) ) { - List dbsnpList = tracker.getValues(Feature.class, DbSNPHelper.STANDARD_DBSNP_TRACK_NAME); + if ( tracker.hasValues(dbsnp.dbsnp) ) { + List dbsnpList = tracker.getValues(dbsnp.dbsnp, ref.getLocus()); rsIDs = new HashSet(); for ( Object d : dbsnpList ) { if (d instanceof DbSNPFeature ) diff --git a/public/java/test/org/broadinstitute/sting/gatk/walkers/variantutils/SelectVariantsIntegrationTest.java b/public/java/test/org/broadinstitute/sting/gatk/walkers/variantutils/SelectVariantsIntegrationTest.java index b2ac3f4a6..bec0d5dd4 100755 --- a/public/java/test/org/broadinstitute/sting/gatk/walkers/variantutils/SelectVariantsIntegrationTest.java +++ b/public/java/test/org/broadinstitute/sting/gatk/walkers/variantutils/SelectVariantsIntegrationTest.java @@ -55,7 +55,7 @@ public class SelectVariantsIntegrationTest extends WalkerTest { String testFile = validationDataLocation + "NA12878.hg19.example1.vcf"; WalkerTestSpec spec = new WalkerTestSpec( - "-T SelectVariants -R " + hg19Reference + " -sn NA12878 -L 20:1012700-1020000 -conc:VCF " + b37hapmapGenotypes + " --variant:VCF " + testFile + " -o %s -NO_HEADER", + "-T SelectVariants -R " + hg19Reference + " -sn NA12878 -L 20:1012700-1020000 -conc:VCF " + b37hapmapGenotypes + " --variant " + testFile + " -o %s -NO_HEADER", 1, Arrays.asList("d2ba3ea30a810f6f0fbfb1b643292b6a") ); @@ -68,7 +68,7 @@ public class SelectVariantsIntegrationTest extends WalkerTest { String testFile = validationDataLocation + "combine.3.vcf"; WalkerTestSpec spec = new WalkerTestSpec( - "-T SelectVariants -R " + b36KGReference + " -sn NA12892 -B:variant,VCF " + testFile + " -o %s -NO_HEADER", + "-T SelectVariants -R " + b36KGReference + " -sn NA12892 --variant " + testFile + " -o %s -NO_HEADER", 1, Arrays.asList("") ); diff --git a/public/java/test/org/broadinstitute/sting/gatk/walkers/variantutils/ValidateVariantsIntegrationTest.java b/public/java/test/org/broadinstitute/sting/gatk/walkers/variantutils/ValidateVariantsIntegrationTest.java index 4d5f0359d..adf3b21a8 100755 --- a/public/java/test/org/broadinstitute/sting/gatk/walkers/variantutils/ValidateVariantsIntegrationTest.java +++ b/public/java/test/org/broadinstitute/sting/gatk/walkers/variantutils/ValidateVariantsIntegrationTest.java @@ -95,7 +95,7 @@ public class ValidateVariantsIntegrationTest extends WalkerTest { @Test public void testBadID() { WalkerTestSpec spec = new WalkerTestSpec( - baseTestString("validationExampleBad.vcf", "IDS") + " -B:dbsnp,vcf " + b36dbSNP129, + baseTestString("validationExampleBad.vcf", "IDS") + " --dbsnp " + b36dbSNP129, 0, UserException.MalformedFile.class ); diff --git a/public/java/test/org/broadinstitute/sting/utils/variantcontext/VariantContextIntegrationTest.java b/public/java/test/org/broadinstitute/sting/utils/variantcontext/VariantContextIntegrationTest.java index 7cdb6af95..67fe7d012 100755 --- a/public/java/test/org/broadinstitute/sting/utils/variantcontext/VariantContextIntegrationTest.java +++ b/public/java/test/org/broadinstitute/sting/utils/variantcontext/VariantContextIntegrationTest.java @@ -15,8 +15,7 @@ public class VariantContextIntegrationTest extends WalkerTest { " -R " + b36KGReference; private static String root = cmdRoot + - " -L 1:1-1,000,000 -B:dbsnp,vcf " + b36dbSNP129 + - " -B:vcf,VCF3 " + validationDataLocation + "yri.trio.gatk_glftrio.intersection.annotated.filtered.chr1.vcf"; + " -L 1:1-1,000,000 -V " + b36dbSNP129; private static final class VCITTest extends TestDataProvider { String args, md5; @@ -30,15 +29,15 @@ public class VariantContextIntegrationTest extends WalkerTest { @DataProvider(name = "VCITTestData") public Object[][] createVCITTestData() { - new VCITTest("--printPerLocus", ""); - new VCITTest("--printPerLocus --onlyContextsOfType SNP", ""); - new VCITTest("--printPerLocus --onlyContextsOfType INDEL", ""); - new VCITTest("--printPerLocus --onlyContextsOfType MIXED", ""); - new VCITTest("--printPerLocus --onlyContextsOfType NO_VARIATION", ""); - new VCITTest("--printPerLocus --takeFirstOnly", ""); - new VCITTest("--printPerLocus --onlyContextsOfType INDEL --onlyContextsStartinAtCurrentPosition", ""); - new VCITTest("--printPerLocus --onlyContextsStartinAtCurrentPosition", ""); - new VCITTest("--printPerLocus --takeFirstOnly --onlyContextsStartinAtCurrentPosition", ""); + new VCITTest("--printPerLocus", "e9d0f1fe80659bb55b40aa6c3a2e921e"); + new VCITTest("--printPerLocus --onlyContextsOfType SNP", "0e620db3e45771df42c54a9c0ae4a29f"); + new VCITTest("--printPerLocus --onlyContextsOfType INDEL", "b725c204fefe3814644d50e7c20f9dfe"); + new VCITTest("--printPerLocus --onlyContextsOfType MIXED", "3ccc33f496a1718df55722d11cc14334"); + new VCITTest("--printPerLocus --onlyContextsOfType NO_VARIATION", "39335acdb34c8a2af433dc50d619bcbc"); + new VCITTest("--printPerLocus --takeFirstOnly", "3a45561da042b2b44b6a679744f16103"); + new VCITTest("--printPerLocus --onlyContextsOfType INDEL --onlyContextsStartinAtCurrentPosition", "4746f269ecc377103f83eb61cc162c39"); + new VCITTest("--printPerLocus --onlyContextsStartinAtCurrentPosition", "2749e3fae458650a85a2317e346dc44c"); + new VCITTest("--printPerLocus --takeFirstOnly --onlyContextsStartinAtCurrentPosition", "9bd48c2a40813023e29ffaa23d59d382"); return VCITTest.getTests(VCITTest.class); } @@ -58,7 +57,7 @@ public class VariantContextIntegrationTest extends WalkerTest { public void testToVCF() { // this really just tests that we are seeing the same number of objects over all of chr1 - WalkerTestSpec spec = new WalkerTestSpec( cmdRoot + " -NO_HEADER -B:vcf,VCF3 " + validationDataLocation + "yri.trio.gatk_glftrio.intersection.annotated.filtered.chr1.500.vcf -L 1:1-1000000 -o %s --outputVCF %s", + WalkerTestSpec spec = new WalkerTestSpec( cmdRoot + " -NO_HEADER -V:VCF3 " + validationDataLocation + "yri.trio.gatk_glftrio.intersection.annotated.filtered.chr1.500.vcf -L 1:1-1000000 -o %s --outputVCF %s", 2, // just one output file Arrays.asList("e3c35d0c4b5d4935c84a270f9df0951f", "ff91731213fd0bbdc200ab6fd1c93e63")); executeTest("testToVCF", spec);