Moving more tools over to the new rod system

This commit is contained in:
Eric Banks 2011-08-10 13:42:35 -04:00
parent a42f90db11
commit 749c8bfbcd
12 changed files with 60 additions and 35 deletions

View File

@ -50,12 +50,14 @@ import java.util.*;
/**
* Annotates variant calls with context information. Users can specify which of the available annotations to use.
*/
@Requires(value={})
@Allows(value={DataSource.READS, DataSource.REFERENCE})
@Reference(window=@Window(start=-50,stop=50))
@By(DataSource.REFERENCE)
public class VariantAnnotator extends RodWalker<Integer, Integer> {
@ArgumentCollection protected StandardVariantContextInputArgumentCollection variantCollection = new StandardVariantContextInputArgumentCollection();
@ArgumentCollection
protected StandardVariantContextInputArgumentCollection variantCollection = new StandardVariantContextInputArgumentCollection();
@Input(fullName="snpEffFile", shortName = "snpEffFile", doc="SnpEff file", required=false)
public RodBinding<SnpEffFeature> snpEffFile;
@ -65,7 +67,8 @@ public class VariantAnnotator extends RodWalker<Integer, Integer> {
*
* 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();
@ArgumentCollection
protected DbsnpArgumentCollection dbsnp = new DbsnpArgumentCollection();
/**
* A comparisons VCF file from which to annotate.

View File

@ -22,10 +22,11 @@
package org.broadinstitute.sting.gatk.walkers.coverage;
import org.broad.tribble.Feature;
import org.broad.tribble.bed.FullBEDFeature;
import org.broad.tribble.bed.BEDFeature;
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.gatk.contexts.AlignmentContext;
import org.broadinstitute.sting.gatk.contexts.ReferenceContext;
import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker;
@ -44,11 +45,11 @@ public class CompareCallableLociWalker extends RodWalker<List<CallableLociWalker
@Output
protected PrintStream out;
@Argument(shortName="comp1", doc="First comparison track name", required=false)
protected String COMP1 = "comp1";
@Input(fullName="comp1", shortName = "comp1", doc="First comparison track name", required=true)
public RodBinding<BEDFeature> compTrack1;
@Argument(shortName="comp2", doc="First comparison track name", required=false)
protected String COMP2 = "comp2";
@Input(fullName="comp2", shortName = "comp2", doc="Second comparison track name", required=true)
public RodBinding<BEDFeature> compTrack2;
@Argument(shortName="printState", doc="If provided, prints sites satisfying this state pair", required=false)
protected String printState = null;
@ -78,8 +79,8 @@ public class CompareCallableLociWalker extends RodWalker<List<CallableLociWalker
// --------------------------------------------------------------------------------------------------------------
public List<CallableLociWalker.CallableBaseState> map(RefMetaDataTracker tracker, ReferenceContext ref, AlignmentContext context) {
if ( tracker != null ) {
CallableLociWalker.CallableBaseState comp1 = getCallableBaseState(tracker, COMP1);
CallableLociWalker.CallableBaseState comp2 = getCallableBaseState(tracker, COMP2);
CallableLociWalker.CallableBaseState comp1 = getCallableBaseState(tracker, compTrack1);
CallableLociWalker.CallableBaseState comp2 = getCallableBaseState(tracker, compTrack2);
if ( printState != null && comp1.getState() == printState1 && comp2.getState() == printState2 ) {
out.printf("%s %s %s %s%n", comp1.getLocation(), comp1.getState(), comp2.getLocation(), comp2.getState());
@ -91,14 +92,14 @@ public class CompareCallableLociWalker extends RodWalker<List<CallableLociWalker
}
}
private CallableLociWalker.CallableBaseState getCallableBaseState(RefMetaDataTracker tracker, String track) {
private CallableLociWalker.CallableBaseState getCallableBaseState(RefMetaDataTracker tracker, RodBinding<BEDFeature> rodBinding) {
//System.out.printf("tracker %s%n", tracker);
List<Feature> bindings = tracker.getValues(Feature.class, track);
if ( bindings.size() != 1 || ! (bindings.get(0) instanceof FullBEDFeature)) {
throw new UserException.MalformedFile(String.format("%s track isn't a properly formated CallableBases object!", track));
List<BEDFeature> bindings = tracker.getValues(rodBinding);
if ( bindings.size() != 1 ) {
throw new UserException.MalformedFile(String.format("%s track isn't a properly formated CallableBases object!", rodBinding.getName()));
}
FullBEDFeature bed = (FullBEDFeature)bindings.get(0);
BEDFeature bed = bindings.get(0);
GenomeLoc loc = getToolkit().getGenomeLocParser().createGenomeLoc(bed.getChr(), bed.getStart(), bed.getEnd());
CallableLociWalker.CalledState state = CallableLociWalker.CalledState.valueOf(bed.getName());
return new CallableLociWalker.CallableBaseState(getToolkit().getGenomeLocParser(),loc, state);
@ -128,7 +129,7 @@ public class CompareCallableLociWalker extends RodWalker<List<CallableLociWalker
public void onTraversalDone(long[][] result) {
for ( CallableLociWalker.CalledState state1 : CallableLociWalker.CalledState.values() ) {
for ( CallableLociWalker.CalledState state2 : CallableLociWalker.CalledState.values() ) {
out.printf("%s %s %s %s %d%n", COMP1, COMP2, state1, state2, result[state1.ordinal()][state2.ordinal()]);
out.printf("%s %s %s %s %d%n", compTrack1.getName(), compTrack2.getName(), state1, state2, result[state1.ordinal()][state2.ordinal()]);
}
}
}

View File

@ -83,7 +83,7 @@ public class IndelRealigner extends ReadWalker<Integer, Integer> {
}
@Input(fullName="known", shortName = "known", doc="Input VCF file with known indels", required=false)
public RodBinding<VariantContext> known = RodBinding.makeUnbound(VariantContext.class);
public List<RodBinding<VariantContext>> known = Collections.emptyList();
@Input(fullName="targetIntervals", shortName="targetIntervals", doc="intervals file output from RealignerTargetCreator", required=true)
protected String intervalsFile = null;

View File

@ -26,7 +26,9 @@
package org.broadinstitute.sting.gatk.walkers.indels;
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.gatk.contexts.AlignmentContext;
import org.broadinstitute.sting.gatk.contexts.ReferenceContext;
import org.broadinstitute.sting.gatk.filters.BadCigarFilter;
@ -46,6 +48,8 @@ import org.broadinstitute.sting.utils.variantcontext.VariantContext;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
/**
* Emits intervals for the Local Indel Realigner to target for cleaning. Ignores 454 reads, MQ0 reads, and reads with consecutive indel operators in the CIGAR string.
@ -56,9 +60,13 @@ import java.util.ArrayList;
@By(DataSource.REFERENCE)
@BAQMode(ApplicationTime = BAQ.ApplicationTime.FORBIDDEN)
public class RealignerTargetCreator extends RodWalker<RealignerTargetCreator.Event, RealignerTargetCreator.Event> {
@Output
protected PrintStream out;
@Input(fullName="known", shortName = "known", doc="Input VCF file with known indels", required=false)
public List<RodBinding<VariantContext>> known = Collections.emptyList();
// mismatch/entropy/SNP arguments
@Argument(fullName="windowSize", shortName="window", doc="window size for calculating entropy or SNP clusters", required=false)
protected int windowSize = 10;
@ -110,7 +118,7 @@ public class RealignerTargetCreator extends RodWalker<RealignerTargetCreator.Eve
// look at the rods for indels or SNPs
if ( tracker != null ) {
for ( VariantContext vc : tracker.getValues(VariantContext.class) ) {
for ( VariantContext vc : tracker.getValues(known) ) {
switch ( vc.getType() ) {
case INDEL:
hasIndel = true;

View File

@ -1,6 +1,8 @@
package org.broadinstitute.sting.gatk.walkers.phasing;
import org.broadinstitute.sting.commandline.Input;
import org.broadinstitute.sting.commandline.Output;
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;
@ -24,6 +26,12 @@ public class MergeAndMatchHaplotypes extends RodWalker<Integer, Integer> {
@Output
protected VCFWriter vcfWriter = null;
@Input(fullName="pbt", shortName = "pbt", doc="Input VCF truth file", required=true)
public RodBinding<VariantContext> pbtTrack;
@Input(fullName="rbp", shortName = "rbp", doc="Input VCF truth file", required=true)
public RodBinding<VariantContext> rbpTrack;
private Map<String, Genotype> pbtCache = new HashMap<String, Genotype>();
private Map<String, Genotype> rbpCache = new HashMap<String, Genotype>();
@ -31,7 +39,7 @@ public class MergeAndMatchHaplotypes extends RodWalker<Integer, Integer> {
public void initialize() {
ArrayList<String> rodNames = new ArrayList<String>();
rodNames.add("pbt");
rodNames.add(pbtTrack.getName());
Map<String, VCFHeader> vcfRods = VCFUtils.getVCFHeadersFromRods(getToolkit(), rodNames);
Set<String> vcfSamples = SampleUtils.getSampleList(vcfRods, VariantContextUtils.GenotypeMergeType.REQUIRE_UNIQUE);
@ -44,8 +52,8 @@ public class MergeAndMatchHaplotypes extends RodWalker<Integer, Integer> {
@Override
public Integer map(RefMetaDataTracker tracker, ReferenceContext ref, AlignmentContext context) {
if (tracker != null) {
Collection<VariantContext> pbts = tracker.getValues(VariantContext.class, "pbt", ref.getLocus());
Collection<VariantContext> rbps = tracker.getValues(VariantContext.class, "rbp", ref.getLocus());
Collection<VariantContext> pbts = tracker.getValues(pbtTrack, ref.getLocus());
Collection<VariantContext> rbps = tracker.getValues(rbpTrack, ref.getLocus());
VariantContext pbt = pbts.iterator().hasNext() ? pbts.iterator().next() : null;
VariantContext rbp = rbps.iterator().hasNext() ? rbps.iterator().next() : null;

View File

@ -1,7 +1,9 @@
package org.broadinstitute.sting.gatk.walkers.phasing;
import org.broadinstitute.sting.commandline.Argument;
import org.broadinstitute.sting.commandline.ArgumentCollection;
import org.broadinstitute.sting.commandline.Output;
import org.broadinstitute.sting.gatk.arguments.StandardVariantContextInputArgumentCollection;
import org.broadinstitute.sting.gatk.contexts.AlignmentContext;
import org.broadinstitute.sting.gatk.contexts.ReferenceContext;
import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker;
@ -31,13 +33,16 @@ import java.util.*;
* begin.
*/
public class PhaseByTransmission extends RodWalker<Integer, Integer> {
@ArgumentCollection
protected StandardVariantContextInputArgumentCollection variantCollection = new StandardVariantContextInputArgumentCollection();
@Argument(shortName="f", fullName="familySpec", required=true, doc="Patterns for the family structure (usage: mom+dad=child). Specify several trios by supplying this argument many times and/or a file containing many patterns.")
public ArrayList<String> familySpecs = null;
@Output
protected VCFWriter vcfWriter = null;
private final String ROD_NAME = "variant";
private final String TRANSMISSION_PROBABILITY_TAG_NAME = "TP";
private final String SOURCE_NAME = "PhaseByTransmission";
@ -102,7 +107,7 @@ public class PhaseByTransmission extends RodWalker<Integer, Integer> {
trios = getFamilySpecsFromCommandLineInput(familySpecs);
ArrayList<String> rodNames = new ArrayList<String>();
rodNames.add(ROD_NAME);
rodNames.add(variantCollection.variants.getName());
Map<String, VCFHeader> vcfRods = VCFUtils.getVCFHeadersFromRods(getToolkit(), rodNames);
Set<String> vcfSamples = SampleUtils.getSampleList(vcfRods, VariantContextUtils.GenotypeMergeType.REQUIRE_UNIQUE);
@ -289,7 +294,7 @@ public class PhaseByTransmission extends RodWalker<Integer, Integer> {
@Override
public Integer map(RefMetaDataTracker tracker, ReferenceContext ref, AlignmentContext context) {
if (tracker != null) {
VariantContext vc = tracker.getFirstValue(VariantContext.class, ROD_NAME, context.getLocation());
VariantContext vc = tracker.getFirstValue(variantCollection.variants, context.getLocation());
Map<String, Genotype> genotypeMap = vc.getGenotypes();

View File

@ -30,7 +30,7 @@ import org.testng.annotations.Test;
import java.util.Arrays;
public class CompareCallableLociWalkerIntegrationTest extends WalkerTest {
final static String commonArgs = "-R " + hg18Reference + " -T CompareCallableLoci -B:comp1,Bed " + validationDataLocation + "1kg_slx.chr1_10mb.callable.bed -B:comp2,Bed " + validationDataLocation + "ga2_slx.chr1_10mb.callable.bed -o %s";
final static String commonArgs = "-R " + hg18Reference + " -T CompareCallableLoci --comp1:Bed " + validationDataLocation + "1kg_slx.chr1_10mb.callable.bed --comp2:Bed " + validationDataLocation + "ga2_slx.chr1_10mb.callable.bed -o %s";
@Test
public void testCompareCallableLociWalker1() {

View File

@ -15,7 +15,7 @@ public class UnifiedGenotyperPerformanceTest extends WalkerTest {
" -glm BOTH" +
" -I " + evaluationDataLocation + "NA12878.GAII.chr1.50MB.bam" +
" -L chr1:1-50,000,000" +
" -dbsnp:VCF " + b36dbSNP129 +
" --dbsnp:VCF " + b36dbSNP129 +
" -o /dev/null",
0,
new ArrayList<String>(0));
@ -30,7 +30,7 @@ public class UnifiedGenotyperPerformanceTest extends WalkerTest {
" -glm BOTH" +
" -I " + evaluationDataLocation + "NA12878.ESP.WEx.chr1.bam" +
" -L " + evaluationDataLocation + "whole_exome_agilent_designed_120.targets.chr1.interval_list" +
" -dbsnp:vcf " + b36dbSNP129 +
" --dbsnp:vcf " + b36dbSNP129 +
" -o /dev/null",
0,
new ArrayList<String>(0));
@ -46,7 +46,7 @@ public class UnifiedGenotyperPerformanceTest extends WalkerTest {
" -glm BOTH" +
" -L chr1:1-50,000,000" +
" -nt 10" +
" -dbsnp:vcf " + b36dbSNP129 +
" --dbsnp:vcf " + b36dbSNP129 +
" -o /dev/null",
0,
new ArrayList<String>(0));

View File

@ -17,13 +17,13 @@ public class RealignerTargetCreatorIntegrationTest extends WalkerTest {
executeTest("test standard", spec1);
WalkerTest.WalkerTestSpec spec2 = new WalkerTest.WalkerTestSpec(
"-T RealignerTargetCreator -B:dbsnp,vcf " + b36dbSNP129 + " -R " + b36KGReference + " -I " + validationDataLocation + "NA12878.1kg.p2.chr1_10mb_11_mb.SLX.bam -L 1:10,000,000-10,050,000 -o %s",
"-T RealignerTargetCreator --known " + b36dbSNP129 + " -R " + b36KGReference + " -I " + validationDataLocation + "NA12878.1kg.p2.chr1_10mb_11_mb.SLX.bam -L 1:10,000,000-10,050,000 -o %s",
1,
Arrays.asList("0367d39a122c8ac0899fb868a82ef728"));
executeTest("test dbsnp", spec2);
WalkerTest.WalkerTestSpec spec3 = new WalkerTest.WalkerTestSpec(
"-T RealignerTargetCreator -R " + b36KGReference + " -B:indels,VCF " + validationDataLocation + "NA12878.chr1_10mb_11mb.slx.indels.vcf4 -BTI indels -o %s",
"-T RealignerTargetCreator -R " + b36KGReference + " --known " + validationDataLocation + "NA12878.chr1_10mb_11mb.slx.indels.vcf4 -BTI known -o %s",
1,
Arrays.asList("5206cee6c01b299417bf2feeb8b3dc96"));
executeTest("test rods only", spec3);

View File

@ -12,7 +12,7 @@ public class RealignerTargetCreatorPerformanceTest extends WalkerTest {
WalkerTestSpec spec1 = new WalkerTestSpec(
"-R " + hg18Reference +
" -T RealignerTargetCreator" +
" -B:dbsnp,vcf " + GATKDataLocation + "dbsnp_132.hg18.vcf" +
" --known " + GATKDataLocation + "dbsnp_132.hg18.vcf" +
" -I " + evaluationDataLocation + "NA12878.GAII.chr1.50MB.bam" +
" -L chr1:1-50,000,000" +
" -o /dev/null",
@ -23,7 +23,7 @@ public class RealignerTargetCreatorPerformanceTest extends WalkerTest {
WalkerTestSpec spec2 = new WalkerTestSpec(
"-R " + hg18Reference +
" -T RealignerTargetCreator" +
" -B:dbsnp,vcf " + GATKDataLocation + "dbsnp_132.hg18.vcf" +
" --known " + GATKDataLocation + "dbsnp_132.hg18.vcf" +
" -I " + evaluationDataLocation + "NA12878.ESP.WEx.chr1.bam" +
" -L " + evaluationDataLocation + "whole_exome_agilent_designed_120.targets.chr1.interval_list" +
" -o /dev/null",

View File

@ -16,8 +16,8 @@ public class MergeAndMatchHaplotypesIntegrationTest extends WalkerTest {
buildCommandLine(
"-T MergeAndMatchHaplotypes",
"-R " + b37KGReference,
"-B:pbt,VCF " + fundamentalTestPBTVCF,
"-B:rbp,VCF " + fundamentalTestRBPVCF,
"--pbt " + fundamentalTestPBTVCF,
"--rbp " + fundamentalTestRBPVCF,
"-o %s"
),
1,

View File

@ -16,7 +16,7 @@ public class PhaseByTransmissionIntegrationTest extends WalkerTest {
"-T PhaseByTransmission",
"-NO_HEADER",
"-R " + b37KGReference,
"-B:variant,VCF " + fundamentalTestVCF,
"--variant " + fundamentalTestVCF,
"-f NA12892+NA12891=NA12878",
"-o %s"
),