VariantEval now uses the "standard" modules only by default. You can add other modules with the -E argument and not use all of the standard ones with -noStandard (they can be added back individually with -E).
Generalized some of the packaging code from VariantAnnotator. Matt might want to take a look to make this nicer...? git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@3925 348d0f76-0448-11de-a6fe-93d51630548a
This commit is contained in:
parent
a7ff9caf54
commit
2307bed742
|
|
@ -63,7 +63,7 @@ public class VariantAnnotator extends RodWalker<Integer, Integer> {
|
||||||
protected String[] annotationsToUse = {};
|
protected String[] annotationsToUse = {};
|
||||||
|
|
||||||
@Argument(fullName="group", shortName="G", doc="One or more classes/groups of annotations to apply to variant calls", required=false)
|
@Argument(fullName="group", shortName="G", doc="One or more classes/groups of annotations to apply to variant calls", required=false)
|
||||||
protected String[] annotationClassesToUse = { };
|
protected String[] annotationGroupsToUse = {};
|
||||||
|
|
||||||
@Argument(fullName="useAllAnnotations", shortName="all", doc="Use all possible annotations (not for the faint of heart)", required=false)
|
@Argument(fullName="useAllAnnotations", shortName="all", doc="Use all possible annotations (not for the faint of heart)", required=false)
|
||||||
protected Boolean USE_ALL_ANNOTATIONS = false;
|
protected Boolean USE_ALL_ANNOTATIONS = false;
|
||||||
|
|
@ -131,7 +131,7 @@ public class VariantAnnotator extends RodWalker<Integer, Integer> {
|
||||||
if ( USE_ALL_ANNOTATIONS )
|
if ( USE_ALL_ANNOTATIONS )
|
||||||
engine = new VariantAnnotatorEngine(getToolkit());
|
engine = new VariantAnnotatorEngine(getToolkit());
|
||||||
else
|
else
|
||||||
engine = new VariantAnnotatorEngine(getToolkit(), annotationClassesToUse, annotationsToUse);
|
engine = new VariantAnnotatorEngine(getToolkit(), annotationGroupsToUse, annotationsToUse);
|
||||||
|
|
||||||
// setup the header fields
|
// setup the header fields
|
||||||
Set<VCFHeaderLine> hInfo = new HashSet<VCFHeaderLine>();
|
Set<VCFHeaderLine> hInfo = new HashSet<VCFHeaderLine>();
|
||||||
|
|
|
||||||
|
|
@ -60,8 +60,8 @@ public class VariantAnnotatorEngine {
|
||||||
|
|
||||||
public static final String dbPrefix = "comp";
|
public static final String dbPrefix = "comp";
|
||||||
|
|
||||||
private ArrayList<InfoFieldAnnotation> requestedInfoAnnotations;
|
private List<InfoFieldAnnotation> requestedInfoAnnotations;
|
||||||
private ArrayList<GenotypeAnnotation> requestedGenotypeAnnotations;
|
private List<GenotypeAnnotation> requestedGenotypeAnnotations;
|
||||||
|
|
||||||
private HashMap<String, String> dbAnnotations = new HashMap<String, String>();
|
private HashMap<String, String> dbAnnotations = new HashMap<String, String>();
|
||||||
|
|
||||||
|
|
@ -82,16 +82,14 @@ public class VariantAnnotatorEngine {
|
||||||
|
|
||||||
// use this constructor if you want all possible annotations
|
// use this constructor if you want all possible annotations
|
||||||
public VariantAnnotatorEngine(GenomeAnalysisEngine engine) {
|
public VariantAnnotatorEngine(GenomeAnalysisEngine engine) {
|
||||||
List<Class<? extends InfoFieldAnnotation>> infoAnnotationClasses = PackageUtils.getClassesImplementingInterface(InfoFieldAnnotation.class);
|
requestedInfoAnnotations = PackageUtils.getInstancesOfClassesImplementingInterface(InfoFieldAnnotation.class);
|
||||||
requestedInfoAnnotations = getInstances(infoAnnotationClasses);
|
requestedGenotypeAnnotations = PackageUtils.getInstancesOfClassesImplementingInterface(GenotypeAnnotation.class);
|
||||||
List<Class<? extends GenotypeAnnotation>> genotypeAnnotationClasses = PackageUtils.getClassesImplementingInterface(GenotypeAnnotation.class);
|
|
||||||
requestedGenotypeAnnotations = getInstances(genotypeAnnotationClasses);
|
|
||||||
|
|
||||||
initialize(engine);
|
initialize(engine);
|
||||||
}
|
}
|
||||||
|
|
||||||
// use this constructor if you want to select specific annotations (and/or interfaces)
|
// use this constructor if you want to select specific annotations (and/or interfaces)
|
||||||
public VariantAnnotatorEngine(GenomeAnalysisEngine engine, String[] annotationClassesToUse, String[] annotationsToUse) {
|
public VariantAnnotatorEngine(GenomeAnalysisEngine engine, String[] annotationGroupsToUse, String[] annotationsToUse) {
|
||||||
|
|
||||||
// create a map for all annotation classes which implement our top-level interfaces
|
// create a map for all annotation classes which implement our top-level interfaces
|
||||||
HashMap<String, Class> classMap = new HashMap<String, Class>();
|
HashMap<String, Class> classMap = new HashMap<String, Class>();
|
||||||
for ( Class c : PackageUtils.getClassesImplementingInterface(InfoFieldAnnotation.class) )
|
for ( Class c : PackageUtils.getClassesImplementingInterface(InfoFieldAnnotation.class) )
|
||||||
|
|
@ -103,7 +101,7 @@ public class VariantAnnotatorEngine {
|
||||||
|
|
||||||
HashSet<Class> classes = new HashSet<Class>();
|
HashSet<Class> classes = new HashSet<Class>();
|
||||||
// get the classes from the provided groups (interfaces)
|
// get the classes from the provided groups (interfaces)
|
||||||
for ( String group : annotationClassesToUse ) {
|
for ( String group : annotationGroupsToUse ) {
|
||||||
Class interfaceClass = classMap.get(group);
|
Class interfaceClass = classMap.get(group);
|
||||||
if ( interfaceClass == null )
|
if ( interfaceClass == null )
|
||||||
interfaceClass = classMap.get(group + "Annotation");
|
interfaceClass = classMap.get(group + "Annotation");
|
||||||
|
|
@ -128,31 +126,14 @@ public class VariantAnnotatorEngine {
|
||||||
for ( Class c : classes ) {
|
for ( Class c : classes ) {
|
||||||
// note that technically an annotation can work on both the INFO and FORMAT fields
|
// note that technically an annotation can work on both the INFO and FORMAT fields
|
||||||
if ( InfoFieldAnnotation.class.isAssignableFrom(c) )
|
if ( InfoFieldAnnotation.class.isAssignableFrom(c) )
|
||||||
requestedInfoAnnotations.add((InfoFieldAnnotation)getInstance(c));
|
requestedInfoAnnotations.add((InfoFieldAnnotation)PackageUtils.getSimpleInstance(c));
|
||||||
if ( GenotypeAnnotation.class.isAssignableFrom(c) )
|
if ( GenotypeAnnotation.class.isAssignableFrom(c) )
|
||||||
requestedGenotypeAnnotations.add((GenotypeAnnotation)getInstance(c));
|
requestedGenotypeAnnotations.add((GenotypeAnnotation)PackageUtils.getSimpleInstance(c));
|
||||||
}
|
}
|
||||||
|
|
||||||
initialize(engine);
|
initialize(engine);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static <T> ArrayList<T> getInstances(List<Class<? extends T>> classes) {
|
|
||||||
ArrayList<T> objects = new ArrayList<T>();
|
|
||||||
for ( Class c : classes )
|
|
||||||
objects.add((T)getInstance(c));
|
|
||||||
return objects;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static <T> T getInstance(Class<T> c) {
|
|
||||||
try {
|
|
||||||
return c.newInstance();
|
|
||||||
} catch (InstantiationException e) {
|
|
||||||
throw new StingException(String.format("Cannot instantiate annotation class '%s': must be concrete class", c.getSimpleName()));
|
|
||||||
} catch (IllegalAccessException e) {
|
|
||||||
throw new StingException(String.format("Cannot instantiate annotation class '%s': must have no-arg constructor", c.getSimpleName()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void initialize(GenomeAnalysisEngine engine) {
|
private void initialize(GenomeAnalysisEngine engine) {
|
||||||
|
|
||||||
// check to see whether comp rods were included
|
// check to see whether comp rods were included
|
||||||
|
|
@ -181,15 +162,8 @@ public class VariantAnnotatorEngine {
|
||||||
return descriptions;
|
return descriptions;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
// A slightly simplified interface for when you don't have any reads, so the stratifiedContexts aren't necessary, and
|
||||||
* A slightly simplified interface for when you don't have any reads, so the stratifiedContexts aren't necessary, and
|
// you only permit a single return value
|
||||||
* you only permit a single return value
|
|
||||||
*
|
|
||||||
* @param tracker
|
|
||||||
* @param ref
|
|
||||||
* @param vc
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public VariantContext annotateContext(RefMetaDataTracker tracker, ReferenceContext ref, VariantContext vc) {
|
public VariantContext annotateContext(RefMetaDataTracker tracker, ReferenceContext ref, VariantContext vc) {
|
||||||
Collection<VariantContext> results = this.annotateContext(tracker, ref, EMPTY_STRATIFIED_ALIGNMENT_CONTEXT, vc);
|
Collection<VariantContext> results = this.annotateContext(tracker, ref, EMPTY_STRATIFIED_ALIGNMENT_CONTEXT, vc);
|
||||||
|
|
||||||
|
|
@ -278,13 +252,7 @@ public class VariantAnnotatorEngine {
|
||||||
return returnValue;
|
return returnValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
// Finish processing data from GenomicAnnotation.
|
||||||
* Finish processing data from GenomicAnnotation.
|
|
||||||
*
|
|
||||||
* @param infoAnnotationOutputsList
|
|
||||||
* @param annotationsForCurrentLocusFromAllAnnotatorInputTables
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
private List<Map<String, Object>> processGenomicAnnotation( List<Map<String, Object>> infoAnnotationOutputsList, Map<String, Object> annotationsForCurrentLocusFromAllAnnotatorInputTables)
|
private List<Map<String, Object>> processGenomicAnnotation( List<Map<String, Object>> infoAnnotationOutputsList, Map<String, Object> annotationsForCurrentLocusFromAllAnnotatorInputTables)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
@ -330,15 +298,8 @@ public class VariantAnnotatorEngine {
|
||||||
return infoAnnotationOutputsList;
|
return infoAnnotationOutputsList;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
// Performs a join between the an info field record represented by outputRecordInfoField and the infoAnnotationOutputsList.
|
||||||
* Performs a join between the an info field record represented by outputRecordInfoField and the infoAnnotationOutputsList.
|
private List<Map<String, Object>> performJoin( List<Map<String, Object>> infoAnnotationOutputsList, Map<String, Object> outputRecordInfoField, JoinTable joinTable)
|
||||||
*
|
|
||||||
* @param infoAnnotationOutputsList
|
|
||||||
* @param outputRecordInfoField
|
|
||||||
* @param joinTable
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
private List<Map<String, Object>> performJoin( List<Map<String, Object>> infoAnnotationOutputsList, Map<String, Object> outputRecordInfoField, JoinTable joinTable)
|
|
||||||
{
|
{
|
||||||
//System.err.println("Looking at: " + joinTable.getLocalBindingName()+ "- join to " + joinTable.getExternalBindingName() + "." + joinTable.getExternalColumnName() );
|
//System.err.println("Looking at: " + joinTable.getLocalBindingName()+ "- join to " + joinTable.getExternalBindingName() + "." + joinTable.getExternalColumnName() );
|
||||||
//for the current joinTable, for each output line, find the externalJoinColumnValue and see if it matches the joinColumnValue of any record(s) in this joinTable.
|
//for the current joinTable, for each output line, find the externalJoinColumnValue and see if it matches the joinColumnValue of any record(s) in this joinTable.
|
||||||
|
|
@ -413,16 +374,10 @@ public class VariantAnnotatorEngine {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
// Implements not-oneToMany mode, where the output lines have a one-to-one relationship
|
||||||
* Implements not-oneToMany mode, where the output lines have a one-to-one relationship
|
// with the input variants, and all multiple-match records are collapsed into the single info field.
|
||||||
* with the input variants, and all multiple-match records are collapsed into the single info field.
|
// The collapsing is done by appending an _i to each key name (where 'i' is a record counter), as well
|
||||||
* The collapsing is done by appending an _i to each key name (where 'i' is a record counter), as well
|
// as a special bindingName.numMatchingRecords=n key-value pair which specifies the upper limit of the counter.
|
||||||
* as a special bindingName.numMatchingRecords=n key-value pair which specifies the upper limit of the counter.
|
|
||||||
*
|
|
||||||
* @param infoAnnotationOutputsList
|
|
||||||
* @param matchingRecords
|
|
||||||
* @param bindingName
|
|
||||||
*/
|
|
||||||
private void addToExistingAnnotationOutputs(
|
private void addToExistingAnnotationOutputs(
|
||||||
final List<Map<String, Object>> infoAnnotationOutputsList,
|
final List<Map<String, Object>> infoAnnotationOutputsList,
|
||||||
final List<Map<String, String>> matchingRecords,
|
final List<Map<String, String>> matchingRecords,
|
||||||
|
|
@ -470,19 +425,12 @@ public class VariantAnnotatorEngine {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
// Implements oneToMany mode. Takes the current infoAnnotationOutputsList
|
||||||
* Implements oneToMany mode. Takes the current infoAnnotationOutputsList
|
// (where each element represents a line in the output VCF file), and
|
||||||
* (where each element represents a line in the output VCF file), and
|
// generates a new infoAnnotationOutputsList which contains one copy of the current
|
||||||
* generates a new infoAnnotationOutputsList which contains one copy of the current
|
// infoAnnotationOutputs for each record matchingRecords.
|
||||||
* infoAnnotationOutputs for each record matchingRecords.
|
// The returned list will have size:
|
||||||
* The returned list will have size:
|
// infoAnnotationOutputsList.size() * matchingRecords.size()
|
||||||
* infoAnnotationOutputsList.size() * matchingRecords.size()
|
|
||||||
*
|
|
||||||
* @param infoAnnotationOutputsList
|
|
||||||
* @param matchingRecords
|
|
||||||
* @param bindingName
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
private List<Map<String, Object>> explodeInfoAnnotationOutputsList(
|
private List<Map<String, Object>> explodeInfoAnnotationOutputsList(
|
||||||
final List<Map<String, Object>> infoAnnotationOutputsList,
|
final List<Map<String, Object>> infoAnnotationOutputsList,
|
||||||
final List<Map<String, String>> matchingRecords,
|
final List<Map<String, String>> matchingRecords,
|
||||||
|
|
@ -515,8 +463,8 @@ public class VariantAnnotatorEngine {
|
||||||
* Records statistics for the explodeInfoAnnotationOutputsList(..) calculation.
|
* Records statistics for the explodeInfoAnnotationOutputsList(..) calculation.
|
||||||
* @param bindingName The table from which annotations were gotten
|
* @param bindingName The table from which annotations were gotten
|
||||||
* @param numNewVCFRecordsAnnotatedWithBindingNameData The number of new output VCF records created with annotations from this table
|
* @param numNewVCFRecordsAnnotatedWithBindingNameData The number of new output VCF records created with annotations from this table
|
||||||
* @param infoAnnotationOutputsList
|
* @param infoAnnotationOutputsList output list
|
||||||
* @parma matchingRecordsSize
|
* @param matchingRecordsSize matching records size
|
||||||
*/
|
*/
|
||||||
private void recordStats( final String bindingName, int numNewVCFRecordsAnnotatedWithBindingNameData, final List<Map<String, Object>> infoAnnotationOutputsList, int matchingRecordsSize ) {
|
private void recordStats( final String bindingName, int numNewVCFRecordsAnnotatedWithBindingNameData, final List<Map<String, Object>> infoAnnotationOutputsList, int matchingRecordsSize ) {
|
||||||
|
|
||||||
|
|
@ -549,13 +497,7 @@ public class VariantAnnotatorEngine {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Applies the -S arg to the results
|
||||||
/**
|
|
||||||
* Applies the -S arg to the results
|
|
||||||
*
|
|
||||||
* @param infoAnnotationOutputsList
|
|
||||||
* @return The new newInfoAnnotationOutputList with -S arg applied.
|
|
||||||
*/
|
|
||||||
private List<Map<String, Object>> applySelectArg( final List<Map<String, Object>> infoAnnotationOutputsList )
|
private List<Map<String, Object>> applySelectArg( final List<Map<String, Object>> infoAnnotationOutputsList )
|
||||||
{
|
{
|
||||||
final List<Map<String, Object>> newInfoAnnotationOutputList = new LinkedList<Map<String, Object>>();
|
final List<Map<String, Object>> newInfoAnnotationOutputList = new LinkedList<Map<String, Object>>();
|
||||||
|
|
@ -614,7 +556,7 @@ public class VariantAnnotatorEngine {
|
||||||
*
|
*
|
||||||
* See class-level comments for more details.
|
* See class-level comments for more details.
|
||||||
*
|
*
|
||||||
* @param oneToMany
|
* @param oneToMany true if we should break out from one to many
|
||||||
*/
|
*/
|
||||||
public void setOneToMany(boolean oneToMany) {
|
public void setOneToMany(boolean oneToMany) {
|
||||||
this.oneToMany = oneToMany;
|
this.oneToMany = oneToMany;
|
||||||
|
|
@ -694,9 +636,7 @@ public class VariantAnnotatorEngine {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
//Returns a map containing stats on how many output vcf records were annotated from each database
|
||||||
* Returns a map containing stats on how many output vcf records were annotated from each database
|
|
||||||
*/
|
|
||||||
public Map<String, Integer> getInputTableHitCounter() {
|
public Map<String, Integer> getInputTableHitCounter() {
|
||||||
return Collections.unmodifiableMap(inputTableHitCounter);
|
return Collections.unmodifiableMap(inputTableHitCounter);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ import org.broadinstitute.sting.playground.utils.report.tags.DataPoint;
|
||||||
* the Broad Institute nor MIT can be responsible for its use, misuse, or functionality.
|
* the Broad Institute nor MIT can be responsible for its use, misuse, or functionality.
|
||||||
*/
|
*/
|
||||||
@Analysis(name = "Comp Overlap", description = "the overlap between eval and comp sites")
|
@Analysis(name = "Comp Overlap", description = "the overlap between eval and comp sites")
|
||||||
public class CompOverlap extends VariantEvaluator {
|
public class CompOverlap extends VariantEvaluator implements StandardEval {
|
||||||
|
|
||||||
@DataPoint(name = "eval sites", description = "number of eval SNP sites")
|
@DataPoint(name = "eval sites", description = "number of eval SNP sites")
|
||||||
long nEvalSNPs = 0;
|
long nEvalSNPs = 0;
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ import org.broadinstitute.sting.utils.StingException;
|
||||||
|
|
||||||
|
|
||||||
@Analysis(name = "Count Variants", description = "Counts different classes of variants in the sample")
|
@Analysis(name = "Count Variants", description = "Counts different classes of variants in the sample")
|
||||||
public class CountVariants extends VariantEvaluator {
|
public class CountVariants extends VariantEvaluator implements StandardEval {
|
||||||
|
|
||||||
// the following fields are in output order:
|
// the following fields are in output order:
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@ import java.util.*;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@Analysis(name = "Genotype Concordance", description = "Determine the genotype concordance between the genotypes in difference tracks")
|
@Analysis(name = "Genotype Concordance", description = "Determine the genotype concordance between the genotypes in difference tracks")
|
||||||
public class GenotypeConcordance extends VariantEvaluator {
|
public class GenotypeConcordance extends VariantEvaluator implements StandardEval {
|
||||||
private static final boolean PRINT_INTERESTING_SITES = true;
|
private static final boolean PRINT_INTERESTING_SITES = true;
|
||||||
|
|
||||||
protected final static Logger logger = Logger.getLogger(GenotypeConcordance.class);
|
protected final static Logger logger = Logger.getLogger(GenotypeConcordance.class);
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,6 @@ import org.broadinstitute.sting.playground.utils.report.tags.Analysis;
|
||||||
import org.broadinstitute.sting.playground.utils.report.tags.DataPoint;
|
import org.broadinstitute.sting.playground.utils.report.tags.DataPoint;
|
||||||
import org.broadinstitute.sting.playground.utils.report.utils.TableType;
|
import org.broadinstitute.sting.playground.utils.report.utils.TableType;
|
||||||
import org.broadinstitute.sting.utils.StingException;
|
import org.broadinstitute.sting.utils.StingException;
|
||||||
import org.broad.tribble.vcf.VCFGenotypeRecord;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
|
@ -43,7 +42,7 @@ import java.util.ArrayList;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@Analysis(name = "Quality Metrics by allele count", description = "Shows various stats binned by allele count")
|
@Analysis(name = "Quality Metrics by allele count", description = "Shows various stats binned by allele count")
|
||||||
public class SimpleMetricsByAC extends VariantEvaluator {
|
public class SimpleMetricsByAC extends VariantEvaluator implements StandardEval {
|
||||||
// a mapping from quality score histogram bin to Ti/Tv ratio
|
// a mapping from quality score histogram bin to Ti/Tv ratio
|
||||||
@DataPoint(name="TiTv by AC", description = "TiTv by allele count")
|
@DataPoint(name="TiTv by AC", description = "TiTv by allele count")
|
||||||
MetricsByAc metrics = null;
|
MetricsByAc metrics = null;
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,28 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2010.
|
||||||
|
*
|
||||||
|
* 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.varianteval;
|
||||||
|
|
||||||
|
public interface StandardEval {}
|
||||||
|
|
@ -8,7 +8,7 @@ import org.broadinstitute.sting.playground.utils.report.tags.Analysis;
|
||||||
import org.broadinstitute.sting.playground.utils.report.tags.DataPoint;
|
import org.broadinstitute.sting.playground.utils.report.tags.DataPoint;
|
||||||
|
|
||||||
@Analysis(name = "Ti/Tv Variant Evaluator", description = "Ti/Tv Variant Evaluator")
|
@Analysis(name = "Ti/Tv Variant Evaluator", description = "Ti/Tv Variant Evaluator")
|
||||||
public class TiTvVariantEvaluator extends VariantEvaluator {
|
public class TiTvVariantEvaluator extends VariantEvaluator implements StandardEval {
|
||||||
|
|
||||||
@DataPoint(name = "ti_count", description = "number of transition loci")
|
@DataPoint(name = "ti_count", description = "number of transition loci")
|
||||||
long nTi = 0;
|
long nTi = 0;
|
||||||
|
|
|
||||||
|
|
@ -136,11 +136,11 @@ public class VariantEvalWalker extends RodWalker<Integer, Integer> {
|
||||||
//
|
//
|
||||||
// Arguments for choosing which modules to run
|
// Arguments for choosing which modules to run
|
||||||
//
|
//
|
||||||
@Argument(fullName="evalModule", shortName="E", doc="One or more specific eval modules to apply to the eval track(s)", required=false)
|
@Argument(fullName="evalModule", shortName="E", doc="One or more specific eval modules to apply to the eval track(s) (in addition to the standard modules, unless -noStandard is specified)", required=false)
|
||||||
protected String[] modulesToUse = {};
|
protected String[] modulesToUse = {};
|
||||||
|
|
||||||
@Argument(fullName="useNoModules", shortName="none", doc="Use no eval modules", required=false)
|
@Argument(fullName="doNotUseAllStandardModules", shortName="noStandard", doc="Do not use the standard modules by default (instead, only those that are specified with the -E option)")
|
||||||
protected Boolean USE_NO_MODULES = false;
|
protected Boolean NO_STANDARD = false;
|
||||||
|
|
||||||
@Argument(fullName="list", shortName="ls", doc="List the available eval modules and exit")
|
@Argument(fullName="list", shortName="ls", doc="List the available eval modules and exit")
|
||||||
protected Boolean LIST = false;
|
protected Boolean LIST = false;
|
||||||
|
|
@ -272,7 +272,7 @@ public class VariantEvalWalker extends RodWalker<Integer, Integer> {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Dynamically determined variantEvaluation classes
|
// Dynamically determined variantEvaluation classes
|
||||||
private List<Class<? extends VariantEvaluator>> evaluationClasses = null;
|
private Set<Class<? extends VariantEvaluator>> evaluationClasses = null;
|
||||||
|
|
||||||
/** output writer for interesting sites */
|
/** output writer for interesting sites */
|
||||||
private VCFWriter writer = null;
|
private VCFWriter writer = null;
|
||||||
|
|
@ -392,21 +392,23 @@ public class VariantEvalWalker extends RodWalker<Integer, Integer> {
|
||||||
for ( Class<? extends VariantEvaluator> c : PackageUtils.getClassesImplementingInterface(VariantEvaluator.class) )
|
for ( Class<? extends VariantEvaluator> c : PackageUtils.getClassesImplementingInterface(VariantEvaluator.class) )
|
||||||
classMap.put(c.getSimpleName(), c);
|
classMap.put(c.getSimpleName(), c);
|
||||||
|
|
||||||
if ( USE_NO_MODULES ) {
|
evaluationClasses = new HashSet<Class<? extends VariantEvaluator>>();
|
||||||
evaluationClasses = new ArrayList<Class<? extends VariantEvaluator>>(0);
|
|
||||||
} else if ( modulesToUse.length == 0 ) {
|
// by default, use standard eval modules
|
||||||
evaluationClasses = new ArrayList<Class<? extends VariantEvaluator>>(classMap.values());
|
if ( !NO_STANDARD ) {
|
||||||
} else {
|
for ( Class<? extends StandardEval> myClass : PackageUtils.getClassesImplementingInterface(StandardEval.class) ) {
|
||||||
// get the specific classes provided
|
if ( classMap.containsKey(myClass.getSimpleName()) )
|
||||||
evaluationClasses = new ArrayList<Class<? extends VariantEvaluator>>(modulesToUse.length);
|
evaluationClasses.add(classMap.get(myClass.getSimpleName()));
|
||||||
for ( String module : modulesToUse ) {
|
|
||||||
Class<? extends VariantEvaluator> moduleClass = classMap.get(module);
|
|
||||||
if ( moduleClass == null )
|
|
||||||
throw new StingException("Class " + module + " is not found; please check that you have specified the class name correctly");
|
|
||||||
evaluationClasses.add(moduleClass);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// get the specific classes provided
|
||||||
|
for ( String module : modulesToUse ) {
|
||||||
|
if ( !classMap.containsKey(module) )
|
||||||
|
throw new StingException("Class " + module + " is not found; please check that you have specified the class name correctly");
|
||||||
|
evaluationClasses.add(classMap.get(module));
|
||||||
|
}
|
||||||
|
|
||||||
for ( VariantEvaluator e : instantiateEvalationsSet() ) {
|
for ( VariantEvaluator e : instantiateEvalationsSet() ) {
|
||||||
// for collecting purposes
|
// for collecting purposes
|
||||||
variantEvaluationNames.add(e.getName());
|
variantEvaluationNames.add(e.getName());
|
||||||
|
|
|
||||||
|
|
@ -28,10 +28,9 @@ package org.broadinstitute.sting.utils.classloader;
|
||||||
import org.reflections.Reflections;
|
import org.reflections.Reflections;
|
||||||
import org.reflections.scanners.ResourcesScanner;
|
import org.reflections.scanners.ResourcesScanner;
|
||||||
import org.reflections.scanners.SubTypesScanner;
|
import org.reflections.scanners.SubTypesScanner;
|
||||||
import org.reflections.util.ClasspathHelper;
|
|
||||||
import org.reflections.util.ConfigurationBuilder;
|
import org.reflections.util.ConfigurationBuilder;
|
||||||
import org.reflections.util.ManifestAwareClasspathHelper;
|
import org.reflections.util.ManifestAwareClasspathHelper;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.broadinstitute.sting.utils.StingException;
|
||||||
|
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
@ -81,6 +80,24 @@ public class PackageUtils {
|
||||||
return concreteTypes;
|
return concreteTypes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static <T> List<T> getInstancesOfClassesImplementingInterface(Class<T> iface) {
|
||||||
|
List<Class<? extends T>> classes = PackageUtils.getClassesImplementingInterface(iface);
|
||||||
|
List<T> instances = new ArrayList<T>();
|
||||||
|
for ( Class<? extends T> c : classes )
|
||||||
|
instances.add(getSimpleInstance(c));
|
||||||
|
return instances;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static <T> T getSimpleInstance(Class<T> c) {
|
||||||
|
try {
|
||||||
|
return c.newInstance();
|
||||||
|
} catch (InstantiationException e) {
|
||||||
|
throw new StingException(String.format("Cannot instantiate class '%s': must be concrete class", c.getSimpleName()));
|
||||||
|
} catch (IllegalAccessException e) {
|
||||||
|
throw new StingException(String.format("Cannot instantiate class '%s': must have no-arg constructor", c.getSimpleName()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the interface classes that extend the specified interface.
|
* Return the interface classes that extend the specified interface.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ public class
|
||||||
String extraArgs = "-L 1:1-10,000,000";
|
String extraArgs = "-L 1:1-10,000,000";
|
||||||
for (String tests : testsEnumerations) {
|
for (String tests : testsEnumerations) {
|
||||||
WalkerTestSpec spec = new WalkerTestSpec(withSelect(tests, "DP < 50", "DP50") + " " + extraArgs + " -o %s",
|
WalkerTestSpec spec = new WalkerTestSpec(withSelect(tests, "DP < 50", "DP50") + " " + extraArgs + " -o %s",
|
||||||
1, Arrays.asList("119601d7e9e67a1053663b2e546250ed"));
|
1, Arrays.asList("a12bd969ca3bc676752e078d205c730a"));
|
||||||
executeTest("testSelect1", spec);
|
executeTest("testSelect1", spec);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -38,7 +38,7 @@ public class
|
||||||
public void testSelect2() {
|
public void testSelect2() {
|
||||||
String extraArgs = "-L 1:1-10,000,000";
|
String extraArgs = "-L 1:1-10,000,000";
|
||||||
WalkerTestSpec spec = new WalkerTestSpec( withSelect(withSelect(root, "DP < 50", "DP50"), "set==\"Intersection\"", "intersection") + " " + extraArgs + " -o %s",
|
WalkerTestSpec spec = new WalkerTestSpec( withSelect(withSelect(root, "DP < 50", "DP50"), "set==\"Intersection\"", "intersection") + " " + extraArgs + " -o %s",
|
||||||
1, Arrays.asList("06d495ab8169a2570eebdc54ecdffe10"));
|
1, Arrays.asList("2c1a99b225b55dcf605410ba5e6be789"));
|
||||||
executeTest("testSelect2", spec);
|
executeTest("testSelect2", spec);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -46,7 +46,7 @@ public class
|
||||||
public void testVEGenotypeConcordance() {
|
public void testVEGenotypeConcordance() {
|
||||||
String vcfFiles[] = {"GenotypeConcordanceEval.vcf", "GenotypeConcordanceEval.vcf.gz"};
|
String vcfFiles[] = {"GenotypeConcordanceEval.vcf", "GenotypeConcordanceEval.vcf.gz"};
|
||||||
for (String vcfFile : vcfFiles) {
|
for (String vcfFile : vcfFiles) {
|
||||||
WalkerTestSpec spec = new WalkerTestSpec(cmdRoot + " -B eval,VCF," + validationDataLocation + vcfFile + " -B comp,VCF," + validationDataLocation + "GenotypeConcordanceComp.vcf -E GenotypeConcordance -reportType CSV -o %s",
|
WalkerTestSpec spec = new WalkerTestSpec(cmdRoot + " -B eval,VCF," + validationDataLocation + vcfFile + " -B comp,VCF," + validationDataLocation + "GenotypeConcordanceComp.vcf -noStandard -E GenotypeConcordance -reportType CSV -o %s",
|
||||||
1,
|
1,
|
||||||
Arrays.asList("15d1075d384da2bb7445f7493f2b6a07"));
|
Arrays.asList("15d1075d384da2bb7445f7493f2b6a07"));
|
||||||
executeTest("testVEGenotypeConcordance" + vcfFile, spec);
|
executeTest("testVEGenotypeConcordance" + vcfFile, spec);
|
||||||
|
|
@ -57,8 +57,8 @@ public class
|
||||||
@Test
|
@Test
|
||||||
public void testVESimple() {
|
public void testVESimple() {
|
||||||
HashMap<String, String> expectations = new HashMap<String, String>();
|
HashMap<String, String> expectations = new HashMap<String, String>();
|
||||||
expectations.put("-L 1:1-10,000,000", "629b8b124306435ff56b66357354dfbc");
|
expectations.put("-L 1:1-10,000,000", "a48e4ca3a019bf46eb3a178a6a80822f");
|
||||||
expectations.put("-L 1:1-10,000,000 -family NA19238+NA19239=NA19240 -MVQ 0", "f51c299d500b347d098c7ab25f54a436");
|
expectations.put("-L 1:1-10,000,000 -family NA19238+NA19239=NA19240 -MVQ 0 -E MendelianViolationEvaluator", "bc35dfefce72899d4c673bfc37c9a7f3");
|
||||||
|
|
||||||
for ( Map.Entry<String, String> entry : expectations.entrySet() ) {
|
for ( Map.Entry<String, String> entry : expectations.entrySet() ) {
|
||||||
String extraArgs = entry.getKey();
|
String extraArgs = entry.getKey();
|
||||||
|
|
@ -75,15 +75,15 @@ public class
|
||||||
@Test
|
@Test
|
||||||
public void testVEComplex() {
|
public void testVEComplex() {
|
||||||
HashMap<String, String> expectations = new HashMap<String, String>();
|
HashMap<String, String> expectations = new HashMap<String, String>();
|
||||||
String extraArgs1 = "-L " + validationDataLocation + "chr1_b36_pilot3.interval_list -family NA19238+NA19239=NA19240 -MVQ 30" +
|
String extraArgs1 = "-L " + validationDataLocation + "chr1_b36_pilot3.interval_list -family NA19238+NA19239=NA19240 -MVQ 30 -E MendelianViolationEvaluator" +
|
||||||
" -B dbsnp_130,dbSNP," + GATKDataLocation + "dbsnp_130_b36.rod" +
|
" -B dbsnp_130,dbSNP," + GATKDataLocation + "dbsnp_130_b36.rod" +
|
||||||
" -B comp_hapmap,VCF," + validationDataLocation + "CEU_hapmap_nogt_23.vcf";
|
" -B comp_hapmap,VCF," + validationDataLocation + "CEU_hapmap_nogt_23.vcf";
|
||||||
|
|
||||||
|
|
||||||
String matchingMD5 = "d01725ce4e46c8fea0855a923c1598fd";
|
String matchingMD5 = "38c8906cc364d04ba39a437d93d752d3";
|
||||||
expectations.put("", matchingMD5);
|
expectations.put("", matchingMD5);
|
||||||
expectations.put(" -known comp_hapmap -known dbsnp", matchingMD5);
|
expectations.put(" -known comp_hapmap -known dbsnp", matchingMD5);
|
||||||
expectations.put(" -known comp_hapmap", "a50be9240f6c90503fb6333d8a78b974");
|
expectations.put(" -known comp_hapmap", "b839c8e9f26b01281899f86362b5323c");
|
||||||
for (String tests : testsEnumerations) {
|
for (String tests : testsEnumerations) {
|
||||||
for (Map.Entry<String, String> entry : expectations.entrySet()) {
|
for (Map.Entry<String, String> entry : expectations.entrySet()) {
|
||||||
String extraArgs2 = entry.getKey();
|
String extraArgs2 = entry.getKey();
|
||||||
|
|
@ -103,7 +103,7 @@ public class
|
||||||
"-R " + oneKGLocation + "reference/human_b36_both.fasta " +
|
"-R " + oneKGLocation + "reference/human_b36_both.fasta " +
|
||||||
"-L 21 " +
|
"-L 21 " +
|
||||||
"-D " + GATKDataLocation + "dbsnp_129_b36.rod " +
|
"-D " + GATKDataLocation + "dbsnp_129_b36.rod " +
|
||||||
"-E CountFunctionalClasses " +
|
"-E CountFunctionalClasses -noStandard " +
|
||||||
"-B eval,VCF," + validationDataLocation + "test.filtered.maf_annotated.vcf " +
|
"-B eval,VCF," + validationDataLocation + "test.filtered.maf_annotated.vcf " +
|
||||||
"-o %s";
|
"-o %s";
|
||||||
String md5 = "d41d8cd98f00b204e9800998ecf8427e";
|
String md5 = "d41d8cd98f00b204e9800998ecf8427e";
|
||||||
|
|
@ -114,11 +114,11 @@ public class
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testVEWriteVCF() {
|
public void testVEWriteVCF() {
|
||||||
String extraArgs = "-L 1:1-10,000,000 -family NA19238+NA19239=NA19240 -MVQ 30";
|
String extraArgs = "-L 1:1-10,000,000 -family NA19238+NA19239=NA19240 -MVQ 30 -E MendelianViolationEvaluator";
|
||||||
for (String tests : testsEnumerations) {
|
for (String tests : testsEnumerations) {
|
||||||
WalkerTestSpec spec = new WalkerTestSpec(tests + " " + extraArgs + " -o %s -outputVCF %s",
|
WalkerTestSpec spec = new WalkerTestSpec(tests + " " + extraArgs + " -o %s -outputVCF %s",
|
||||||
2,
|
2,
|
||||||
Arrays.asList("483f821ce96f4cf571e9bba356c9f325", "989bc30dea6c8a4cf771cd1b9fdab488"));
|
Arrays.asList("8059c6b53ba15598bf89d65c79742566", "989bc30dea6c8a4cf771cd1b9fdab488"));
|
||||||
executeTest("testVEWriteVCF", spec);
|
executeTest("testVEWriteVCF", spec);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue