Cleaned up VariantContext accessors in RefMetaDataTracker
It's no longer possible to provided allowed types, as this was a very rarely used feature in the engine. These get methods have been removed and local uses replaced with tests directly in their code. This simplified the RefMetaDataTracker significantly VariantContextRodBinding now forwards along all of the RefMetaDataTracker methods, so it is possible to create a full equivalent VariantContextRodBinding now as a walker field variable. All walkers updated to the new RefMetaDataTracker function call style
This commit is contained in:
parent
c83f9432eb
commit
f7a126722b
|
|
@ -26,13 +26,13 @@ package org.broadinstitute.sting.commandline;
|
|||
|
||||
import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker;
|
||||
import org.broadinstitute.sting.gatk.refdata.utils.GATKFeature;
|
||||
import org.broadinstitute.sting.gatk.refdata.utils.RODRecordList;
|
||||
import org.broadinstitute.sting.utils.exceptions.UserException;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* A RodBinding representing a walker argument that gets bound to a ROD track.
|
||||
*
|
||||
* There is no constraint on the type of the ROD bound.
|
||||
*/
|
||||
public class RodBinding {
|
||||
final String variableName;
|
||||
|
|
@ -53,23 +53,23 @@ public class RodBinding {
|
|||
return source;
|
||||
}
|
||||
|
||||
public List<Object> getValues(RefMetaDataTracker tracker) {
|
||||
public List<Object> getValues(final RefMetaDataTracker tracker) {
|
||||
return tracker.getValues(variableName);
|
||||
}
|
||||
|
||||
public <T> List<T> getValues(RefMetaDataTracker tracker, Class<T> clazz) {
|
||||
public <T> List<T> getValues(final RefMetaDataTracker tracker, final Class<T> clazz) {
|
||||
return tracker.getValues(variableName, clazz);
|
||||
}
|
||||
|
||||
public <T> T getFirstValue(RefMetaDataTracker tracker, Class<T> clazz) {
|
||||
public <T> T getFirstValue(final RefMetaDataTracker tracker, final Class<T> clazz) {
|
||||
return tracker.getFirstValue(variableName, clazz);
|
||||
}
|
||||
|
||||
public boolean hasValues(RefMetaDataTracker tracker) {
|
||||
public boolean hasValues(final RefMetaDataTracker tracker) {
|
||||
return tracker.hasValues(variableName);
|
||||
}
|
||||
|
||||
public List<GATKFeature> getValuesAsGATKFeatures(RefMetaDataTracker tracker) {
|
||||
public List<GATKFeature> getValuesAsGATKFeatures(final RefMetaDataTracker tracker) {
|
||||
return tracker.getValuesAsGATKFeatures(variableName);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -29,42 +29,54 @@ import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker;
|
|||
import org.broadinstitute.sting.utils.GenomeLoc;
|
||||
import org.broadinstitute.sting.utils.variantcontext.VariantContext;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
*
|
||||
* A RodBinding representing a walker argument that gets bound to a ROD track containing VariantContexts
|
||||
*/
|
||||
public class VariantContextRodBinding extends RodBinding {
|
||||
/**
|
||||
* Create a new RodBinding specialized to provide VariantContexts.
|
||||
* @param variableName the name of the field in the walker that we will bind the ROD track too
|
||||
* @param sourceFile the data source from which we will read the VCs
|
||||
* @param parser the Engine parser used to obtain information about this argument, such as its underlying file type
|
||||
*/
|
||||
protected VariantContextRodBinding(final String variableName, final String sourceFile, final ParsingEngine parser) {
|
||||
super(variableName, sourceFile, parser);
|
||||
}
|
||||
|
||||
public VariantContext getVariantContext(RefMetaDataTracker tracker, ReferenceContext ref, GenomeLoc loc) {
|
||||
return tracker.getVariantContext(ref, variableName, loc);
|
||||
/**
|
||||
* Forwarding method to identical tracker method
|
||||
*/
|
||||
public Collection<VariantContext> getVariantContexts(final RefMetaDataTracker tracker,
|
||||
final ReferenceContext ref,
|
||||
final GenomeLoc curLocation,
|
||||
final boolean requireStartHere,
|
||||
final boolean takeFirstOnly ) {
|
||||
return tracker.getVariantContexts(ref, variableName, curLocation, requireStartHere, takeFirstOnly);
|
||||
}
|
||||
|
||||
// public Collection<VariantContext> getAllVariantContexts(ReferenceContext ref) {
|
||||
// }
|
||||
//
|
||||
// public Collection<VariantContext> getAllVariantContexts(ReferenceContext ref, GenomeLoc curLocation) {
|
||||
// }
|
||||
//
|
||||
// public Collection<VariantContext> getAllVariantContexts(ReferenceContext ref, EnumSet<VariantContext.Type> allowedTypes, GenomeLoc curLocation, boolean requireStartHere, boolean takeFirstOnly ) {
|
||||
// }
|
||||
//
|
||||
// public Collection<VariantContext> getVariantContexts(ReferenceContext ref, String name, EnumSet<VariantContext.Type> allowedTypes, GenomeLoc curLocation, boolean requireStartHere, boolean takeFirstOnly ) {
|
||||
// }
|
||||
//
|
||||
// public Collection<VariantContext> getVariantContexts(ReferenceContext ref, Collection<String> names, EnumSet<VariantContext.Type> allowedTypes, GenomeLoc curLocation, boolean requireStartHere, boolean takeFirstOnly ) {
|
||||
// }
|
||||
//
|
||||
// public Collection<VariantContext> getVariantContextsByPrefix(ReferenceContext ref, Collection<String> names, EnumSet<VariantContext.Type> allowedTypes, GenomeLoc curLocation, boolean requireStartHere, boolean takeFirstOnly ) {
|
||||
// }
|
||||
//
|
||||
// public VariantContext getVariantContext(ReferenceContext ref, String name, EnumSet<VariantContext.Type> allowedTypes, GenomeLoc curLocation, boolean requireStartHere ) {
|
||||
// }
|
||||
//
|
||||
// public VariantContext getVariantContext(ReferenceContext ref, String name, GenomeLoc curLocation) {
|
||||
// }
|
||||
/**
|
||||
* Forwarding method to identical tracker method
|
||||
* @param tracker
|
||||
* @param ref
|
||||
* @param curLocation
|
||||
* @param requireStartHere
|
||||
* @return
|
||||
*/
|
||||
public VariantContext getVariantContext(final RefMetaDataTracker tracker,
|
||||
final ReferenceContext ref,
|
||||
final GenomeLoc curLocation,
|
||||
final boolean requireStartHere ) {
|
||||
return tracker.getVariantContext(ref, variableName, curLocation, requireStartHere);
|
||||
}
|
||||
|
||||
/**
|
||||
* Forwarding method to identical tracker method
|
||||
*/
|
||||
public VariantContext getVariantContext(final RefMetaDataTracker tracker,
|
||||
final ReferenceContext ref,
|
||||
final GenomeLoc curLocation) {
|
||||
return tracker.getVariantContext(ref, variableName, curLocation);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ public class RefMetaDataTracker {
|
|||
*
|
||||
* Important: The list returned by this function is guaranteed not to be null, but may be empty!
|
||||
*/
|
||||
public <T> List<T> getValues(final String name, Class<T> clazz) {
|
||||
public <T> List<T> getValues(final String name, final Class<T> clazz) {
|
||||
RODRecordList list = getTrackDataByName(name);
|
||||
|
||||
if (list == null)
|
||||
|
|
@ -73,10 +73,10 @@ public class RefMetaDataTracker {
|
|||
}
|
||||
|
||||
/**
|
||||
* get a singleton record, given the name and a type. This function will return the first record at the current position seen,
|
||||
* and emit a logger warning if there were more than one option.
|
||||
* get a singleton record, given the name and a type. This function will return the first record at the
|
||||
* current position seen. The object is cast into a type clazz, or thoses an error if this isn't possible.
|
||||
*
|
||||
* WARNING: we now suppport more than one RMD at a single position for all tracks. If there are
|
||||
* * WARNING: we now suppport more than one RMD at a single position for all tracks. If there are
|
||||
* are multiple RMD objects at this location, there is no contract for which object this method will pick, and which object gets
|
||||
* picked may change from time to time! BE WARNED!
|
||||
*
|
||||
|
|
@ -85,7 +85,7 @@ public class RefMetaDataTracker {
|
|||
* @param <T> the type to parameterize on, matching the clazz argument
|
||||
* @return a record of type T, or null if no record is present.
|
||||
*/
|
||||
public <T> T getFirstValue(final String name, Class<T> clazz) {
|
||||
public <T> T getFirstValue(final String name, final Class<T> clazz) {
|
||||
RODRecordList objects = getTrackDataByName(name);
|
||||
|
||||
// if empty or null return null;
|
||||
|
|
@ -172,6 +172,8 @@ public class RefMetaDataTracker {
|
|||
* Binds the list of reference ordered data records (RMDs) to track name at this site. Should be used only by the traversal
|
||||
* system to provide access to RMDs in a structured way to the walkers.
|
||||
*
|
||||
* DO NOT USE THIS FUNCTION UNLESS YOU ARE THE GATK ENGINE
|
||||
*
|
||||
* @param name the name of the track
|
||||
* @param rod the collection of RMD data
|
||||
*/
|
||||
|
|
@ -180,6 +182,13 @@ public class RefMetaDataTracker {
|
|||
map.put(canonicalName(name), rod);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------
|
||||
//
|
||||
//
|
||||
// VariantContext helpers
|
||||
//
|
||||
//
|
||||
// ------------------------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Converts all possible ROD tracks to VariantContexts objects, of all types, allowing any start and any number
|
||||
|
|
@ -189,8 +198,8 @@ public class RefMetaDataTracker {
|
|||
* @param ref reference context
|
||||
* @return variant context
|
||||
*/
|
||||
public Collection<VariantContext> getAllVariantContexts(ReferenceContext ref) {
|
||||
return getAllVariantContexts(ref, null, null, false, false);
|
||||
public Collection<VariantContext> getAllVariantContexts(final ReferenceContext ref) {
|
||||
return getAllVariantContexts(ref, null, false, false);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -199,8 +208,9 @@ public class RefMetaDataTracker {
|
|||
* @param curLocation
|
||||
* @return
|
||||
*/
|
||||
public Collection<VariantContext> getAllVariantContexts(ReferenceContext ref, GenomeLoc curLocation) {
|
||||
return getAllVariantContexts(ref, null, curLocation, true, false);
|
||||
public Collection<VariantContext> getAllVariantContexts(final ReferenceContext ref,
|
||||
final GenomeLoc curLocation) {
|
||||
return getAllVariantContexts(ref, curLocation, true, false);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -215,17 +225,19 @@ public class RefMetaDataTracker {
|
|||
* The name of each VariantContext corresponds to the ROD name.
|
||||
*
|
||||
* @param ref reference context
|
||||
* @param allowedTypes allowed types
|
||||
* @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
|
||||
*/
|
||||
public Collection<VariantContext> getAllVariantContexts(ReferenceContext ref, EnumSet<VariantContext.Type> allowedTypes, GenomeLoc curLocation, boolean requireStartHere, boolean takeFirstOnly ) {
|
||||
public Collection<VariantContext> getAllVariantContexts(final ReferenceContext ref,
|
||||
final GenomeLoc curLocation,
|
||||
final boolean requireStartHere,
|
||||
final boolean takeFirstOnly ) {
|
||||
List<VariantContext> contexts = new ArrayList<VariantContext>();
|
||||
|
||||
for ( RODRecordList rodList : getBoundRodTracks() ) {
|
||||
addVariantContexts(contexts, rodList, ref, allowedTypes, curLocation, requireStartHere, takeFirstOnly);
|
||||
addVariantContexts(contexts, rodList, ref, curLocation, requireStartHere, takeFirstOnly);
|
||||
}
|
||||
|
||||
return contexts;
|
||||
|
|
@ -239,31 +251,30 @@ public class RefMetaDataTracker {
|
|||
* @param ref ReferenceContext to enable conversion to variant context
|
||||
* @param name name
|
||||
* @param curLocation location
|
||||
* @param allowedTypes allowed types
|
||||
* @param requireStartHere do we require the rod to start at this location?
|
||||
* @param takeFirstOnly do we take the first rod only?
|
||||
* @return variant context
|
||||
*/
|
||||
// public Collection<VariantContext> getVariantContexts(String name, EnumSet<VariantContext.Type> allowedTypes, GenomeLoc curLocation, boolean requireStartHere, boolean takeFirstOnly ) {
|
||||
// return getVariantContexts(null, Arrays.asList(name), allowedTypes, curLocation, requireStartHere, takeFirstOnly);
|
||||
// }
|
||||
|
||||
public Collection<VariantContext> getVariantContexts(ReferenceContext ref, String name, EnumSet<VariantContext.Type> allowedTypes, GenomeLoc curLocation, boolean requireStartHere, boolean takeFirstOnly ) {
|
||||
return getVariantContexts(ref, Arrays.asList(name), allowedTypes, curLocation, requireStartHere, takeFirstOnly);
|
||||
public Collection<VariantContext> getVariantContexts(final ReferenceContext ref,
|
||||
final String name,
|
||||
final GenomeLoc curLocation,
|
||||
final boolean requireStartHere,
|
||||
final boolean takeFirstOnly ) {
|
||||
return getVariantContexts(ref, Arrays.asList(name), curLocation, requireStartHere, takeFirstOnly);
|
||||
}
|
||||
|
||||
// public Collection<VariantContext> getVariantContexts(Collection<String> names, EnumSet<VariantContext.Type> allowedTypes, GenomeLoc curLocation, boolean requireStartHere, boolean takeFirstOnly ) {
|
||||
// return getVariantContexts(null, names, allowedTypes, curLocation, requireStartHere, takeFirstOnly);
|
||||
// }
|
||||
|
||||
public Collection<VariantContext> getVariantContexts(ReferenceContext ref, Collection<String> names, EnumSet<VariantContext.Type> allowedTypes, GenomeLoc curLocation, boolean requireStartHere, boolean takeFirstOnly ) {
|
||||
public Collection<VariantContext> getVariantContexts(final ReferenceContext ref,
|
||||
final Collection<String> names,
|
||||
final GenomeLoc curLocation,
|
||||
final boolean requireStartHere,
|
||||
final boolean takeFirstOnly ) {
|
||||
Collection<VariantContext> contexts = new ArrayList<VariantContext>();
|
||||
|
||||
for ( String name : names ) {
|
||||
RODRecordList rodList = getTrackDataByName(name); // require that the name is an exact match
|
||||
|
||||
if ( rodList != null )
|
||||
addVariantContexts(contexts, rodList, ref, allowedTypes, curLocation, requireStartHere, takeFirstOnly );
|
||||
addVariantContexts(contexts, rodList, ref, curLocation, requireStartHere, takeFirstOnly );
|
||||
}
|
||||
|
||||
return contexts;
|
||||
|
|
@ -275,12 +286,14 @@ public class RefMetaDataTracker {
|
|||
*
|
||||
* @param name name
|
||||
* @param curLocation location
|
||||
* @param allowedTypes allowed types
|
||||
* @param requireStartHere do we require the rod to start at this location?
|
||||
* @return variant context
|
||||
*/
|
||||
public VariantContext getVariantContext(ReferenceContext ref, String name, EnumSet<VariantContext.Type> allowedTypes, GenomeLoc curLocation, boolean requireStartHere ) {
|
||||
Collection<VariantContext> contexts = getVariantContexts(ref, name, allowedTypes, curLocation, requireStartHere, false );
|
||||
public VariantContext getVariantContext(final ReferenceContext ref,
|
||||
final String name,
|
||||
final GenomeLoc curLocation,
|
||||
final boolean requireStartHere ) {
|
||||
Collection<VariantContext> contexts = getVariantContexts(ref, 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);
|
||||
|
|
@ -299,24 +312,27 @@ public class RefMetaDataTracker {
|
|||
* @param curLocation
|
||||
* @return
|
||||
*/
|
||||
public VariantContext getVariantContext(ReferenceContext ref, String name, GenomeLoc curLocation) {
|
||||
return getVariantContext(ref, name, null, curLocation, true);
|
||||
public VariantContext getVariantContext(final ReferenceContext ref,
|
||||
final String name,
|
||||
final GenomeLoc curLocation) {
|
||||
return getVariantContext(ref, name, curLocation, true);
|
||||
}
|
||||
|
||||
private void addVariantContexts(Collection<VariantContext> contexts, RODRecordList rodList, ReferenceContext ref, EnumSet<VariantContext.Type> allowedTypes, GenomeLoc curLocation, boolean requireStartHere, boolean takeFirstOnly ) {
|
||||
private void addVariantContexts(final Collection<VariantContext> contexts,
|
||||
final RODRecordList rodList,
|
||||
final ReferenceContext ref,
|
||||
final GenomeLoc curLocation,
|
||||
final boolean requireStartHere,
|
||||
final boolean takeFirstOnly ) {
|
||||
for ( GATKFeature rec : rodList ) {
|
||||
if ( VariantContextAdaptors.canBeConvertedToVariantContext(rec.getUnderlyingObject()) ) {
|
||||
// ok, we might actually be able to turn this record in a variant context
|
||||
VariantContext vc = VariantContextAdaptors.toVariantContext(rodList.getName(), rec.getUnderlyingObject(), ref);
|
||||
final VariantContext vc = VariantContextAdaptors.toVariantContext(rodList.getName(), rec.getUnderlyingObject(), ref);
|
||||
|
||||
if ( vc == null ) // sometimes the track has odd stuff in it that can't be converted
|
||||
continue;
|
||||
|
||||
// now, let's decide if we want to keep it
|
||||
boolean goodType = allowedTypes == null || allowedTypes.contains(vc.getType());
|
||||
boolean goodPos = ! requireStartHere || rec.getLocation().getStart() == curLocation.getStart();
|
||||
|
||||
if ( goodType && goodPos ) { // ok, we are going to keep this thing
|
||||
if ( ! requireStartHere || rec.getLocation().getStart() == curLocation.getStart() ) { // ok, we are going to keep this thing
|
||||
contexts.add(vc);
|
||||
|
||||
if ( takeFirstOnly )
|
||||
|
|
|
|||
|
|
@ -202,7 +202,7 @@ public class VariantAnnotator extends RodWalker<Integer, Integer> {
|
|||
if ( tracker == null )
|
||||
return 0;
|
||||
|
||||
Collection<VariantContext> VCs = tracker.getVariantContexts(ref, "variant", null, context.getLocation(), true, false);
|
||||
Collection<VariantContext> VCs = tracker.getVariantContexts(ref, "variant", context.getLocation(), true, false);
|
||||
if ( VCs.size() == 0 )
|
||||
return 0;
|
||||
|
||||
|
|
|
|||
|
|
@ -203,7 +203,7 @@ public class VariantAnnotatorEngine {
|
|||
infoAnnotations.put(VariantContext.ID_KEY, rsID);
|
||||
} else {
|
||||
boolean overlapsComp = false;
|
||||
for ( VariantContext comp : tracker.getVariantContexts(ref, dbSet.getKey(), null, ref.getLocus(), false, false) ) {
|
||||
for ( VariantContext comp : tracker.getVariantContexts(ref, dbSet.getKey(), ref.getLocus(), false, false) ) {
|
||||
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(ref, expression.bindingName, null, ref.getLocus(), false, true);
|
||||
Collection<VariantContext> VCs = tracker.getVariantContexts(ref, expression.bindingName, ref.getLocus(), false, true);
|
||||
if ( VCs.size() == 0 )
|
||||
continue;
|
||||
|
||||
|
|
|
|||
|
|
@ -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(ref, "variant", null, context.getLocation(), true, false)) {
|
||||
for (VariantContext vc : tracker.getVariantContexts(ref, "variant", context.getLocation(), true, false)) {
|
||||
if ( (vc.isFiltered() && IGNORE_FILTERED_SITES) ||
|
||||
(vc.isVariant() && !vc.isBiallelic()) ) {
|
||||
results.add(vc);
|
||||
|
|
|
|||
|
|
@ -119,9 +119,9 @@ public class BeagleOutputToVCFWalker extends RodWalker<Integer, Integer> {
|
|||
return 0;
|
||||
|
||||
GenomeLoc loc = context.getLocation();
|
||||
VariantContext vc_input = tracker.getVariantContext(ref,INPUT_ROD_NAME, null, loc, true);
|
||||
VariantContext vc_input = tracker.getVariantContext(ref,INPUT_ROD_NAME, loc, true);
|
||||
|
||||
VariantContext vc_comp = tracker.getVariantContext(ref,COMP_ROD_NAME, null, loc, true);
|
||||
VariantContext vc_comp = tracker.getVariantContext(ref,COMP_ROD_NAME, loc, true);
|
||||
|
||||
if ( vc_input == null )
|
||||
return 0;
|
||||
|
|
|
|||
|
|
@ -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(ref, ROD_NAME, null, loc, true);
|
||||
VariantContext validation_eval = tracker.getVariantContext(ref,VALIDATION_ROD_NAME,null,loc, true);
|
||||
VariantContext variant_eval = tracker.getVariantContext(ref, ROD_NAME, loc, true);
|
||||
VariantContext validation_eval = tracker.getVariantContext(ref,VALIDATION_ROD_NAME, loc, true);
|
||||
|
||||
if ( goodSite(variant_eval,validation_eval) ) {
|
||||
if ( useValidation(validation_eval, ref) ) {
|
||||
|
|
|
|||
|
|
@ -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(ref, ROD_NAME, null, loc, true);
|
||||
VariantContext vc = tracker.getVariantContext(ref, ROD_NAME, loc, true);
|
||||
|
||||
if ( ProduceBeagleInputWalker.canBeOutputToBeagle(vc) ) {
|
||||
// do we want to hold back this site?
|
||||
|
|
|
|||
|
|
@ -149,7 +149,7 @@ public class VariantFiltrationWalker extends RodWalker<Integer, Integer> {
|
|||
if ( tracker == null )
|
||||
return 0;
|
||||
|
||||
Collection<VariantContext> VCs = tracker.getVariantContexts(ref, INPUT_VARIANT_ROD_BINDING_NAME, null, context.getLocation(), true, false);
|
||||
Collection<VariantContext> VCs = tracker.getVariantContexts(ref, INPUT_VARIANT_ROD_BINDING_NAME, context.getLocation(), true, false);
|
||||
|
||||
// is there a SNP mask present?
|
||||
boolean hasMask = tracker.getValues("mask").size() > 0;
|
||||
|
|
|
|||
|
|
@ -293,6 +293,9 @@ public class IndelGenotypeLikelihoodsCalculationModel extends GenotypeLikelihood
|
|||
return aList;
|
||||
|
||||
}
|
||||
|
||||
private final static EnumSet<VariantContext.Type> allowableTypes = EnumSet.of(VariantContext.Type.INDEL, VariantContext.Type.MIXED);
|
||||
|
||||
public Allele getLikelihoods(RefMetaDataTracker tracker,
|
||||
ReferenceContext ref,
|
||||
Map<String, AlignmentContext> contexts,
|
||||
|
|
@ -318,11 +321,10 @@ public class IndelGenotypeLikelihoodsCalculationModel extends GenotypeLikelihood
|
|||
haplotypeMap.clear();
|
||||
|
||||
if (getAlleleListFromVCF) {
|
||||
EnumSet<VariantContext.Type> allowableTypes = EnumSet.of(VariantContext.Type.INDEL);
|
||||
allowableTypes.add(VariantContext.Type.MIXED);
|
||||
for( final VariantContext vc_input : tracker.getVariantContexts(ref, "alleles",
|
||||
allowableTypes, ref.getLocus(), false, false) ) {
|
||||
if( vc_input != null && ref.getLocus().getStart() == vc_input.getStart()) {
|
||||
for( final VariantContext vc_input : tracker.getVariantContexts(ref, "alleles", ref.getLocus(), false, false) ) {
|
||||
if( vc_input != null &&
|
||||
allowableTypes.contains(vc_input.getType()) &&
|
||||
ref.getLocus().getStart() == vc_input.getStart()) {
|
||||
vc = vc_input;
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@ public class SNPGenotypeLikelihoodsCalculationModel extends GenotypeLikelihoodsC
|
|||
VariantContext vc = null;
|
||||
|
||||
// search for usable record
|
||||
for( final VariantContext vc_input : tracker.getVariantContexts(ref, "alleles", null, ref.getLocus(), true, false) ) {
|
||||
for( final VariantContext vc_input : tracker.getVariantContexts(ref, "alleles", ref.getLocus(), true, false) ) {
|
||||
if ( vc_input != null && ! vc_input.isFiltered() && (! requireSNP || vc_input.isSNP() )) {
|
||||
if ( vc == null ) {
|
||||
vc = vc_input;
|
||||
|
|
|
|||
|
|
@ -96,7 +96,7 @@ public class UGCallVariants extends RodWalker<VariantCallContext, Integer> {
|
|||
|
||||
List<VariantContext> VCs = new ArrayList<VariantContext>();
|
||||
for ( String name : trackNames ) {
|
||||
Collection<VariantContext> vc = tracker.getVariantContexts(ref, name, null, context.getLocation(), true, true);
|
||||
Collection<VariantContext> vc = tracker.getVariantContexts(ref, name, context.getLocation(), true, true);
|
||||
VCs.addAll(vc);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -155,7 +155,7 @@ public class AnnotateMNPsWalker extends RodWalker<Integer, Integer> {
|
|||
|
||||
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(ref, rodNames, null, context.getLocation(), requireStartHere, takeFirstOnly)) {
|
||||
for (VariantContext vc : tracker.getVariantContexts(ref, rodNames, context.getLocation(), requireStartHere, takeFirstOnly)) {
|
||||
GenomeLoc vcLoc = VariantContextUtils.getLocation(locParser, vc);
|
||||
boolean atStartOfVc = curLocus.getStart() == vcLoc.getStart();
|
||||
boolean atEndOfVc = curLocus.getStart() == vcLoc.getStop();
|
||||
|
|
|
|||
|
|
@ -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(ref, "pbt", null, ref.getLocus(), true, true);
|
||||
Collection<VariantContext> rbps = tracker.getVariantContexts(ref, "rbp", null, ref.getLocus(), true, true);
|
||||
Collection<VariantContext> pbts = tracker.getVariantContexts(ref, "pbt", ref.getLocus(), true, true);
|
||||
Collection<VariantContext> rbps = tracker.getVariantContexts(ref, "rbp", ref.getLocus(), true, true);
|
||||
|
||||
VariantContext pbt = pbts.iterator().hasNext() ? pbts.iterator().next() : null;
|
||||
VariantContext rbp = rbps.iterator().hasNext() ? rbps.iterator().next() : null;
|
||||
|
|
|
|||
|
|
@ -103,7 +103,7 @@ public class MergeMNPsWalker extends RodWalker<Integer, Integer> {
|
|||
|
||||
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(ref, rodNames, null, context.getLocation(), requireStartHere, takeFirstOnly))
|
||||
for (VariantContext vc : tracker.getVariantContexts(ref, rodNames, context.getLocation(), requireStartHere, takeFirstOnly))
|
||||
writeVCF(vc);
|
||||
|
||||
return 0;
|
||||
|
|
|
|||
|
|
@ -140,7 +140,7 @@ public class MergeSegregatingAlternateAllelesWalker extends RodWalker<Integer, I
|
|||
|
||||
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(ref, rodNames, null, context.getLocation(), requireStartHere, takeFirstOnly))
|
||||
for (VariantContext vc : tracker.getVariantContexts(ref, rodNames, context.getLocation(), requireStartHere, takeFirstOnly))
|
||||
writeVCF(vc);
|
||||
|
||||
return 0;
|
||||
|
|
|
|||
|
|
@ -289,7 +289,7 @@ 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(ref, ROD_NAME, null, context.getLocation(), true, true);
|
||||
Collection<VariantContext> vcs = tracker.getVariantContexts(ref, ROD_NAME, context.getLocation(), true, true);
|
||||
|
||||
for (VariantContext vc : vcs) {
|
||||
Map<String, Genotype> genotypeMap = vc.getGenotypes();
|
||||
|
|
|
|||
|
|
@ -209,7 +209,7 @@ public class ReadBackedPhasingWalker extends RodWalker<PhasingStatsAndOutput, Ph
|
|||
|
||||
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(ref, rodNames, null, context.getLocation(), requireStartHere, takeFirstOnly)) {
|
||||
for (VariantContext vc : tracker.getVariantContexts(ref, rodNames, context.getLocation(), requireStartHere, takeFirstOnly)) {
|
||||
if (samplesToPhase != null) vc = reduceVCToSamples(vc, samplesToPhase);
|
||||
|
||||
if (ReadBackedPhasingWalker.processVariantInPhasing(vc)) {
|
||||
|
|
|
|||
|
|
@ -40,9 +40,12 @@ public class Novelty extends VariantStratifier implements StandardStratification
|
|||
allowableTypes.add(eval.getType());
|
||||
}
|
||||
|
||||
Collection<VariantContext> knownComps = tracker.getVariantContexts(ref, knownName, allowableTypes, ref.getLocus(), true, true);
|
||||
|
||||
isNovel = knownComps.size() == 0;
|
||||
Collection<VariantContext> knownComps = tracker.getVariantContexts(ref, knownName, ref.getLocus(), true, true);
|
||||
for ( VariantContext c : knownComps )
|
||||
if ( allowableTypes.contains(c.getType()) ) {
|
||||
isNovel = false;
|
||||
break;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -270,30 +270,7 @@ public class VariantEvalUtils {
|
|||
Set<String> compNames,
|
||||
Set<String> evalNames,
|
||||
boolean dynamicSelectTypes ) {
|
||||
if ( dynamicSelectTypes ) { // todo -- this code is really conceptually broken
|
||||
EnumSet<VariantContext.Type> allowableTypes = EnumSet.of(VariantContext.Type.NO_VARIATION);
|
||||
|
||||
if (tracker != null) {
|
||||
Collection<VariantContext> evalvcs = tracker.getVariantContexts(ref, evalNames, null, ref.getLocus(), true, false);
|
||||
|
||||
for (VariantContext vc : evalvcs) {
|
||||
allowableTypes.add(vc.getType());
|
||||
}
|
||||
|
||||
if (allowableTypes.size() == 1) {
|
||||
// We didn't find any variation in the eval track, so now let's look at the comp track for allowable types
|
||||
Collection<VariantContext> compvcs = tracker.getVariantContexts(ref, compNames, null, ref.getLocus(), true, false);
|
||||
|
||||
for (VariantContext vc : compvcs) {
|
||||
allowableTypes.add(vc.getType());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return allowableTypes;
|
||||
} else {
|
||||
return EnumSet.allOf(VariantContext.Type.class);
|
||||
}
|
||||
return EnumSet.allOf(VariantContext.Type.class);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -359,7 +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(ref, trackName, allowableTypes, ref.getLocus(), true, true);
|
||||
Collection<VariantContext> contexts = tracker == null ? null : tracker.getVariantContexts(ref, trackName, ref.getLocus(), true, true);
|
||||
VariantContext vc = contexts != null && contexts.size() == 1 ? contexts.iterator().next() : null;
|
||||
|
||||
// First, filter the VariantContext to represent only the samples for evaluation
|
||||
|
|
|
|||
|
|
@ -168,7 +168,7 @@ public class ApplyRecalibration extends RodWalker<Integer, Integer> {
|
|||
return 1;
|
||||
}
|
||||
|
||||
for( VariantContext vc : tracker.getVariantContexts(ref, inputNames, null, context.getLocation(), true, false) ) {
|
||||
for( VariantContext vc : tracker.getVariantContexts(ref, inputNames, context.getLocation(), true, false) ) {
|
||||
if( vc != null ) {
|
||||
if( VariantRecalibrator.checkRecalibrationMode( vc, MODE ) && (vc.isNotFiltered() || ignoreInputFilterSet.containsAll(vc.getFilters())) ) {
|
||||
String filterString = null;
|
||||
|
|
|
|||
|
|
@ -258,7 +258,7 @@ public class VariantDataManager {
|
|||
datum.consensusCount = 0;
|
||||
|
||||
for( final TrainingSet trainingSet : trainingSets ) {
|
||||
for( final VariantContext trainVC : tracker.getVariantContexts( ref, trainingSet.name, null, context.getLocation(), false, false ) ) {
|
||||
for( final VariantContext trainVC : tracker.getVariantContexts( ref, trainingSet.name, context.getLocation(), false, false ) ) {
|
||||
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()) ) {
|
||||
|
|
|
|||
|
|
@ -163,7 +163,7 @@ public class VariantRecalibrator extends RodWalker<ExpandingArrayList<VariantDat
|
|||
return mapList;
|
||||
}
|
||||
|
||||
for( final VariantContext vc : tracker.getVariantContexts(ref, inputNames, null, context.getLocation(), true, false) ) {
|
||||
for( final VariantContext vc : tracker.getVariantContexts(ref, inputNames, context.getLocation(), true, false) ) {
|
||||
if( vc != null && ( vc.isNotFiltered() || ignoreInputFilterSet.containsAll(vc.getFilters()) ) ) {
|
||||
if( checkRecalibrationMode( vc, VRAC.MODE ) ) {
|
||||
final VariantDatum datum = new VariantDatum();
|
||||
|
|
|
|||
|
|
@ -150,7 +150,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(ref, null, context.getLocation(), true, false);
|
||||
Collection<VariantContext> vcs = tracker.getAllVariantContexts(ref, context.getLocation(), true, false);
|
||||
|
||||
if ( sitesOnlyVCF ) {
|
||||
vcs = VariantContextUtils.sitesOnlyVariantContexts(vcs);
|
||||
|
|
|
|||
|
|
@ -85,7 +85,7 @@ public class FilterLiftedVariants extends RodWalker<Integer, Integer> {
|
|||
if ( tracker == null )
|
||||
return 0;
|
||||
|
||||
Collection<VariantContext> VCs = tracker.getVariantContexts(ref, "variant", null, context.getLocation(), true, false);
|
||||
Collection<VariantContext> VCs = tracker.getVariantContexts(ref, "variant", context.getLocation(), true, false);
|
||||
for ( VariantContext vc : VCs )
|
||||
filterAndWrite(ref.getBases(), vc);
|
||||
|
||||
|
|
|
|||
|
|
@ -68,7 +68,7 @@ public class LeftAlignVariants extends RodWalker<Integer, Integer> {
|
|||
if ( tracker == null )
|
||||
return 0;
|
||||
|
||||
Collection<VariantContext> VCs = tracker.getVariantContexts(ref, "variant", null, context.getLocation(), true, false);
|
||||
Collection<VariantContext> VCs = tracker.getVariantContexts(ref, "variant", context.getLocation(), true, false);
|
||||
|
||||
int changedSites = 0;
|
||||
for ( VariantContext vc : VCs )
|
||||
|
|
|
|||
|
|
@ -143,7 +143,7 @@ public class LiftoverVariants extends RodWalker<Integer, Integer> {
|
|||
if ( tracker == null )
|
||||
return 0;
|
||||
|
||||
Collection<VariantContext> VCs = tracker.getVariantContexts(ref, "variant", null, context.getLocation(), true, false);
|
||||
Collection<VariantContext> VCs = tracker.getVariantContexts(ref, "variant", context.getLocation(), true, false);
|
||||
for ( VariantContext vc : VCs )
|
||||
convertAndWrite(vc, ref);
|
||||
|
||||
|
|
|
|||
|
|
@ -97,7 +97,7 @@ public class RandomlySplitVariants extends RodWalker<Integer, Integer> {
|
|||
if ( tracker == null )
|
||||
return 0;
|
||||
|
||||
Collection<VariantContext> vcs = tracker.getVariantContexts(ref, INPUT_VARIANT_ROD_BINDING_NAME, null, context.getLocation(), true, false);
|
||||
Collection<VariantContext> vcs = tracker.getVariantContexts(ref, INPUT_VARIANT_ROD_BINDING_NAME, context.getLocation(), true, false);
|
||||
for ( VariantContext vc : vcs ) {
|
||||
int random = GenomeAnalysisEngine.getRandomGenerator().nextInt(1000);
|
||||
if ( random < iFraction )
|
||||
|
|
|
|||
|
|
@ -317,7 +317,7 @@ public class SelectVariants extends RodWalker<Integer, Integer> {
|
|||
if ( tracker == null )
|
||||
return 0;
|
||||
|
||||
Collection<VariantContext> vcs = tracker.getVariantContexts(ref, variantRodName, null, context.getLocation(), true, false);
|
||||
Collection<VariantContext> vcs = tracker.getVariantContexts(ref, variantRodName, context.getLocation(), true, false);
|
||||
|
||||
if ( vcs == null || vcs.size() == 0) {
|
||||
return 0;
|
||||
|
|
@ -345,12 +345,12 @@ public class SelectVariants extends RodWalker<Integer, Integer> {
|
|||
break;
|
||||
}
|
||||
if (DISCORDANCE_ONLY) {
|
||||
Collection<VariantContext> compVCs = tracker.getVariantContexts(ref, discordanceRodName, null, context.getLocation(), true, false);
|
||||
Collection<VariantContext> compVCs = tracker.getVariantContexts(ref, discordanceRodName, context.getLocation(), true, false);
|
||||
if (!isDiscordant(vc, compVCs))
|
||||
return 0;
|
||||
}
|
||||
if (CONCORDANCE_ONLY) {
|
||||
Collection<VariantContext> compVCs = tracker.getVariantContexts(ref, concordanceRodName, null, context.getLocation(), true, false);
|
||||
Collection<VariantContext> compVCs = tracker.getVariantContexts(ref, concordanceRodName, context.getLocation(), true, false);
|
||||
if (!isConcordant(vc, compVCs))
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -86,7 +86,7 @@ public class ValidateVariants extends RodWalker<Integer, Integer> {
|
|||
if ( tracker == null )
|
||||
return 0;
|
||||
|
||||
Collection<VariantContext> VCs = tracker.getVariantContexts(ref, "variant", null, context.getLocation(), true, false);
|
||||
Collection<VariantContext> VCs = tracker.getVariantContexts(ref, "variant", context.getLocation(), true, false);
|
||||
for ( VariantContext vc : VCs )
|
||||
validate(vc, tracker, ref);
|
||||
|
||||
|
|
|
|||
|
|
@ -90,21 +90,23 @@ public class VariantsToVCF extends RodWalker<Integer, Integer> {
|
|||
Collection<VariantContext> contexts = getVariantContexts(tracker, ref);
|
||||
|
||||
for ( VariantContext vc : contexts ) {
|
||||
Map<String, Object> attrs = new HashMap<String, Object>(vc.getAttributes());
|
||||
if ( rsID != null && !vc.hasID() ) {
|
||||
attrs.put(VariantContext.ID_KEY, rsID);
|
||||
vc = VariantContext.modifyAttributes(vc, attrs);
|
||||
}
|
||||
if ( ALLOWED_VARIANT_CONTEXT_TYPES.contains(vc.getType()) ) {
|
||||
Map<String, Object> attrs = new HashMap<String, Object>(vc.getAttributes());
|
||||
if ( rsID != null && !vc.hasID() ) {
|
||||
attrs.put(VariantContext.ID_KEY, rsID);
|
||||
vc = VariantContext.modifyAttributes(vc, attrs);
|
||||
}
|
||||
|
||||
// set the appropriate sample name if necessary
|
||||
if ( sampleName != null && vc.hasGenotypes() && vc.hasGenotype(INPUT_ROD_NAME) ) {
|
||||
Genotype g = Genotype.modifyName(vc.getGenotype(INPUT_ROD_NAME), sampleName);
|
||||
Map<String, Genotype> genotypes = new HashMap<String, Genotype>();
|
||||
genotypes.put(sampleName, g);
|
||||
vc = VariantContext.modifyGenotypes(vc, genotypes);
|
||||
}
|
||||
// set the appropriate sample name if necessary
|
||||
if ( sampleName != null && vc.hasGenotypes() && vc.hasGenotype(INPUT_ROD_NAME) ) {
|
||||
Genotype g = Genotype.modifyName(vc.getGenotype(INPUT_ROD_NAME), sampleName);
|
||||
Map<String, Genotype> genotypes = new HashMap<String, Genotype>();
|
||||
genotypes.put(sampleName, g);
|
||||
vc = VariantContext.modifyGenotypes(vc, genotypes);
|
||||
}
|
||||
|
||||
writeRecord(vc, tracker, ref.getBase());
|
||||
writeRecord(vc, tracker, ref.getBase());
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
|
|
@ -160,7 +162,7 @@ public class VariantsToVCF extends RodWalker<Integer, Integer> {
|
|||
}
|
||||
|
||||
// for everything else, we can just convert to VariantContext
|
||||
return tracker.getVariantContexts(ref, INPUT_ROD_NAME, ALLOWED_VARIANT_CONTEXT_TYPES, ref.getLocus(), true, false);
|
||||
return tracker.getVariantContexts(ref, INPUT_ROD_NAME, ref.getLocus(), true, false);
|
||||
}
|
||||
|
||||
private DbSNPFeature getDbsnpFeature(String rsID) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue