Continuing refactoring of RefMetaDataTracker.

On the path towards converging getVariantContext() and getValues() in tracker so that we can have a single approach to get values from RODs with the new RodBinding() types
This commit is contained in:
Mark DePristo 2011-07-28 17:48:28 -04:00
parent 7c5c656b46
commit 39b4e76fde
43 changed files with 291 additions and 275 deletions

View File

@ -1,82 +1,78 @@
///*
// * Copyright (c) 2011, The Broad Institute
// *
// * Permission is hereby granted, free of charge, to any person
// * obtaining a copy of this software and associated documentation
// * files (the "Software"), to deal in the Software without
// * restriction, including without limitation the rights to use,
// * copy, modify, merge, publish, distribute, sublicense, and/or sell
// * copies of the Software, and to permit persons to whom the
// * Software is furnished to do so, subject to the following
// * conditions:
// *
// * The above copyright notice and this permission notice shall be
// * included in all copies or substantial portions of the Software.
// * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
// * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
// * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
// * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
// * OTHER DEALINGS IN THE SOFTWARE.
// */
//
//package org.broadinstitute.sting.commandline;
//
//import org.broadinstitute.sting.gatk.contexts.ReferenceContext;
//import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker;
//import org.broadinstitute.sting.utils.GenomeLoc;
//import org.broadinstitute.sting.utils.variantcontext.VariantContext;
//
//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);
// }
//
// /**
// * 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);
// }
//
// /**
// * 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);
// }
//}
/*
* Copyright (c) 2011, The Broad Institute
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following
* conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*/
package org.broadinstitute.sting.commandline;
import org.broadinstitute.sting.gatk.contexts.ReferenceContext;
import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker;
import org.broadinstitute.sting.utils.GenomeLoc;
import org.broadinstitute.sting.utils.variantcontext.VariantContext;
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(VariantContext.class, variableName, sourceFile, parser);
}
/**
* Forwarding method to identical tracker method
*/
public Collection<VariantContext> getVariantContexts(final RefMetaDataTracker tracker,
final GenomeLoc curLocation,
final boolean requireStartHere,
final boolean takeFirstOnly ) {
return tracker.getVariantContexts(variableName, curLocation, requireStartHere, takeFirstOnly);
}
/**
* Forwarding method to identical tracker method
* @param tracker
* @param curLocation
* @param requireStartHere
* @return
*/
public VariantContext getVariantContext(final RefMetaDataTracker tracker,
final GenomeLoc curLocation,
final boolean requireStartHere ) {
return tracker.getVariantContext(variableName, curLocation, requireStartHere);
}
/**
* Forwarding method to identical tracker method
*/
public VariantContext getVariantContext(final RefMetaDataTracker tracker,
final GenomeLoc curLocation) {
return tracker.getVariantContext(variableName, curLocation);
}
}

View File

@ -1,5 +1,6 @@
package org.broadinstitute.sting.gatk.datasources.providers;
import org.broadinstitute.sting.gatk.contexts.ReferenceContext;
import org.broadinstitute.sting.gatk.datasources.rmd.ReferenceOrderedDataSource;
import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker;
import org.broadinstitute.sting.gatk.refdata.utils.LocationAwareSeekableRODIterator;
@ -49,8 +50,8 @@ public class ManagingReferenceOrderedView implements ReferenceOrderedView {
* @param loc Locus at which to track.
* @return A tracker containing information about this locus.
*/
public RefMetaDataTracker getReferenceOrderedDataAtLocus( GenomeLoc loc ) {
RefMetaDataTracker tracks = new RefMetaDataTracker(states.size());
public RefMetaDataTracker getReferenceOrderedDataAtLocus( GenomeLoc loc, ReferenceContext referenceContext ) {
RefMetaDataTracker tracks = new RefMetaDataTracker(states.size(), referenceContext);
for ( ReferenceOrderedDataState state: states )
tracks.bind( state.dataSource.getName(), state.iterator.seekForward(loc) );
return tracks;

View File

@ -1,8 +1,9 @@
package org.broadinstitute.sting.gatk.datasources.providers;
import org.broadinstitute.sting.gatk.contexts.ReferenceContext;
import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker;
import org.broadinstitute.sting.utils.GenomeLoc;
public interface ReferenceOrderedView extends View {
RefMetaDataTracker getReferenceOrderedDataAtLocus( GenomeLoc loc );
RefMetaDataTracker getReferenceOrderedDataAtLocus( GenomeLoc loc, ReferenceContext refContext );
}

View File

@ -26,6 +26,7 @@
package org.broadinstitute.sting.gatk.datasources.providers;
import org.broadinstitute.sting.gatk.contexts.AlignmentContext;
import org.broadinstitute.sting.gatk.contexts.ReferenceContext;
import org.broadinstitute.sting.gatk.datasources.rmd.ReferenceOrderedDataSource;
import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker;
import org.broadinstitute.sting.gatk.refdata.utils.LocationAwareSeekableRODIterator;
@ -45,7 +46,8 @@ public class RodLocusView extends LocusView implements ReferenceOrderedView {
*/
private RODMergingIterator rodQueue = null;
RefMetaDataTracker tracker = null;
Collection<RODRecordList> allTracksHere;
GenomeLoc lastLoc = null;
RODRecordList interval = null;
@ -98,8 +100,17 @@ public class RodLocusView extends LocusView implements ReferenceOrderedView {
//throw new StingException("RodLocusView currently disabled");
}
public RefMetaDataTracker getReferenceOrderedDataAtLocus( GenomeLoc loc ) {
return tracker;
public RefMetaDataTracker getReferenceOrderedDataAtLocus( GenomeLoc loc, ReferenceContext referenceContext ) {
RefMetaDataTracker t = new RefMetaDataTracker(allTracksHere.size(), referenceContext);
for ( RODRecordList track : allTracksHere ) {
if ( ! t.hasValues(track.getName()) )
t.bind(track.getName(), track);
}
// special case the interval again -- add it into the ROD
if ( interval != null ) { t.bind(interval.getName(), interval); }
return t;
}
public boolean hasNext() {
@ -122,10 +133,7 @@ public class RodLocusView extends LocusView implements ReferenceOrderedView {
if ( DEBUG ) System.out.printf("In RodLocusView.next(): creating tracker...%n");
// Update the tracker here for use
Collection<RODRecordList> allTracksHere = getSpanningTracks(datum);
tracker = createTracker(allTracksHere);
allTracksHere = getSpanningTracks(datum);
GenomeLoc rodSite = datum.getLocation();
GenomeLoc site = genomeLocParser.createGenomeLoc( rodSite.getContig(), rodSite.getStart(), rodSite.getStart());
@ -137,19 +145,6 @@ public class RodLocusView extends LocusView implements ReferenceOrderedView {
return new AlignmentContext(site, new ReadBackedPileupImpl(site), skippedBases);
}
private RefMetaDataTracker createTracker( Collection<RODRecordList> allTracksHere ) {
RefMetaDataTracker t = new RefMetaDataTracker(allTracksHere.size());
for ( RODRecordList track : allTracksHere ) {
if ( ! t.hasValues(track.getName()) )
t.bind(track.getName(), track);
}
// special case the interval again -- add it into the ROD
if ( interval != null ) { t.bind(interval.getName(), interval); }
return t;
}
private Collection<RODRecordList> getSpanningTracks(RODRecordList marker) {
return rodQueue.allElementsLTE(marker);
}
@ -197,10 +192,6 @@ public class RodLocusView extends LocusView implements ReferenceOrderedView {
return getSkippedBases(getLocOneBeyondShard());
}
public RefMetaDataTracker getTracker() {
return tracker;
}
/**
* Closes the current view.
*/
@ -209,6 +200,6 @@ public class RodLocusView extends LocusView implements ReferenceOrderedView {
state.dataSource.close( state.iterator );
rodQueue = null;
tracker = null;
allTracksHere = null;
}
}

View File

@ -4,6 +4,7 @@ import org.apache.log4j.Logger;
import org.broadinstitute.sting.gatk.contexts.ReferenceContext;
import org.broadinstitute.sting.gatk.refdata.utils.GATKFeature;
import org.broadinstitute.sting.gatk.refdata.utils.RODRecordList;
import org.broadinstitute.sting.gatk.walkers.Reference;
import org.broadinstitute.sting.utils.GenomeLoc;
import org.broadinstitute.sting.utils.exceptions.ReviewedStingException;
import org.broadinstitute.sting.utils.exceptions.UserException;
@ -18,7 +19,7 @@ import java.util.*;
* The standard interaction model is:
*
* Traversal system arrives at a site, which has a bunch of RMDs covering it
Genotype * Traversal calls tracker.bind(name, RMD) for each RMDs in RMDs
Genotype * Traversal calls tracker.bind(name, RMD) for each RMDs in RMDs
* Traversal passes tracker to the walker
* walker calls lookup(name, default) to obtain the RMDs values at this site, or default if none was
* bound at this site.
@ -29,15 +30,83 @@ Genotype * Traversal calls tracker.bind(name, RMD) for each RMDs in RMDs
*/
public class RefMetaDataTracker {
final Map<String, RODRecordList> map;
final ReferenceContext ref;
protected static Logger logger = Logger.getLogger(RefMetaDataTracker.class);
public RefMetaDataTracker(int nBindings) {
public RefMetaDataTracker(int nBindings, ReferenceContext ref) {
this.ref = ref;
if ( nBindings == 0 )
map = Collections.emptyMap();
else
map = new HashMap<String, RODRecordList>(nBindings);
}
// ------------------------------------------------------------------------------------------
//
//
// Special ENGINE interaction functions
//
//
// ------------------------------------------------------------------------------------------
/**
* 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
*/
public void bind(final String name, RODRecordList rod) {
//logger.debug(String.format("Binding %s to %s", name, rod));
map.put(canonicalName(name), maybeConvertToVariantContext(rod));
}
/**
* A private converter that transforms a RODRecordList of objects of type X into
* a list of VariantContexts, if possible.
*
* TODO: should be removed when Features like dbsnp and hapmap produce VCs directly
*
* @param bindings
* @return
*/
private final RODRecordList maybeConvertToVariantContext(RODRecordList bindings) {
List<GATKFeature> values = new ArrayList<GATKFeature>(bindings.size());
for ( GATKFeature rec : bindings ) {
if ( VariantContextAdaptors.canBeConvertedToVariantContext(rec.getUnderlyingObject()) ) {
final VariantContext vc = VariantContextAdaptors.toVariantContext(bindings.getName(), rec.getUnderlyingObject(), ref);
if ( vc != null ) // it's possible that the conversion failed, but we continue along anyway
values.add(new GATKFeature.TribbleGATKFeature(ref.getGenomeLocParser(), vc, rec.getName()));
}
}
return new RODRecordListImpl(bindings.getName(), values, bindings.getLocation());
}
// /**
// * Temporary setting for putting a reference context into the system.
// *
// * DO NOT USE THIS FUNCTION UNLESS YOU ARE THE GATK ENGINE
// *
// * @param ref
// */
// public void setRef(final ReferenceContext ref) {
// this.ref = ref;
// }
// ------------------------------------------------------------------------------------------
//
//
// Generic accessors
//
//
// ------------------------------------------------------------------------------------------
/**
* No-assumption version of getValues(name, class). Returns Objects.
*/
@ -60,18 +129,11 @@ public class RefMetaDataTracker {
if (list == null)
return Collections.emptyList();
else {
List<T> objects = new ArrayList<T>();
for (GATKFeature feature : list) {
final Object obj = feature.getUnderlyingObject();
if (!(clazz.isAssignableFrom(obj.getClass())))
throw new UserException.CommandLineException("Unable to case track named " + name + " to type of " + clazz.toString()
+ " it's of type " + obj.getClass());
objects.add((T)obj);
}
return objects;
return addValues(name, clazz, new ArrayList<T>(), list, list.getLocation(), false, false);
}
}
/**
* 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.
@ -79,7 +141,7 @@ public class RefMetaDataTracker {
* * 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!
*
*
* @param name the name of the track
* @param clazz the underlying type to return
* @param <T> the type to parameterize on, matching the clazz argument
@ -116,7 +178,7 @@ public class RefMetaDataTracker {
*
* @return collection of all rods
*/
public Collection<GATKFeature> getAllValuesAsGATKFeatures() {
public List<GATKFeature> getAllValuesAsGATKFeatures() {
List<GATKFeature> l = new ArrayList<GATKFeature>();
for ( RODRecordList rl : map.values() ) {
if ( rl != null )
@ -125,7 +187,7 @@ public class RefMetaDataTracker {
return l;
}
/**
/**
* get all the GATK features associated with a specific track name
* @param name the name of the track we're looking for
* @return a list of GATKFeatures for the target rmd
@ -141,9 +203,9 @@ public class RefMetaDataTracker {
* Get all of the RMD tracks at the current site. Each track is returned as a single compound
* object (RODRecordList) that may contain multiple RMD records associated with the current site.
*
* @return collection of all tracks
* @return List of all tracks
*/
public Collection<RODRecordList> getBoundRodTracks() {
public List<RODRecordList> getBoundRodTracks() {
LinkedList<RODRecordList> bound = new LinkedList<RODRecordList>();
for ( RODRecordList value : map.values() ) {
@ -167,21 +229,6 @@ public class RefMetaDataTracker {
return n;
}
/**
* 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
*/
public void bind(final String name, RODRecordList rod) {
//logger.debug(String.format("Binding %s to %s", name, rod));
map.put(canonicalName(name), rod);
}
// ------------------------------------------------------------------------------------------
//
//
@ -195,22 +242,20 @@ public class RefMetaDataTracker {
* of entries per ROD.
* The name of each VariantContext corresponds to the ROD name.
*
* @param ref reference context
* @return variant context
*/
public Collection<VariantContext> getAllVariantContexts(final ReferenceContext ref) {
return getAllVariantContexts(ref, null, false, false);
public List<VariantContext> getAllVariantContexts() {
return getAllVariantContexts(null, false, false);
}
/**
* Returns all of the variant contexts that start at the current location
* @param ref
*
* @param curLocation
* @return
*/
public Collection<VariantContext> getAllVariantContexts(final ReferenceContext ref,
final GenomeLoc curLocation) {
return getAllVariantContexts(ref, curLocation, true, false);
public List<VariantContext> getAllVariantContexts(final GenomeLoc curLocation) {
return getAllVariantContexts(curLocation, true, false);
}
/**
@ -224,20 +269,19 @@ public class RefMetaDataTracker {
*
* The name of each VariantContext corresponds to the ROD name.
*
* @param ref reference context
*
* @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(final ReferenceContext ref,
final GenomeLoc curLocation,
final boolean requireStartHere,
final boolean takeFirstOnly ) {
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, ref, curLocation, requireStartHere, takeFirstOnly);
addVariantContexts(contexts, rodList, curLocation, requireStartHere, takeFirstOnly);
}
return contexts;
@ -248,33 +292,31 @@ public class RefMetaDataTracker {
*
* see getVariantContexts for more information.
*
* @param ref ReferenceContext to enable conversion to variant context
*
* @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
*/
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 List<VariantContext> getVariantContexts(final String name,
final GenomeLoc curLocation,
final boolean requireStartHere,
final boolean takeFirstOnly) {
return getVariantContexts(Arrays.asList(name), curLocation, requireStartHere, 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>();
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
if ( rodList != null )
addVariantContexts(contexts, rodList, ref, curLocation, requireStartHere, takeFirstOnly );
addVariantContexts(contexts, rodList, curLocation, requireStartHere, takeFirstOnly );
}
return contexts;
@ -284,16 +326,16 @@ public class RefMetaDataTracker {
* 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
*/
public VariantContext getVariantContext(final ReferenceContext ref,
final String name,
public VariantContext getVariantContext(final String name,
final GenomeLoc curLocation,
final boolean requireStartHere ) {
Collection<VariantContext> contexts = getVariantContexts(ref, name, curLocation, requireStartHere, false );
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);
@ -306,46 +348,53 @@ public class RefMetaDataTracker {
/**
* 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 ref
*
*
* @param name
* @param curLocation
* @return
*/
public VariantContext getVariantContext(final ReferenceContext ref,
final String name,
public VariantContext getVariantContext(final String name,
final GenomeLoc curLocation) {
return getVariantContext(ref, name, curLocation, true);
return getVariantContext(name, curLocation, true);
}
private void addVariantContexts(final Collection<VariantContext> contexts,
private void addVariantContexts(final List<VariantContext> contexts,
final RODRecordList rodList,
final ReferenceContext ref,
final GenomeLoc curLocation,
final boolean requireStartHere,
final boolean takeFirstOnly ) {
addValues("xxx", VariantContext.class, contexts, rodList, curLocation, requireStartHere, takeFirstOnly);
}
private static <T> List<T> addValues(final String name,
final Class<T> type,
final List<T> values,
final RODRecordList rodList,
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
final VariantContext vc = VariantContextAdaptors.toVariantContext(rodList.getName(), rec.getUnderlyingObject(), ref);
if ( ! requireStartHere || rec.getLocation().getStart() == curLocation.getStart() ) { // ok, we are going to keep this thing
Object obj = rec.getUnderlyingObject();
if (!(type.isAssignableFrom(obj.getClass())))
throw new UserException.CommandLineException("Unable to cast track named " + name + " to type of " + type.toString()
+ " it's of type " + obj.getClass());
if ( vc == null ) // sometimes the track has odd stuff in it that can't be converted
continue;
values.add((T)obj);
if ( ! requireStartHere || rec.getLocation().getStart() == curLocation.getStart() ) { // ok, we are going to keep this thing
contexts.add(vc);
if ( takeFirstOnly )
// we only want the first passing instance, so break the loop over records in rodList
break;
}
if ( takeFirstOnly )
// we only want the first passing instance, so break the loop over records in rodList
break;
}
}
return values;
}
/**
* Finds the reference metadata track named 'name' and returns all ROD records from that track associated
* with the current site as a RODRecordList collection object. If no data track with specified name is available,
* with the current site as a RODRecordList List object. If no data track with specified name is available,
* returns defaultValue wrapped as RODRecordList object. NOTE: if defaultValue is null, it will be wrapped up
* with track name set to 'name' and location set to null; otherwise the wrapper object will have name and
* location set to defaultValue.getName() and defaultValue.getLocation(), respectively (use caution,

View File

@ -65,13 +65,13 @@ public class TraverseLoci<M,T> extends TraversalEngine<M,T,LocusWalker<M,T>,Locu
referenceView.expandBoundsToAccomodateLoc(location);
}
// Iterate forward to get all reference ordered data covering this location
final RefMetaDataTracker tracker = referenceOrderedDataView.getReferenceOrderedDataAtLocus(locus.getLocation());
// create reference context. Note that if we have a pileup of "extended events", the context will
// hold the (longest) stretch of deleted reference bases (if deletions are present in the pileup).
ReferenceContext refContext = referenceView.getReferenceContext(location);
// Iterate forward to get all reference ordered data covering this location
final RefMetaDataTracker tracker = referenceOrderedDataView.getReferenceOrderedDataAtLocus(locus.getLocation(), refContext);
final boolean keepMeP = walker.filter(tracker, refContext, locus);
if (keepMeP) {
M x = walker.map(tracker, refContext, locus);

View File

@ -202,7 +202,7 @@ public class VariantAnnotator extends RodWalker<Integer, Integer> {
if ( tracker == null )
return 0;
Collection<VariantContext> VCs = tracker.getVariantContexts(ref, "variant", context.getLocation(), true, false);
Collection<VariantContext> VCs = tracker.getVariantContexts("variant", context.getLocation(), true, false);
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(ref, dbSet.getKey(), ref.getLocus(), false, false) ) {
for ( VariantContext comp : tracker.getVariantContexts(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, ref.getLocus(), false, true);
Collection<VariantContext> VCs = tracker.getVariantContexts(expression.bindingName, ref.getLocus(), false, true);
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(ref, "variant", context.getLocation(), true, false)) {
for (VariantContext vc : tracker.getVariantContexts("variant", context.getLocation(), true, false)) {
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(ref,INPUT_ROD_NAME, loc, true);
VariantContext vc_input = tracker.getVariantContext(INPUT_ROD_NAME, loc, true);
VariantContext vc_comp = tracker.getVariantContext(ref,COMP_ROD_NAME, loc, true);
VariantContext vc_comp = tracker.getVariantContext(COMP_ROD_NAME, loc, true);
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(ref, ROD_NAME, loc, true);
VariantContext validation_eval = tracker.getVariantContext(ref,VALIDATION_ROD_NAME, loc, true);
VariantContext variant_eval = tracker.getVariantContext(ROD_NAME, loc, true);
VariantContext validation_eval = tracker.getVariantContext(VALIDATION_ROD_NAME, loc, true);
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(ref, ROD_NAME, loc, true);
VariantContext vc = tracker.getVariantContext(ROD_NAME, loc, true);
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(ref);
Collection<VariantContext> vcs = tracker.getAllVariantContexts();
// 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(ref, INPUT_VARIANT_ROD_BINDING_NAME, context.getLocation(), true, false);
Collection<VariantContext> VCs = tracker.getVariantContexts(INPUT_VARIANT_ROD_BINDING_NAME, context.getLocation(), true, false);
// 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(ref, "alleles", ref.getLocus(), false, false) ) {
for( final VariantContext vc_input : tracker.getVariantContexts("alleles", ref.getLocus(), false, false) ) {
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(ref, "alleles", ref.getLocus(), true, false) ) {
for( final VariantContext vc_input : tracker.getVariantContexts("alleles", ref.getLocus(), true, false) ) {
if ( vc_input != null && ! vc_input.isFiltered() && (! requireSNP || vc_input.isSNP() )) {
if ( vc == null ) {
vc = vc_input;

View File

@ -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, context.getLocation(), true, true);
Collection<VariantContext> vc = tracker.getVariantContexts(name, context.getLocation(), true, true);
VCs.addAll(vc);
}

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(ref) ) {
for ( VariantContext vc : tracker.getAllVariantContexts() ) {
switch ( vc.getType() ) {
case INDEL:
hasIndel = true;

View File

@ -64,7 +64,7 @@ public class AnnotateMNPsWalker extends RodWalker<Integer, Integer> {
@Argument(fullName = "emitOnlyMNPs", shortName = "emitOnlyMNPs", doc = "Only output MNP records; [default:false]", required = false)
protected boolean emitOnlyMNPs = false;
private LinkedList<String> rodNames = null;
private String rodName = "variant";
private GenomeLocParser locParser = null;
private TreeMap<GenomeLoc, Set<GenomeLoc>> MNPstartToStops = null; // Must be TreeMap sorted by START sites!
@ -105,9 +105,6 @@ public class AnnotateMNPsWalker extends RodWalker<Integer, Integer> {
protected final static String REFSEQ_HAS_MULT_AA_CHANGES = "alleleHasMultAAchanges";
public void initialize() {
rodNames = new LinkedList<String>();
rodNames.add(VARIANT_ROD_NAME);
locParser = getToolkit().getGenomeLocParser();
MNPstartToStops = new TreeMap<GenomeLoc, Set<GenomeLoc>>(); // sorted by start sites
@ -125,8 +122,8 @@ public class AnnotateMNPsWalker extends RodWalker<Integer, Integer> {
hInfo.addAll(VCFUtils.getHeaderFields(getToolkit()));
hInfo.add(new VCFHeaderLine("reference", getToolkit().getArguments().referenceFile.getName()));
Map<String, VCFHeader> rodNameToHeader = getVCFHeadersFromRods(getToolkit(), rodNames);
writer.writeHeader(new VCFHeader(hInfo, new TreeSet<String>(rodNameToHeader.get(rodNames.get(0)).getGenotypeSamples())));
Map<String, VCFHeader> rodNameToHeader = getVCFHeadersFromRods(getToolkit(), Arrays.asList(rodName));
writer.writeHeader(new VCFHeader(hInfo, new TreeSet<String>(rodNameToHeader.get(rodName).getGenotypeSamples())));
}
public boolean generateExtendedEvents() {
@ -155,7 +152,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, context.getLocation(), requireStartHere, takeFirstOnly)) {
for (VariantContext vc : tracker.getVariantContexts(rodName, context.getLocation(), requireStartHere, takeFirstOnly)) {
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(ref, "pbt", ref.getLocus(), true, true);
Collection<VariantContext> rbps = tracker.getVariantContexts(ref, "rbp", ref.getLocus(), true, true);
Collection<VariantContext> pbts = tracker.getVariantContexts("pbt", ref.getLocus(), true, true);
Collection<VariantContext> rbps = tracker.getVariantContexts("rbp", ref.getLocus(), true, true);
VariantContext pbt = pbts.iterator().hasNext() ? pbts.iterator().next() : null;
VariantContext rbp = rbps.iterator().hasNext() ? rbps.iterator().next() : null;

View File

@ -58,12 +58,9 @@ public class MergeMNPsWalker extends RodWalker<Integer, Integer> {
@Argument(fullName = "maxGenomicDistanceForMNP", shortName = "maxDistMNP", doc = "The maximum reference-genome distance between consecutive heterozygous sites to permit merging phased VCF records into a MNP record; [default:1]", required = false)
protected int maxGenomicDistanceForMNP = 1;
private LinkedList<String> rodNames = null;
private String rodName = "variant";
public void initialize() {
rodNames = new LinkedList<String>();
rodNames.add("variant");
initializeVcfWriter();
}
@ -77,8 +74,8 @@ public class MergeMNPsWalker extends RodWalker<Integer, Integer> {
hInfo.addAll(VCFUtils.getHeaderFields(getToolkit()));
hInfo.add(new VCFHeaderLine("reference", getToolkit().getArguments().referenceFile.getName()));
Map<String, VCFHeader> rodNameToHeader = getVCFHeadersFromRods(getToolkit(), rodNames);
vcMergerWriter.writeHeader(new VCFHeader(hInfo, new TreeSet<String>(rodNameToHeader.get(rodNames.get(0)).getGenotypeSamples())));
Map<String, VCFHeader> rodNameToHeader = getVCFHeadersFromRods(getToolkit(), Arrays.asList(rodName));
vcMergerWriter.writeHeader(new VCFHeader(hInfo, new TreeSet<String>(rodNameToHeader.get(rodName).getGenotypeSamples())));
}
public boolean generateExtendedEvents() {
@ -103,7 +100,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, context.getLocation(), requireStartHere, takeFirstOnly))
for (VariantContext vc : tracker.getVariantContexts(rodName, context.getLocation(), requireStartHere, takeFirstOnly))
writeVCF(vc);
return 0;

View File

@ -81,12 +81,9 @@ public class MergeSegregatingAlternateAllelesWalker extends RodWalker<Integer, I
@Argument(fullName = "dontRequireSomeSampleHasDoubleAltAllele", shortName = "dontRequireSomeSampleHasDoubleAltAllele", doc = "Should the requirement, that SUCCESSIVE records to be merged have at least one sample with a double alternate allele, be relaxed?; [default:false]", required = false)
protected boolean dontRequireSomeSampleHasDoubleAltAllele = false;
private LinkedList<String> rodNames = null;
private String rodName = "variant";
public void initialize() {
rodNames = new LinkedList<String>();
rodNames.add("variant");
initializeVcfWriter();
}
@ -114,8 +111,8 @@ public class MergeSegregatingAlternateAllelesWalker extends RodWalker<Integer, I
hInfo.addAll(VCFUtils.getHeaderFields(getToolkit()));
hInfo.add(new VCFHeaderLine("reference", getToolkit().getArguments().referenceFile.getName()));
Map<String, VCFHeader> rodNameToHeader = getVCFHeadersFromRods(getToolkit(), rodNames);
vcMergerWriter.writeHeader(new VCFHeader(hInfo, new TreeSet<String>(rodNameToHeader.get(rodNames.get(0)).getGenotypeSamples())));
Map<String, VCFHeader> rodNameToHeader = getVCFHeadersFromRods(getToolkit(), Arrays.asList(rodName));
vcMergerWriter.writeHeader(new VCFHeader(hInfo, new TreeSet<String>(rodNameToHeader.get(rodName).getGenotypeSamples())));
}
public boolean generateExtendedEvents() {
@ -140,7 +137,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, context.getLocation(), requireStartHere, takeFirstOnly))
for (VariantContext vc : tracker.getVariantContexts(rodName, context.getLocation(), requireStartHere, takeFirstOnly))
writeVCF(vc);
return 0;

View File

@ -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, context.getLocation(), true, true);
Collection<VariantContext> vcs = tracker.getVariantContexts(ROD_NAME, context.getLocation(), true, true);
for (VariantContext vc : vcs) {
Map<String, Genotype> genotypeMap = vc.getGenotypes();

View File

@ -98,7 +98,7 @@ public class ReadBackedPhasingWalker extends RodWalker<PhasingStatsAndOutput, Ph
private static PreciseNonNegativeDouble ZERO = new PreciseNonNegativeDouble(0.0);
private LinkedList<String> rodNames = null;
private String rodName = "variant";
public static final String PQ_KEY = "PQ";
@ -123,9 +123,6 @@ public class ReadBackedPhasingWalker extends RodWalker<PhasingStatsAndOutput, Ph
if (maxPhaseSites <= 2)
maxPhaseSites = 2; // by definition, must phase a site relative to previous site [thus, 2 in total]
rodNames = new LinkedList<String>();
rodNames.add("variant");
/*
Since we cap each base quality (BQ) by its read's mapping quality (MQ) [in Read.updateBaseAndQuality()], then:
if minBQ > minMQ, then we require that MQ be >= minBQ as well.
@ -175,8 +172,8 @@ public class ReadBackedPhasingWalker extends RodWalker<PhasingStatsAndOutput, Ph
hInfo.add(new VCFInfoHeaderLine(PHASING_INCONSISTENT_KEY, 0, VCFHeaderLineType.Flag, "Are the reads significantly haplotype-inconsistent?"));
// todo -- fix samplesToPhase
Map<String, VCFHeader> rodNameToHeader = getVCFHeadersFromRods(getToolkit(), rodNames);
Set<String> samples = new TreeSet<String>(samplesToPhase == null ? rodNameToHeader.get(rodNames.get(0)).getGenotypeSamples() : samplesToPhase);
Map<String, VCFHeader> rodNameToHeader = getVCFHeadersFromRods(getToolkit(), Arrays.asList(rodName));
Set<String> samples = new TreeSet<String>(samplesToPhase == null ? rodNameToHeader.get(rodName).getGenotypeSamples() : samplesToPhase);
writer.writeHeader(new VCFHeader(hInfo, samples));
}
@ -209,7 +206,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, context.getLocation(), requireStartHere, takeFirstOnly)) {
for (VariantContext vc : tracker.getVariantContexts(rodName, context.getLocation(), requireStartHere, takeFirstOnly)) {
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(ref);
Collection<VariantContext> col = tracker.getAllVariantContexts();
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(ref,"MaskAlleles",ref.getLocus());
VariantContext validate = tracker.getVariantContext(ref,"ValidateAlleles",ref.getLocus());
VariantContext mask = tracker.getVariantContext("MaskAlleles",ref.getLocus());
VariantContext validate = tracker.getVariantContext("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(ref, knownName, ref.getLocus(), true, false);
final Collection<VariantContext> knownComps = tracker.getVariantContexts(knownName, ref.getLocus(), true, false);
for ( final VariantContext c : knownComps ) {
// loop over sites, looking for something that matches the type eval
if ( eval.getType() == c.getType() ) {

View File

@ -336,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, ref.getLocus(), true, true);
Collection<VariantContext> contexts = tracker == null ? null : tracker.getVariantContexts(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

View File

@ -168,7 +168,7 @@ public class ApplyRecalibration extends RodWalker<Integer, Integer> {
return 1;
}
for( VariantContext vc : tracker.getVariantContexts(ref, inputNames, context.getLocation(), true, false) ) {
for( VariantContext vc : tracker.getVariantContexts(inputNames, context.getLocation(), true, false) ) {
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( ref, trainingSet.name, context.getLocation(), false, false ) ) {
for( final VariantContext trainVC : tracker.getVariantContexts(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()) ) {

View File

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

View File

@ -25,7 +25,6 @@
package org.broadinstitute.sting.gatk.walkers.variantutils;
import org.apache.poi.hpsf.Variant;
import org.broadinstitute.sting.commandline.Argument;
import org.broadinstitute.sting.commandline.Hidden;
import org.broadinstitute.sting.commandline.Output;
@ -150,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(ref, context.getLocation(), true, false);
Collection<VariantContext> vcs = tracker.getAllVariantContexts(context.getLocation(), true, false);
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(ref, "variant", context.getLocation(), true, false);
Collection<VariantContext> VCs = tracker.getVariantContexts("variant", context.getLocation(), true, false);
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(ref, "variant", context.getLocation(), true, false);
Collection<VariantContext> VCs = tracker.getVariantContexts("variant", context.getLocation(), true, false);
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(ref, "variant", context.getLocation(), true, false);
Collection<VariantContext> VCs = tracker.getVariantContexts("variant", context.getLocation(), true, false);
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(ref, INPUT_VARIANT_ROD_BINDING_NAME, context.getLocation(), true, false);
Collection<VariantContext> vcs = tracker.getVariantContexts(INPUT_VARIANT_ROD_BINDING_NAME, context.getLocation(), true, false);
for ( VariantContext vc : vcs ) {
int random = GenomeAnalysisEngine.getRandomGenerator().nextInt(1000);
if ( random < iFraction )

View File

@ -25,38 +25,29 @@
package org.broadinstitute.sting.gatk.walkers.variantutils;
import org.broadinstitute.sting.commandline.Hidden;
import org.broadinstitute.sting.commandline.Input;
import org.broadinstitute.sting.utils.MathUtils;
import org.broadinstitute.sting.utils.codecs.vcf.*;
import org.broadinstitute.sting.utils.exceptions.UserException;
import org.broadinstitute.sting.utils.text.XReadLines;
import org.broadinstitute.sting.utils.variantcontext.*;
import org.broadinstitute.sting.gatk.GenomeAnalysisEngine;
import org.broadinstitute.sting.utils.MendelianViolation;
import org.broadinstitute.sting.utils.variantcontext.VariantContext;
import org.broadinstitute.sting.commandline.Argument;
import org.broadinstitute.sting.commandline.Hidden;
import org.broadinstitute.sting.commandline.Output;
import org.broadinstitute.sting.gatk.GenomeAnalysisEngine;
import org.broadinstitute.sting.gatk.contexts.AlignmentContext;
import org.broadinstitute.sting.gatk.contexts.ReferenceContext;
import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker;
import org.broadinstitute.sting.gatk.walkers.RMD;
import org.broadinstitute.sting.gatk.walkers.Requires;
import org.broadinstitute.sting.gatk.walkers.RodWalker;
import org.broadinstitute.sting.utils.MathUtils;
import org.broadinstitute.sting.utils.MendelianViolation;
import org.broadinstitute.sting.utils.SampleUtils;
import org.broadinstitute.sting.utils.codecs.vcf.*;
import org.broadinstitute.sting.utils.variantcontext.Allele;
import org.broadinstitute.sting.utils.variantcontext.Genotype;
import org.broadinstitute.sting.utils.variantcontext.VariantContext;
import org.broadinstitute.sting.utils.variantcontext.VariantContextUtils;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.PrintStream;
import java.lang.annotation.AnnotationFormatError;
import java.util.*;
/**
@ -317,7 +308,7 @@ public class SelectVariants extends RodWalker<Integer, Integer> {
if ( tracker == null )
return 0;
Collection<VariantContext> vcs = tracker.getVariantContexts(ref, variantRodName, context.getLocation(), true, false);
Collection<VariantContext> vcs = tracker.getVariantContexts(variantRodName, context.getLocation(), true, false);
if ( vcs == null || vcs.size() == 0) {
return 0;
@ -345,12 +336,12 @@ public class SelectVariants extends RodWalker<Integer, Integer> {
break;
}
if (DISCORDANCE_ONLY) {
Collection<VariantContext> compVCs = tracker.getVariantContexts(ref, discordanceRodName, context.getLocation(), true, false);
Collection<VariantContext> compVCs = tracker.getVariantContexts(discordanceRodName, context.getLocation(), true, false);
if (!isDiscordant(vc, compVCs))
return 0;
}
if (CONCORDANCE_ONLY) {
Collection<VariantContext> compVCs = tracker.getVariantContexts(ref, concordanceRodName, context.getLocation(), true, false);
Collection<VariantContext> compVCs = tracker.getVariantContexts(concordanceRodName, context.getLocation(), true, false);
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(ref, "variant", context.getLocation(), true, false);
Collection<VariantContext> VCs = tracker.getVariantContexts("variant", context.getLocation(), true, false);
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(ref, INPUT_VARIANT_ROD_BINDING_NAME, ref.getLocus());
VariantContext vc = tracker.getVariantContext(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(ref, context.getLocation());
Collection<VariantContext> vcs = tracker.getAllVariantContexts(context.getLocation());
for ( VariantContext vc : vcs) {
if ( (keepMultiAllelic || vc.isBiallelic()) && ( showFiltered || vc.isNotFiltered() ) ) {
List<String> vals = extractFields(vc, fieldsToTake, ALLOW_MISSING_DATA);

View File

@ -138,7 +138,7 @@ public class VariantsToTableNewRodStyle extends RodWalker<Integer, Integer> {
System.out.printf("VariantList binding %s tags=%s%n", binding, getToolkit().getTags(binding).getPositionalTags());
if ( ++nRecords < MAX_RECORDS || MAX_RECORDS == -1 ) {
VariantContext vc = variants.getVariantContext(tracker, ref, context.getLocation());
VariantContext vc = variants.getVariantContext(tracker, context.getLocation());
if ( (keepMultiAllelic || vc.isBiallelic()) && ( showFiltered || vc.isNotFiltered() ) ) {
List<String> vals = extractFields(vc, fieldsToTake, ALLOW_MISSING_DATA);
out.println(Utils.join("\t", vals));

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(ref, INPUT_ROD_NAME, ref.getLocus(), true, false);
return tracker.getVariantContexts(INPUT_ROD_NAME, ref.getLocus(), true, false);
}
private DbSNPFeature getDbsnpFeature(String rsID) {

View File

@ -69,7 +69,7 @@ public class ReferenceOrderedViewUnitTest extends BaseTest {
LocusShardDataProvider provider = new LocusShardDataProvider(shard, null, genomeLocParser, shard.getGenomeLocs().get(0), null, seq, Collections.<ReferenceOrderedDataSource>emptyList());
ReferenceOrderedView view = new ManagingReferenceOrderedView( provider );
RefMetaDataTracker tracker = view.getReferenceOrderedDataAtLocus(genomeLocParser.createGenomeLoc("chrM",10));
RefMetaDataTracker tracker = view.getReferenceOrderedDataAtLocus(genomeLocParser.createGenomeLoc("chrM",10), null);
Assert.assertEquals(tracker.getAllValuesAsGATKFeatures().size(), 0, "The tracker should not have produced any data");
}
@ -87,7 +87,7 @@ public class ReferenceOrderedViewUnitTest extends BaseTest {
LocusShardDataProvider provider = new LocusShardDataProvider(shard, null, genomeLocParser, shard.getGenomeLocs().get(0), null, seq, Collections.singletonList(dataSource));
ReferenceOrderedView view = new ManagingReferenceOrderedView( provider );
RefMetaDataTracker tracker = view.getReferenceOrderedDataAtLocus(genomeLocParser.createGenomeLoc("chrM",20));
RefMetaDataTracker tracker = view.getReferenceOrderedDataAtLocus(genomeLocParser.createGenomeLoc("chrM",20), null);
TableFeature datum = tracker.getFirstValue("tableTest", TableFeature.class);
Assert.assertEquals(datum.get("COL1"),"C","datum parameter for COL1 is incorrect");
@ -113,7 +113,7 @@ public class ReferenceOrderedViewUnitTest extends BaseTest {
LocusShardDataProvider provider = new LocusShardDataProvider(shard, null, genomeLocParser, shard.getGenomeLocs().get(0), null, seq, Arrays.asList(dataSource1,dataSource2));
ReferenceOrderedView view = new ManagingReferenceOrderedView( provider );
RefMetaDataTracker tracker = view.getReferenceOrderedDataAtLocus(genomeLocParser.createGenomeLoc("chrM",20));
RefMetaDataTracker tracker = view.getReferenceOrderedDataAtLocus(genomeLocParser.createGenomeLoc("chrM",20), null);
TableFeature datum1 = tracker.getFirstValue("tableTest1", TableFeature.class);
Assert.assertEquals(datum1.get("COL1"),"C","datum1 parameter for COL1 is incorrect");