From b25140db83b2acbb2dc2e0520244b64a7f207e44 Mon Sep 17 00:00:00 2001 From: Mark DePristo Date: Wed, 3 Aug 2011 13:34:20 -0400 Subject: [PATCH] Contracts and documentation for some of RefMetaDataTracker Continuing to fix integration tests that don't pass / run --- build.xml | 10 +- .../sting/commandline/RodBinding.java | 2 +- .../gatk/refdata/RefMetaDataTracker.java | 243 +++++++++++------- .../walkers/qc/ValidatingPileupWalker.java | 21 +- .../validation/ValidationAmplicons.java | 22 +- .../ReferenceOrderedViewUnitTest.java | 6 +- .../refdata/RefMetaDataTrackerUnitTest.java | 5 + .../VariantAnnotatorIntegrationTest.java | 28 +- .../VariantFiltrationIntegrationTest.java | 2 +- .../utils/codecs/vcf/VCFIntegrationTest.java | 2 +- 10 files changed, 213 insertions(+), 128 deletions(-) diff --git a/build.xml b/build.xml index 1e4badc2c..9af8949ba 100644 --- a/build.xml +++ b/build.xml @@ -973,11 +973,11 @@ - - - - + + + + + diff --git a/public/java/src/org/broadinstitute/sting/commandline/RodBinding.java b/public/java/src/org/broadinstitute/sting/commandline/RodBinding.java index af5031716..41b5bf6f3 100644 --- a/public/java/src/org/broadinstitute/sting/commandline/RodBinding.java +++ b/public/java/src/org/broadinstitute/sting/commandline/RodBinding.java @@ -90,7 +90,7 @@ public final class RodBinding { final private static Map nameCounter = new HashMap(); /** for UnitTests */ - final protected static void resetNameCounter() { + final public static void resetNameCounter() { nameCounter.clear(); } diff --git a/public/java/src/org/broadinstitute/sting/gatk/refdata/RefMetaDataTracker.java b/public/java/src/org/broadinstitute/sting/gatk/refdata/RefMetaDataTracker.java index e1b9fedf6..73685d758 100644 --- a/public/java/src/org/broadinstitute/sting/gatk/refdata/RefMetaDataTracker.java +++ b/public/java/src/org/broadinstitute/sting/gatk/refdata/RefMetaDataTracker.java @@ -1,5 +1,7 @@ package org.broadinstitute.sting.gatk.refdata; +import com.google.java.contract.Ensures; +import com.google.java.contract.Requires; import org.apache.log4j.Logger; import org.broad.tribble.Feature; import org.broadinstitute.sting.commandline.RodBinding; @@ -18,10 +20,12 @@ import java.util.*; * The standard interaction model is: * * Traversal system arrives at a site, which has a bunch of RMDs covering it - Genotype * Traversal calls tracker.bind(name, RMD) for each RMDs in RMDs - * Traversal passes tracker to the walker - * walker calls lookup(name, default) to obtain the RMDs values at this site, or default if none was - * bound at this site. + * Traversal passes creates a tracker and passes it to the walker + * walker calls get(rodBinding) to obtain the RMDs values at this site for the track + * associated with rodBinding. + * + * Note that this is an immutable class. Once created the underlying data structures + * cannot be modified * * User: mdepristo * Date: Apr 3, 2009 @@ -45,14 +49,19 @@ public class RefMetaDataTracker { public RefMetaDataTracker(final Collection allBindings, final ReferenceContext ref) { this.ref = ref; + + // set up the map if ( allBindings.isEmpty() ) map = Collections.emptyMap(); else { - map = new HashMap(allBindings.size()); + Map tmap = new HashMap(allBindings.size()); for ( RODRecordList rod : allBindings ) { if ( rod != null ) - map.put(canonicalName(rod.getName()), rod); + tmap.put(canonicalName(rod.getName()), rod); } + + // ensure that no one modifies the map itself + map = Collections.unmodifiableMap(tmap); } } @@ -64,76 +73,120 @@ public class RefMetaDataTracker { // // ------------------------------------------------------------------------------------------ + /** + * Gets all of the Tribble features spanning this locus, returning them as a list of specific + * type T extending Feature. This function looks across all tracks to find the Features, so + * if you have two tracks A and B each containing 1 Feature, then getValues will return + * a list containing both features. + * + * Note that this function assumes that all of the bound features are instances of or + * subclasses of T. A ClassCastException will occur if this isn't the case. If you want + * to get all Features without any danger of such an exception use the root Tribble + * interface Feature. + * + * @param type The type of the underlying objects bound here + * @param as above + * @return A freshly allocated list of all of the bindings, or an empty list if none are bound. + */ + @Requires({"type != null"}) + @Ensures("result != null") public List getValues(final Class type) { return addValues(map.keySet(), type, new ArrayList(), null, false, false); } + + /** + * Provides the same functionality as @link #getValues(Class) but will only include + * Features that start as the GenomeLoc provide onlyAtThisLoc. + * + * @param type The type of the underlying objects bound here + * @param onlyAtThisLoc + * @param as above + * @return A freshly allocated list of all of the bindings, or an empty list if none are bound. + */ + @Requires({"type != null", "onlyAtThisLoc != null"}) + @Ensures("result != null") public List getValues(final Class type, final GenomeLoc onlyAtThisLoc) { return addValues(map.keySet(), type, new ArrayList(), onlyAtThisLoc, true, false); } - public List getValues(final Class type, final String name) { - return addValues(name, type, new ArrayList(), getTrackDataByName(name), null, false, false); - } - public List getValues(final Class type, final String name, final GenomeLoc onlyAtThisLoc) { - return addValues(name, type, new ArrayList(), getTrackDataByName(name), onlyAtThisLoc, true, false); - } - public List getValues(final Class type, final Collection names) { - return addValues(names, type, new ArrayList(), null, false, false); - } - public List getValues(final Class type, final Collection names, final GenomeLoc onlyAtThisLoc) { - return addValues(names, type, new ArrayList(), onlyAtThisLoc, true, false); - } + /** + * Uses the same logic as @link #getValues(Class) but arbitrary select one of the resulting + * elements of the list to return. That is, if there would be two elements in the result of + * @link #getValues(Class), one of these two is selected, and which one it will be isn't + * specified. Consequently, this method is only really safe if (1) you absolutely know + * that only one binding will meet the constraints of @link #getValues(Class) or (2) + * you truly don't care which of the multiple bindings available you are going to examine. + * + * If there are no bindings here, getFirstValue() return null + * + * @param type The type of the underlying objects bound here + * @param as above + * @return A random single element the RODs bound here, or null if none are bound. + */ + @Requires({"type != null"}) public T getFirstValue(final Class type) { return safeGetFirst(getValues(type)); } + + /** + * Uses the same logic as @link #getValue(Class,GenomeLoc) to determine the list + * of eligible Features and @link #getFirstValue(Class) to select a single + * element from the interval list. + * + * @param type The type of the underlying objects bound here + * @param as above + * @param onlyAtThisLoc only Features starting at this site are considered + * @return A random single element the RODs bound here starting at onlyAtThisLoc, or null if none are bound. + */ + @Requires({"type != null", "onlyAtThisLoc != null"}) public T getFirstValue(final Class type, final GenomeLoc onlyAtThisLoc) { return safeGetFirst(getValues(type, onlyAtThisLoc)); } - public T getFirstValue(final Class type, final String name) { - return safeGetFirst(getValues(type, name)); - } - public T getFirstValue(final Class type, final String name, final GenomeLoc onlyAtThisLoc) { - return safeGetFirst(getValues(type, name, onlyAtThisLoc)); - } - public T getFirstValue(final Class type, final Collection names) { - return safeGetFirst(getValues(type, names)); - } - public T getFirstValue(final Class type, final Collection names, final GenomeLoc onlyAtThisLoc) { - return safeGetFirst(getValues(type, names, onlyAtThisLoc)); - } // // ROD binding accessors // + @Requires({"rodBinding != null"}) + @Ensures("result != null") public List getValues(final RodBinding rodBinding) { - return getValues(rodBinding.getType(), rodBinding.getName()); + return addValues(rodBinding.getName(), rodBinding.getType(), new ArrayList(1), getTrackDataByName(rodBinding), null, false, false); } + @Requires({"rodBindings != null"}) + @Ensures("result != null") public List getValues(final Collection> rodBindings) { - List results = new ArrayList(); + List results = new ArrayList(1); for ( RodBinding rodBinding : rodBindings ) results.addAll(getValues(rodBinding)); return results; } + @Requires({"rodBinding != null", "onlyAtThisLoc != null"}) + @Ensures("result != null") public List getValues(final RodBinding rodBinding, final GenomeLoc onlyAtThisLoc) { - return getValues(rodBinding.getType(), rodBinding.getName(), onlyAtThisLoc); + return addValues(rodBinding.getName(), rodBinding.getType(), new ArrayList(1), getTrackDataByName(rodBinding), onlyAtThisLoc, true, false); } + @Requires({"rodBindings != null", "onlyAtThisLoc != null"}) + @Ensures("result != null") public List getValues(final Collection> rodBindings, final GenomeLoc onlyAtThisLoc) { - List results = new ArrayList(); + List results = new ArrayList(1); for ( RodBinding rodBinding : rodBindings ) results.addAll(getValues(rodBinding, onlyAtThisLoc)); return results; } + @Requires({"rodBinding != null"}) public T getFirstValue(final RodBinding rodBinding) { - return getFirstValue(rodBinding.getType(), rodBinding.getName()); - } - public T getFirstValue(final RodBinding rodBinding, final GenomeLoc onlyAtThisLoc) { - return getFirstValue(rodBinding.getType(), rodBinding.getName(), onlyAtThisLoc); + return safeGetFirst(addValues(rodBinding.getName(), rodBinding.getType(), null, getTrackDataByName(rodBinding), null, false, true)); } + @Requires({"rodBinding != null", "onlyAtThisLoc != null"}) + public T getFirstValue(final RodBinding rodBinding, final GenomeLoc onlyAtThisLoc) { + return safeGetFirst(addValues(rodBinding.getName(), rodBinding.getType(), null, getTrackDataByName(rodBinding), onlyAtThisLoc, true, true)); + } + + @Requires({"rodBindings != null"}) public T getFirstValue(final Collection> rodBindings) { for ( RodBinding rodBinding : rodBindings ) { T val = getFirstValue(rodBinding); @@ -143,6 +196,7 @@ public class RefMetaDataTracker { return null; } + @Requires({"rodBindings != null", "onlyAtThisLoc != null"}) public T getFirstValue(final Collection> rodBindings, final GenomeLoc onlyAtThisLoc) { for ( RodBinding rodBinding : rodBindings ) { T val = getFirstValue(rodBinding, onlyAtThisLoc); @@ -152,42 +206,58 @@ public class RefMetaDataTracker { return null; } - - + /** + * Is there a binding at this site to a ROD/track with the specified name? + * + * @param rodBinding the rod binding we want to know about + * @return true if any Features are bound in this tracker to rodBinding + */ + @Requires({"rodBinding != null"}) public boolean hasValues(final RodBinding rodBinding) { - return hasValues(rodBinding.getName()); - } - - public List getValuesAsGATKFeatures(final RodBinding rodBinding) { - return getValuesAsGATKFeatures(rodBinding.getName()); + return map.containsKey(canonicalName(rodBinding.getName())); } /** * Helper function for getFirst() operations that takes a list of and * returns the first element, or null if no such element exists. * - * TODO: determine specific behavior for l.size() > 1. Do we turn first or an error? - * TODO: right now we return the first. Should be clearer - * * @param l * @param * @return */ + @Requires({"l != null"}) final private T safeGetFirst(final List l) { - // todo: should we be warning people here? Throwing an error? return l.isEmpty() ? null : l.get(0); } - /** - * Is there a binding at this site to a ROD/track with the specified name? - * - * @param name the name of the rod - * @return true if it has the rod - */ + // + // Deprecated accessors -- will be removed + // + @Deprecated public boolean hasValues(final String name) { return map.containsKey(canonicalName(name)); } + @Deprecated + public List getValues(final Class type, final String name) { + return addValues(name, type, new ArrayList(), getTrackDataByName(name), null, false, false); + } + @Deprecated + public List getValues(final Class type, final String name, final GenomeLoc onlyAtThisLoc) { + return addValues(name, type, new ArrayList(), getTrackDataByName(name), onlyAtThisLoc, true, false); + } + @Deprecated + public List getValues(final Class type, final Collection names, final GenomeLoc onlyAtThisLoc) { + return addValues(names, type, new ArrayList(), onlyAtThisLoc, true, false); + } + @Deprecated + public T getFirstValue(final Class type, final String name) { + return safeGetFirst(getValues(type, name)); + } + @Deprecated + public T getFirstValue(final Class type, final String name, final GenomeLoc onlyAtThisLoc) { + return safeGetFirst(getValues(type, name, onlyAtThisLoc)); + } /** * Get all of the RMDs at the current site. The collection is "flattened": for any track that has multiple records @@ -195,6 +265,7 @@ public class RefMetaDataTracker { * * @return collection of all rods */ + @Deprecated public List getAllValuesAsGATKFeatures() { List l = new ArrayList(); for ( RODRecordList rl : map.values() ) { @@ -204,6 +275,12 @@ public class RefMetaDataTracker { return l; } + @Deprecated + public List getValuesAsGATKFeatures(final RodBinding rodBinding) { + return getValuesAsGATKFeatures(rodBinding.getName()); + } + + /** * get all the GATK features associated with a specific track name * @param name the name of the track we're looking for @@ -211,6 +288,7 @@ public class RefMetaDataTracker { * * Important: The list returned by this function is guaranteed not to be null, but may be empty! */ + @Deprecated public List getValuesAsGATKFeatures(final String name) { return getTrackDataByName(name); } @@ -264,33 +342,6 @@ public class RefMetaDataTracker { } - /** - * get a singleton record, given the name and a type. This function will return the first record at the - * current position seen. The object is cast into a type clazz, or thoses an error if this isn't possible. - * - * * WARNING: we now suppport more than one RMD at a single position for all tracks. If there are - * are multiple RMD objects at this location, there is no contract for which object this method will pick, and which object gets - * picked may change from time to time! BE WARNED! - * - * @param name the name of the track - * @param clazz the underlying type to return - * @param the type to parameterize on, matching the clazz argument - * @return a record of type T, or null if no record is present. - */ - @Deprecated - public T getFirstValue(final String name, final Class clazz) { - RODRecordList objects = getTrackDataByName(name); - - if (objects.isEmpty()) return null; - - Object obj = objects.get(0).getUnderlyingObject(); - if (!(clazz.isAssignableFrom(obj.getClass()))) - throw new UserException.CommandLineException("Unable to case track named " + name + " to type of " + clazz.toString() - + " it's of type " + obj.getClass()); - else - return (T)obj; - } - // ------------------------------------------------------------------------------------------ // // @@ -301,13 +352,15 @@ public class RefMetaDataTracker { private List addValues(final Collection names, final Class type, - final List values, + List values, final GenomeLoc curLocation, final boolean requireStartHere, final boolean takeFirstOnly ) { for ( String name : names ) { RODRecordList rodList = getTrackDataByName(name); // require that the name is an exact match - addValues(name, type, values, rodList, curLocation, requireStartHere, takeFirstOnly ); + values = addValues(name, type, values, rodList, curLocation, requireStartHere, takeFirstOnly ); + if ( takeFirstOnly && ! values.isEmpty() ) + break; } return values; @@ -317,7 +370,7 @@ public class RefMetaDataTracker { private List addValues(final String name, final Class type, - final List values, + List values, final RODRecordList rodList, final GenomeLoc curLocation, final boolean requireStartHere, @@ -329,15 +382,23 @@ public class RefMetaDataTracker { throw new UserException.CommandLineException("Unable to cast track named " + name + " to type of " + type.toString() + " it's of type " + obj.getClass()); - values.add((T)obj); + T objT = (T)obj; + if ( takeFirstOnly ) { + if ( values == null ) + values = Arrays.asList(objT); + else + values.add(objT); - if ( takeFirstOnly ) - // we only want the first passing instance, so break the loop over records in rodList break; + } else { + if ( values == null ) + values = new ArrayList(); + values.add(objT); + } } } - return values; + return values == null ? Collections.emptyList() : values; } /** @@ -358,6 +419,10 @@ public class RefMetaDataTracker { return l == null ? EMPTY_ROD_RECORD_LIST : l; } + private RODRecordList getTrackDataByName(final RodBinding binding) { + return getTrackDataByName(binding.getName()); + } + /** * Returns the canonical name of the rod name (lowercases it) * @param name the name of the rod diff --git a/public/java/src/org/broadinstitute/sting/gatk/walkers/qc/ValidatingPileupWalker.java b/public/java/src/org/broadinstitute/sting/gatk/walkers/qc/ValidatingPileupWalker.java index 0054354c7..bd25a73e0 100755 --- a/public/java/src/org/broadinstitute/sting/gatk/walkers/qc/ValidatingPileupWalker.java +++ b/public/java/src/org/broadinstitute/sting/gatk/walkers/qc/ValidatingPileupWalker.java @@ -26,7 +26,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.refdata.RefMetaDataTracker; @@ -45,8 +47,11 @@ import java.util.Arrays; * each overlapping read, and quality score) to the reference pileup data generated by samtools. Samtools' pileup data * should be specified using the command-line argument '-B pileup,SAMPileup,'. */ -@Requires(value={DataSource.READS,DataSource.REFERENCE},referenceMetaData=@RMD(name="pileup",type=SAMPileupFeature.class)) +@Requires(value={DataSource.READS,DataSource.REFERENCE}) public class ValidatingPileupWalker extends LocusWalker implements TreeReducible { + @Input(fullName = "pileup", doc="The SAMPileup containing the expected output", required = true) + RodBinding pileup; + @Output private PrintStream out; @@ -130,17 +135,17 @@ public class ValidatingPileupWalker extends LocusWalker { + @Input(fullName = "ProbeIntervals", doc="Chris document me", required=true) + RodBinding probeIntervals; + + @Input(fullName = "ValidateAlleles", doc="Chris document me", required=true) + RodBinding validateAlleles; + + @Input(fullName = "MaskAlleles", doc="Chris document me", required=true) + RodBinding maskAlleles; + @Argument(doc="Lower case SNPs rather than replacing with 'N'",fullName="lowerCaseSNPs",required=false) boolean lowerCaseSNPs = false; @@ -99,9 +109,9 @@ public class ValidationAmplicons extends RodWalker { } public Integer map(RefMetaDataTracker tracker, ReferenceContext ref, AlignmentContext context) { - if ( tracker == null || ! tracker.hasValues("ProbeIntervals")) { return null; } + if ( tracker == null || ! tracker.hasValues(probeIntervals)) { return null; } - TableFeature feature = tracker.getFirstValue("ProbeIntervals", TableFeature.class); + TableFeature feature = tracker.getFirstValue(probeIntervals); GenomeLoc interval = feature.getLocation(); //logger.debug(interval); if ( prevInterval == null || ! interval.equals(prevInterval) ) { @@ -138,8 +148,8 @@ public class ValidationAmplicons extends RodWalker { // step 3 (or 1 if not new): // build up the sequence - VariantContext mask = tracker.getFirstValue(VariantContext.class, "MaskAlleles",ref.getLocus()); - VariantContext validate = tracker.getFirstValue(VariantContext.class, "ValidateAlleles",ref.getLocus()); + VariantContext mask = tracker.getFirstValue(maskAlleles, ref.getLocus()); + VariantContext validate = tracker.getFirstValue(validateAlleles,ref.getLocus()); if ( mask == null && validate == null ) { if ( indelCounter > 0 ) { diff --git a/public/java/test/org/broadinstitute/sting/gatk/datasources/providers/ReferenceOrderedViewUnitTest.java b/public/java/test/org/broadinstitute/sting/gatk/datasources/providers/ReferenceOrderedViewUnitTest.java index 52d8fd4d0..dbfaedc1b 100755 --- a/public/java/test/org/broadinstitute/sting/gatk/datasources/providers/ReferenceOrderedViewUnitTest.java +++ b/public/java/test/org/broadinstitute/sting/gatk/datasources/providers/ReferenceOrderedViewUnitTest.java @@ -88,7 +88,7 @@ public class ReferenceOrderedViewUnitTest extends BaseTest { ReferenceOrderedView view = new ManagingReferenceOrderedView( provider ); RefMetaDataTracker tracker = view.getReferenceOrderedDataAtLocus(genomeLocParser.createGenomeLoc("chrM",20), null); - TableFeature datum = tracker.getFirstValue("tableTest", TableFeature.class); + TableFeature datum = tracker.getFirstValue(TableFeature.class, "tableTest"); Assert.assertEquals(datum.get("COL1"),"C","datum parameter for COL1 is incorrect"); Assert.assertEquals(datum.get("COL2"),"D","datum parameter for COL2 is incorrect"); @@ -114,13 +114,13 @@ public class ReferenceOrderedViewUnitTest extends BaseTest { ReferenceOrderedView view = new ManagingReferenceOrderedView( provider ); RefMetaDataTracker tracker = view.getReferenceOrderedDataAtLocus(genomeLocParser.createGenomeLoc("chrM",20), null); - TableFeature datum1 = tracker.getFirstValue("tableTest1", TableFeature.class); + TableFeature datum1 = tracker.getFirstValue(TableFeature.class, "tableTest1"); Assert.assertEquals(datum1.get("COL1"),"C","datum1 parameter for COL1 is incorrect"); Assert.assertEquals(datum1.get("COL2"),"D","datum1 parameter for COL2 is incorrect"); Assert.assertEquals(datum1.get("COL3"),"E","datum1 parameter for COL3 is incorrect"); - TableFeature datum2 = tracker.getFirstValue("tableTest2", TableFeature.class); + TableFeature datum2 = tracker.getFirstValue(TableFeature.class, "tableTest2"); Assert.assertEquals(datum2.get("COL1"),"C","datum2 parameter for COL1 is incorrect"); Assert.assertEquals(datum2.get("COL2"),"D","datum2 parameter for COL2 is incorrect"); diff --git a/public/java/test/org/broadinstitute/sting/gatk/refdata/RefMetaDataTrackerUnitTest.java b/public/java/test/org/broadinstitute/sting/gatk/refdata/RefMetaDataTrackerUnitTest.java index afb6e418a..4c5bdbcda 100644 --- a/public/java/test/org/broadinstitute/sting/gatk/refdata/RefMetaDataTrackerUnitTest.java +++ b/public/java/test/org/broadinstitute/sting/gatk/refdata/RefMetaDataTrackerUnitTest.java @@ -76,6 +76,11 @@ public class RefMetaDataTrackerUnitTest { span10_20 = makeSpan(10, 20); } + @BeforeMethod + public void reset() { + RodBinding.resetNameCounter(); + } + private class MyTest extends BaseTest.TestDataProvider { public RODRecordList AValues, BValues; 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 5a6a66bbd..84e52f037 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 @@ -14,7 +14,7 @@ public class VariantAnnotatorIntegrationTest extends WalkerTest { @Test public void testHasAnnotsNotAsking1() { WalkerTestSpec spec = new WalkerTestSpec( - baseTestString() + " -B:variant,VCF3 " + validationDataLocation + "vcfexample2.vcf -I " + validationDataLocation + "low_coverage_CEU.chr1.10k-11k.bam -L 1:10,020,000-10,021,000", 1, + baseTestString() + " --variants:VCF3 " + validationDataLocation + "vcfexample2.vcf -I " + validationDataLocation + "low_coverage_CEU.chr1.10k-11k.bam -L 1:10,020,000-10,021,000", 1, Arrays.asList("8a105fa5eebdfffe7326bc5b3d8ffd1c")); executeTest("test file has annotations, not asking for annotations, #1", spec); } @@ -22,7 +22,7 @@ public class VariantAnnotatorIntegrationTest extends WalkerTest { @Test public void testHasAnnotsNotAsking2() { WalkerTestSpec spec = new WalkerTestSpec( - baseTestString() + " -B:variant,VCF3 " + validationDataLocation + "vcfexample3.vcf -I " + validationDataLocation + "NA12878.1kg.p2.chr1_10mb_11_mb.SLX.bam -L 1:10,000,000-10,050,000", 1, + baseTestString() + " --variants:VCF3 " + validationDataLocation + "vcfexample3.vcf -I " + validationDataLocation + "NA12878.1kg.p2.chr1_10mb_11_mb.SLX.bam -L 1:10,000,000-10,050,000", 1, Arrays.asList("964f1016ec9a3c55333f62dd834c14d6")); executeTest("test file has annotations, not asking for annotations, #2", spec); } @@ -30,7 +30,7 @@ public class VariantAnnotatorIntegrationTest extends WalkerTest { @Test public void testHasAnnotsAsking1() { WalkerTestSpec spec = new WalkerTestSpec( - baseTestString() + " -G \"Standard\" -B:variant,VCF3 " + validationDataLocation + "vcfexample2.vcf -I " + validationDataLocation + "low_coverage_CEU.chr1.10k-11k.bam -L 1:10,020,000-10,021,000", 1, + baseTestString() + " -G \"Standard\" --variants:VCF3 " + validationDataLocation + "vcfexample2.vcf -I " + validationDataLocation + "low_coverage_CEU.chr1.10k-11k.bam -L 1:10,020,000-10,021,000", 1, Arrays.asList("8e7de435105499cd71ffc099e268a83e")); executeTest("test file has annotations, asking for annotations, #1", spec); } @@ -38,7 +38,7 @@ public class VariantAnnotatorIntegrationTest extends WalkerTest { @Test public void testHasAnnotsAsking2() { WalkerTestSpec spec = new WalkerTestSpec( - baseTestString() + " -G \"Standard\" -B:variant,VCF3 " + validationDataLocation + "vcfexample3.vcf -I " + validationDataLocation + "NA12878.1kg.p2.chr1_10mb_11_mb.SLX.bam -L 1:10,000,000-10,050,000", 1, + baseTestString() + " -G \"Standard\" --variants:VCF3 " + validationDataLocation + "vcfexample3.vcf -I " + validationDataLocation + "NA12878.1kg.p2.chr1_10mb_11_mb.SLX.bam -L 1:10,000,000-10,050,000", 1, Arrays.asList("64b6804cb1e27826e3a47089349be581")); executeTest("test file has annotations, asking for annotations, #2", spec); } @@ -46,7 +46,7 @@ public class VariantAnnotatorIntegrationTest extends WalkerTest { @Test public void testNoAnnotsNotAsking1() { WalkerTestSpec spec = new WalkerTestSpec( - baseTestString() + " -B:variant,VCF3 " + validationDataLocation + "vcfexample2empty.vcf -I " + validationDataLocation + "low_coverage_CEU.chr1.10k-11k.bam -L 1:10,020,000-10,021,000", 1, + baseTestString() + " --variants:VCF3 " + validationDataLocation + "vcfexample2empty.vcf -I " + validationDataLocation + "low_coverage_CEU.chr1.10k-11k.bam -L 1:10,020,000-10,021,000", 1, Arrays.asList("42ccee09fa9f8c58f4a0d4f1139c094f")); executeTest("test file doesn't have annotations, not asking for annotations, #1", spec); } @@ -54,7 +54,7 @@ public class VariantAnnotatorIntegrationTest extends WalkerTest { @Test public void testNoAnnotsNotAsking2() { WalkerTestSpec spec = new WalkerTestSpec( - baseTestString() + " -B:variant,VCF3 " + validationDataLocation + "vcfexample3empty.vcf -I " + validationDataLocation + "NA12878.1kg.p2.chr1_10mb_11_mb.SLX.bam -L 1:10,000,000-10,050,000", 1, + baseTestString() + " --variants:VCF3 " + validationDataLocation + "vcfexample3empty.vcf -I " + validationDataLocation + "NA12878.1kg.p2.chr1_10mb_11_mb.SLX.bam -L 1:10,000,000-10,050,000", 1, Arrays.asList("f2ddfa8105c290b1f34b7a261a02a1ac")); executeTest("test file doesn't have annotations, not asking for annotations, #2", spec); } @@ -62,7 +62,7 @@ public class VariantAnnotatorIntegrationTest extends WalkerTest { @Test public void testNoAnnotsAsking1() { WalkerTestSpec spec = new WalkerTestSpec( - baseTestString() + " -G \"Standard\" -B:variant,VCF3 " + validationDataLocation + "vcfexample2empty.vcf -I " + validationDataLocation + "low_coverage_CEU.chr1.10k-11k.bam -L 1:10,020,000-10,021,000", 1, + baseTestString() + " -G \"Standard\" --variants:VCF3 " + validationDataLocation + "vcfexample2empty.vcf -I " + validationDataLocation + "low_coverage_CEU.chr1.10k-11k.bam -L 1:10,020,000-10,021,000", 1, Arrays.asList("fd1ffb669800c2e07df1e2719aa38e49")); executeTest("test file doesn't have annotations, asking for annotations, #1", spec); } @@ -70,7 +70,7 @@ public class VariantAnnotatorIntegrationTest extends WalkerTest { @Test public void testNoAnnotsAsking2() { WalkerTestSpec spec = new WalkerTestSpec( - baseTestString() + " -G \"Standard\" -B:variant,VCF3 " + validationDataLocation + "vcfexample3empty.vcf -I " + validationDataLocation + "NA12878.1kg.p2.chr1_10mb_11_mb.SLX.bam -L 1:10,000,000-10,050,000", 1, + baseTestString() + " -G \"Standard\" --variants:VCF3 " + validationDataLocation + "vcfexample3empty.vcf -I " + validationDataLocation + "NA12878.1kg.p2.chr1_10mb_11_mb.SLX.bam -L 1:10,000,000-10,050,000", 1, Arrays.asList("09f8e840770a9411ff77508e0ed0837f")); executeTest("test file doesn't have annotations, asking for annotations, #2", spec); } @@ -78,7 +78,7 @@ public class VariantAnnotatorIntegrationTest extends WalkerTest { @Test public void testOverwritingHeader() { WalkerTestSpec spec = new WalkerTestSpec( - baseTestString() + " -G \"Standard\" -B:variant,VCF " + validationDataLocation + "vcfexample4.vcf -I " + validationDataLocation + "NA12878.1kg.p2.chr1_10mb_11_mb.SLX.bam -L 1:10,001,292", 1, + baseTestString() + " -G \"Standard\" --variants:VCF " + validationDataLocation + "vcfexample4.vcf -I " + validationDataLocation + "NA12878.1kg.p2.chr1_10mb_11_mb.SLX.bam -L 1:10,001,292", 1, Arrays.asList("78d2c19f8107d865970dbaf3e12edd92")); executeTest("test overwriting header", spec); } @@ -86,7 +86,7 @@ public class VariantAnnotatorIntegrationTest extends WalkerTest { @Test public void testNoReads() { WalkerTestSpec spec = new WalkerTestSpec( - baseTestString() + " -G \"Standard\" -B:variant,VCF3 " + validationDataLocation + "vcfexample3empty.vcf -BTI variant", 1, + baseTestString() + " -G \"Standard\" --variants:VCF3 " + validationDataLocation + "vcfexample3empty.vcf -BTI variants", 1, Arrays.asList("16e3a1403fc376320d7c69492cad9345")); executeTest("not passing it any reads", spec); } @@ -94,7 +94,7 @@ public class VariantAnnotatorIntegrationTest extends WalkerTest { @Test public void testDBTagWithDbsnp() { WalkerTestSpec spec = new WalkerTestSpec( - baseTestString() + " -B:dbsnp,vcf " + GATKDataLocation + "dbsnp_132.b36.excluding_sites_after_129.vcf -G \"Standard\" -B:variant,VCF3 " + validationDataLocation + "vcfexample3empty.vcf -BTI variant", 1, + baseTestString() + " -B:dbsnp,vcf " + GATKDataLocation + "dbsnp_132.b36.excluding_sites_after_129.vcf -G \"Standard\" --variants:VCF3 " + validationDataLocation + "vcfexample3empty.vcf -BTI variants", 1, Arrays.asList("3da8ca2b6bdaf6e92d94a8c77a71313d")); executeTest("getting DB tag with dbSNP", spec); } @@ -102,7 +102,7 @@ public class VariantAnnotatorIntegrationTest extends WalkerTest { @Test public void testDBTagWithHapMap() { WalkerTestSpec spec = new WalkerTestSpec( - baseTestString() + " -B:compH3,VCF " + validationDataLocation + "fakeHM3.vcf -G \"Standard\" -B:variant,VCF3 " + validationDataLocation + "vcfexample3empty.vcf -BTI variant", 1, + baseTestString() + " -B:compH3,VCF " + validationDataLocation + "fakeHM3.vcf -G \"Standard\" --variants:VCF3 " + validationDataLocation + "vcfexample3empty.vcf -BTI variants", 1, Arrays.asList("1bc01c5b3bd0b7aef75230310c3ce688")); executeTest("getting DB tag with HM3", spec); } @@ -110,7 +110,7 @@ public class VariantAnnotatorIntegrationTest extends WalkerTest { @Test public void testUsingExpression() { WalkerTestSpec spec = new WalkerTestSpec( - baseTestString() + " -B:foo,VCF " + validationDataLocation + "targetAnnotations.vcf -G \"Standard\" -B:variant,VCF3 " + validationDataLocation + "vcfexample3empty.vcf -E foo.AF -BTI variant", 1, + baseTestString() + " -B:foo,VCF " + validationDataLocation + "targetAnnotations.vcf -G \"Standard\" --variants:VCF3 " + validationDataLocation + "vcfexample3empty.vcf -E foo.AF -BTI variants", 1, Arrays.asList("e9c0d832dc6b4ed06c955060f830c140")); executeTest("using expression", spec); } @@ -120,7 +120,7 @@ public class VariantAnnotatorIntegrationTest extends WalkerTest { final String MD5 = "13269d5a2e16f06fd755cc0fb9271acf"; for ( String file : Arrays.asList("CEU.exon.2010_03.sites.vcf", "CEU.exon.2010_03.sites.vcf.gz")) { WalkerTestSpec spec = new WalkerTestSpec( - baseTestString() + " -A HomopolymerRun -B:variant,VCF " + validationDataLocation + "/" + file + " -BTI variant -NO_HEADER", 1, + baseTestString() + " -A HomopolymerRun --variants:VCF " + validationDataLocation + "/" + file + " -BTI variants -NO_HEADER", 1, Arrays.asList(MD5)); executeTest("Testing lookup vcf tabix vs. vcf tribble", spec); } diff --git a/public/java/test/org/broadinstitute/sting/gatk/walkers/filters/VariantFiltrationIntegrationTest.java b/public/java/test/org/broadinstitute/sting/gatk/walkers/filters/VariantFiltrationIntegrationTest.java index 85b7ea8e7..05c0c0982 100755 --- a/public/java/test/org/broadinstitute/sting/gatk/walkers/filters/VariantFiltrationIntegrationTest.java +++ b/public/java/test/org/broadinstitute/sting/gatk/walkers/filters/VariantFiltrationIntegrationTest.java @@ -86,7 +86,7 @@ public class VariantFiltrationIntegrationTest extends WalkerTest { @Test public void testDeletions() { WalkerTestSpec spec = new WalkerTestSpec( - baseTestString() + " --filterExpression 'QUAL < 100' --filterName foo --variants:VCF3 " + validationDataLocation + "twoDeletions.vcf", 1, + baseTestString() + " --filterExpression 'QUAL < 100' --filterName foo --variants:VCF " + validationDataLocation + "twoDeletions.vcf", 1, Arrays.asList("569546fd798afa0e65c5b61b440d07ac")); executeTest("test deletions", spec); } diff --git a/public/java/test/org/broadinstitute/sting/utils/codecs/vcf/VCFIntegrationTest.java b/public/java/test/org/broadinstitute/sting/utils/codecs/vcf/VCFIntegrationTest.java index 741e0bd17..ae64ba6f8 100644 --- a/public/java/test/org/broadinstitute/sting/utils/codecs/vcf/VCFIntegrationTest.java +++ b/public/java/test/org/broadinstitute/sting/utils/codecs/vcf/VCFIntegrationTest.java @@ -17,7 +17,7 @@ public class VCFIntegrationTest extends WalkerTest { String baseCommand = "-R " + b37KGReference + " -NO_HEADER -o %s "; - String test1 = baseCommand + "-T VariantAnnotator -BTI variant --variants:vcf " + testVCF; + String test1 = baseCommand + "-T VariantAnnotator -BTI variants --variants:vcf " + testVCF; WalkerTestSpec spec1 = new WalkerTestSpec(test1, 1, Arrays.asList(md5ofInputVCF)); List result = executeTest("Test Variant Annotator with no changes", spec1).getFirst();