Removed support for RMD in @Requires and @Allows
Merge as well Conflicts: private/java/src/org/broadinstitute/sting/gatk/walkers/qc/TestVariantContextWalker.java public/java/src/org/broadinstitute/sting/gatk/walkers/phasing/PhaseByTransmission.java public/java/src/org/broadinstitute/sting/gatk/walkers/variantrecalibration/VariantDataManager.java public/java/src/org/broadinstitute/sting/gatk/walkers/variantutils/SelectVariants.java public/java/src/org/broadinstitute/sting/gatk/walkers/variantutils/VariantValidationAssessor.java public/java/test/org/broadinstitute/sting/gatk/walkers/recalibration/RecalibrationWalkersIntegrationTest.java public/java/test/org/broadinstitute/sting/gatk/walkers/recalibration/RecalibrationWalkersPerformanceTest.java public/java/test/org/broadinstitute/sting/gatk/walkers/varianteval/VariantEvalIntegrationTest.java public/java/test/org/broadinstitute/sting/utils/variantcontext/VariantContextIntegrationTest.java
This commit is contained in:
parent
79e4a8f6d3
commit
f6563c0f9f
|
|
@ -370,33 +370,6 @@ public class GenomeAnalysisEngine {
|
|||
throw new ArgumentException("Walker does not allow a reference but one was provided.");
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies that all required reference-ordered data has been supplied, and any reference-ordered data that was not
|
||||
* 'allowed' is still present.
|
||||
*
|
||||
* @param rods Reference-ordered data to load.
|
||||
*/
|
||||
protected void validateSuppliedReferenceOrderedData(List<ReferenceOrderedDataSource> rods) {
|
||||
// Check to make sure that all required metadata is present.
|
||||
List<RMD> allRequired = WalkerManager.getRequiredMetaData(walker);
|
||||
for (RMD required : allRequired) {
|
||||
boolean found = false;
|
||||
for (ReferenceOrderedDataSource rod : rods) {
|
||||
if (rod.matchesNameAndRecordType(required.name(), required.type()))
|
||||
found = true;
|
||||
}
|
||||
if (!found)
|
||||
throw new ArgumentException(String.format("Walker requires reference metadata to be supplied named '%s' of type '%s', but this metadata was not provided. " +
|
||||
"Please supply the specified metadata file.", required.name(), required.type().getSimpleName()));
|
||||
}
|
||||
|
||||
// Check to see that no forbidden rods are present.
|
||||
for (ReferenceOrderedDataSource rod : rods) {
|
||||
if (!WalkerManager.isAllowed(walker, rod))
|
||||
throw new ArgumentException(String.format("Walker of type %s does not allow access to metadata: %s", walker.getClass(), rod.getName()));
|
||||
}
|
||||
}
|
||||
|
||||
protected void validateSuppliedIntervals() {
|
||||
// Only read walkers support '-L unmapped' intervals. Trap and validate any other instances of -L unmapped.
|
||||
if(!(walker instanceof ReadWalker)) {
|
||||
|
|
@ -936,7 +909,6 @@ public class GenomeAnalysisEngine {
|
|||
flashbackData()));
|
||||
|
||||
// validation: check to make sure everything the walker needs is present, and that all sequence dictionaries match.
|
||||
validateSuppliedReferenceOrderedData(dataSources);
|
||||
validateSourcesAgainstReference(readsDataSource, referenceDataSource.getReference(), dataSources, builder);
|
||||
|
||||
return dataSources;
|
||||
|
|
|
|||
|
|
@ -177,19 +177,7 @@ public class WalkerManager extends PluginManager<Walker> {
|
|||
* @return The list of allowed reference meta data.
|
||||
*/
|
||||
public static List<RMD> getAllowsMetaData(Class<? extends Walker> walkerClass) {
|
||||
Allows allowsDataSource = getWalkerAllowed(walkerClass);
|
||||
if (allowsDataSource == null)
|
||||
return Collections.<RMD>emptyList();
|
||||
return Arrays.asList(allowsDataSource.referenceMetaData());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of RODs allowed by the walker.
|
||||
* @param walker Walker to query.
|
||||
* @return The list of allowed reference meta data.
|
||||
*/
|
||||
public static List<RMD> getAllowsMetaData(Walker walker) {
|
||||
return getAllowsMetaData(walker.getClass());
|
||||
return Collections.<RMD>emptyList();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -226,24 +214,7 @@ public class WalkerManager extends PluginManager<Walker> {
|
|||
* @return True if the walker forbids this data type. False otherwise.
|
||||
*/
|
||||
public static boolean isAllowed(Class<? extends Walker> walkerClass, ReferenceOrderedDataSource rod) {
|
||||
Allows allowsDataSource = getWalkerAllowed(walkerClass);
|
||||
|
||||
// Allows is less restrictive than requires. If an allows
|
||||
// clause is not specified, any kind of data is allowed.
|
||||
if( allowsDataSource == null )
|
||||
return true;
|
||||
|
||||
// The difference between unspecified RMD and the empty set of metadata can't be detected.
|
||||
// Treat an empty 'allows' as 'allow everything'. Maybe we can have a special RMD flag to account for this
|
||||
// case in the future.
|
||||
if( allowsDataSource.referenceMetaData().length == 0 )
|
||||
return true;
|
||||
|
||||
for( RMD allowed: allowsDataSource.referenceMetaData() ) {
|
||||
if( rod.matchesNameAndRecordType(allowed.name(),allowed.type()) )
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -283,8 +254,7 @@ public class WalkerManager extends PluginManager<Walker> {
|
|||
* @return The list of required reference meta data.
|
||||
*/
|
||||
public static List<RMD> getRequiredMetaData(Class<? extends Walker> walkerClass) {
|
||||
Requires requiresDataSource = getWalkerRequirements(walkerClass);
|
||||
return Arrays.asList(requiresDataSource.referenceMetaData());
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -23,5 +23,4 @@ import java.lang.annotation.*;
|
|||
@Target(ElementType.TYPE)
|
||||
public @interface Allows {
|
||||
DataSource[] value();
|
||||
RMD[] referenceMetaData() default {};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ 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={},referenceMetaData=@RMD(name="alleles", type= VariantContext.class))
|
||||
@Requires(value={})
|
||||
@Reference(window=@Window(start=-200,stop=200))
|
||||
@By(DataSource.READS)
|
||||
@Downsample(by=DownsampleType.BY_SAMPLE, toCoverage=250)
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ import static org.broadinstitute.sting.utils.codecs.vcf.VCFUtils.getVCFHeadersFr
|
|||
* Walks along all variant ROD loci, and merges consecutive sites if they segregate in all samples in the ROD.
|
||||
*/
|
||||
@Allows(value = {DataSource.REFERENCE})
|
||||
@Requires(value = {DataSource.REFERENCE}, referenceMetaData = @RMD(name = "variant", type = ReferenceOrderedDatum.class))
|
||||
@Requires(value = {DataSource.REFERENCE})
|
||||
@By(DataSource.REFERENCE_ORDERED_DATA)
|
||||
|
||||
public class MergeMNPsWalker extends RodWalker<Integer, Integer> {
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ import static org.broadinstitute.sting.utils.codecs.vcf.VCFUtils.getVCFHeadersFr
|
|||
* Walks along all variant ROD loci, and merges consecutive sites if some sample has segregating alt alleles in the ROD.
|
||||
*/
|
||||
@Allows(value = {DataSource.REFERENCE})
|
||||
@Requires(value = {DataSource.REFERENCE}, referenceMetaData = @RMD(name = "variant", type = ReferenceOrderedDatum.class))
|
||||
@Requires(value = {DataSource.REFERENCE})
|
||||
@By(DataSource.REFERENCE_ORDERED_DATA)
|
||||
|
||||
public class MergeSegregatingAlternateAllelesWalker extends RodWalker<Integer, Integer> {
|
||||
|
|
|
|||
|
|
@ -311,8 +311,7 @@ public class PhaseByTransmission extends RodWalker<Integer, Integer> {
|
|||
|
||||
VariantContext newvc = VariantContext.modifyGenotypes(vc, genotypeMap);
|
||||
|
||||
vcfWriter.add(newvc);
|
||||
}
|
||||
vcfWriter.add(newvc);
|
||||
}
|
||||
|
||||
return null;
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ import static org.broadinstitute.sting.utils.codecs.vcf.VCFUtils.getVCFHeadersFr
|
|||
* Walks along all variant ROD loci, caching a user-defined window of VariantContext sites, and then finishes phasing them when they go out of range (using upstream and downstream reads).
|
||||
*/
|
||||
@Allows(value = {DataSource.READS, DataSource.REFERENCE})
|
||||
@Requires(value = {DataSource.READS, DataSource.REFERENCE}, referenceMetaData = @RMD(name = "variant", type = ReferenceOrderedDatum.class))
|
||||
@Requires(value = {DataSource.READS, DataSource.REFERENCE})
|
||||
@By(DataSource.READS)
|
||||
|
||||
@ReadFilters({MappingQualityZeroReadFilter.class})
|
||||
|
|
|
|||
|
|
@ -1,228 +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.variantutils;
|
||||
|
||||
import org.broad.tribble.Feature;
|
||||
import org.broadinstitute.sting.commandline.*;
|
||||
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.MathUtils;
|
||||
import org.broadinstitute.sting.utils.Utils;
|
||||
import org.broadinstitute.sting.utils.exceptions.UserException;
|
||||
import org.broadinstitute.sting.utils.variantcontext.VariantContext;
|
||||
import org.broadinstitute.sting.utils.variantcontext.VariantContextUtils;
|
||||
|
||||
import java.io.PrintStream;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* Emits specific fields as dictated by the user from one or more VCF files.
|
||||
*/
|
||||
public class TestRodBindings extends RodWalker<Integer, Integer> {
|
||||
@Output(doc="File to which results should be written",required=true)
|
||||
protected PrintStream out;
|
||||
|
||||
@Argument(fullName="fields", shortName="F", doc="Fields to emit from the VCF, allows any VCF field, any info field, and some meta fields like nHets", required=true)
|
||||
public ArrayList<String> fieldsToTake = new ArrayList<String>();
|
||||
|
||||
@Argument(fullName="showFiltered", shortName="raw", doc="Include filtered records")
|
||||
public boolean showFiltered = false;
|
||||
|
||||
@Argument(fullName="maxRecords", shortName="M", doc="Maximum number of records to emit, if provided", required=false)
|
||||
public int MAX_RECORDS = -1;
|
||||
int nRecords = 0;
|
||||
|
||||
@Argument(fullName="keepMultiAllelic", shortName="KMA", doc="If provided, we will not require the site to be biallelic", required=false)
|
||||
public boolean keepMultiAllelic = false;
|
||||
|
||||
@Argument(fullName="allowMissingData", shortName="AMD", doc="If provided, we will not require every record to contain every field", required=false)
|
||||
public boolean ALLOW_MISSING_DATA = false;
|
||||
|
||||
@Input(fullName="variants", shortName="V", doc="The variant file we will convert to a table", required=true)
|
||||
public RodBinding<VariantContext> variants;
|
||||
|
||||
@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() {
|
||||
out.println(Utils.join("\t", fieldsToTake));
|
||||
}
|
||||
|
||||
public static abstract class Getter { public abstract String get(VariantContext vc); }
|
||||
public static Map<String, Getter> getters = new HashMap<String, Getter>();
|
||||
|
||||
static {
|
||||
// #CHROM POS ID REF ALT QUAL FILTER INFO FORMAT
|
||||
getters.put("CHROM", new Getter() { public String get(VariantContext vc) { return vc.getChr(); } });
|
||||
getters.put("POS", new Getter() { public String get(VariantContext vc) { return Integer.toString(vc.getStart()); } });
|
||||
getters.put("REF", new Getter() {
|
||||
public String get(VariantContext vc) {
|
||||
String x = "";
|
||||
if (vc.hasAttribute(VariantContext.REFERENCE_BASE_FOR_INDEL_KEY)) {
|
||||
Byte refByte = (Byte)(vc.getAttribute(VariantContext.REFERENCE_BASE_FOR_INDEL_KEY));
|
||||
x=x+new String(new byte[]{refByte});
|
||||
}
|
||||
return x+vc.getReference().getDisplayString();
|
||||
}
|
||||
});
|
||||
getters.put("ALT", new Getter() {
|
||||
public String get(VariantContext vc) {
|
||||
StringBuilder x = new StringBuilder();
|
||||
int n = vc.getAlternateAlleles().size();
|
||||
if ( n == 0 ) return ".";
|
||||
if (vc.hasAttribute(VariantContext.REFERENCE_BASE_FOR_INDEL_KEY)) {
|
||||
Byte refByte = (Byte)(vc.getAttribute(VariantContext.REFERENCE_BASE_FOR_INDEL_KEY));
|
||||
x.append(new String(new byte[]{refByte}));
|
||||
}
|
||||
|
||||
for ( int i = 0; i < n; i++ ) {
|
||||
if ( i != 0 ) x.append(",");
|
||||
x.append(vc.getAlternateAllele(i).getDisplayString());
|
||||
}
|
||||
return x.toString();
|
||||
}
|
||||
});
|
||||
getters.put("QUAL", new Getter() { public String get(VariantContext vc) { return Double.toString(vc.getPhredScaledQual()); } });
|
||||
getters.put("TRANSITION", new Getter() { public String get(VariantContext vc) {
|
||||
if ( vc.isSNP() && vc.isBiallelic() )
|
||||
return VariantContextUtils.isTransition(vc) ? "1" : "0";
|
||||
else
|
||||
return "-1";
|
||||
}});
|
||||
getters.put("FILTER", new Getter() { public String get(VariantContext vc) {
|
||||
return vc.isNotFiltered() ? "PASS" : Utils.join(",", vc.getFilters()); }
|
||||
});
|
||||
|
||||
getters.put("HET", new Getter() { public String get(VariantContext vc) { return Integer.toString(vc.getHetCount()); } });
|
||||
getters.put("HOM-REF", new Getter() { public String get(VariantContext vc) { return Integer.toString(vc.getHomRefCount()); } });
|
||||
getters.put("HOM-VAR", new Getter() { public String get(VariantContext vc) { return Integer.toString(vc.getHomVarCount()); } });
|
||||
getters.put("NO-CALL", new Getter() { public String get(VariantContext vc) { return Integer.toString(vc.getNoCallCount()); } });
|
||||
getters.put("VAR", new Getter() { public String get(VariantContext vc) { return Integer.toString(vc.getHetCount() + vc.getHomVarCount()); } });
|
||||
getters.put("NSAMPLES", new Getter() { public String get(VariantContext vc) { return Integer.toString(vc.getNSamples()); } });
|
||||
getters.put("NCALLED", new Getter() { public String get(VariantContext vc) { return Integer.toString(vc.getNSamples() - vc.getNoCallCount()); } });
|
||||
getters.put("GQ", new Getter() { public String get(VariantContext vc) {
|
||||
if ( vc.getNSamples() > 1 ) throw new UserException("Cannot get GQ values for multi-sample VCF");
|
||||
return String.format("%.2f", 10 * vc.getGenotype(0).getNegLog10PError());
|
||||
}});
|
||||
}
|
||||
|
||||
|
||||
public Integer map(RefMetaDataTracker tracker, ReferenceContext ref, AlignmentContext context) {
|
||||
if ( tracker == null ) // RodWalkers can make funky map calls
|
||||
return 0;
|
||||
|
||||
for ( RodBinding binding : variantsList )
|
||||
System.out.printf("VariantList binding %s tags=%s%n", binding, binding.getTags().getPositionalTags());
|
||||
|
||||
if ( ++nRecords < MAX_RECORDS || MAX_RECORDS == -1 ) {
|
||||
VariantContext vc = tracker.getFirstValue(variants, context.getLocation());
|
||||
if ( (keepMultiAllelic || vc.isBiallelic()) && ( showFiltered || vc.isNotFiltered() ) ) {
|
||||
List<String> vals = extractFields(vc, fieldsToTake, ALLOW_MISSING_DATA);
|
||||
out.println(Utils.join("\t", vals));
|
||||
}
|
||||
return 1;
|
||||
} else {
|
||||
if ( nRecords >= MAX_RECORDS ) {
|
||||
logger.warn("Calling sys exit to leave after " + nRecords + " records");
|
||||
System.exit(0); // todo -- what's the recommend way to abort like this?
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
private static final boolean isWildCard(String s) {
|
||||
return s.endsWith("*");
|
||||
}
|
||||
|
||||
public static List<String> extractFields(VariantContext vc, List<String> fields, boolean allowMissingData) {
|
||||
List<String> vals = new ArrayList<String>();
|
||||
|
||||
for ( String field : fields ) {
|
||||
String val = "NA";
|
||||
|
||||
if ( getters.containsKey(field) ) {
|
||||
val = getters.get(field).get(vc);
|
||||
} else if ( vc.hasAttribute(field) ) {
|
||||
val = vc.getAttributeAsString(field);
|
||||
} else if ( isWildCard(field) ) {
|
||||
Set<String> wildVals = new HashSet<String>();
|
||||
for ( Map.Entry<String,Object> elt : vc.getAttributes().entrySet()) {
|
||||
if ( elt.getKey().startsWith(field.substring(0, field.length() - 1)) ) {
|
||||
wildVals.add(elt.getValue().toString());
|
||||
}
|
||||
}
|
||||
|
||||
if ( wildVals.size() > 0 ) {
|
||||
List<String> toVal = new ArrayList<String>(wildVals);
|
||||
Collections.sort(toVal);
|
||||
val = Utils.join(",", toVal);
|
||||
}
|
||||
} else if ( ! allowMissingData ) {
|
||||
throw new UserException(String.format("Missing field %s in vc %s at %s", field, vc.getSource(), vc));
|
||||
}
|
||||
|
||||
if (field.equals("AF") || field.equals("AC")) {
|
||||
String afo = val;
|
||||
|
||||
double af=0;
|
||||
if (afo.contains(",")) {
|
||||
String[] afs = afo.split(",");
|
||||
afs[0] = afs[0].substring(1,afs[0].length());
|
||||
afs[afs.length-1] = afs[afs.length-1].substring(0,afs[afs.length-1].length()-1);
|
||||
|
||||
double[] afd = new double[afs.length];
|
||||
|
||||
for (int k=0; k < afd.length; k++)
|
||||
afd[k] = Double.valueOf(afs[k]);
|
||||
|
||||
af = MathUtils.arrayMax(afd);
|
||||
//af = Double.valueOf(afs[0]);
|
||||
|
||||
}
|
||||
else
|
||||
if (!afo.equals("NA"))
|
||||
af = Double.valueOf(afo);
|
||||
|
||||
val = Double.toString(af);
|
||||
|
||||
}
|
||||
vals.add(val);
|
||||
}
|
||||
|
||||
return vals;
|
||||
}
|
||||
|
||||
public Integer reduceInit() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public Integer reduce(Integer counter, Integer sum) {
|
||||
return counter + sum;
|
||||
}
|
||||
|
||||
public void onTraversalDone(Integer sum) {}
|
||||
}
|
||||
|
|
@ -48,7 +48,7 @@ import java.util.*;
|
|||
*/
|
||||
@Reference(window=@Window(start=0,stop=40))
|
||||
@Requires(value={})
|
||||
public class VariantValidationAssessor extends RodWalker<Pair<VariantContext, Byte>,Integer> {
|
||||
public class VariantValidationAssessor extends RodWalker<VariantContext,Integer> {
|
||||
@Input(fullName="variants", shortName = "V", doc="Input VCF file", required=true)
|
||||
public RodBinding<VariantContext> variants;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue