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,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);
|
||||
|
|
|
|||
|
|
@ -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<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" +
|
||||
" -R " + reference +
|
||||
" -I " + validationDataLocation + reads +
|
||||
" -B:variant,VCF " + validationDataLocation + VCF +
|
||||
" --variants " + validationDataLocation + VCF +
|
||||
" --cacheWindowSize " + cacheWindowSize +
|
||||
" --maxPhaseSites " + maxPhaseSites +
|
||||
" --phaseQualityThresh " + phaseQualityThresh +
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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<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));
|
||||
executeTest("Test Variants To VCF from new output", spec2);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue