diff --git a/public/java/src/org/broadinstitute/sting/commandline/ArgumentTypeDescriptor.java b/public/java/src/org/broadinstitute/sting/commandline/ArgumentTypeDescriptor.java index ebed68022..0fb8bbd3a 100644 --- a/public/java/src/org/broadinstitute/sting/commandline/ArgumentTypeDescriptor.java +++ b/public/java/src/org/broadinstitute/sting/commandline/ArgumentTypeDescriptor.java @@ -317,39 +317,46 @@ class RodBindingArgumentTypeDescriptor extends ArgumentTypeDescriptor { String tribbleType = null; Tags tags = getArgumentTags(matches); // must have one or two tag values here - if ( tags.getPositionalTags().size() == 2 ) { // -X:name,type style + if ( tags.getPositionalTags().size() > 2 ) { + throw new UserException.CommandLineException( + String.format("Unexpected number of positional tags for argument %s : %s. " + + "Rod bindings only suport -X:type and -X:name,type argument styles", + value, source.field.getName())); + } if ( tags.getPositionalTags().size() == 2 ) { + // -X:name,type style name = tags.getPositionalTags().get(0); tribbleType = tags.getPositionalTags().get(1); } else { - if ( tags.getPositionalTags().size() == 1 ) { - // -X:type style is a type when we cannot determine the type dynamically - tribbleType = tags.getPositionalTags().get(0); + // case with 0 or 1 positional tags + FeatureManager manager = new FeatureManager(); + + // -X:type style is a type when we cannot determine the type dynamically + String tag1 = tags.getPositionalTags().size() == 1 ? tags.getPositionalTags().get(0) : null; + if ( tag1 != null ) { + if ( manager.getByName(tag1) != null ) // this a type + tribbleType = tag1; + else + name = tag1; } - // try to determine the file type dynamically - FeatureManager manager = new FeatureManager(); - File file = new File(value); - if ( file.canRead() && file.isFile() ) { - FeatureManager.FeatureDescriptor featureDescriptor = manager.getByFiletype(file); - if ( featureDescriptor != null ) { - tribbleType = featureDescriptor.getName(); - logger.warn("Dynamically determined type of " + file + " to be " + tribbleType); - - if ( tags.getPositionalTags().size() == 1 ) { - // -X:type style is a name when we can determine the type dynamically - name = tags.getPositionalTags().get(0); + if ( tribbleType == null ) { + // try to determine the file type dynamically + File file = new File(value); + if ( file.canRead() && file.isFile() ) { + FeatureManager.FeatureDescriptor featureDescriptor = manager.getByFiletype(file); + if ( featureDescriptor != null ) { + tribbleType = featureDescriptor.getName(); + logger.warn("Dynamically determined type of " + file + " to be " + tribbleType); } } } - - // now, if we haven't found a type - if ( tribbleType == null ) - throw new UserException.CommandLineException( - String.format("Unexpected number of positional tags for argument %s : %s. " + - "Rod bindings only suport -X:type and -X:name,type argument styles", - value, source.field.getName())); } + if ( tribbleType == null ) // error handling + throw new UserException.CommandLineException( + String.format("Could not parse argument %s with value %s", + defaultDefinition.fullName, value)); + Constructor ctor = (makeRawTypeIfNecessary(type)).getConstructor(Class.class, String.class, String.class, String.class, Tags.class); Class parameterType = getParameterizedTypeClass(type); RodBinding result = (RodBinding)ctor.newInstance(parameterType, name, value, tribbleType, tags); diff --git a/public/java/test/org/broadinstitute/sting/gatk/EngineFeaturesIntegrationTest.java b/public/java/test/org/broadinstitute/sting/gatk/EngineFeaturesIntegrationTest.java index cdca08abd..80a8d2fa4 100644 --- a/public/java/test/org/broadinstitute/sting/gatk/EngineFeaturesIntegrationTest.java +++ b/public/java/test/org/broadinstitute/sting/gatk/EngineFeaturesIntegrationTest.java @@ -24,26 +24,16 @@ package org.broadinstitute.sting.gatk; -import org.broad.tribble.Feature; import org.broadinstitute.sting.WalkerTest; -import org.broadinstitute.sting.commandline.Input; -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.RodWalker; import org.broadinstitute.sting.utils.exceptions.UserException; -import org.testng.Assert; import org.testng.annotations.Test; -import java.util.List; - /** * */ public class EngineFeaturesIntegrationTest extends WalkerTest { private void testBadRODBindingInput(String type, String name, Class c) { - WalkerTestSpec spec = new WalkerTestSpec("-T SelectVariants -L 1:1 --variants:" + type + " " + WalkerTestSpec spec = new WalkerTestSpec("-T SelectVariants -L 1:1 --variants:variants," + type + " " + b37dbSNP132 + " -R " + b37KGReference + " -o %s", 1, c); executeTest(name, spec); @@ -64,27 +54,4 @@ public class EngineFeaturesIntegrationTest extends WalkerTest { @Test() private void testBadRODBindingInputTypeUnknownType() { testBadRODBindingInput("bedXXX", "Unknown input to VCF expecting walker", UserException.UnknownTribbleType.class); } -} - -//class TestRodBindings extends RodWalker { -// @Input(fullName="req", required=true) -// public RodBinding required; -// -// @Input(fullName="optional", required=false) -// public RodBinding optional = RodBinding.makeUnbound(Feature.class); -// -// @Input(fullName="rodList", shortName="RL", doc="A list of ROD types that we will convert to a table", required=true) -// public List> variantsList; -// -// public void initialize() { -// // bound values -// Assert.assertEquals(required.isBound(), true); -// -// -// System.exit(0); -// } -// -// public Integer map(RefMetaDataTracker tracker, ReferenceContext ref, AlignmentContext context) { return 0; } -// public Integer reduceInit() { return 0; } -// public Integer reduce(Integer counter, Integer sum) { return counter + sum; } -//} \ No newline at end of file +} \ No newline at end of file diff --git a/public/java/test/org/broadinstitute/sting/gatk/walkers/phasing/ReadBackedPhasingIntegrationTest.java b/public/java/test/org/broadinstitute/sting/gatk/walkers/phasing/ReadBackedPhasingIntegrationTest.java index 1bf3e579f..3566ecd05 100644 --- a/public/java/test/org/broadinstitute/sting/gatk/walkers/phasing/ReadBackedPhasingIntegrationTest.java +++ b/public/java/test/org/broadinstitute/sting/gatk/walkers/phasing/ReadBackedPhasingIntegrationTest.java @@ -11,7 +11,7 @@ public class ReadBackedPhasingIntegrationTest extends WalkerTest { return "-T ReadBackedPhasing" + " -R " + reference + " -I " + validationDataLocation + reads + - " -B:variant,VCF " + validationDataLocation + VCF + + " --variants " + validationDataLocation + VCF + " --cacheWindowSize " + cacheWindowSize + " --maxPhaseSites " + maxPhaseSites + " --phaseQualityThresh " + phaseQualityThresh + diff --git a/public/java/test/org/broadinstitute/sting/gatk/walkers/variantutils/CombineVariantsIntegrationTest.java b/public/java/test/org/broadinstitute/sting/gatk/walkers/variantutils/CombineVariantsIntegrationTest.java index f52504ccb..4abf0a102 100755 --- a/public/java/test/org/broadinstitute/sting/gatk/walkers/variantutils/CombineVariantsIntegrationTest.java +++ b/public/java/test/org/broadinstitute/sting/gatk/walkers/variantutils/CombineVariantsIntegrationTest.java @@ -72,7 +72,7 @@ public class CombineVariantsIntegrationTest extends WalkerTest { public void combinePLs(String file1, String file2, String md5) { WalkerTestSpec spec = new WalkerTestSpec( - "-T CombineVariants -NO_HEADER -o %s -R " + b36KGReference + " -priority v1,v2 -B:v1,VCF " + validationDataLocation + file1 + " -B:v2,VCF " + validationDataLocation + file2, + "-T CombineVariants -NO_HEADER -o %s -R " + b36KGReference + " -priority v1,v2 -V:v1 " + validationDataLocation + file1 + " -V:v2 " + validationDataLocation + file2, 1, Arrays.asList(md5)); executeTest("combine PLs 1:" + new File(file1).getName() + " 2:" + new File(file2).getName(), 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 a89c0315c..e758ce0a2 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,11 +17,11 @@ public class VCFIntegrationTest extends WalkerTest { String baseCommand = "-R " + b37KGReference + " -NO_HEADER -o %s "; - String test1 = baseCommand + "-T VariantAnnotator --variants:vcf " + testVCF + " -BTI variants"; + String test1 = baseCommand + "-T VariantAnnotator --variants " + testVCF + " -BTI variants"; WalkerTestSpec spec1 = new WalkerTestSpec(test1, 1, Arrays.asList(md5ofInputVCF)); List result = executeTest("Test Variant Annotator with no changes", spec1).getFirst(); - String test2 = baseCommand + "-T VariantsToVCF --variants:vcf " + result.get(0).getAbsolutePath(); + String test2 = baseCommand + "-T VariantsToVCF --variants " + result.get(0).getAbsolutePath(); WalkerTestSpec spec2 = new WalkerTestSpec(test2, 1, Arrays.asList(md5ofInputVCF)); executeTest("Test Variants To VCF from new output", spec2); }