Better interface for getting RodBindings to the VariantAnnotatorEngine and its annotations: pass around an AnnotatorCompatibleWalker (interface) object. Updating VA to use the new rod system.

This commit is contained in:
Eric Banks 2011-08-10 22:43:08 -04:00
parent cb6cf25bb0
commit bdb1da30fd
41 changed files with 163 additions and 645 deletions

View File

@ -42,7 +42,7 @@ public class DbsnpArgumentCollection {
* A dbSNP VCF file.
*/
@Input(fullName="dbsnp", shortName = "D", doc="dbSNP file", required=false)
public RodBinding<VariantContext> dbsnp = RodBinding.makeUnbound(VariantContext.class);
public RodBinding<VariantContext> dbsnp;
}

View File

@ -25,7 +25,6 @@
package org.broadinstitute.sting.gatk.refdata.features;
import net.sf.samtools.util.SequenceUtil;
import org.broad.tribble.Feature;
import org.broad.tribble.annotation.Strand;
import org.broad.tribble.dbsnp.DbSNPFeature;
import org.broadinstitute.sting.utils.Utils;
@ -44,50 +43,13 @@ public class DbSNPHelper {
private DbSNPHelper() {} // don't make a DbSNPHelper
public static DbSNPFeature getFirstRealSNP(List<Object> dbsnpList) {
if (dbsnpList == null)
return null;
DbSNPFeature dbsnp = null;
for (Object d : dbsnpList) {
if (d instanceof DbSNPFeature && DbSNPHelper.isSNP((DbSNPFeature)d)) {
dbsnp = (DbSNPFeature) d;
break;
}
}
return dbsnp;
}
public static String rsIDOfFirstRealSNP(List<Feature> featureList, boolean deleteMe) {
if (featureList == null)
return null;
String rsID = null;
for ( Feature d : featureList ) {
if ( d instanceof DbSNPFeature ) {
if ( DbSNPHelper.isSNP((DbSNPFeature)d) ) {
rsID = ((DbSNPFeature)d).getRsID();
break;
}
} else if ( d instanceof VariantContext) {
if ( ((VariantContext)d).isSNP() ) {
rsID = ((VariantContext)d).getID();
break;
}
}
}
return rsID;
}
public static String rsIDOfFirstRealSNP(List<VariantContext> VCs) {
public static String rsIDOfFirstRealVariant(List<VariantContext> VCs, VariantContext.Type type) {
if ( VCs == null )
return null;
String rsID = null;
for ( VariantContext vc : VCs ) {
if ( vc.isSNP() ) {
if ( vc.getType() == type ) {
rsID = vc.getID();
break;
}
@ -96,28 +58,6 @@ public class DbSNPHelper {
return rsID;
}
public static String rsIDOfFirstRealIndel(List<Feature> featureList) {
if (featureList == null)
return null;
String rsID = null;
for ( Feature d : featureList ) {
if ( d instanceof DbSNPFeature ) {
if ( DbSNPHelper.isIndel((DbSNPFeature) d) ) {
rsID = ((DbSNPFeature)d).getRsID();
break;
}
} else if ( d instanceof VariantContext) {
if ( ((VariantContext)d).isIndel() ) {
rsID = ((VariantContext)d).getID();
break;
}
}
}
return rsID;
}
/**
* get the -1 * (log 10 of the error value)
*

View File

@ -25,11 +25,10 @@
package org.broadinstitute.sting.gatk.walkers.annotator;
import org.broad.tribble.Feature;
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.annotator.interfaces.AnnotatorCompatibleWalker;
import org.broadinstitute.sting.gatk.walkers.annotator.interfaces.InfoFieldAnnotation;
import org.broadinstitute.sting.utils.MathUtils;
import org.broadinstitute.sting.utils.codecs.vcf.VCFHeaderLineType;
@ -46,7 +45,7 @@ import java.util.Map;
public class AlleleBalance extends InfoFieldAnnotation {
public Map<String, Object> annotate(RefMetaDataTracker tracker, Map<String, RodBinding<? extends Feature>> rodBindings, ReferenceContext ref, Map<String, AlignmentContext> stratifiedContexts, VariantContext vc) {
public Map<String, Object> annotate(RefMetaDataTracker tracker, AnnotatorCompatibleWalker walker, ReferenceContext ref, Map<String, AlignmentContext> stratifiedContexts, VariantContext vc) {
if ( stratifiedContexts.size() == 0 )
return null;

View File

@ -1,10 +1,9 @@
package org.broadinstitute.sting.gatk.walkers.annotator;
import org.broad.tribble.Feature;
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.annotator.interfaces.AnnotatorCompatibleWalker;
import org.broadinstitute.sting.gatk.walkers.annotator.interfaces.ExperimentalAnnotation;
import org.broadinstitute.sting.gatk.walkers.annotator.interfaces.GenotypeAnnotation;
import org.broadinstitute.sting.utils.MathUtils;
@ -19,7 +18,7 @@ import java.util.*;
public class AlleleBalanceBySample extends GenotypeAnnotation implements ExperimentalAnnotation {
public Map<String, Object> annotate(RefMetaDataTracker tracker, Map<String, RodBinding<? extends Feature>> rodBindings, ReferenceContext ref, AlignmentContext stratifiedContext, VariantContext vc, Genotype g) {
public Map<String, Object> annotate(RefMetaDataTracker tracker, AnnotatorCompatibleWalker walker, ReferenceContext ref, AlignmentContext stratifiedContext, VariantContext vc, Genotype g) {
Double ratio = annotateSNP(stratifiedContext, vc, g);
if (ratio == null)
return null;

View File

@ -31,11 +31,10 @@
package org.broadinstitute.sting.gatk.walkers.annotator;
import org.broad.tribble.Feature;
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.annotator.interfaces.AnnotatorCompatibleWalker;
import org.broadinstitute.sting.gatk.walkers.annotator.interfaces.InfoFieldAnnotation;
import org.broadinstitute.sting.utils.BaseUtils;
import org.broadinstitute.sting.utils.codecs.vcf.VCFHeaderLineType;
@ -50,7 +49,7 @@ import java.util.Map;
public class BaseCounts extends InfoFieldAnnotation {
public Map<String, Object> annotate(RefMetaDataTracker tracker, Map<String, RodBinding<? extends Feature>> rodBindings, ReferenceContext ref, Map<String, AlignmentContext> stratifiedContexts, VariantContext vc) {
public Map<String, Object> annotate(RefMetaDataTracker tracker, AnnotatorCompatibleWalker walker, ReferenceContext ref, Map<String, AlignmentContext> stratifiedContexts, VariantContext vc) {
if ( stratifiedContexts.size() == 0 )
return null;

View File

@ -25,11 +25,10 @@
package org.broadinstitute.sting.gatk.walkers.annotator;
import org.broad.tribble.Feature;
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.annotator.interfaces.AnnotatorCompatibleWalker;
import org.broadinstitute.sting.gatk.walkers.annotator.interfaces.InfoFieldAnnotation;
import org.broadinstitute.sting.gatk.walkers.annotator.interfaces.StandardAnnotation;
import org.broadinstitute.sting.utils.codecs.vcf.VCFConstants;
@ -52,7 +51,7 @@ public class ChromosomeCounts extends InfoFieldAnnotation implements StandardAnn
new VCFInfoHeaderLine(VCFConstants.ALLELE_COUNT_KEY, VCFHeaderLineCount.A, VCFHeaderLineType.Integer, "Allele count in genotypes, for each ALT allele, in the same order as listed"),
new VCFInfoHeaderLine(VCFConstants.ALLELE_NUMBER_KEY, 1, VCFHeaderLineType.Integer, "Total number of alleles in called genotypes") };
public Map<String, Object> annotate(RefMetaDataTracker tracker, Map<String, RodBinding<? extends Feature>> rodBindings, ReferenceContext ref, Map<String, AlignmentContext> stratifiedContexts, VariantContext vc) {
public Map<String, Object> annotate(RefMetaDataTracker tracker, AnnotatorCompatibleWalker walker, ReferenceContext ref, Map<String, AlignmentContext> stratifiedContexts, VariantContext vc) {
if ( ! vc.hasGenotypes() )
return null;

View File

@ -1,10 +1,9 @@
package org.broadinstitute.sting.gatk.walkers.annotator;
import org.broad.tribble.Feature;
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.annotator.interfaces.AnnotatorCompatibleWalker;
import org.broadinstitute.sting.gatk.walkers.annotator.interfaces.InfoFieldAnnotation;
import org.broadinstitute.sting.gatk.walkers.annotator.interfaces.StandardAnnotation;
import org.broadinstitute.sting.utils.codecs.vcf.VCFConstants;
@ -20,7 +19,7 @@ import java.util.Map;
public class DepthOfCoverage extends InfoFieldAnnotation implements StandardAnnotation {
public Map<String, Object> annotate(RefMetaDataTracker tracker, Map<String, RodBinding<? extends Feature>> rodBindings, ReferenceContext ref, Map<String, AlignmentContext> stratifiedContexts, VariantContext vc) {
public Map<String, Object> annotate(RefMetaDataTracker tracker, AnnotatorCompatibleWalker walker, ReferenceContext ref, Map<String, AlignmentContext> stratifiedContexts, VariantContext vc) {
if ( stratifiedContexts.size() == 0 )
return null;

View File

@ -1,10 +1,9 @@
package org.broadinstitute.sting.gatk.walkers.annotator;
import org.broad.tribble.Feature;
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.annotator.interfaces.AnnotatorCompatibleWalker;
import org.broadinstitute.sting.gatk.walkers.annotator.interfaces.GenotypeAnnotation;
import org.broadinstitute.sting.gatk.walkers.annotator.interfaces.StandardAnnotation;
import org.broadinstitute.sting.utils.codecs.vcf.VCFFormatHeaderLine;
@ -30,7 +29,7 @@ public class DepthPerAlleleBySample extends GenotypeAnnotation implements Standa
private static String DEL = "DEL"; // constant, for speed: no need to create a key string for deletion allele every time
public Map<String, Object> annotate(RefMetaDataTracker tracker, Map<String, RodBinding<? extends Feature>> rodBindings, ReferenceContext ref, AlignmentContext stratifiedContext, VariantContext vc, Genotype g) {
public Map<String, Object> annotate(RefMetaDataTracker tracker, AnnotatorCompatibleWalker walker, ReferenceContext ref, AlignmentContext stratifiedContext, VariantContext vc, Genotype g) {
if ( g == null || !g.isCalled() )
return null;

View File

@ -25,11 +25,10 @@
package org.broadinstitute.sting.gatk.walkers.annotator;
import cern.jet.math.Arithmetic;
import org.broad.tribble.Feature;
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.annotator.interfaces.AnnotatorCompatibleWalker;
import org.broadinstitute.sting.gatk.walkers.annotator.interfaces.InfoFieldAnnotation;
import org.broadinstitute.sting.gatk.walkers.annotator.interfaces.StandardAnnotation;
import org.broadinstitute.sting.gatk.walkers.genotyper.IndelGenotypeLikelihoodsCalculationModel;
@ -48,7 +47,7 @@ public class FisherStrand extends InfoFieldAnnotation implements StandardAnnotat
private static final String FS = "FS";
private static final double MIN_PVALUE = 1E-320;
public Map<String, Object> annotate(RefMetaDataTracker tracker, Map<String, RodBinding<? extends Feature>> rodBindings, ReferenceContext ref, Map<String, AlignmentContext> stratifiedContexts, VariantContext vc) {
public Map<String, Object> annotate(RefMetaDataTracker tracker, AnnotatorCompatibleWalker walker, ReferenceContext ref, Map<String, AlignmentContext> stratifiedContexts, VariantContext vc) {
if ( ! vc.isVariant() || vc.isFiltered() )
return null;

View File

@ -1,10 +1,9 @@
package org.broadinstitute.sting.gatk.walkers.annotator;
import org.broad.tribble.Feature;
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.annotator.interfaces.AnnotatorCompatibleWalker;
import org.broadinstitute.sting.gatk.walkers.annotator.interfaces.ExperimentalAnnotation;
import org.broadinstitute.sting.gatk.walkers.annotator.interfaces.InfoFieldAnnotation;
import org.broadinstitute.sting.utils.BaseUtils;
@ -20,7 +19,7 @@ import java.util.Map;
public class GCContent extends InfoFieldAnnotation implements ExperimentalAnnotation {
public Map<String, Object> annotate(RefMetaDataTracker tracker, Map<String, RodBinding<? extends Feature>> rodBindings, ReferenceContext ref, Map<String, AlignmentContext> stratifiedContexts, VariantContext vc) {
public Map<String, Object> annotate(RefMetaDataTracker tracker, AnnotatorCompatibleWalker walker, ReferenceContext ref, Map<String, AlignmentContext> stratifiedContexts, VariantContext vc) {
double content = computeGCContent(ref);
Map<String, Object> map = new HashMap<String, Object>();
map.put(getKeyNames().get(0), String.format("%.2f", content));

View File

@ -1,10 +1,9 @@
package org.broadinstitute.sting.gatk.walkers.annotator;
import org.broad.tribble.Feature;
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.annotator.interfaces.AnnotatorCompatibleWalker;
import org.broadinstitute.sting.gatk.walkers.annotator.interfaces.InfoFieldAnnotation;
import org.broadinstitute.sting.gatk.walkers.annotator.interfaces.StandardAnnotation;
import org.broadinstitute.sting.utils.MathUtils;
@ -29,7 +28,7 @@ public class GLstats extends InfoFieldAnnotation implements StandardAnnotation {
private static final int MIN_SAMPLES = 10;
public Map<String, Object> annotate(RefMetaDataTracker tracker, Map<String, RodBinding<? extends Feature>> rodBindings, ReferenceContext ref, Map<String, AlignmentContext> stratifiedContexts, VariantContext vc) {
public Map<String, Object> annotate(RefMetaDataTracker tracker, AnnotatorCompatibleWalker walker, ReferenceContext ref, Map<String, AlignmentContext> stratifiedContexts, VariantContext vc) {
final Map<String, Genotype> genotypes = vc.getGenotypes();
if ( genotypes == null || genotypes.size() < MIN_SAMPLES )

View File

@ -25,12 +25,11 @@
package org.broadinstitute.sting.gatk.walkers.annotator;
import net.sf.samtools.SAMRecord;
import org.broad.tribble.Feature;
import org.broadinstitute.sting.commandline.RodBinding;
import org.broadinstitute.sting.gatk.contexts.AlignmentContext;
import org.broadinstitute.sting.gatk.contexts.AlignmentContextUtils;
import org.broadinstitute.sting.gatk.contexts.ReferenceContext;
import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker;
import org.broadinstitute.sting.gatk.walkers.annotator.interfaces.AnnotatorCompatibleWalker;
import org.broadinstitute.sting.gatk.walkers.annotator.interfaces.InfoFieldAnnotation;
import org.broadinstitute.sting.gatk.walkers.annotator.interfaces.StandardAnnotation;
import org.broadinstitute.sting.gatk.walkers.genotyper.IndelGenotypeLikelihoodsCalculationModel;
@ -56,7 +55,7 @@ public class HaplotypeScore extends InfoFieldAnnotation implements StandardAnnot
private final static int MAX_CONSENSUS_HAPLOTYPES_TO_CONSIDER = 50;
private final static char REGEXP_WILDCARD = '.';
public Map<String, Object> annotate(RefMetaDataTracker tracker, Map<String, RodBinding<? extends Feature>> rodBindings, ReferenceContext ref, Map<String, AlignmentContext> stratifiedContexts, VariantContext vc) {
public Map<String, Object> annotate(RefMetaDataTracker tracker, AnnotatorCompatibleWalker walker, ReferenceContext ref, Map<String, AlignmentContext> stratifiedContexts, VariantContext vc) {
if (stratifiedContexts.size() == 0 ) // size 0 means that call was made by someone else and we have no data here
return null;

View File

@ -1,11 +1,10 @@
package org.broadinstitute.sting.gatk.walkers.annotator;
import org.broad.tribble.Feature;
import org.broad.tribble.util.popgen.HardyWeinbergCalculation;
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.annotator.interfaces.AnnotatorCompatibleWalker;
import org.broadinstitute.sting.gatk.walkers.annotator.interfaces.InfoFieldAnnotation;
import org.broadinstitute.sting.gatk.walkers.annotator.interfaces.WorkInProgressAnnotation;
import org.broadinstitute.sting.utils.QualityUtils;
@ -26,7 +25,7 @@ public class HardyWeinberg extends InfoFieldAnnotation implements WorkInProgress
private static final int MIN_GENOTYPE_QUALITY = 10;
private static final int MIN_NEG_LOG10_PERROR = MIN_GENOTYPE_QUALITY / 10;
public Map<String, Object> annotate(RefMetaDataTracker tracker, Map<String, RodBinding<? extends Feature>> rodBindings, ReferenceContext ref, Map<String, AlignmentContext> stratifiedContexts, VariantContext vc) {
public Map<String, Object> annotate(RefMetaDataTracker tracker, AnnotatorCompatibleWalker walker, ReferenceContext ref, Map<String, AlignmentContext> stratifiedContexts, VariantContext vc) {
final Map<String, Genotype> genotypes = vc.getGenotypes();
if ( genotypes == null || genotypes.size() < MIN_SAMPLES )

View File

@ -1,10 +1,9 @@
package org.broadinstitute.sting.gatk.walkers.annotator;
import org.broad.tribble.Feature;
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.annotator.interfaces.AnnotatorCompatibleWalker;
import org.broadinstitute.sting.gatk.walkers.annotator.interfaces.InfoFieldAnnotation;
import org.broadinstitute.sting.gatk.walkers.annotator.interfaces.StandardAnnotation;
import org.broadinstitute.sting.utils.GenomeLoc;
@ -22,7 +21,7 @@ public class HomopolymerRun extends InfoFieldAnnotation implements StandardAnnot
private boolean ANNOTATE_INDELS = true;
public Map<String, Object> annotate(RefMetaDataTracker tracker, Map<String, RodBinding<? extends Feature>> rodBindings, ReferenceContext ref, Map<String, AlignmentContext> stratifiedContexts, VariantContext vc) {
public Map<String, Object> annotate(RefMetaDataTracker tracker, AnnotatorCompatibleWalker walker, ReferenceContext ref, Map<String, AlignmentContext> stratifiedContexts, VariantContext vc) {
if ( !vc.isBiallelic() )
return null;

View File

@ -1,10 +1,9 @@
package org.broadinstitute.sting.gatk.walkers.annotator;
import org.broad.tribble.Feature;
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.annotator.interfaces.AnnotatorCompatibleWalker;
import org.broadinstitute.sting.gatk.walkers.annotator.interfaces.ExperimentalAnnotation;
import org.broadinstitute.sting.gatk.walkers.annotator.interfaces.InfoFieldAnnotation;
import org.broadinstitute.sting.utils.IndelUtils;
@ -23,7 +22,7 @@ import java.util.*;
*/
public class IndelType extends InfoFieldAnnotation implements ExperimentalAnnotation {
public Map<String, Object> annotate(RefMetaDataTracker tracker, Map<String, RodBinding<? extends Feature>> rodBindings, ReferenceContext ref, Map<String, AlignmentContext> stratifiedContexts, VariantContext vc) {
public Map<String, Object> annotate(RefMetaDataTracker tracker, AnnotatorCompatibleWalker walker, ReferenceContext ref, Map<String, AlignmentContext> stratifiedContexts, VariantContext vc) {
int run;
if (vc.isMixed()) {

View File

@ -1,10 +1,9 @@
package org.broadinstitute.sting.gatk.walkers.annotator;
import org.broad.tribble.Feature;
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.annotator.interfaces.AnnotatorCompatibleWalker;
import org.broadinstitute.sting.gatk.walkers.annotator.interfaces.InfoFieldAnnotation;
import org.broadinstitute.sting.utils.codecs.vcf.VCFHeaderLineType;
import org.broadinstitute.sting.utils.codecs.vcf.VCFInfoHeaderLine;
@ -20,7 +19,7 @@ import java.util.Map;
public class LowMQ extends InfoFieldAnnotation {
public Map<String, Object> annotate(RefMetaDataTracker tracker, Map<String, RodBinding<? extends Feature>> rodBindings, ReferenceContext ref, Map<String, AlignmentContext> stratifiedContexts, VariantContext vc) {
public Map<String, Object> annotate(RefMetaDataTracker tracker, AnnotatorCompatibleWalker walker, ReferenceContext ref, Map<String, AlignmentContext> stratifiedContexts, VariantContext vc) {
if ( stratifiedContexts.size() == 0 )
return null;

View File

@ -1,10 +1,9 @@
package org.broadinstitute.sting.gatk.walkers.annotator;
import org.broad.tribble.Feature;
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.annotator.interfaces.AnnotatorCompatibleWalker;
import org.broadinstitute.sting.gatk.walkers.annotator.interfaces.InfoFieldAnnotation;
import org.broadinstitute.sting.gatk.walkers.annotator.interfaces.StandardAnnotation;
import org.broadinstitute.sting.utils.codecs.vcf.VCFConstants;
@ -22,7 +21,7 @@ import java.util.Map;
public class MappingQualityZero extends InfoFieldAnnotation implements StandardAnnotation {
public Map<String, Object> annotate(RefMetaDataTracker tracker, Map<String, RodBinding<? extends Feature>> rodBindings, ReferenceContext ref, Map<String, AlignmentContext> stratifiedContexts, VariantContext vc) {
public Map<String, Object> annotate(RefMetaDataTracker tracker, AnnotatorCompatibleWalker walker, ReferenceContext ref, Map<String, AlignmentContext> stratifiedContexts, VariantContext vc) {
if ( stratifiedContexts.size() == 0 )
return null;

View File

@ -25,11 +25,10 @@
package org.broadinstitute.sting.gatk.walkers.annotator;
import org.broad.tribble.Feature;
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.annotator.interfaces.AnnotatorCompatibleWalker;
import org.broadinstitute.sting.gatk.walkers.annotator.interfaces.GenotypeAnnotation;
import org.broadinstitute.sting.utils.codecs.vcf.VCFConstants;
import org.broadinstitute.sting.utils.codecs.vcf.VCFFormatHeaderLine;
@ -52,8 +51,8 @@ import java.util.Map;
* To change this template use File | Settings | File Templates.
*/
public class MappingQualityZeroBySample extends GenotypeAnnotation {
public Map<String, Object> annotate(RefMetaDataTracker tracker, Map<String, RodBinding<? extends Feature>> rodBindings,
ReferenceContext ref, AlignmentContext context, VariantContext vc, Genotype g) {
public Map<String, Object> annotate(RefMetaDataTracker tracker,
AnnotatorCompatibleWalker walker, ReferenceContext ref, AlignmentContext context, VariantContext vc, Genotype g) {
if ( g == null || !g.isCalled() )
return null;

View File

@ -1,10 +1,9 @@
package org.broadinstitute.sting.gatk.walkers.annotator;
import org.broad.tribble.Feature;
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.annotator.interfaces.AnnotatorCompatibleWalker;
import org.broadinstitute.sting.gatk.walkers.annotator.interfaces.ExperimentalAnnotation;
import org.broadinstitute.sting.gatk.walkers.annotator.interfaces.InfoFieldAnnotation;
import org.broadinstitute.sting.utils.codecs.vcf.VCFHeaderLineType;
@ -22,7 +21,7 @@ import java.util.Map;
public class MappingQualityZeroFraction extends InfoFieldAnnotation implements ExperimentalAnnotation {
public Map<String, Object> annotate(RefMetaDataTracker tracker, Map<String, RodBinding<? extends Feature>> rodBindings, ReferenceContext ref, Map<String, AlignmentContext> stratifiedContexts, VariantContext vc) {
public Map<String, Object> annotate(RefMetaDataTracker tracker, AnnotatorCompatibleWalker walker, ReferenceContext ref, Map<String, AlignmentContext> stratifiedContexts, VariantContext vc) {
if ( stratifiedContexts.size() == 0 )
return null;

View File

@ -1,10 +1,9 @@
package org.broadinstitute.sting.gatk.walkers.annotator;
import org.broad.tribble.Feature;
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.annotator.interfaces.AnnotatorCompatibleWalker;
import org.broadinstitute.sting.gatk.walkers.annotator.interfaces.InfoFieldAnnotation;
import org.broadinstitute.sting.utils.BaseUtils;
import org.broadinstitute.sting.utils.codecs.vcf.VCFHeaderLineType;
@ -24,7 +23,7 @@ import java.util.Map;
*/
public class NBaseCount extends InfoFieldAnnotation {
public Map<String, Object> annotate(RefMetaDataTracker tracker, Map<String, RodBinding<? extends Feature>> rodBindings, ReferenceContext ref, Map<String, AlignmentContext> stratifiedContexts, VariantContext vc) {
public Map<String, Object> annotate(RefMetaDataTracker tracker, AnnotatorCompatibleWalker walker, ReferenceContext ref, Map<String, AlignmentContext> stratifiedContexts, VariantContext vc) {
if( stratifiedContexts.size() == 0 )
return null;

View File

@ -1,11 +1,9 @@
package org.broadinstitute.sting.gatk.walkers.annotator;
import org.broad.tribble.Feature;
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.annotator.interfaces.InfoFieldAnnotation;
import org.broadinstitute.sting.gatk.walkers.annotator.interfaces.AnnotatorCompatibleWalker;
import org.broadinstitute.sting.gatk.walkers.annotator.interfaces.StandardAnnotation;
import org.broadinstitute.sting.utils.codecs.vcf.VCFHeaderLineType;
import org.broadinstitute.sting.utils.codecs.vcf.VCFInfoHeaderLine;
@ -20,7 +18,7 @@ import java.util.Map;
public class QualByDepth extends AnnotationByDepth implements StandardAnnotation {
public Map<String, Object> annotate(RefMetaDataTracker tracker, Map<String, RodBinding<? extends Feature>> rodBindings, ReferenceContext ref, Map<String, AlignmentContext> stratifiedContexts, VariantContext vc) {
public Map<String, Object> annotate(RefMetaDataTracker tracker, AnnotatorCompatibleWalker walker, ReferenceContext ref, Map<String, AlignmentContext> stratifiedContexts, VariantContext vc) {
if ( stratifiedContexts.size() == 0 )
return null;

View File

@ -1,10 +1,9 @@
package org.broadinstitute.sting.gatk.walkers.annotator;
import org.broad.tribble.Feature;
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.annotator.interfaces.AnnotatorCompatibleWalker;
import org.broadinstitute.sting.gatk.walkers.annotator.interfaces.InfoFieldAnnotation;
import org.broadinstitute.sting.gatk.walkers.annotator.interfaces.StandardAnnotation;
import org.broadinstitute.sting.utils.MathUtils;
@ -24,7 +23,7 @@ import java.util.Map;
public class RMSMappingQuality extends InfoFieldAnnotation implements StandardAnnotation {
public Map<String, Object> annotate(RefMetaDataTracker tracker, Map<String, RodBinding<? extends Feature>> rodBindings, ReferenceContext ref, Map<String, AlignmentContext> stratifiedContexts, VariantContext vc) {
public Map<String, Object> annotate(RefMetaDataTracker tracker, AnnotatorCompatibleWalker walker, ReferenceContext ref, Map<String, AlignmentContext> stratifiedContexts, VariantContext vc) {
if ( stratifiedContexts.size() == 0 )
return null;

View File

@ -1,10 +1,9 @@
package org.broadinstitute.sting.gatk.walkers.annotator;
import org.broad.tribble.Feature;
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.annotator.interfaces.AnnotatorCompatibleWalker;
import org.broadinstitute.sting.gatk.walkers.annotator.interfaces.InfoFieldAnnotation;
import org.broadinstitute.sting.gatk.walkers.annotator.interfaces.StandardAnnotation;
import org.broadinstitute.sting.gatk.walkers.genotyper.IndelGenotypeLikelihoodsCalculationModel;
@ -27,7 +26,7 @@ public abstract class RankSumTest extends InfoFieldAnnotation implements Standar
static final double INDEL_LIKELIHOOD_THRESH = 0.1;
static final boolean DEBUG = false;
public Map<String, Object> annotate(RefMetaDataTracker tracker, Map<String, RodBinding<? extends Feature>> rodBindings, ReferenceContext ref, Map<String, AlignmentContext> stratifiedContexts, VariantContext vc) {
public Map<String, Object> annotate(RefMetaDataTracker tracker, AnnotatorCompatibleWalker walker, ReferenceContext ref, Map<String, AlignmentContext> stratifiedContexts, VariantContext vc) {
if ( stratifiedContexts.size() == 0 )
return null;

View File

@ -25,11 +25,10 @@
package org.broadinstitute.sting.gatk.walkers.annotator;
import org.broad.tribble.Feature;
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.annotator.interfaces.AnnotatorCompatibleWalker;
import org.broadinstitute.sting.gatk.walkers.annotator.interfaces.GenotypeAnnotation;
import org.broadinstitute.sting.utils.codecs.vcf.VCFFormatHeaderLine;
import org.broadinstitute.sting.utils.codecs.vcf.VCFHeaderLineCount;
@ -60,7 +59,7 @@ public class ReadDepthAndAllelicFractionBySample extends GenotypeAnnotation {
private static String DEL = "DEL"; // constant, for speed: no need to create a key string for deletion allele every time
public Map<String, Object> annotate(RefMetaDataTracker tracker, Map<String, RodBinding<? extends Feature>> rodBindings, ReferenceContext ref,
public Map<String, Object> annotate(RefMetaDataTracker tracker, AnnotatorCompatibleWalker walker, ReferenceContext ref,
AlignmentContext stratifiedContext, VariantContext vc, Genotype g) {
if ( g == null || !g.isCalled() )
return null;

View File

@ -1,10 +1,9 @@
package org.broadinstitute.sting.gatk.walkers.annotator;
import org.broad.tribble.Feature;
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.annotator.interfaces.AnnotatorCompatibleWalker;
import org.broadinstitute.sting.utils.codecs.vcf.VCFConstants;
import org.broadinstitute.sting.utils.codecs.vcf.VCFHeaderLineType;
import org.broadinstitute.sting.utils.codecs.vcf.VCFInfoHeaderLine;
@ -20,7 +19,7 @@ import java.util.Map;
public class SBByDepth extends AnnotationByDepth {
public Map<String, Object> annotate(RefMetaDataTracker tracker, Map<String, RodBinding<? extends Feature>> rodBindings, ReferenceContext ref, Map<String, AlignmentContext> stratifiedContexts, VariantContext vc) {
public Map<String, Object> annotate(RefMetaDataTracker tracker, AnnotatorCompatibleWalker walker, ReferenceContext ref, Map<String, AlignmentContext> stratifiedContexts, VariantContext vc) {
if ( stratifiedContexts.size() == 0 )
return null;

View File

@ -25,11 +25,10 @@
package org.broadinstitute.sting.gatk.walkers.annotator;
import org.broad.tribble.Feature;
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.annotator.interfaces.AnnotatorCompatibleWalker;
import org.broadinstitute.sting.gatk.walkers.annotator.interfaces.InfoFieldAnnotation;
import org.broadinstitute.sting.utils.codecs.vcf.VCFHeaderLineCount;
import org.broadinstitute.sting.utils.codecs.vcf.VCFHeaderLineType;
@ -45,7 +44,7 @@ import java.util.Map;
public class SampleList extends InfoFieldAnnotation {
public Map<String, Object> annotate(RefMetaDataTracker tracker, Map<String, RodBinding<? extends Feature>> rodBindings, ReferenceContext ref, Map<String, AlignmentContext> stratifiedContexts, VariantContext vc) {
public Map<String, Object> annotate(RefMetaDataTracker tracker, AnnotatorCompatibleWalker walker, ReferenceContext ref, Map<String, AlignmentContext> stratifiedContexts, VariantContext vc) {
if ( vc.isMonomorphic() || !vc.hasGenotypes() )
return null;

View File

@ -24,11 +24,11 @@
package org.broadinstitute.sting.gatk.walkers.annotator;
import org.broad.tribble.Feature;
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.annotator.interfaces.AnnotatorCompatibleWalker;
import org.broadinstitute.sting.gatk.walkers.annotator.interfaces.ExperimentalAnnotation;
import org.broadinstitute.sting.gatk.walkers.annotator.interfaces.InfoFieldAnnotation;
import org.broadinstitute.sting.utils.Utils;
@ -70,10 +70,8 @@ public class SnpEff extends InfoFieldAnnotation implements ExperimentalAnnotatio
public static final String CODON_NUM_KEY = "CODON_NUM";
public static final String CDS_SIZE_KEY = "CDS_SIZE";
public static final String SNPEFF_ROD_NAME = "snpEffFile";
public Map<String, Object> annotate ( RefMetaDataTracker tracker, Map<String, RodBinding<? extends Feature>> rodBindings, ReferenceContext ref, Map<String, AlignmentContext> stratifiedContexts, VariantContext vc ) {
RodBinding<SnpEffFeature> snpEffRodBinding = (RodBinding<SnpEffFeature>)rodBindings.get(SNPEFF_ROD_NAME);
public Map<String, Object> annotate(RefMetaDataTracker tracker, AnnotatorCompatibleWalker walker, ReferenceContext ref, Map<String, AlignmentContext> stratifiedContexts, VariantContext vc) {
RodBinding<SnpEffFeature> snpEffRodBinding = walker.getSnpEffRodBinding();
List<SnpEffFeature> features = tracker.getValues(snpEffRodBinding);
// Add only annotations for one of the most biologically-significant effects as defined in

View File

@ -1,10 +1,9 @@
package org.broadinstitute.sting.gatk.walkers.annotator;
import org.broad.tribble.Feature;
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.annotator.interfaces.AnnotatorCompatibleWalker;
import org.broadinstitute.sting.gatk.walkers.annotator.interfaces.InfoFieldAnnotation;
import org.broadinstitute.sting.gatk.walkers.annotator.interfaces.StandardAnnotation;
import org.broadinstitute.sting.utils.codecs.vcf.VCFHeaderLineType;
@ -20,7 +19,7 @@ import java.util.Map;
public class SpanningDeletions extends InfoFieldAnnotation implements StandardAnnotation {
public Map<String, Object> annotate(RefMetaDataTracker tracker, Map<String, RodBinding<? extends Feature>> rodBindings, ReferenceContext ref, Map<String, AlignmentContext> stratifiedContexts, VariantContext vc) {
public Map<String, Object> annotate(RefMetaDataTracker tracker, AnnotatorCompatibleWalker walker, ReferenceContext ref, Map<String, AlignmentContext> stratifiedContexts, VariantContext vc) {
if ( stratifiedContexts.size() == 0 )
return null;

View File

@ -1,10 +1,9 @@
package org.broadinstitute.sting.gatk.walkers.annotator;
import org.broad.tribble.Feature;
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.annotator.interfaces.AnnotatorCompatibleWalker;
import org.broadinstitute.sting.gatk.walkers.annotator.interfaces.ExperimentalAnnotation;
import org.broadinstitute.sting.gatk.walkers.annotator.interfaces.InfoFieldAnnotation;
import org.broadinstitute.sting.utils.codecs.vcf.VCFHeaderLineType;
@ -31,7 +30,7 @@ public class TechnologyComposition extends InfoFieldAnnotation implements Experi
private String n454 ="Num454";
private String nSolid = "NumSOLiD";
private String nOther = "NumOther";
public Map<String, Object> annotate(RefMetaDataTracker tracker, Map<String, RodBinding<? extends Feature>> rodBindings, ReferenceContext ref, Map<String, AlignmentContext> stratifiedContexts, VariantContext vc) {
public Map<String, Object> annotate(RefMetaDataTracker tracker, AnnotatorCompatibleWalker walker, ReferenceContext ref, Map<String, AlignmentContext> stratifiedContexts, VariantContext vc) {
if ( stratifiedContexts.size() == 0 )
return null;

View File

@ -25,7 +25,6 @@
package org.broadinstitute.sting.gatk.walkers.annotator;
import org.broad.tribble.Feature;
import org.broadinstitute.sting.commandline.*;
import org.broadinstitute.sting.gatk.arguments.DbsnpArgumentCollection;
import org.broadinstitute.sting.gatk.arguments.StandardVariantContextInputArgumentCollection;
@ -35,6 +34,7 @@ import org.broadinstitute.sting.gatk.contexts.ReferenceContext;
import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker;
import org.broadinstitute.sting.gatk.walkers.*;
import org.broadinstitute.sting.gatk.walkers.annotator.interfaces.AnnotationType;
import org.broadinstitute.sting.gatk.walkers.annotator.interfaces.AnnotatorCompatibleWalker;
import org.broadinstitute.sting.gatk.walkers.annotator.interfaces.GenotypeAnnotation;
import org.broadinstitute.sting.gatk.walkers.annotator.interfaces.InfoFieldAnnotation;
import org.broadinstitute.sting.utils.BaseUtils;
@ -55,7 +55,7 @@ import java.util.*;
@Allows(value={DataSource.READS, DataSource.REFERENCE})
@Reference(window=@Window(start=-50,stop=50))
@By(DataSource.REFERENCE)
public class VariantAnnotator extends RodWalker<Integer, Integer> {
public class VariantAnnotator extends RodWalker<Integer, Integer> implements AnnotatorCompatibleWalker {
@ArgumentCollection
protected StandardVariantContextInputArgumentCollection variantCollection = new StandardVariantContextInputArgumentCollection();
@ -67,7 +67,8 @@ public class VariantAnnotator extends RodWalker<Integer, Integer> {
* listed in the SnpEff output file for each variant.
*/
@Input(fullName="snpEffFile", shortName = "snpEffFile", doc="SnpEff file", required=false)
public RodBinding<SnpEffFeature> snpEffFile = RodBinding.makeUnbound(SnpEffFeature.class);
public RodBinding<SnpEffFeature> snpEffFile;
public RodBinding<SnpEffFeature> getSnpEffRodBinding() { return snpEffFile; }
/**
* A dbSNP VCF file from which to annotate.
@ -76,16 +77,30 @@ public class VariantAnnotator extends RodWalker<Integer, Integer> {
*/
@ArgumentCollection
protected DbsnpArgumentCollection dbsnp = new DbsnpArgumentCollection();
public RodBinding<VariantContext> getDbsnpRodBinding() { return dbsnp.dbsnp; }
/**
* A comparisons VCF file from which to annotate.
* A comparisons VCF file or files from which to annotate.
*
* If a record in the 'variant' track overlaps with a record from the provided comp track, the INFO field will be annotated
* as such in the output with the track name (e.g. -comp:FOO will have 'FOO' in the INFO field). Records that are filtered in the comp track will be ignored.
* Note that 'dbSNP' has been special-cased (see the --dbsnp argument).
*/
@Input(fullName="comp", shortName = "comp", doc="comparison VCF file", required=false)
public RodBinding<VariantContext> comps = RodBinding.makeUnbound(VariantContext.class);
public List<RodBinding<VariantContext>> comps = Collections.emptyList();
public List<RodBinding<VariantContext>> getCompRodBindings() { return comps; }
/**
* An external resource VCF file or files from which to annotate.
*
* One can add annotations from one of the resource VCFs to the output.
* For example, if you want to annotate your 'variant' VCF with the AC field value from the rod bound to 'resource',
* you can specify '-E resource.AC' and records in the output VCF will be annotated with 'resource.AC=N' when a record exists in that rod at the given position.
* If multiple records in the rod overlap the given position, one is chosen arbitrarily.
*/
@Input(fullName="resource", shortName = "resource", doc="external resource VCF file", required=false)
public List<RodBinding<VariantContext>> resources = Collections.emptyList();
public List<RodBinding<VariantContext>> getResourceRodBindings() { return resources; }
@Output(doc="File to which variants should be written",required=true)
protected VCFWriter vcfWriter = null;
@ -122,8 +137,6 @@ public class VariantAnnotator extends RodWalker<Integer, Integer> {
private Collection<VariantContext> indelBufferContext;
private Map<String, RodBinding<? extends Feature>> rodBindings = new HashMap<String, RodBinding<? extends Feature>>();
private void listAnnotationsAndExit() {
List<Class<? extends InfoFieldAnnotation>> infoAnnotationClasses = new PluginManager<InfoFieldAnnotation>(InfoFieldAnnotation.class).getPlugins();
@ -166,12 +179,10 @@ public class VariantAnnotator extends RodWalker<Integer, Integer> {
logger.warn("There are no samples input at all; use the --sampleName argument to specify one if desired.");
}
initializeRodBindingMap();
if ( USE_ALL_ANNOTATIONS )
engine = new VariantAnnotatorEngine(getToolkit(), rodBindings);
engine = new VariantAnnotatorEngine(this);
else
engine = new VariantAnnotatorEngine(getToolkit(), annotationGroupsToUse, annotationsToUse, rodBindings);
engine = new VariantAnnotatorEngine(annotationGroupsToUse, annotationsToUse, this);
engine.initializeExpressions(expressionsToUse);
// setup the header fields
@ -191,13 +202,6 @@ public class VariantAnnotator extends RodWalker<Integer, Integer> {
}
}
private void initializeRodBindingMap() {
rodBindings.put(variantCollection.variants.getName(), variantCollection.variants);
rodBindings.put(snpEffFile.getName(), snpEffFile);
rodBindings.put(dbsnp.dbsnp.getName(), dbsnp.dbsnp);
rodBindings.put(comps.getName(), comps);
}
public static boolean isUniqueHeaderLine(VCFHeaderLine line, Set<VCFHeaderLine> currentSet) {
if ( !(line instanceof VCFCompoundHeaderLine) )
return true;

View File

@ -25,15 +25,13 @@
package org.broadinstitute.sting.gatk.walkers.annotator;
import org.broad.tribble.Feature;
import org.broadinstitute.sting.commandline.RodBinding;
import org.broadinstitute.sting.gatk.GenomeAnalysisEngine;
import org.broadinstitute.sting.gatk.contexts.AlignmentContext;
import org.broadinstitute.sting.gatk.contexts.ReferenceContext;
import org.broadinstitute.sting.gatk.datasources.rmd.ReferenceOrderedDataSource;
import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker;
import org.broadinstitute.sting.gatk.refdata.features.DbSNPHelper;
import org.broadinstitute.sting.gatk.walkers.annotator.interfaces.AnnotationInterfaceManager;
import org.broadinstitute.sting.gatk.walkers.annotator.interfaces.AnnotatorCompatibleWalker;
import org.broadinstitute.sting.gatk.walkers.annotator.interfaces.GenotypeAnnotation;
import org.broadinstitute.sting.gatk.walkers.annotator.interfaces.InfoFieldAnnotation;
import org.broadinstitute.sting.utils.codecs.vcf.VCFConstants;
@ -49,49 +47,56 @@ import java.util.*;
public class VariantAnnotatorEngine {
public static final String dbPrefix = "comp";
private List<InfoFieldAnnotation> requestedInfoAnnotations;
private List<GenotypeAnnotation> requestedGenotypeAnnotations;
private List<VAExpression> requestedExpressions = new ArrayList<VAExpression>();
private HashMap<String, String> dbAnnotations = new HashMap<String, String>();
private Map<String, RodBinding<? extends Feature>> rodBindings;
private HashMap<RodBinding<VariantContext>, String> dbAnnotations = new HashMap<RodBinding<VariantContext>, String>();
private AnnotatorCompatibleWalker walker;
private static class VAExpression {
public String fullName, bindingName, fieldName;
public VAExpression(String fullEpression) {
public String fullName, fieldName;
public RodBinding<VariantContext> binding;
public VAExpression(String fullEpression, List<RodBinding<VariantContext>> bindings) {
int indexOfDot = fullEpression.lastIndexOf(".");
if ( indexOfDot == -1 )
throw new UserException.BadArgumentValue(fullEpression, "it should be in rodname.value format");
fullName = fullEpression;
bindingName = fullEpression.substring(0, indexOfDot);
fieldName = fullEpression.substring(indexOfDot+1);
String bindingName = fullEpression.substring(0, indexOfDot);
for ( RodBinding<VariantContext> rod : bindings ) {
if ( rod.getName().equals(bindingName) ) {
binding = rod;
break;
}
}
}
}
// use this constructor if you want all possible annotations
public VariantAnnotatorEngine(GenomeAnalysisEngine engine, Map<String, RodBinding<? extends Feature>> rodBindings) {
public VariantAnnotatorEngine(AnnotatorCompatibleWalker walker) {
this.walker = walker;
requestedInfoAnnotations = AnnotationInterfaceManager.createAllInfoFieldAnnotations();
requestedGenotypeAnnotations = AnnotationInterfaceManager.createAllGenotypeAnnotations();
initializeDBs(engine);
this.rodBindings = rodBindings;
initializeDBs();
}
// use this constructor if you want to select specific annotations (and/or interfaces)
public VariantAnnotatorEngine(GenomeAnalysisEngine engine, List<String> annotationGroupsToUse, List<String> annotationsToUse, Map<String, RodBinding<? extends Feature>> rodBindings) {
public VariantAnnotatorEngine(List<String> annotationGroupsToUse, List<String> annotationsToUse, AnnotatorCompatibleWalker walker) {
this.walker = walker;
initializeAnnotations(annotationGroupsToUse, annotationsToUse);
initializeDBs(engine);
this.rodBindings = rodBindings;
initializeDBs();
}
// select specific expressions to use
public void initializeExpressions(List<String> expressionsToUse) {
// set up the expressions
for ( String expression : expressionsToUse )
requestedExpressions.add(new VAExpression(expression));
requestedExpressions.add(new VAExpression(expression, walker.getResourceRodBindings()));
}
private void initializeAnnotations(List<String> annotationGroupsToUse, List<String> annotationsToUse) {
@ -100,18 +105,16 @@ public class VariantAnnotatorEngine {
requestedGenotypeAnnotations = AnnotationInterfaceManager.createGenotypeAnnotations(annotationGroupsToUse, annotationsToUse);
}
private void initializeDBs(GenomeAnalysisEngine engine) {
private void initializeDBs() {
// check to see whether comp rods were included
List<ReferenceOrderedDataSource> dataSources = engine.getRodDataSources();
for ( ReferenceOrderedDataSource source : dataSources ) {
if ( source.getName().equals(DbSNPHelper.STANDARD_DBSNP_TRACK_NAME) ) {
dbAnnotations.put(DbSNPHelper.STANDARD_DBSNP_TRACK_NAME, VCFConstants.DBSNP_KEY);
}
else if ( source.getName().startsWith(dbPrefix) ) {
dbAnnotations.put(source.getName(), source.getName().substring(dbPrefix.length()));
}
}
final RodBinding<VariantContext> dbsnp = walker.getDbsnpRodBinding();
if ( dbsnp.isBound() )
dbAnnotations.put(dbsnp, VCFConstants.DBSNP_KEY);
final List<RodBinding<VariantContext>> comps = walker.getCompRodBindings();
for ( RodBinding<VariantContext> rod : comps )
dbAnnotations.put(rod, rod.getName());
}
public Set<VCFHeaderLine> getVCFAnnotationDescriptions() {
@ -122,8 +125,8 @@ public class VariantAnnotatorEngine {
descriptions.addAll(annotation.getDescriptions());
for ( GenotypeAnnotation annotation : requestedGenotypeAnnotations )
descriptions.addAll(annotation.getDescriptions());
for ( Map.Entry<String, String> dbSet : dbAnnotations.entrySet() )
descriptions.add(new VCFInfoHeaderLine(dbSet.getValue(), 0, VCFHeaderLineType.Flag, (dbSet.getKey().equals(DbSNPHelper.STANDARD_DBSNP_TRACK_NAME) ? "dbSNP" : dbSet.getValue()) + " Membership"));
for ( String db : dbAnnotations.values() )
descriptions.add(new VCFInfoHeaderLine(db, 0, VCFHeaderLineType.Flag, (db.equals(VCFConstants.DBSNP_KEY) ? "dbSNP" : db) + " Membership"));
return descriptions;
}
@ -140,7 +143,7 @@ public class VariantAnnotatorEngine {
// go through all the requested info annotationTypes
for ( InfoFieldAnnotation annotationType : requestedInfoAnnotations ) {
Map<String, Object> annotationsFromCurrentType = annotationType.annotate(tracker, rodBindings, ref, stratifiedContexts, vc);
Map<String, Object> annotationsFromCurrentType = annotationType.annotate(tracker, walker, ref, stratifiedContexts, vc);
if ( annotationsFromCurrentType != null )
infoAnnotations.putAll(annotationsFromCurrentType);
}
@ -153,21 +156,16 @@ public class VariantAnnotatorEngine {
}
private void annotateDBs(RefMetaDataTracker tracker, ReferenceContext ref, VariantContext vc, Map<String, Object> infoAnnotations) {
for ( Map.Entry<String, String> dbSet : dbAnnotations.entrySet() ) {
if ( dbSet.getKey().equals(DbSNPHelper.STANDARD_DBSNP_TRACK_NAME) ) {
String rsID = null;
if (vc.isSNP())
rsID = DbSNPHelper.rsIDOfFirstRealSNP(tracker.getValues(Feature.class, DbSNPHelper.STANDARD_DBSNP_TRACK_NAME), true);
else if (vc.isIndel())
rsID = DbSNPHelper.rsIDOfFirstRealIndel(tracker.getValues(Feature.class, DbSNPHelper.STANDARD_DBSNP_TRACK_NAME));
infoAnnotations.put(VCFConstants.DBSNP_KEY, rsID != null );
for ( Map.Entry<RodBinding<VariantContext>, String> dbSet : dbAnnotations.entrySet() ) {
if ( dbSet.getValue().equals(VCFConstants.DBSNP_KEY) ) {
String rsID = DbSNPHelper.rsIDOfFirstRealVariant(tracker.getValues(dbSet.getKey(), ref.getLocus()), vc.getType());
infoAnnotations.put(VCFConstants.DBSNP_KEY, rsID != null);
// annotate dbsnp id if available and not already there
if ( rsID != null && (!vc.hasID() || vc.getID().equals(VCFConstants.EMPTY_ID_FIELD)) )
infoAnnotations.put(VariantContext.ID_KEY, rsID);
} else {
boolean overlapsComp = false;
for ( VariantContext comp : tracker.getValues(VariantContext.class, dbSet.getKey()) ) {
for ( VariantContext comp : tracker.getValues(dbSet.getKey(), ref.getLocus()) ) {
if ( !comp.isFiltered() ) {
overlapsComp = true;
break;
@ -180,7 +178,7 @@ public class VariantAnnotatorEngine {
private void annotateExpressions(RefMetaDataTracker tracker, ReferenceContext ref, Map<String, Object> infoAnnotations) {
for ( VAExpression expression : requestedExpressions ) {
Collection<VariantContext> VCs = tracker.getValues(VariantContext.class, expression.bindingName);
Collection<VariantContext> VCs = tracker.getValues(expression.binding, ref.getLocus());
if ( VCs.size() == 0 )
continue;
@ -205,7 +203,7 @@ public class VariantAnnotatorEngine {
Map<String, Object> genotypeAnnotations = new HashMap<String, Object>(genotype.getAttributes());
for ( GenotypeAnnotation annotation : requestedGenotypeAnnotations ) {
Map<String, Object> result = annotation.annotate(tracker, rodBindings, ref, context, vc, genotype);
Map<String, Object> result = annotation.annotate(tracker, walker, ref, context, vc, genotype);
if ( result != null )
genotypeAnnotations.putAll(result);
}
@ -214,404 +212,4 @@ public class VariantAnnotatorEngine {
return genotypes;
}
/*
// Finish processing data from GenomicAnnotation.
private List<Map<String, Object>> processGenomicAnnotation( List<Map<String, Object>> infoAnnotationOutputsList, Map<String, Object> annotationsForCurrentLocusFromAllAnnotatorInputTables)
{
//process the map returned by GenomicAnnotation. This completes processing of the -B args.
for( Map.Entry<String, Object> annotationsFromOneInputTable : annotationsForCurrentLocusFromAllAnnotatorInputTables.entrySet() )
{
final String inputTableBindingName = annotationsFromOneInputTable.getKey();
final List<Map<String, String>> matchingRecords = (List<Map<String, String>>) annotationsFromOneInputTable.getValue();
if( matchingRecords.size() > 1 && oneToMany)
{
//More than one record matched in this file. After this, infoAnnotationOutputsList.size() will be infoAnnotationOutputsList.size()*matchingRecords.size().
infoAnnotationOutputsList = explodeInfoAnnotationOutputsList( infoAnnotationOutputsList, matchingRecords, inputTableBindingName );
}
else
{
//This doesn't change infoAnnotationOutputsList.size(). If more than one record matched, their annotations will
//all be added to the same output line, with keys disambiguated by appending _i .
addToExistingAnnotationOutputs( infoAnnotationOutputsList, matchingRecords, inputTableBindingName );
}
}
//process -J args
if(joinTables != null)
{
//for each joinTable, join it with the data in the info-field of each output line.
for(JoinTable joinTable : joinTables)
{
//for each info field, join it to the current join table
final List<Map<String, Object>> previousInfoAnnotationOutputsList = new LinkedList<Map<String, Object>>(infoAnnotationOutputsList); //create a shallow copy because infoAnnotationOutputsList will change during the iteration.
for(Map<String, Object> outputRecordInfoField : previousInfoAnnotationOutputsList)
{
infoAnnotationOutputsList = performJoin( infoAnnotationOutputsList, outputRecordInfoField, joinTable );
}
}
}
//apply -S args last to select the columns requested by the user
if(requestedColumnsMap != null) {
infoAnnotationOutputsList = applySelectArg(infoAnnotationOutputsList);
}
return 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)
{
//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.
final String externalBindingName = joinTable.getExternalBindingName();
final String externalColumnName = joinTable.getExternalColumnName();
final String fullyQualifiedExternalColumnName = GenomicAnnotation.generateInfoFieldKey(externalBindingName, externalColumnName);
//find the externalJoinColumnValue in the current info field, and then look up any joinTable records that have this value for the localJoinColumnValue
ArrayList<String> matchingJoinTableRecord = null; //record in the join table whose joinColumnValue matches the joinColumnValue inside the current outputRecordInfoField.
final Object numInfoFieldKeysToCheckObj = outputRecordInfoField.get(GenomicAnnotation.generateInfoFieldKey(externalBindingName, GenomicAnnotation.NUM_MATCHES_SPECIAL_INFO_FIELD));
if(numInfoFieldKeysToCheckObj == null) {
//only 1 record in the externalBindingName -B AnnotationInfoTable overlapped the current position
Object externalColumnValue = outputRecordInfoField.get(fullyQualifiedExternalColumnName);
if(externalColumnValue != null) {
matchingJoinTableRecord = joinTable.get(externalColumnValue.toString());
//System.err.println("Found matching record in join table for record: " + outputRecordInfoField + " where " + fullyQualifiedExternalColumnName + "==" + externalColumnValue + ": " + matchingJoinTableRecords);
}
} else {
//multiple records in the externalBindingName -B AnnotationInfoTable overlapped the current position
final int numInfoFieldKeysToCheck = Integer.parseInt(numInfoFieldKeysToCheckObj.toString());
for (int i = 0; i < numInfoFieldKeysToCheck; i++) {
final Object externalColumnValue = outputRecordInfoField.get(fullyQualifiedExternalColumnName + "_" + i);
if ( externalColumnValue != null ) {
matchingJoinTableRecord = joinTable.get(externalColumnValue.toString());
if ( matchingJoinTableRecord != null ) {
//System.err.println("Found matching record(s) in join table for record: " + outputRecordInfoField + " where " + fullyQualifiedExternalColumnName + "==" + externalColumnValue + ": " + matchingJoinTableRecords);
break;
}
}
}
}
//if a match for the externalJoinColumnValue in the current outputRecordInfoField has been found in the join table, perform the join.
if ( matchingJoinTableRecord != null )
{
final String joinTableBindingName = joinTable.getLocalBindingName();
//convert the List<ArrayList<String>> to List<Map<String, String>> by hashing the values from the ArrayList<String> by their column names.
final List<Map<String, String>> matchingJoinTableRecordsConverted = new LinkedList<Map<String,String>>();
final List<String> columnNames = joinTable.getColumnNames();
final Map<String, String> matchingRecord = new LinkedHashMap<String, String>();
for (int i = 0; i < columnNames.size(); i++)
matchingRecord.put(columnNames.get(i), matchingJoinTableRecord.get(i));
matchingJoinTableRecordsConverted.add(GenomicAnnotation.convertRecordToAnnotations(joinTableBindingName, matchingRecord));
// do the join between the outputRecordInfoField and the matchingJoinTableRecords, then add the results to to infoAnnotationOutputsList
List<Map<String, Object>> tempList = new LinkedList<Map<String, Object>>();
tempList.add(outputRecordInfoField);
if( matchingJoinTableRecordsConverted.size() > 1 && oneToMany)
{
//More than one record in the joinTable matched the current info field. After this, infoAnnotationOutputsList.size() will be infoAnnotationOutputsList.size()*matchingRecords.size().
tempList = explodeInfoAnnotationOutputsList( tempList, matchingJoinTableRecordsConverted, joinTableBindingName );
}
else
{
//This doesn't change infoAnnotationOutputsList.size(). If more than one record matched, their annotations will
//all be added to the same output line, with keys disambiguated by appending _i .
addToExistingAnnotationOutputs( tempList, matchingJoinTableRecordsConverted, joinTableBindingName );
}
infoAnnotationOutputsList.remove(outputRecordInfoField); //remove the old info field
infoAnnotationOutputsList.addAll(tempList); //add the new info field(s) that have been joined with the matchingJoinTableRecords
}
return infoAnnotationOutputsList;
}
// 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.
// 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.
private void addToExistingAnnotationOutputs(
final List<Map<String, Object>> infoAnnotationOutputsList,
final List<Map<String, String>> matchingRecords,
final String bindingName) {
//For each matching record, just add its annotations to all existing output lines.
final boolean renameKeys = matchingRecords.size() > 1;
for(int i = 0; i < matchingRecords.size(); i++) {
Map<String,String> currentRecord = matchingRecords.get(i);
if(renameKeys) {
//Rename keys to avoid naming conflicts. After this all keys from the i'th matching record will have _i appended to them.
// (This solves the following problem: if you have multiple dbsnp matches - such as dbSNP.avHet=value1 from record 1 and
// dbSNP.avHet=value2 from record 2, the keys will be renamed to dbSNP.avHet_1=value1 and dbSNP.avHet_2=value2 )
Map<String,String> currentRecordWithRenamedKeys = new LinkedHashMap<String, String>();
for(final Map.Entry<String, String> annotation : currentRecord.entrySet()) {
currentRecordWithRenamedKeys.put(annotation.getKey() + "_" + (i + 1), annotation.getValue());
}
currentRecordWithRenamedKeys.put(GenomicAnnotation.generateInfoFieldKey(bindingName, GenomicAnnotation.NUM_MATCHES_SPECIAL_INFO_FIELD),
Integer.toString(matchingRecords.size())); //add the special field that specifies how many matchingRecords there were.
currentRecord = currentRecordWithRenamedKeys;
}
//Add the annotations from this record to each output line.
for(Map<String, Object> outputRecordInfoField : infoAnnotationOutputsList) {
outputRecordInfoField.putAll(currentRecord);
}
}
incrementStatsCounter(bindingName, infoAnnotationOutputsList.size());
}
*/
/**
* Records statistics that will be printed when GenomicAnnotator finishes.
*
* @param bindingName The table from which annotations were gotten
* @param numNewRecords The number of new output VCF records created with annotations from this table
*//*
private void incrementStatsCounter( final String bindingName, int numNewRecords) {
//record some stats - there were infoAnnotationOutputsList.size() output VCF records annotated with data from the 'bindingName' input table.
Integer counter = inputTableHitCounter.get(bindingName);
if( counter == null ) {
inputTableHitCounter.put(bindingName, numNewRecords); //init the counter
} else {
inputTableHitCounter.put(bindingName, counter + numNewRecords); //increment the counter
}
}
// Implements oneToMany mode. Takes the current infoAnnotationOutputsList
// (where each element represents a line in the output VCF file), and
// generates a new infoAnnotationOutputsList which contains one copy of the current
// infoAnnotationOutputs for each record matchingRecords.
// The returned list will have size:
// infoAnnotationOutputsList.size() * matchingRecords.size()
private List<Map<String, Object>> explodeInfoAnnotationOutputsList(
final List<Map<String, Object>> infoAnnotationOutputsList,
final List<Map<String, String>> matchingRecords,
final String bindingName) {
//This is the return value. It represents the new list of lines in the output VCF file.
final List<Map<String, Object>> newInfoAnnotationOutputsList = new LinkedList<Map<String, Object>>();
//For each matching record, generate a new output line
for(int i = 0; i < matchingRecords.size(); i++) {
Map<String,String> annotationsForRecord = matchingRecords.get(i);
//Add the annotations from this record to each output line.
for(Map<String, Object> outputRecordInfoField : infoAnnotationOutputsList) {
Map<String, Object> outputRecordInfoFieldCopy = new LinkedHashMap<String, Object>(outputRecordInfoField); //create a new copy of this line.
outputRecordInfoFieldCopy.putAll(annotationsForRecord); //Adds the column-value pairs from this record to this line.
newInfoAnnotationOutputsList.add(outputRecordInfoFieldCopy); //Add the line to the new list of lines.
}
}
recordStats(bindingName, newInfoAnnotationOutputsList.size(), infoAnnotationOutputsList, matchingRecords.size());
return newInfoAnnotationOutputsList;
}
*/
/**
* Records statistics for the explodeInfoAnnotationOutputsList(..) calculation.
* @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 infoAnnotationOutputsList output list
* @param matchingRecordsSize matching records size
*//*
private void recordStats( final String bindingName, int numNewVCFRecordsAnnotatedWithBindingNameData, final List<Map<String, Object>> infoAnnotationOutputsList, int matchingRecordsSize ) {
//update stats for the 'bindingName' table
incrementStatsCounter(bindingName, numNewVCFRecordsAnnotatedWithBindingNameData); //All records in newInfoAnnotationOutputsList were annotated with data from bindingName.
//update stats for all other tables besides 'bindingName'
for(String otherBindingName : inputTableHitCounter.keySet()) {
if(otherBindingName.equals(bindingName)) {
continue;
}
//count how many records in the initial infoAnnotationOutputsList were annotated with data from otherBindingName
int numAnnotatedWithOtherBindingNameData = 0;
for(Map<String, Object> outputRecordInfoField : infoAnnotationOutputsList) {
for(String outputRecordInfoFieldKey : outputRecordInfoField.keySet()) {
if(outputRecordInfoFieldKey.contains(otherBindingName)) {
//this record has some annotations from the otherBindingName table
numAnnotatedWithOtherBindingNameData++;
break;
}
}
}
if(numAnnotatedWithOtherBindingNameData > 0) {
//numAnnotatedWithOtherBindingNameData * (matchingRecordsSize - 1) is how many additional output VCF records were created with annotations from otherBindingName
incrementStatsCounter(otherBindingName, numAnnotatedWithOtherBindingNameData * (matchingRecordsSize - 1));
}
}
}
// Applies the -S arg to the results
private List<Map<String, Object>> applySelectArg( final List<Map<String, Object>> infoAnnotationOutputsList )
{
final List<Map<String, Object>> newInfoAnnotationOutputList = new LinkedList<Map<String, Object>>();
for(final Map<String, Object> outputRecordInfoField : infoAnnotationOutputsList) {
final Map<String, Object> newOutputRecordInfoField = new LinkedHashMap<String, Object>();
for(final Entry<String, Object> keyValue : outputRecordInfoField.entrySet()) {
if(!isKeyFilteredOutBySelectArg(keyValue.getKey())) {
newOutputRecordInfoField.put(keyValue.getKey(), keyValue.getValue());
}
}
newInfoAnnotationOutputList.add(newOutputRecordInfoField);
}
return newInfoAnnotationOutputList;
}
*/
/**
* Determines whether to exclude the given column from the annotations.
* @param key The fully qualified columnName
* @return Whether the -S arg specifies that this column should be included in the annotations.
*
*//*
private boolean isKeyFilteredOutBySelectArg(String key)
{
for(final String bindingName : requestedColumnsMap.keySet()) {
if(key.contains(bindingName)) {
final Set<String> selectArgsWithThisBindingName = requestedColumnsMap.get(bindingName);
for(final String selectArgWithThisBindingName : selectArgsWithThisBindingName) {
if(key.contains(selectArgWithThisBindingName)) {
return false; //this key matches one of the -s args, so the user explicitly requested this key
}
}
if(!selectArgsWithThisBindingName.isEmpty()) {
return true; //the -S arg contains some keys with this binding name, but doesn't include this key
}
}
}
return false; //the -S arg doesn't have anything with the same binding name as this key, so the user implicitly requested this key
}
*/
/**
* Determines how the engine will handle the case where multiple records in a ROD file
* overlap a particular single locus. If oneToMany is set to true, the output will be
* one-to-many, so that each locus in the input VCF file could result in multiple
* entries in the output VCF file. Otherwise, the output will be one-to-one, and
* all multiple-match records will be collapsed into the single info field.
* The collapsing is done by appending an _i to each key name (where 'i' is a
* record counter).
*
* See class-level comments for more details.
*
* @param oneToMany true if we should break out from one to many
*//*
public void setOneToMany(boolean oneToMany) {
this.oneToMany = oneToMany;
}
*/
/**
* Sets the columns that will be used for the info annotation field.
* Column names should be of the form bindingName.columnName (eg. dbsnp.avHet).
*
* @param columns An array of strings where each string is a comma-separated list
* of columnNames (eg ["dbsnp.avHet,dbsnp.valid", "file2.col1,file3.col1"] ).
*//*
public void setRequestedColumns(String[] columns) {
if(columns == null) {
throw new IllegalArgumentException("columns arg is null. Please check the -s command-line arg.");
}
//System.err.println("COLUMNS: "+Arrays.asList(columns).toString());
this.requestedColumnsMap = parseColumnsArg(columns);
}
*/
/**
* Passes in a pointer to the JoinTables.
*
* @param joinTables The list of JoinTables. There should be one JoinTable object for each -J arg.
*//*
public void setJoinTables(List<JoinTable> joinTables) {
this.joinTables = joinTables;
}
*/
/**
* Parses the columns arg and returns a Map of columns hashed by their binding name.
* For example:
* The command line:
* -s dbSnp.valid,dbsnp.avHet -s refGene.txStart,refGene.txEnd
*
* will be passed to this method as:
* ["dbSnp.valid,dbsnp.avHet", "refGene.txStart,refGene.txEnd"]
*
* resulting in a return value of:
* {
* "dbSnp" -> "dbSnp.valid" ,
* "dbSnp" -> "dbsnp.avHet" ,
* "refGene" -> "refGene.txStart",
* "refGene" -> "refGene.txEnd"
* }
*
* @param columnsArg The -s command line arg value.
*
* @return Map representing a parsed version of this arg - see above.
*//*
private static Map<String, Set<String>> parseColumnsArg(String[] columnsArg) {
Map<String, Set<String>> result = new HashMap<String, Set<String>>();
for(String s : columnsArg) {
for(String columnSpecifier : s.split(",") ) {
String[] rodNameColumnName = columnSpecifier.split("\\.");
if(rodNameColumnName.length != 2) {
throw new IllegalArgumentException("The following column specifier in the -s arg is invalid: [" + columnSpecifier + "]. It must be of the form 'bindingName.columnName'.");
}
String rodName = rodNameColumnName[0];
//String columnName = rodNameColumnName[1];
Set<String> requestedColumns = result.get(rodName);
if(requestedColumns == null) {
requestedColumns = new HashSet<String>();
result.put(rodName, requestedColumns);
}
requestedColumns.add(columnSpecifier);
}
}
return result;
}
//Returns a map containing stats on how many output vcf records were annotated from each database
public Map<String, Integer> getInputTableHitCounter() {
return Collections.unmodifiableMap(inputTableHitCounter);
}
*/
}

View File

@ -0,0 +1,16 @@
package org.broadinstitute.sting.gatk.walkers.annotator.interfaces;
import org.broadinstitute.sting.commandline.RodBinding;
import org.broadinstitute.sting.utils.codecs.snpEff.SnpEffFeature;
import org.broadinstitute.sting.utils.variantcontext.VariantContext;
import java.util.List;
public interface AnnotatorCompatibleWalker {
// getter methods for various used bindings
public abstract RodBinding<SnpEffFeature> getSnpEffRodBinding();
public abstract RodBinding<VariantContext> getDbsnpRodBinding();
public abstract List<RodBinding<VariantContext>> getCompRodBindings();
public abstract List<RodBinding<VariantContext>> getResourceRodBindings();
}

View File

@ -1,7 +1,5 @@
package org.broadinstitute.sting.gatk.walkers.annotator.interfaces;
import org.broad.tribble.Feature;
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;
@ -15,7 +13,7 @@ import java.util.Map;
public abstract class GenotypeAnnotation extends VariantAnnotatorAnnotation {
// return annotations for the given contexts/genotype split by sample
public abstract Map<String, Object> annotate(RefMetaDataTracker tracker, Map<String, RodBinding<? extends Feature>> rodBindings,
public abstract Map<String, Object> annotate(RefMetaDataTracker tracker, AnnotatorCompatibleWalker walker,
ReferenceContext ref, AlignmentContext stratifiedContext, VariantContext vc, Genotype g);
// return the descriptions used for the VCF FORMAT meta field

View File

@ -1,7 +1,5 @@
package org.broadinstitute.sting.gatk.walkers.annotator.interfaces;
import org.broad.tribble.Feature;
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;
@ -13,7 +11,7 @@ import java.util.Map;
public abstract class InfoFieldAnnotation extends VariantAnnotatorAnnotation {
// return annotations for the given contexts split by sample
public abstract Map<String, Object> annotate(RefMetaDataTracker tracker, Map<String, RodBinding<? extends Feature>> rodBindings,
public abstract Map<String, Object> annotate(RefMetaDataTracker tracker, AnnotatorCompatibleWalker walker,
ReferenceContext ref, Map<String, AlignmentContext> stratifiedContexts, VariantContext vc);
// return the descriptions used for the VCF INFO meta field

View File

@ -55,7 +55,7 @@ public class BeagleOutputToVCFWalker extends RodWalker<Integer, Integer> {
protected StandardVariantContextInputArgumentCollection variantCollection = new StandardVariantContextInputArgumentCollection();
@Input(fullName="comp", shortName = "comp", doc="Comparison VCF file", required=false)
public RodBinding<VariantContext> comp = RodBinding.makeUnbound(VariantContext.class);
public RodBinding<VariantContext> comp;
@Input(fullName="beagleR2", shortName = "beagleR2", doc="VCF file", required=true)
public RodBinding<BeagleFeature> beagleR2;

View File

@ -55,7 +55,7 @@ public class ProduceBeagleInputWalker extends RodWalker<Integer, Integer> {
@ArgumentCollection protected StandardVariantContextInputArgumentCollection variantCollection = new StandardVariantContextInputArgumentCollection();
@Input(fullName="validation", shortName = "validation", doc="Input VCF file", required=false)
public RodBinding<VariantContext> validation = RodBinding.makeUnbound(VariantContext.class);
public RodBinding<VariantContext> validation;
@Output(doc="File to which BEAGLE input should be written",required=true)
protected PrintStream beagleWriter = null;

View File

@ -52,7 +52,7 @@ public class FastaAlternateReferenceWalker extends FastaReferenceWalker {
public List<RodBinding<VariantContext>> variants;
@Input(fullName="snpmask", shortName = "snpmask", doc="SNP mask VCF file", required=false)
public RodBinding<VariantContext> snpmask = RodBinding.makeUnbound(VariantContext.class);
public RodBinding<VariantContext> snpmask;
private int deletionBasesRemaining = 0;

View File

@ -53,7 +53,7 @@ public class VariantFiltrationWalker extends RodWalker<Integer, Integer> {
protected StandardVariantContextInputArgumentCollection variantCollection = new StandardVariantContextInputArgumentCollection();
@Input(fullName="mask", doc="Input ROD mask", required=false)
public RodBinding<Feature> mask = RodBinding.makeUnbound(Feature.class);
public RodBinding<Feature> mask;
@Output(doc="File to which variants should be written", required=true)
protected VCFWriter writer = null;

View File

@ -25,7 +25,6 @@
package org.broadinstitute.sting.gatk.walkers.genotyper;
import org.broad.tribble.Feature;
import org.broadinstitute.sting.commandline.Argument;
import org.broadinstitute.sting.commandline.ArgumentCollection;
import org.broadinstitute.sting.commandline.Output;
@ -34,16 +33,17 @@ import org.broadinstitute.sting.gatk.DownsampleType;
import org.broadinstitute.sting.gatk.arguments.DbsnpArgumentCollection;
import org.broadinstitute.sting.gatk.contexts.AlignmentContext;
import org.broadinstitute.sting.gatk.contexts.ReferenceContext;
import org.broadinstitute.sting.gatk.datasources.rmd.ReferenceOrderedDataSource;
import org.broadinstitute.sting.gatk.filters.BadMateFilter;
import org.broadinstitute.sting.gatk.filters.MappingQualityUnavailableReadFilter;
import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker;
import org.broadinstitute.sting.gatk.refdata.features.DbSNPHelper;
import org.broadinstitute.sting.gatk.walkers.*;
import org.broadinstitute.sting.gatk.walkers.annotator.VariantAnnotatorEngine;
import org.broadinstitute.sting.gatk.walkers.annotator.interfaces.AnnotatorCompatibleWalker;
import org.broadinstitute.sting.utils.SampleUtils;
import org.broadinstitute.sting.utils.baq.BAQ;
import org.broadinstitute.sting.utils.codecs.snpEff.SnpEffFeature;
import org.broadinstitute.sting.utils.codecs.vcf.*;
import org.broadinstitute.sting.utils.variantcontext.VariantContext;
import java.io.PrintStream;
import java.util.*;
@ -58,7 +58,7 @@ import java.util.*;
@Reference(window=@Window(start=-200,stop=200))
@By(DataSource.REFERENCE)
@Downsample(by=DownsampleType.BY_SAMPLE, toCoverage=250)
public class UnifiedGenotyper extends LocusWalker<VariantCallContext, UnifiedGenotyper.UGStatistics> implements TreeReducible<UnifiedGenotyper.UGStatistics> {
public class UnifiedGenotyper extends LocusWalker<VariantCallContext, UnifiedGenotyper.UGStatistics> implements TreeReducible<UnifiedGenotyper.UGStatistics>, AnnotatorCompatibleWalker {
@ArgumentCollection private UnifiedArgumentCollection UAC = new UnifiedArgumentCollection();
@ -68,6 +68,10 @@ public class UnifiedGenotyper extends LocusWalker<VariantCallContext, UnifiedGen
* rsIDs from this file are used to populate the ID column of the output. Also, the DB INFO flag will be set when appropriate.
*/
@ArgumentCollection protected DbsnpArgumentCollection dbsnp = new DbsnpArgumentCollection();
public RodBinding<VariantContext> getDbsnpRodBinding() { return dbsnp.dbsnp; }
public RodBinding<SnpEffFeature> getSnpEffRodBinding() { return RodBinding.makeUnbound(SnpEffFeature.class); }
public List<RodBinding<VariantContext>> getCompRodBindings() { return Collections.emptyList(); }
public List<RodBinding<VariantContext>> getResourceRodBindings() { return Collections.emptyList(); }
// control the output
@Output(doc="File to which variants should be written",required=true)
@ -140,8 +144,7 @@ public class UnifiedGenotyper extends LocusWalker<VariantCallContext, UnifiedGen
if ( verboseWriter != null )
verboseWriter.println("AFINFO\tLOC\tREF\tALT\tMAF\tF\tAFprior\tAFposterior\tNormalizedPosterior");
// TODO: Fill in the final argument with actual RodBinding map
annotationEngine = new VariantAnnotatorEngine(getToolkit(), Arrays.asList(annotationClassesToUse), annotationsToUse, new HashMap<String, RodBinding<? extends Feature>>());
annotationEngine = new VariantAnnotatorEngine(Arrays.asList(annotationClassesToUse), annotationsToUse, this);
UG_engine = new UnifiedGenotyperEngine(getToolkit(), UAC, logger, verboseWriter, annotationEngine, samples);
// initialize the header
@ -160,16 +163,8 @@ public class UnifiedGenotyper extends LocusWalker<VariantCallContext, UnifiedGen
headerInfo.add(new VCFInfoHeaderLine(VCFConstants.DOWNSAMPLED_KEY, 0, VCFHeaderLineType.Flag, "Were any of the samples downsampled?"));
// also, check to see whether comp rods were included
List<ReferenceOrderedDataSource> dataSources = getToolkit().getRodDataSources();
for ( ReferenceOrderedDataSource source : dataSources ) {
if ( source.getName().equals(DbSNPHelper.STANDARD_DBSNP_TRACK_NAME) ) {
headerInfo.add(new VCFInfoHeaderLine(VCFConstants.DBSNP_KEY, 0, VCFHeaderLineType.Flag, "dbSNP Membership"));
}
else if ( source.getName().startsWith(VariantAnnotatorEngine.dbPrefix) ) {
String name = source.getName().substring(VariantAnnotatorEngine.dbPrefix.length());
headerInfo.add(new VCFInfoHeaderLine(name, 0, VCFHeaderLineType.Flag, name + " Membership"));
}
}
if ( dbsnp.dbsnp.isBound() )
headerInfo.add(new VCFInfoHeaderLine(VCFConstants.DBSNP_KEY, 0, VCFHeaderLineType.Flag, "dbSNP Membership"));
// FORMAT and INFO fields
headerInfo.addAll(getSupportedHeaderStrings());

View File

@ -27,10 +27,8 @@ package org.broadinstitute.sting.gatk.walkers.variantutils;
import net.sf.samtools.util.CloseableIterator;
import org.broad.tribble.Feature;
import org.broadinstitute.sting.commandline.Argument;
import org.broadinstitute.sting.commandline.Input;
import org.broadinstitute.sting.commandline.Output;
import org.broadinstitute.sting.commandline.RodBinding;
import org.broadinstitute.sting.commandline.*;
import org.broadinstitute.sting.gatk.arguments.DbsnpArgumentCollection;
import org.broadinstitute.sting.gatk.contexts.AlignmentContext;
import org.broadinstitute.sting.gatk.contexts.ReferenceContext;
import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker;
@ -66,8 +64,8 @@ public class VariantsToVCF extends RodWalker<Integer, Integer> {
@Input(fullName="variant", shortName = "V", doc="Input variant file", required=true)
public RodBinding<Feature> variants;
@Input(fullName="dbsnp", shortName = "D", doc="dbSNP VCF for populating rsIDs", required=false)
public RodBinding<VariantContext> dbsnp;
@ArgumentCollection
protected DbsnpArgumentCollection dbsnp = new DbsnpArgumentCollection();
@Argument(fullName="sample", shortName="sample", doc="The sample name represented by the variant rod (for data like GELI with genotypes)", required=false)
protected String sampleName = null;
@ -89,7 +87,7 @@ public class VariantsToVCF extends RodWalker<Integer, Integer> {
if ( tracker == null || !BaseUtils.isRegularBase(ref.getBase()) )
return 0;
String rsID = dbsnp == null ? null : DbSNPHelper.rsIDOfFirstRealSNP(tracker.getValues(dbsnp, context.getLocation()));
String rsID = dbsnp == null ? null : DbSNPHelper.rsIDOfFirstRealVariant(tracker.getValues(dbsnp.dbsnp, context.getLocation()), VariantContext.Type.SNP);
Collection<VariantContext> contexts = getVariantContexts(tracker, ref);
@ -169,7 +167,7 @@ public class VariantsToVCF extends RodWalker<Integer, Integer> {
throw new UserException.BadInput("No dbSNP rod was provided, but one is needed to decipher the correct indel alleles from the HapMap records");
RMDTrackBuilder builder = new RMDTrackBuilder(getToolkit().getReferenceDataSource().getReference().getSequenceDictionary(),getToolkit().getGenomeLocParser(),getToolkit().getArguments().unsafe);
dbsnpIterator = builder.createInstanceOfTrack(VCFCodec.class, new File(dbsnp.getSource())).getIterator();
dbsnpIterator = builder.createInstanceOfTrack(VCFCodec.class, new File(dbsnp.dbsnp.getSource())).getIterator();
// Note that we should really use some sort of seekable iterator here so that the search doesn't take forever
// (but it's complicated because the hapmap location doesn't match the dbsnp location, so we don't know where to seek to)
}

View File

@ -94,7 +94,7 @@ public class VariantAnnotatorIntegrationTest extends WalkerTest {
@Test
public void testDBTagWithDbsnp() {
WalkerTestSpec spec = new WalkerTestSpec(
baseTestString() + " -B:dbsnp,vcf " + b36dbSNP129 + " -G \"Standard\" --variant:VCF3 " + validationDataLocation + "vcfexample3empty.vcf -BTI variant", 1,
baseTestString() + " --dbsnp " + b36dbSNP129 + " -G \"Standard\" --variant:VCF3 " + validationDataLocation + "vcfexample3empty.vcf -BTI variant", 1,
Arrays.asList("3da8ca2b6bdaf6e92d94a8c77a71313d"));
executeTest("getting DB tag with dbSNP", spec);
}
@ -102,7 +102,7 @@ public class VariantAnnotatorIntegrationTest extends WalkerTest {
@Test
public void testDBTagWithHapMap() {
WalkerTestSpec spec = new WalkerTestSpec(
baseTestString() + " -B:compH3,VCF " + validationDataLocation + "fakeHM3.vcf -G \"Standard\" --variant:VCF3 " + validationDataLocation + "vcfexample3empty.vcf -BTI variant", 1,
baseTestString() + " --comp:H3 " + validationDataLocation + "fakeHM3.vcf -G \"Standard\" --variant:VCF3 " + validationDataLocation + "vcfexample3empty.vcf -BTI variant", 1,
Arrays.asList("1bc01c5b3bd0b7aef75230310c3ce688"));
executeTest("getting DB tag with HM3", spec);
}
@ -110,7 +110,7 @@ public class VariantAnnotatorIntegrationTest extends WalkerTest {
@Test
public void testUsingExpression() {
WalkerTestSpec spec = new WalkerTestSpec(
baseTestString() + " -B:foo,VCF " + validationDataLocation + "targetAnnotations.vcf -G \"Standard\" --variant:VCF3 " + validationDataLocation + "vcfexample3empty.vcf -E foo.AF -BTI variant", 1,
baseTestString() + " --resource:foo " + validationDataLocation + "targetAnnotations.vcf -G \"Standard\" --variant:VCF3 " + validationDataLocation + "vcfexample3empty.vcf -E foo.AF -BTI variant", 1,
Arrays.asList("e9c0d832dc6b4ed06c955060f830c140"));
executeTest("using expression", spec);
}