Single positional arguments are now treated as names unless they actually match a tribble feature
This commit is contained in:
parent
f8a56bc64b
commit
80924d24de
|
|
@ -317,38 +317,45 @@ class RodBindingArgumentTypeDescriptor extends ArgumentTypeDescriptor {
|
||||||
String tribbleType = null;
|
String tribbleType = null;
|
||||||
Tags tags = getArgumentTags(matches);
|
Tags tags = getArgumentTags(matches);
|
||||||
// must have one or two tag values here
|
// 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);
|
name = tags.getPositionalTags().get(0);
|
||||||
tribbleType = tags.getPositionalTags().get(1);
|
tribbleType = tags.getPositionalTags().get(1);
|
||||||
} else {
|
} else {
|
||||||
if ( tags.getPositionalTags().size() == 1 ) {
|
// case with 0 or 1 positional tags
|
||||||
|
FeatureManager manager = new FeatureManager();
|
||||||
|
|
||||||
// -X:type style is a type when we cannot determine the type dynamically
|
// -X:type style is a type when we cannot determine the type dynamically
|
||||||
tribbleType = tags.getPositionalTags().get(0);
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( tribbleType == null ) {
|
||||||
// try to determine the file type dynamically
|
// try to determine the file type dynamically
|
||||||
FeatureManager manager = new FeatureManager();
|
|
||||||
File file = new File(value);
|
File file = new File(value);
|
||||||
if ( file.canRead() && file.isFile() ) {
|
if ( file.canRead() && file.isFile() ) {
|
||||||
FeatureManager.FeatureDescriptor featureDescriptor = manager.getByFiletype(file);
|
FeatureManager.FeatureDescriptor featureDescriptor = manager.getByFiletype(file);
|
||||||
if ( featureDescriptor != null ) {
|
if ( featureDescriptor != null ) {
|
||||||
tribbleType = featureDescriptor.getName();
|
tribbleType = featureDescriptor.getName();
|
||||||
logger.warn("Dynamically determined type of " + file + " to be " + tribbleType);
|
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);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// now, if we haven't found a type
|
if ( tribbleType == null ) // error handling
|
||||||
if ( tribbleType == null )
|
|
||||||
throw new UserException.CommandLineException(
|
throw new UserException.CommandLineException(
|
||||||
String.format("Unexpected number of positional tags for argument %s : %s. " +
|
String.format("Could not parse argument %s with value %s",
|
||||||
"Rod bindings only suport -X:type and -X:name,type argument styles",
|
defaultDefinition.fullName, value));
|
||||||
value, source.field.getName()));
|
|
||||||
}
|
|
||||||
|
|
||||||
Constructor ctor = (makeRawTypeIfNecessary(type)).getConstructor(Class.class, String.class, String.class, String.class, Tags.class);
|
Constructor ctor = (makeRawTypeIfNecessary(type)).getConstructor(Class.class, String.class, String.class, String.class, Tags.class);
|
||||||
Class parameterType = getParameterizedTypeClass(type);
|
Class parameterType = getParameterizedTypeClass(type);
|
||||||
|
|
|
||||||
|
|
@ -24,26 +24,16 @@
|
||||||
|
|
||||||
package org.broadinstitute.sting.gatk;
|
package org.broadinstitute.sting.gatk;
|
||||||
|
|
||||||
import org.broad.tribble.Feature;
|
|
||||||
import org.broadinstitute.sting.WalkerTest;
|
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.broadinstitute.sting.utils.exceptions.UserException;
|
||||||
import org.testng.Assert;
|
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class EngineFeaturesIntegrationTest extends WalkerTest {
|
public class EngineFeaturesIntegrationTest extends WalkerTest {
|
||||||
private void testBadRODBindingInput(String type, String name, Class c) {
|
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",
|
+ b37dbSNP132 + " -R " + b37KGReference + " -o %s",
|
||||||
1, c);
|
1, c);
|
||||||
executeTest(name, spec);
|
executeTest(name, spec);
|
||||||
|
|
@ -65,26 +55,3 @@ public class EngineFeaturesIntegrationTest extends WalkerTest {
|
||||||
testBadRODBindingInput("bedXXX", "Unknown input to VCF expecting walker", UserException.UnknownTribbleType.class);
|
testBadRODBindingInput("bedXXX", "Unknown input to VCF expecting walker", UserException.UnknownTribbleType.class);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//class TestRodBindings extends RodWalker<Integer, Integer> {
|
|
||||||
// @Input(fullName="req", required=true)
|
|
||||||
// public RodBinding<Feature> required;
|
|
||||||
//
|
|
||||||
// @Input(fullName="optional", required=false)
|
|
||||||
// public RodBinding<Feature> 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<RodBinding<Feature>> 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; }
|
|
||||||
//}
|
|
||||||
|
|
@ -11,7 +11,7 @@ public class ReadBackedPhasingIntegrationTest extends WalkerTest {
|
||||||
return "-T ReadBackedPhasing" +
|
return "-T ReadBackedPhasing" +
|
||||||
" -R " + reference +
|
" -R " + reference +
|
||||||
" -I " + validationDataLocation + reads +
|
" -I " + validationDataLocation + reads +
|
||||||
" -B:variant,VCF " + validationDataLocation + VCF +
|
" --variants " + validationDataLocation + VCF +
|
||||||
" --cacheWindowSize " + cacheWindowSize +
|
" --cacheWindowSize " + cacheWindowSize +
|
||||||
" --maxPhaseSites " + maxPhaseSites +
|
" --maxPhaseSites " + maxPhaseSites +
|
||||||
" --phaseQualityThresh " + phaseQualityThresh +
|
" --phaseQualityThresh " + phaseQualityThresh +
|
||||||
|
|
|
||||||
|
|
@ -72,7 +72,7 @@ public class CombineVariantsIntegrationTest extends WalkerTest {
|
||||||
|
|
||||||
public void combinePLs(String file1, String file2, String md5) {
|
public void combinePLs(String file1, String file2, String md5) {
|
||||||
WalkerTestSpec spec = new WalkerTestSpec(
|
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,
|
1,
|
||||||
Arrays.asList(md5));
|
Arrays.asList(md5));
|
||||||
executeTest("combine PLs 1:" + new File(file1).getName() + " 2:" + new File(file2).getName(), spec);
|
executeTest("combine PLs 1:" + new File(file1).getName() + " 2:" + new File(file2).getName(), spec);
|
||||||
|
|
|
||||||
|
|
@ -17,11 +17,11 @@ public class VCFIntegrationTest extends WalkerTest {
|
||||||
|
|
||||||
String baseCommand = "-R " + b37KGReference + " -NO_HEADER -o %s ";
|
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));
|
WalkerTestSpec spec1 = new WalkerTestSpec(test1, 1, Arrays.asList(md5ofInputVCF));
|
||||||
List<File> result = executeTest("Test Variant Annotator with no changes", spec1).getFirst();
|
List<File> 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));
|
WalkerTestSpec spec2 = new WalkerTestSpec(test2, 1, Arrays.asList(md5ofInputVCF));
|
||||||
executeTest("Test Variants To VCF from new output", spec2);
|
executeTest("Test Variants To VCF from new output", spec2);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue