Removed getVariantContext() code

This commit is contained in:
Mark DePristo 2011-08-01 13:41:09 -04:00
parent f69bff5dd6
commit 8b1adb8c95
37 changed files with 162 additions and 297 deletions

View File

@ -254,27 +254,7 @@ public class RefMetaDataTracker {
*/
@Deprecated
public List<Object> getValues(final String name) {
return (List<Object>)(List)getValues(name, Feature.class);
}
/**
* get all the reference meta data associated with a track name.
* @param name the name of the track we're looking for
* @param clazz the expected class of the elements bound to rod name
* @return a list of objects, representing the underlying objects that the tracks produce. I.e. for a
* dbSNP RMD this will be a RodDbSNP, etc.
*
* Important: The list returned by this function is guaranteed not to be null, but may be empty!
*/
@Deprecated
public <T extends Feature> List<T> getValues(final String name, final Class<T> clazz) {
RODRecordList list = getTrackDataByName(name);
if (list.isEmpty())
return Collections.emptyList();
else {
return addValues(name, clazz, new ArrayList<T>(), list, list.getLocation(), false, false);
}
return (List<Object>)(List)getValues(Feature.class, name);
}
@ -313,142 +293,6 @@ public class RefMetaDataTracker {
//
// ------------------------------------------------------------------------------------------
/**
* Converts all possible ROD tracks to VariantContexts objects, of all types, allowing any start and any number
* of entries per ROD.
* The name of each VariantContext corresponds to the ROD name.
*
* @return variant context
*/
@Deprecated
public List<VariantContext> getAllVariantContexts() {
return getAllVariantContexts(null, false, false);
}
/**
* Returns all of the variant contexts that start at the current location
*
* @param curLocation
* @return
*/
@Deprecated
public List<VariantContext> getAllVariantContexts(final GenomeLoc curLocation) {
return getAllVariantContexts(curLocation, true, false);
}
/**
* Converts all possible ROD tracks to VariantContexts objects. If allowedTypes != null, then only
* VariantContexts in the allow set of types will be returned. If requireStartsHere is true, then curLocation
* must not be null, and only records whose start position is == to curLocation.getStart() will be returned.
* If takeFirstOnly is true, then only a single VariantContext will be converted from any individual ROD. Of course,
* this single object must pass the allowed types and start here options if provided. Note that the result
* may return multiple VariantContexts with the same name if that particular track contained multiple RODs spanning
* the current location.
*
* The name of each VariantContext corresponds to the ROD name.
*
*
* @param curLocation location
* @param requireStartHere do we require the rod to start at this location?
* @param takeFirstOnly do we take the first rod only?
* @return variant context
*/
@Deprecated
public List<VariantContext> getAllVariantContexts(final GenomeLoc curLocation,
final boolean requireStartHere,
final boolean takeFirstOnly) {
List<VariantContext> contexts = new ArrayList<VariantContext>();
for ( RODRecordList rodList : getBoundRodTracks() ) {
addVariantContexts(contexts, rodList, curLocation, requireStartHere, takeFirstOnly);
}
return contexts;
}
/**
* Gets the variant contexts associated with track name name
*
* see getVariantContexts for more information.
*
*
* @param name name
* @param curLocation location
* @param requireStartHere do we require the rod to start at this location?
* @param takeFirstOnly do we take the first rod only?
* @return variant context
*/
@Deprecated
public List<VariantContext> getVariantContexts(final String name,
final GenomeLoc curLocation,
final boolean requireStartHere,
final boolean takeFirstOnly) {
return getVariantContexts(Arrays.asList(name), curLocation, requireStartHere, takeFirstOnly);
}
@Deprecated
public List<VariantContext> getVariantContexts(final Collection<String> names,
final GenomeLoc curLocation,
final boolean requireStartHere,
final boolean takeFirstOnly) {
List<VariantContext> contexts = new ArrayList<VariantContext>();
for ( String name : names ) {
RODRecordList rodList = getTrackDataByName(name); // require that the name is an exact match
addVariantContexts(contexts, rodList, curLocation, requireStartHere, takeFirstOnly );
}
return contexts;
}
/**
* Gets the variant context associated with name, and assumes the system only has a single bound track at this location. Throws an exception if not.
* see getVariantContexts for more information.
*
*
* @param name name
* @param curLocation location
* @param requireStartHere do we require the rod to start at this location?
* @return variant context
*/
@Deprecated
public VariantContext getVariantContext(final String name,
final GenomeLoc curLocation,
final boolean requireStartHere) {
List<VariantContext> contexts = getVariantContexts(name, curLocation, requireStartHere, false );
if ( contexts.size() > 1 )
throw new ReviewedStingException("Requested a single VariantContext object for track " + name + " but multiple variants were present at position " + curLocation);
else if ( contexts.size() == 0 )
return null;
else
return contexts.iterator().next();
}
/**
* Very simple accessor that gets the first (and only!) VC associated with name at the current location, or
* null if there's no binding here.
*
*
* @param name
* @param curLocation
* @return
*/
@Deprecated
public VariantContext getVariantContext(final String name,
final GenomeLoc curLocation) {
return getVariantContext(name, curLocation, true);
}
@Deprecated
private void addVariantContexts(final List<VariantContext> contexts,
final RODRecordList rodList,
final GenomeLoc curLocation,
final boolean requireStartHere,
final boolean takeFirstOnly ) {
addValues("xxx", VariantContext.class, contexts, rodList, curLocation, requireStartHere, takeFirstOnly);
}
private <T extends Feature> List<T> addValues(final Collection<String> names,
final Class<T> type,
final List<T> values,

View File

@ -202,7 +202,7 @@ public class VariantAnnotator extends RodWalker<Integer, Integer> {
if ( tracker == null )
return 0;
Collection<VariantContext> VCs = tracker.getVariantContexts("variant", context.getLocation(), true, false);
Collection<VariantContext> VCs = tracker.getValues(VariantContext.class, "variant", context.getLocation());
if ( VCs.size() == 0 )
return 0;

View File

@ -203,7 +203,7 @@ public class VariantAnnotatorEngine {
infoAnnotations.put(VariantContext.ID_KEY, rsID);
} else {
boolean overlapsComp = false;
for ( VariantContext comp : tracker.getVariantContexts(dbSet.getKey(), ref.getLocus(), false, false) ) {
for ( VariantContext comp : tracker.getValues(VariantContext.class, dbSet.getKey()) ) {
if ( !comp.isFiltered() ) {
overlapsComp = true;
break;
@ -216,7 +216,7 @@ public class VariantAnnotatorEngine {
private void annotateExpressions(RefMetaDataTracker tracker, ReferenceContext ref, Map<String, Object> infoAnnotations) {
for ( VAExpression expression : requestedExpressions ) {
Collection<VariantContext> VCs = tracker.getVariantContexts(expression.bindingName, ref.getLocus(), false, true);
Collection<VariantContext> VCs = tracker.getValues(VariantContext.class, expression.bindingName);
if ( VCs.size() == 0 )
continue;

View File

@ -244,7 +244,7 @@ public class GenomicAnnotator extends RodWalker<Integer, Integer> implements Tre
return 0;
Set<VariantContext> results = new LinkedHashSet<VariantContext>();
for (VariantContext vc : tracker.getVariantContexts("variant", context.getLocation(), true, false)) {
for (VariantContext vc : tracker.getValues(VariantContext.class, "variant", context.getLocation())) {
if ( (vc.isFiltered() && IGNORE_FILTERED_SITES) ||
(vc.isVariant() && !vc.isBiallelic()) ) {
results.add(vc);

View File

@ -119,9 +119,9 @@ public class BeagleOutputToVCFWalker extends RodWalker<Integer, Integer> {
return 0;
GenomeLoc loc = context.getLocation();
VariantContext vc_input = tracker.getVariantContext(INPUT_ROD_NAME, loc, true);
VariantContext vc_input = tracker.getFirstValue(VariantContext.class, INPUT_ROD_NAME, loc);
VariantContext vc_comp = tracker.getVariantContext(COMP_ROD_NAME, loc, true);
VariantContext vc_comp = tracker.getFirstValue(VariantContext.class, COMP_ROD_NAME, loc);
if ( vc_input == null )
return 0;

View File

@ -121,8 +121,8 @@ public class ProduceBeagleInputWalker extends RodWalker<Integer, Integer> {
public Integer map( RefMetaDataTracker tracker, ReferenceContext ref, AlignmentContext context ) {
if( tracker != null ) {
GenomeLoc loc = context.getLocation();
VariantContext variant_eval = tracker.getVariantContext(ROD_NAME, loc, true);
VariantContext validation_eval = tracker.getVariantContext(VALIDATION_ROD_NAME, loc, true);
VariantContext variant_eval = tracker.getFirstValue(VariantContext.class, ROD_NAME, loc);
VariantContext validation_eval = tracker.getFirstValue(VariantContext.class, VALIDATION_ROD_NAME, loc);
if ( goodSite(variant_eval,validation_eval) ) {
if ( useValidation(validation_eval, ref) ) {

View File

@ -102,7 +102,7 @@ public class VariantsToBeagleUnphasedWalker extends RodWalker<Integer, Integer>
public Integer map( RefMetaDataTracker tracker, ReferenceContext ref, AlignmentContext context ) {
if( tracker != null ) {
GenomeLoc loc = context.getLocation();
VariantContext vc = tracker.getVariantContext(ROD_NAME, loc, true);
VariantContext vc = tracker.getFirstValue(VariantContext.class, ROD_NAME, loc);
if ( ProduceBeagleInputWalker.canBeOutputToBeagle(vc) ) {
// do we want to hold back this site?

View File

@ -57,7 +57,7 @@ public class FastaAlternateReferenceWalker extends FastaReferenceWalker {
String refBase = String.valueOf((char)ref.getBase());
Collection<VariantContext> vcs = tracker.getAllVariantContexts();
Collection<VariantContext> vcs = tracker.getValues(VariantContext.class);
// Check to see if we have a called snp
for ( VariantContext vc : vcs ) {

View File

@ -149,7 +149,7 @@ public class VariantFiltrationWalker extends RodWalker<Integer, Integer> {
if ( tracker == null )
return 0;
Collection<VariantContext> VCs = tracker.getVariantContexts(INPUT_VARIANT_ROD_BINDING_NAME, context.getLocation(), true, false);
Collection<VariantContext> VCs = tracker.getValues(VariantContext.class, INPUT_VARIANT_ROD_BINDING_NAME, context.getLocation());
// is there a SNP mask present?
boolean hasMask = tracker.getValues("mask").size() > 0;

View File

@ -321,7 +321,7 @@ public class IndelGenotypeLikelihoodsCalculationModel extends GenotypeLikelihood
haplotypeMap.clear();
if (getAlleleListFromVCF) {
for( final VariantContext vc_input : tracker.getVariantContexts("alleles", ref.getLocus(), false, false) ) {
for( final VariantContext vc_input : tracker.getValues(VariantContext.class, "alleles") ) {
if( vc_input != null &&
allowableTypes.contains(vc_input.getType()) &&
ref.getLocus().getStart() == vc_input.getStart()) {

View File

@ -63,7 +63,7 @@ public class SNPGenotypeLikelihoodsCalculationModel extends GenotypeLikelihoodsC
VariantContext vc = null;
// search for usable record
for( final VariantContext vc_input : tracker.getVariantContexts("alleles", ref.getLocus(), true, false) ) {
for( final VariantContext vc_input : tracker.getValues(VariantContext.class, "alleles", ref.getLocus()) ) {
if ( vc_input != null && ! vc_input.isFiltered() && (! requireSNP || vc_input.isSNP() )) {
if ( vc == null ) {
vc = vc_input;

View File

@ -96,8 +96,8 @@ public class UGCallVariants extends RodWalker<VariantCallContext, Integer> {
List<VariantContext> VCs = new ArrayList<VariantContext>();
for ( String name : trackNames ) {
Collection<VariantContext> vc = tracker.getVariantContexts(name, context.getLocation(), true, true);
VCs.addAll(vc);
VariantContext vc = tracker.getFirstValue(VariantContext.class, name, context.getLocation());
VCs.add(vc);
}
VariantContext mergedVC = mergeVCsWithGLs(VCs);

View File

@ -110,7 +110,7 @@ public class RealignerTargetCreator extends RodWalker<RealignerTargetCreator.Eve
// look at the rods for indels or SNPs
if ( tracker != null ) {
for ( VariantContext vc : tracker.getAllVariantContexts() ) {
for ( VariantContext vc : tracker.getValues(VariantContext.class) ) {
switch ( vc.getType() ) {
case INDEL:
hasIndel = true;

View File

@ -150,9 +150,7 @@ public class AnnotateMNPsWalker extends RodWalker<Integer, Integer> {
GenomeLoc curLocus = ref.getLocus();
clearOldLocusFeatures(curLocus);
boolean requireStartHere = false; // see EVERY site of the MNP
boolean takeFirstOnly = false; // take as many entries as the VCF file has
for (VariantContext vc : tracker.getVariantContexts(rodName, context.getLocation(), requireStartHere, takeFirstOnly)) {
for (VariantContext vc : tracker.getValues(VariantContext.class, rodName)) {
GenomeLoc vcLoc = VariantContextUtils.getLocation(locParser, vc);
boolean atStartOfVc = curLocus.getStart() == vcLoc.getStart();
boolean atEndOfVc = curLocus.getStart() == vcLoc.getStop();

View File

@ -44,8 +44,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.getVariantContexts("pbt", ref.getLocus(), true, true);
Collection<VariantContext> rbps = tracker.getVariantContexts("rbp", ref.getLocus(), true, true);
Collection<VariantContext> pbts = tracker.getValues(VariantContext.class, "pbt", ref.getLocus());
Collection<VariantContext> rbps = tracker.getValues(VariantContext.class, "rbp", ref.getLocus());
VariantContext pbt = pbts.iterator().hasNext() ? pbts.iterator().next() : null;
VariantContext rbp = rbps.iterator().hasNext() ? rbps.iterator().next() : null;

View File

@ -98,9 +98,7 @@ public class MergeMNPsWalker extends RodWalker<Integer, Integer> {
if (tracker == null)
return null;
boolean requireStartHere = true; // only see each VariantContext once
boolean takeFirstOnly = false; // take as many entries as the VCF file has
for (VariantContext vc : tracker.getVariantContexts(rodName, context.getLocation(), requireStartHere, takeFirstOnly))
for (VariantContext vc : tracker.getValues(VariantContext.class, rodName, context.getLocation()))
writeVCF(vc);
return 0;

View File

@ -135,9 +135,7 @@ public class MergeSegregatingAlternateAllelesWalker extends RodWalker<Integer, I
if (tracker == null)
return null;
boolean requireStartHere = true; // only see each VariantContext once
boolean takeFirstOnly = false; // take as many entries as the VCF file has
for (VariantContext vc : tracker.getVariantContexts(rodName, context.getLocation(), requireStartHere, takeFirstOnly))
for (VariantContext vc : tracker.getValues(VariantContext.class, rodName, context.getLocation()))
writeVCF(vc);
return 0;

View File

@ -289,31 +289,29 @@ public class PhaseByTransmission extends RodWalker<Integer, Integer> {
@Override
public Integer map(RefMetaDataTracker tracker, ReferenceContext ref, AlignmentContext context) {
if (tracker != null) {
Collection<VariantContext> vcs = tracker.getVariantContexts(ROD_NAME, context.getLocation(), true, true);
VariantContext vc = tracker.getFirstValue(VariantContext.class, ROD_NAME, context.getLocation());
for (VariantContext vc : vcs) {
Map<String, Genotype> genotypeMap = vc.getGenotypes();
Map<String, Genotype> genotypeMap = vc.getGenotypes();
for (Trio trio : trios) {
Genotype mother = vc.getGenotype(trio.getMother());
Genotype father = vc.getGenotype(trio.getFather());
Genotype child = vc.getGenotype(trio.getChild());
for (Trio trio : trios) {
Genotype mother = vc.getGenotype(trio.getMother());
Genotype father = vc.getGenotype(trio.getFather());
Genotype child = vc.getGenotype(trio.getChild());
ArrayList<Genotype> trioGenotypes = phaseTrioGenotypes(vc.getReference(), vc.getAltAlleleWithHighestAlleleCount(), mother, father, child);
ArrayList<Genotype> trioGenotypes = phaseTrioGenotypes(vc.getReference(), vc.getAltAlleleWithHighestAlleleCount(), mother, father, child);
Genotype phasedMother = trioGenotypes.get(0);
Genotype phasedFather = trioGenotypes.get(1);
Genotype phasedChild = trioGenotypes.get(2);
Genotype phasedMother = trioGenotypes.get(0);
Genotype phasedFather = trioGenotypes.get(1);
Genotype phasedChild = trioGenotypes.get(2);
genotypeMap.put(phasedMother.getSampleName(), phasedMother);
genotypeMap.put(phasedFather.getSampleName(), phasedFather);
genotypeMap.put(phasedChild.getSampleName(), phasedChild);
}
VariantContext newvc = VariantContext.modifyGenotypes(vc, genotypeMap);
vcfWriter.add(newvc, ref.getBase());
genotypeMap.put(phasedMother.getSampleName(), phasedMother);
genotypeMap.put(phasedFather.getSampleName(), phasedFather);
genotypeMap.put(phasedChild.getSampleName(), phasedChild);
}
VariantContext newvc = VariantContext.modifyGenotypes(vc, genotypeMap);
vcfWriter.add(newvc, ref.getBase());
}
return null;

View File

@ -204,9 +204,7 @@ public class ReadBackedPhasingWalker extends RodWalker<PhasingStatsAndOutput, Ph
PhasingStats phaseStats = new PhasingStats();
List<VariantContext> unprocessedList = new LinkedList<VariantContext>();
boolean requireStartHere = true; // only see each VariantContext once
boolean takeFirstOnly = false; // take as many entries as the VCF file has
for (VariantContext vc : tracker.getVariantContexts(rodName, context.getLocation(), requireStartHere, takeFirstOnly)) {
for (VariantContext vc : tracker.getValues(VariantContext.class, rodName, context.getLocation())) {
if (samplesToPhase != null) vc = reduceVCToSamples(vc, samplesToPhase);
if (ReadBackedPhasingWalker.processVariantInPhasing(vc)) {

View File

@ -84,7 +84,7 @@ public class RodSystemValidationWalker extends RodWalker<Integer,Integer> {
// if the argument was set, check for equivalence
if (allRecordsVariantContextEquivalent && tracker != null) {
Collection<VariantContext> col = tracker.getAllVariantContexts();
Collection<VariantContext> col = tracker.getValues(VariantContext.class);
VariantContext con = null;
for (VariantContext contextInList : col)
if (con == null) con = contextInList;

View File

@ -138,8 +138,8 @@ public class ValidationAmplicons extends RodWalker<Integer,Integer> {
// step 3 (or 1 if not new):
// build up the sequence
VariantContext mask = tracker.getVariantContext("MaskAlleles",ref.getLocus());
VariantContext validate = tracker.getVariantContext("ValidateAlleles",ref.getLocus());
VariantContext mask = tracker.getFirstValue(VariantContext.class, "MaskAlleles",ref.getLocus());
VariantContext validate = tracker.getFirstValue(VariantContext.class, "ValidateAlleles",ref.getLocus());
if ( mask == null && validate == null ) {
if ( indelCounter > 0 ) {

View File

@ -25,7 +25,7 @@ public class Novelty extends VariantStratifier implements StandardStratification
public ArrayList<String> getRelevantStates(ReferenceContext ref, RefMetaDataTracker tracker, VariantContext comp, String compName, VariantContext eval, String evalName, String sampleName) {
if (tracker != null && eval != null) {
for (final String knownName : knownNames) {
final Collection<VariantContext> knownComps = tracker.getVariantContexts(knownName, ref.getLocus(), true, false);
final Collection<VariantContext> knownComps = tracker.getValues(VariantContext.class, knownName, ref.getLocus());
for ( final VariantContext c : knownComps ) {
// loop over sites, looking for something that matches the type eval
if ( eval.getType() == c.getType() ) {

View File

@ -336,8 +336,7 @@ public class VariantEvalUtils {
for (String trackName : trackNames) {
HashMap<String, VariantContext> vcs = new HashMap<String, VariantContext>();
Collection<VariantContext> contexts = tracker == null ? null : tracker.getVariantContexts(trackName, ref.getLocus(), true, true);
VariantContext vc = contexts != null && contexts.size() == 1 ? contexts.iterator().next() : null;
VariantContext vc = tracker == null ? null : tracker.getFirstValue(VariantContext.class, trackName, ref.getLocus());
// First, filter the VariantContext to represent only the samples for evaluation
if (vc != null) {

View File

@ -168,7 +168,7 @@ public class ApplyRecalibration extends RodWalker<Integer, Integer> {
return 1;
}
for( VariantContext vc : tracker.getVariantContexts(inputNames, context.getLocation(), true, false) ) {
for( VariantContext vc : tracker.getValues(VariantContext.class, inputNames, context.getLocation()) ) {
if( vc != null ) {
if( VariantRecalibrator.checkRecalibrationMode( vc, MODE ) && (vc.isNotFiltered() || ignoreInputFilterSet.containsAll(vc.getFilters())) ) {
String filterString = null;

View File

@ -258,7 +258,7 @@ public class VariantDataManager {
datum.consensusCount = 0;
for( final TrainingSet trainingSet : trainingSets ) {
for( final VariantContext trainVC : tracker.getVariantContexts(trainingSet.name, context.getLocation(), false, false ) ) {
for( final VariantContext trainVC : tracker.getValues(VariantContext.class, trainingSet.name) ) {
if( trainVC != null && trainVC.isNotFiltered() && trainVC.isVariant() &&
((evalVC.isSNP() && trainVC.isSNP()) || ((evalVC.isIndel()||evalVC.isMixed()) && (trainVC.isIndel()||trainVC.isMixed()))) &&
(TRUST_ALL_POLYMORPHIC || !trainVC.hasGenotypes() || trainVC.isPolymorphic()) ) {

View File

@ -163,7 +163,7 @@ public class VariantRecalibrator extends RodWalker<ExpandingArrayList<VariantDat
return mapList;
}
for( final VariantContext vc : tracker.getVariantContexts(inputNames, context.getLocation(), true, false) ) {
for( final VariantContext vc : tracker.getValues(VariantContext.class, inputNames, context.getLocation()) ) {
if( vc != null && ( vc.isNotFiltered() || ignoreInputFilterSet.containsAll(vc.getFilters()) ) ) {
if( checkRecalibrationMode( vc, VRAC.MODE ) ) {
final VariantDatum datum = new VariantDatum();

View File

@ -149,7 +149,7 @@ public class CombineVariants extends RodWalker<Integer, Integer> {
// get all of the vcf rods at this locus
// Need to provide reference bases to simpleMerge starting at current locus
Collection<VariantContext> vcs = tracker.getAllVariantContexts(context.getLocation(), true, false);
Collection<VariantContext> vcs = tracker.getValues(VariantContext.class, context.getLocation());
if ( sitesOnlyVCF ) {
vcs = VariantContextUtils.sitesOnlyVariantContexts(vcs);

View File

@ -85,7 +85,7 @@ public class FilterLiftedVariants extends RodWalker<Integer, Integer> {
if ( tracker == null )
return 0;
Collection<VariantContext> VCs = tracker.getVariantContexts("variant", context.getLocation(), true, false);
Collection<VariantContext> VCs = tracker.getValues(VariantContext.class, "variant", context.getLocation());
for ( VariantContext vc : VCs )
filterAndWrite(ref.getBases(), vc);

View File

@ -68,7 +68,7 @@ public class LeftAlignVariants extends RodWalker<Integer, Integer> {
if ( tracker == null )
return 0;
Collection<VariantContext> VCs = tracker.getVariantContexts("variant", context.getLocation(), true, false);
Collection<VariantContext> VCs = tracker.getValues(VariantContext.class, "variant", context.getLocation());
int changedSites = 0;
for ( VariantContext vc : VCs )

View File

@ -143,7 +143,7 @@ public class LiftoverVariants extends RodWalker<Integer, Integer> {
if ( tracker == null )
return 0;
Collection<VariantContext> VCs = tracker.getVariantContexts("variant", context.getLocation(), true, false);
Collection<VariantContext> VCs = tracker.getValues(VariantContext.class, "variant", context.getLocation());
for ( VariantContext vc : VCs )
convertAndWrite(vc, ref);

View File

@ -97,7 +97,7 @@ public class RandomlySplitVariants extends RodWalker<Integer, Integer> {
if ( tracker == null )
return 0;
Collection<VariantContext> vcs = tracker.getVariantContexts(INPUT_VARIANT_ROD_BINDING_NAME, context.getLocation(), true, false);
Collection<VariantContext> vcs = tracker.getValues(VariantContext.class, INPUT_VARIANT_ROD_BINDING_NAME, context.getLocation());
for ( VariantContext vc : vcs ) {
int random = GenomeAnalysisEngine.getRandomGenerator().nextInt(1000);
if ( random < iFraction )

View File

@ -308,7 +308,7 @@ public class SelectVariants extends RodWalker<Integer, Integer> {
if ( tracker == null )
return 0;
Collection<VariantContext> vcs = tracker.getVariantContexts(variantRodName, context.getLocation(), true, false);
Collection<VariantContext> vcs = tracker.getValues(VariantContext.class, variantRodName, context.getLocation());
if ( vcs == null || vcs.size() == 0) {
return 0;
@ -336,12 +336,12 @@ public class SelectVariants extends RodWalker<Integer, Integer> {
break;
}
if (DISCORDANCE_ONLY) {
Collection<VariantContext> compVCs = tracker.getVariantContexts(discordanceRodName, context.getLocation(), true, false);
Collection<VariantContext> compVCs = tracker.getValues(VariantContext.class, discordanceRodName, context.getLocation());
if (!isDiscordant(vc, compVCs))
return 0;
}
if (CONCORDANCE_ONLY) {
Collection<VariantContext> compVCs = tracker.getVariantContexts(concordanceRodName, context.getLocation(), true, false);
Collection<VariantContext> compVCs = tracker.getValues(VariantContext.class, concordanceRodName, context.getLocation());
if (!isConcordant(vc, compVCs))
return 0;
}

View File

@ -86,7 +86,7 @@ public class ValidateVariants extends RodWalker<Integer, Integer> {
if ( tracker == null )
return 0;
Collection<VariantContext> VCs = tracker.getVariantContexts("variant", context.getLocation(), true, false);
Collection<VariantContext> VCs = tracker.getValues(VariantContext.class, "variant", context.getLocation());
for ( VariantContext vc : VCs )
validate(vc, tracker, ref);

View File

@ -93,7 +93,7 @@ public class VariantValidationAssessor extends RodWalker<Pair<VariantContext, By
if ( tracker == null )
return null;
VariantContext vc = tracker.getVariantContext(INPUT_VARIANT_ROD_BINDING_NAME, ref.getLocus());
VariantContext vc = tracker.getFirstValue(VariantContext.class, INPUT_VARIANT_ROD_BINDING_NAME, ref.getLocus());
// ignore places where we don't have a variant
if ( vc == null )
return null;

View File

@ -132,7 +132,7 @@ public class VariantsToTable extends RodWalker<Integer, Integer> {
return 0;
if ( ++nRecords < MAX_RECORDS || MAX_RECORDS == -1 ) {
Collection<VariantContext> vcs = tracker.getAllVariantContexts(context.getLocation());
Collection<VariantContext> vcs = tracker.getValues(VariantContext.class, context.getLocation());
for ( VariantContext vc : vcs) {
if ( (keepMultiAllelic || vc.isBiallelic()) && ( showFiltered || vc.isNotFiltered() ) ) {
List<String> vals = extractFields(vc, fieldsToTake, ALLOW_MISSING_DATA);

View File

@ -162,7 +162,7 @@ public class VariantsToVCF extends RodWalker<Integer, Integer> {
}
// for everything else, we can just convert to VariantContext
return tracker.getVariantContexts(INPUT_ROD_NAME, ref.getLocus(), true, false);
return tracker.getValues(VariantContext.class, INPUT_ROD_NAME, ref.getLocus());
}
private DbSNPFeature getDbsnpFeature(String rsID) {

View File

@ -2,6 +2,7 @@ package org.broadinstitute.sting.gatk.walkers.recalibration;
import org.broadinstitute.sting.WalkerTest;
import org.broadinstitute.sting.utils.exceptions.UserException;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import java.util.HashMap;
@ -15,75 +16,106 @@ public class RecalibrationWalkersIntegrationTest extends WalkerTest {
static HashMap<String, String> paramsFilesNoReadGroupTest = new HashMap<String, String>();
static HashMap<String, String> paramsFilesSolidIndels = new HashMap<String, String>();
@Test
public void testCountCovariates1() {
HashMap<String, String> e = new HashMap<String, String>();
e.put( validationDataLocation + "NA12892.SLX.SRP000031.2009_06.selected.bam", "7b5832d4b2a23b8ef2bb639eb59bfa88" );
e.put( validationDataLocation + "NA19240.chr1.BFAST.SOLID.bam", "9c006f8e9fb5752b1c139f5a8cc7ea88");
e.put( validationDataLocation + "NA12873.454.SRP000031.2009_06.chr1.10_20mb.bam", "e6f7b4ab9aa291022e0ba8b7dbe4c77e" );
e.put( validationDataLocation + "NA12878.1kg.p2.chr1_10mb_11_mb.allTechs.bam", "e6b98af01c5a08e4954b79ec42db6fc3" );
private static final class CCTest extends TestDataProvider {
String file, md5;
for ( String parallelism : Arrays.asList("", " -nt 4")) {
for ( Map.Entry<String, String> entry : e.entrySet() ) {
String bam = entry.getKey();
String md5 = entry.getValue();
WalkerTest.WalkerTestSpec spec = new WalkerTest.WalkerTestSpec(
"-R " + b36KGReference +
" --DBSNP " + GATKDataLocation + "dbsnp_129_b36.rod" +
" -T CountCovariates" +
" -I " + bam +
( bam.equals( validationDataLocation + "NA12878.1kg.p2.chr1_10mb_11_mb.allTechs.bam" )
? " -L 1:10,800,000-10,810,000" : " -L 1:10,000,000-10,200,000" ) +
" -cov ReadGroupCovariate" +
" -cov QualityScoreCovariate" +
" -cov CycleCovariate" +
" -cov DinucCovariate" +
" --solid_recal_mode SET_Q_ZERO" +
" -recalFile %s" + parallelism,
1, // just one output file
Arrays.asList(md5));
List<File> result = executeTest("testCountCovariates1" + parallelism, spec).getFirst();
paramsFiles.put(bam, result.get(0).getAbsolutePath());
}
private CCTest(final String file, final String md5) {
super(CCTest.class);
this.file = file;
this.md5 = md5;
}
}
@Test
public void testTableRecalibrator1() {
HashMap<String, String> e = new HashMap<String, String>();
e.put( validationDataLocation + "NA12892.SLX.SRP000031.2009_06.selected.bam", "0278cce4cfdab869dc0c11d6852a984b" );
e.put( validationDataLocation + "NA19240.chr1.BFAST.SOLID.bam", "6797d7ffa4ef6c48413719ba32696ccf");
e.put( validationDataLocation + "NA12873.454.SRP000031.2009_06.chr1.10_20mb.bam", "2bb3374dde131791d7638031ae3b3e10" );
e.put( validationDataLocation + "NA12878.1kg.p2.chr1_10mb_11_mb.allTechs.bam", "1f9d8944b73169b367cb83b0d22e5432" );
for ( Map.Entry<String, String> entry : e.entrySet() ) {
String bam = entry.getKey();
String md5 = entry.getValue();
String paramsFile = paramsFiles.get(bam);
System.out.printf("PARAMS FOR %s is %s%n", bam, paramsFile);
if ( paramsFile != null ) {
WalkerTestSpec spec = new WalkerTestSpec(
"-R " + b36KGReference +
" -T TableRecalibration" +
" -I " + bam +
( bam.equals( validationDataLocation + "NA12878.1kg.p2.chr1_10mb_11_mb.allTechs.bam" )
@DataProvider(name = "cctestdata")
public Object[][] createCCTestData() {
new CCTest( validationDataLocation + "NA12892.SLX.SRP000031.2009_06.selected.bam", "" );
new CCTest( validationDataLocation + "NA19240.chr1.BFAST.SOLID.bam", "");
new CCTest( validationDataLocation + "NA12873.454.SRP000031.2009_06.chr1.10_20mb.bam", "" );
new CCTest( validationDataLocation + "NA12878.1kg.p2.chr1_10mb_11_mb.allTechs.bam", "" );
return CCTest.getTests(CCTest.class);
}
@Test(dataProvider = "cctestdata")
public void testCountCovariates1(CCTest test) {
testCC(test, "");
}
@Test(dataProvider = "cctestdata")
public void testCountCovariates4(CCTest test) {
testCC(test, " -nt 4");
}
private final void testCC(CCTest test, String parallelism) {
String bam = test.file;
String md5 = test.md5;
WalkerTest.WalkerTestSpec spec = new WalkerTest.WalkerTestSpec(
"-R " + b36KGReference +
" --DBSNP " + GATKDataLocation + "dbsnp_132_b37.vcf" +
" -T CountCovariates" +
" -I " + bam +
( bam.equals( validationDataLocation + "NA12878.1kg.p2.chr1_10mb_11_mb.allTechs.bam" )
? " -L 1:10,800,000-10,810,000" : " -L 1:10,000,000-10,200,000" ) +
" -cov ReadGroupCovariate" +
" -cov QualityScoreCovariate" +
" -cov CycleCovariate" +
" -cov DinucCovariate" +
" --solid_recal_mode SET_Q_ZERO" +
" -recalFile %s" + parallelism,
1, // just one output file
Arrays.asList(md5));
List<File> result = executeTest("testCountCovariates1" + parallelism, spec).getFirst();
paramsFiles.put(bam, result.get(0).getAbsolutePath());
}
private static final class TRTest extends TestDataProvider {
String file, md5;
private TRTest(final String file, final String md5) {
super(TRTest.class);
this.file = file;
this.md5 = md5;
}
}
@DataProvider(name = "trtestdata")
public Object[][] createTRTestData() {
new TRTest( validationDataLocation + "NA12892.SLX.SRP000031.2009_06.selected.bam", "" );
new TRTest( validationDataLocation + "NA19240.chr1.BFAST.SOLID.bam", "");
new TRTest( validationDataLocation + "NA12873.454.SRP000031.2009_06.chr1.10_20mb.bam", "" );
new TRTest( validationDataLocation + "NA12878.1kg.p2.chr1_10mb_11_mb.allTechs.bam", "" );
return TRTest.getTests(TRTest.class);
}
@Test(dataProvider = "trtestdata", dependsOnMethods = "testCountCovariates1")
public void testTableRecalibrator1(TRTest test) {
String bam = test.file;
String md5 = test.md5;
String paramsFile = paramsFiles.get(bam);
System.out.printf("PARAMS FOR %s is %s%n", bam, paramsFile);
if ( paramsFile != null ) {
WalkerTestSpec spec = new WalkerTestSpec(
"-R " + b36KGReference +
" -T TableRecalibration" +
" -I " + bam +
( bam.equals( validationDataLocation + "NA12878.1kg.p2.chr1_10mb_11_mb.allTechs.bam" )
? " -L 1:10,800,000-10,810,000" : " -L 1:10,100,000-10,300,000" ) +
" -o %s" +
" --no_pg_tag" +
" --solid_recal_mode SET_Q_ZERO" +
" -recalFile " + paramsFile,
1, // just one output file
Arrays.asList(md5));
executeTest("testTableRecalibrator1", spec);
}
" -o %s" +
" --no_pg_tag" +
" --solid_recal_mode SET_Q_ZERO" +
" -recalFile " + paramsFile,
1, // just one output file
Arrays.asList(md5));
executeTest("testTableRecalibrator1", spec);
}
}
@Test
public void testCountCovariatesUseOriginalQuals() {
HashMap<String, String> e = new HashMap<String, String>();
e.put( validationDataLocation + "originalQuals.1kg.chr1.1-1K.bam", "3404965ec4fa99873fe6a44521944fd5");
e.put( validationDataLocation + "originalQuals.1kg.chr1.1-1K.bam", "");
for ( Map.Entry<String, String> entry : e.entrySet() ) {
String bam = entry.getKey();
@ -97,7 +129,7 @@ public class RecalibrationWalkersIntegrationTest extends WalkerTest {
" -standard" +
" -OQ" +
" -recalFile %s" +
" --DBSNP " + GATKDataLocation + "dbsnp_129_b36.rod",
" --DBSNP " + GATKDataLocation + "dbsnp_132_b37.vcf",
1, // just one output file
Arrays.asList(md5));
executeTest("testCountCovariatesUseOriginalQuals", spec);
@ -107,7 +139,7 @@ public class RecalibrationWalkersIntegrationTest extends WalkerTest {
@Test
public void testTableRecalibratorMaxQ70() {
HashMap<String, String> e = new HashMap<String, String>();
e.put( validationDataLocation + "NA12892.SLX.SRP000031.2009_06.selected.bam", "0278cce4cfdab869dc0c11d6852a984b" );
e.put( validationDataLocation + "NA12892.SLX.SRP000031.2009_06.selected.bam", "" );
for ( Map.Entry<String, String> entry : e.entrySet() ) {
String bam = entry.getKey();
@ -136,7 +168,7 @@ public class RecalibrationWalkersIntegrationTest extends WalkerTest {
@Test
public void testCountCovariatesSolidIndelsRemoveRefBias() {
HashMap<String, String> e = new HashMap<String, String>();
e.put( validationDataLocation + "NA19240.chr1.BFAST.SOLID.bam", "c9ea5f995e1e2b7a5688533e678dcedc" );
e.put( validationDataLocation + "NA19240.chr1.BFAST.SOLID.bam", "" );
for ( Map.Entry<String, String> entry : e.entrySet() ) {
String bam = entry.getKey();
@ -144,7 +176,7 @@ public class RecalibrationWalkersIntegrationTest extends WalkerTest {
WalkerTest.WalkerTestSpec spec = new WalkerTest.WalkerTestSpec(
"-R " + b36KGReference +
" --DBSNP " + GATKDataLocation + "dbsnp_129_b36.rod" +
" --DBSNP " + GATKDataLocation + "dbsnp_132_b37.vcf" +
" -T CountCovariates" +
" -I " + bam +
" -standard" +
@ -162,7 +194,7 @@ public class RecalibrationWalkersIntegrationTest extends WalkerTest {
@Test
public void testTableRecalibratorSolidIndelsRemoveRefBias() {
HashMap<String, String> e = new HashMap<String, String>();
e.put( validationDataLocation + "NA19240.chr1.BFAST.SOLID.bam", "993fae4270e7e1e15986f270acf247af" );
e.put( validationDataLocation + "NA19240.chr1.BFAST.SOLID.bam", "" );
for ( Map.Entry<String, String> entry : e.entrySet() ) {
String bam = entry.getKey();
@ -190,7 +222,7 @@ public class RecalibrationWalkersIntegrationTest extends WalkerTest {
@Test
public void testCountCovariatesVCF() {
HashMap<String, String> e = new HashMap<String, String>();
e.put( validationDataLocation + "NA12892.SLX.SRP000031.2009_06.selected.bam", "170f0c3cc4b8d72c539136effeec9a16");
e.put( validationDataLocation + "NA12892.SLX.SRP000031.2009_06.selected.bam", "");
for ( Map.Entry<String, String> entry : e.entrySet() ) {
String bam = entry.getKey();
@ -214,7 +246,7 @@ public class RecalibrationWalkersIntegrationTest extends WalkerTest {
@Test
public void testCountCovariatesBED() {
HashMap<String, String> e = new HashMap<String, String>();
e.put( validationDataLocation + "NA12892.SLX.SRP000031.2009_06.selected.bam", "b460478d9683e827784e42bc352db8bb");
e.put( validationDataLocation + "NA12892.SLX.SRP000031.2009_06.selected.bam", "");
for ( Map.Entry<String, String> entry : e.entrySet() ) {
String bam = entry.getKey();
@ -238,7 +270,7 @@ public class RecalibrationWalkersIntegrationTest extends WalkerTest {
@Test
public void testCountCovariatesVCFPlusDBsnp() {
HashMap<String, String> e = new HashMap<String, String>();
e.put( validationDataLocation + "NA12892.SLX.SRP000031.2009_06.selected.bam", "a3d892bd60d8f679affda3c1e3af96c1");
e.put( validationDataLocation + "NA12892.SLX.SRP000031.2009_06.selected.bam", "");
for ( Map.Entry<String, String> entry : e.entrySet() ) {
String bam = entry.getKey();
@ -249,7 +281,7 @@ public class RecalibrationWalkersIntegrationTest extends WalkerTest {
" -B:anyNameABCD,VCF3 " + validationDataLocation + "vcfexample3.vcf" +
" -T CountCovariates" +
" -I " + bam +
" --DBSNP " + GATKDataLocation + "dbsnp_129_b36.rod" +
" --DBSNP " + GATKDataLocation + "dbsnp_132_b37.vcf" +
" -L 1:10,000,000-10,200,000" +
" -cov ReadGroupCovariate" +
" -cov QualityScoreCovariate" +
@ -266,7 +298,7 @@ public class RecalibrationWalkersIntegrationTest extends WalkerTest {
@Test
public void testCountCovariatesNoIndex() {
HashMap<String, String> e = new HashMap<String, String>();
e.put( validationDataLocation + "NA12878.1kg.p2.chr1_10mb_11_mb.allTechs.noindex.bam", "284ccac1f8fe485e52c86333cac7c2d4" );
e.put( validationDataLocation + "NA12878.1kg.p2.chr1_10mb_11_mb.allTechs.noindex.bam", "" );
for ( Map.Entry<String, String> entry : e.entrySet() ) {
String bam = entry.getKey();
@ -274,7 +306,7 @@ public class RecalibrationWalkersIntegrationTest extends WalkerTest {
WalkerTest.WalkerTestSpec spec = new WalkerTest.WalkerTestSpec(
"-R " + b36KGReference +
" --DBSNP " + GATKDataLocation + "dbsnp_129_b36.rod" +
" --DBSNP " + GATKDataLocation + "dbsnp_132_b37.vcf" +
" -T CountCovariates" +
" -I " + bam +
" -cov ReadGroupCovariate" +
@ -292,7 +324,7 @@ public class RecalibrationWalkersIntegrationTest extends WalkerTest {
@Test
public void testTableRecalibratorNoIndex() {
HashMap<String, String> e = new HashMap<String, String>();
e.put( validationDataLocation + "NA12878.1kg.p2.chr1_10mb_11_mb.allTechs.noindex.bam", "c167799c2d9cab815d7c9b23337f162e" );
e.put( validationDataLocation + "NA12878.1kg.p2.chr1_10mb_11_mb.allTechs.noindex.bam", "" );
for ( Map.Entry<String, String> entry : e.entrySet() ) {
String bam = entry.getKey();