Contracts and documentation for some of RefMetaDataTracker
Continuing to fix integration tests that don't pass / run
This commit is contained in:
parent
85c67e9891
commit
b25140db83
10
build.xml
10
build.xml
|
|
@ -973,11 +973,11 @@
|
|||
<sourcepath path="${java.public.source.dir}"/>
|
||||
<sourcepath path="${external.dir}"/>
|
||||
</javadoc>
|
||||
<javadoc destdir="javadoc"
|
||||
classpathref="external.dependencies">
|
||||
<sourcepath path="${java.private.source.dir}"/>
|
||||
<exclude name="**" unless="include.private" />
|
||||
</javadoc>
|
||||
<!-- <javadoc destdir="javadoc" -->
|
||||
<!-- classpathref="external.dependencies"> -->
|
||||
<!-- <sourcepath path="${java.private.source.dir}"/> -->
|
||||
<!-- <exclude name="**" unless="include.private" /> -->
|
||||
<!-- </javadoc> -->
|
||||
<mkdir dir="scaladoc"/>
|
||||
<scaladoc srcdir="" destdir="scaladoc" classpathref="scala.dependencies" deprecation="yes" unchecked="yes">
|
||||
<src path="${scala.public.source.dir}"/>
|
||||
|
|
|
|||
|
|
@ -90,7 +90,7 @@ public final class RodBinding<T extends Feature> {
|
|||
final private static Map<String, Integer> nameCounter = new HashMap<String, Integer>();
|
||||
|
||||
/** for UnitTests */
|
||||
final protected static void resetNameCounter() {
|
||||
final public static void resetNameCounter() {
|
||||
nameCounter.clear();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
package org.broadinstitute.sting.gatk.refdata;
|
||||
|
||||
import com.google.java.contract.Ensures;
|
||||
import com.google.java.contract.Requires;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.broad.tribble.Feature;
|
||||
import org.broadinstitute.sting.commandline.RodBinding;
|
||||
|
|
@ -18,10 +20,12 @@ 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
|
||||
* 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.
|
||||
* Traversal passes creates a tracker and passes it to the walker
|
||||
* walker calls get(rodBinding) to obtain the RMDs values at this site for the track
|
||||
* associated with rodBinding.
|
||||
*
|
||||
* Note that this is an immutable class. Once created the underlying data structures
|
||||
* cannot be modified
|
||||
*
|
||||
* User: mdepristo
|
||||
* Date: Apr 3, 2009
|
||||
|
|
@ -45,14 +49,19 @@ public class RefMetaDataTracker {
|
|||
|
||||
public RefMetaDataTracker(final Collection<RODRecordList> allBindings, final ReferenceContext ref) {
|
||||
this.ref = ref;
|
||||
|
||||
// set up the map
|
||||
if ( allBindings.isEmpty() )
|
||||
map = Collections.emptyMap();
|
||||
else {
|
||||
map = new HashMap<String, RODRecordList>(allBindings.size());
|
||||
Map<String, RODRecordList> tmap = new HashMap<String, RODRecordList>(allBindings.size());
|
||||
for ( RODRecordList rod : allBindings ) {
|
||||
if ( rod != null )
|
||||
map.put(canonicalName(rod.getName()), rod);
|
||||
tmap.put(canonicalName(rod.getName()), rod);
|
||||
}
|
||||
|
||||
// ensure that no one modifies the map itself
|
||||
map = Collections.unmodifiableMap(tmap);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -64,76 +73,120 @@ public class RefMetaDataTracker {
|
|||
//
|
||||
// ------------------------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Gets all of the Tribble features spanning this locus, returning them as a list of specific
|
||||
* type T extending Feature. This function looks across all tracks to find the Features, so
|
||||
* if you have two tracks A and B each containing 1 Feature, then getValues will return
|
||||
* a list containing both features.
|
||||
*
|
||||
* Note that this function assumes that all of the bound features are instances of or
|
||||
* subclasses of T. A ClassCastException will occur if this isn't the case. If you want
|
||||
* to get all Features without any danger of such an exception use the root Tribble
|
||||
* interface Feature.
|
||||
*
|
||||
* @param type The type of the underlying objects bound here
|
||||
* @param <T> as above
|
||||
* @return A freshly allocated list of all of the bindings, or an empty list if none are bound.
|
||||
*/
|
||||
@Requires({"type != null"})
|
||||
@Ensures("result != null")
|
||||
public <T extends Feature> List<T> getValues(final Class<T> type) {
|
||||
return addValues(map.keySet(), type, new ArrayList<T>(), null, false, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides the same functionality as @link #getValues(Class<T>) but will only include
|
||||
* Features that start as the GenomeLoc provide onlyAtThisLoc.
|
||||
*
|
||||
* @param type The type of the underlying objects bound here
|
||||
* @param onlyAtThisLoc
|
||||
* @param <T> as above
|
||||
* @return A freshly allocated list of all of the bindings, or an empty list if none are bound.
|
||||
*/
|
||||
@Requires({"type != null", "onlyAtThisLoc != null"})
|
||||
@Ensures("result != null")
|
||||
public <T extends Feature> List<T> getValues(final Class<T> type, final GenomeLoc onlyAtThisLoc) {
|
||||
return addValues(map.keySet(), type, new ArrayList<T>(), onlyAtThisLoc, true, false);
|
||||
}
|
||||
public <T extends Feature> List<T> getValues(final Class<T> type, final String name) {
|
||||
return addValues(name, type, new ArrayList<T>(), getTrackDataByName(name), null, false, false);
|
||||
}
|
||||
public <T extends Feature> List<T> getValues(final Class<T> type, final String name, final GenomeLoc onlyAtThisLoc) {
|
||||
return addValues(name, type, new ArrayList<T>(), getTrackDataByName(name), onlyAtThisLoc, true, false);
|
||||
}
|
||||
public <T extends Feature> List<T> getValues(final Class<T> type, final Collection<String> names) {
|
||||
return addValues(names, type, new ArrayList<T>(), null, false, false);
|
||||
}
|
||||
public <T extends Feature> List<T> getValues(final Class<T> type, final Collection<String> names, final GenomeLoc onlyAtThisLoc) {
|
||||
return addValues(names, type, new ArrayList<T>(), onlyAtThisLoc, true, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Uses the same logic as @link #getValues(Class) but arbitrary select one of the resulting
|
||||
* elements of the list to return. That is, if there would be two elements in the result of
|
||||
* @link #getValues(Class), one of these two is selected, and which one it will be isn't
|
||||
* specified. Consequently, this method is only really safe if (1) you absolutely know
|
||||
* that only one binding will meet the constraints of @link #getValues(Class) or (2)
|
||||
* you truly don't care which of the multiple bindings available you are going to examine.
|
||||
*
|
||||
* If there are no bindings here, getFirstValue() return null
|
||||
*
|
||||
* @param type The type of the underlying objects bound here
|
||||
* @param <T> as above
|
||||
* @return A random single element the RODs bound here, or null if none are bound.
|
||||
*/
|
||||
@Requires({"type != null"})
|
||||
public <T extends Feature> T getFirstValue(final Class<T> type) {
|
||||
return safeGetFirst(getValues(type));
|
||||
}
|
||||
|
||||
/**
|
||||
* Uses the same logic as @link #getValue(Class,GenomeLoc) to determine the list
|
||||
* of eligible Features and @link #getFirstValue(Class) to select a single
|
||||
* element from the interval list.
|
||||
*
|
||||
* @param type The type of the underlying objects bound here
|
||||
* @param <T> as above
|
||||
* @param onlyAtThisLoc only Features starting at this site are considered
|
||||
* @return A random single element the RODs bound here starting at onlyAtThisLoc, or null if none are bound.
|
||||
*/
|
||||
@Requires({"type != null", "onlyAtThisLoc != null"})
|
||||
public <T extends Feature> T getFirstValue(final Class<T> type, final GenomeLoc onlyAtThisLoc) {
|
||||
return safeGetFirst(getValues(type, onlyAtThisLoc));
|
||||
}
|
||||
public <T extends Feature> T getFirstValue(final Class<T> type, final String name) {
|
||||
return safeGetFirst(getValues(type, name));
|
||||
}
|
||||
public <T extends Feature> T getFirstValue(final Class<T> type, final String name, final GenomeLoc onlyAtThisLoc) {
|
||||
return safeGetFirst(getValues(type, name, onlyAtThisLoc));
|
||||
}
|
||||
public <T extends Feature> T getFirstValue(final Class<T> type, final Collection<String> names) {
|
||||
return safeGetFirst(getValues(type, names));
|
||||
}
|
||||
public <T extends Feature> T getFirstValue(final Class<T> type, final Collection<String> names, final GenomeLoc onlyAtThisLoc) {
|
||||
return safeGetFirst(getValues(type, names, onlyAtThisLoc));
|
||||
}
|
||||
|
||||
//
|
||||
// ROD binding accessors
|
||||
//
|
||||
@Requires({"rodBinding != null"})
|
||||
@Ensures("result != null")
|
||||
public <T extends Feature> List<T> getValues(final RodBinding<T> rodBinding) {
|
||||
return getValues(rodBinding.getType(), rodBinding.getName());
|
||||
return addValues(rodBinding.getName(), rodBinding.getType(), new ArrayList<T>(1), getTrackDataByName(rodBinding), null, false, false);
|
||||
}
|
||||
|
||||
@Requires({"rodBindings != null"})
|
||||
@Ensures("result != null")
|
||||
public <T extends Feature> List<T> getValues(final Collection<RodBinding<T>> rodBindings) {
|
||||
List<T> results = new ArrayList<T>();
|
||||
List<T> results = new ArrayList<T>(1);
|
||||
for ( RodBinding<T> rodBinding : rodBindings )
|
||||
results.addAll(getValues(rodBinding));
|
||||
return results;
|
||||
}
|
||||
|
||||
@Requires({"rodBinding != null", "onlyAtThisLoc != null"})
|
||||
@Ensures("result != null")
|
||||
public <T extends Feature> List<T> getValues(final RodBinding<T> rodBinding, final GenomeLoc onlyAtThisLoc) {
|
||||
return getValues(rodBinding.getType(), rodBinding.getName(), onlyAtThisLoc);
|
||||
return addValues(rodBinding.getName(), rodBinding.getType(), new ArrayList<T>(1), getTrackDataByName(rodBinding), onlyAtThisLoc, true, false);
|
||||
}
|
||||
|
||||
@Requires({"rodBindings != null", "onlyAtThisLoc != null"})
|
||||
@Ensures("result != null")
|
||||
public <T extends Feature> List<T> getValues(final Collection<RodBinding<T>> rodBindings, final GenomeLoc onlyAtThisLoc) {
|
||||
List<T> results = new ArrayList<T>();
|
||||
List<T> results = new ArrayList<T>(1);
|
||||
for ( RodBinding<T> rodBinding : rodBindings )
|
||||
results.addAll(getValues(rodBinding, onlyAtThisLoc));
|
||||
return results;
|
||||
}
|
||||
|
||||
@Requires({"rodBinding != null"})
|
||||
public <T extends Feature> T getFirstValue(final RodBinding<T> rodBinding) {
|
||||
return getFirstValue(rodBinding.getType(), rodBinding.getName());
|
||||
}
|
||||
public <T extends Feature> T getFirstValue(final RodBinding<T> rodBinding, final GenomeLoc onlyAtThisLoc) {
|
||||
return getFirstValue(rodBinding.getType(), rodBinding.getName(), onlyAtThisLoc);
|
||||
return safeGetFirst(addValues(rodBinding.getName(), rodBinding.getType(), null, getTrackDataByName(rodBinding), null, false, true));
|
||||
}
|
||||
|
||||
@Requires({"rodBinding != null", "onlyAtThisLoc != null"})
|
||||
public <T extends Feature> T getFirstValue(final RodBinding<T> rodBinding, final GenomeLoc onlyAtThisLoc) {
|
||||
return safeGetFirst(addValues(rodBinding.getName(), rodBinding.getType(), null, getTrackDataByName(rodBinding), onlyAtThisLoc, true, true));
|
||||
}
|
||||
|
||||
@Requires({"rodBindings != null"})
|
||||
public <T extends Feature> T getFirstValue(final Collection<RodBinding<T>> rodBindings) {
|
||||
for ( RodBinding<T> rodBinding : rodBindings ) {
|
||||
T val = getFirstValue(rodBinding);
|
||||
|
|
@ -143,6 +196,7 @@ public class RefMetaDataTracker {
|
|||
return null;
|
||||
}
|
||||
|
||||
@Requires({"rodBindings != null", "onlyAtThisLoc != null"})
|
||||
public <T extends Feature> T getFirstValue(final Collection<RodBinding<T>> rodBindings, final GenomeLoc onlyAtThisLoc) {
|
||||
for ( RodBinding<T> rodBinding : rodBindings ) {
|
||||
T val = getFirstValue(rodBinding, onlyAtThisLoc);
|
||||
|
|
@ -152,42 +206,58 @@ public class RefMetaDataTracker {
|
|||
return null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Is there a binding at this site to a ROD/track with the specified name?
|
||||
*
|
||||
* @param rodBinding the rod binding we want to know about
|
||||
* @return true if any Features are bound in this tracker to rodBinding
|
||||
*/
|
||||
@Requires({"rodBinding != null"})
|
||||
public boolean hasValues(final RodBinding rodBinding) {
|
||||
return hasValues(rodBinding.getName());
|
||||
}
|
||||
|
||||
public List<GATKFeature> getValuesAsGATKFeatures(final RodBinding rodBinding) {
|
||||
return getValuesAsGATKFeatures(rodBinding.getName());
|
||||
return map.containsKey(canonicalName(rodBinding.getName()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function for getFirst() operations that takes a list of <T> and
|
||||
* returns the first element, or null if no such element exists.
|
||||
*
|
||||
* TODO: determine specific behavior for l.size() > 1. Do we turn first or an error?
|
||||
* TODO: right now we return the first. Should be clearer
|
||||
*
|
||||
* @param l
|
||||
* @param <T>
|
||||
* @return
|
||||
*/
|
||||
@Requires({"l != null"})
|
||||
final private <T extends Feature> T safeGetFirst(final List<T> l) {
|
||||
// todo: should we be warning people here? Throwing an error?
|
||||
return l.isEmpty() ? null : l.get(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Is there a binding at this site to a ROD/track with the specified name?
|
||||
*
|
||||
* @param name the name of the rod
|
||||
* @return true if it has the rod
|
||||
*/
|
||||
//
|
||||
// Deprecated accessors -- will be removed
|
||||
//
|
||||
@Deprecated
|
||||
public boolean hasValues(final String name) {
|
||||
return map.containsKey(canonicalName(name));
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public <T extends Feature> List<T> getValues(final Class<T> type, final String name) {
|
||||
return addValues(name, type, new ArrayList<T>(), getTrackDataByName(name), null, false, false);
|
||||
}
|
||||
@Deprecated
|
||||
public <T extends Feature> List<T> getValues(final Class<T> type, final String name, final GenomeLoc onlyAtThisLoc) {
|
||||
return addValues(name, type, new ArrayList<T>(), getTrackDataByName(name), onlyAtThisLoc, true, false);
|
||||
}
|
||||
@Deprecated
|
||||
public <T extends Feature> List<T> getValues(final Class<T> type, final Collection<String> names, final GenomeLoc onlyAtThisLoc) {
|
||||
return addValues(names, type, new ArrayList<T>(), onlyAtThisLoc, true, false);
|
||||
}
|
||||
@Deprecated
|
||||
public <T extends Feature> T getFirstValue(final Class<T> type, final String name) {
|
||||
return safeGetFirst(getValues(type, name));
|
||||
}
|
||||
@Deprecated
|
||||
public <T extends Feature> T getFirstValue(final Class<T> type, final String name, final GenomeLoc onlyAtThisLoc) {
|
||||
return safeGetFirst(getValues(type, name, onlyAtThisLoc));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all of the RMDs at the current site. The collection is "flattened": for any track that has multiple records
|
||||
|
|
@ -195,6 +265,7 @@ public class RefMetaDataTracker {
|
|||
*
|
||||
* @return collection of all rods
|
||||
*/
|
||||
@Deprecated
|
||||
public List<GATKFeature> getAllValuesAsGATKFeatures() {
|
||||
List<GATKFeature> l = new ArrayList<GATKFeature>();
|
||||
for ( RODRecordList rl : map.values() ) {
|
||||
|
|
@ -204,6 +275,12 @@ public class RefMetaDataTracker {
|
|||
return l;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public List<GATKFeature> getValuesAsGATKFeatures(final RodBinding rodBinding) {
|
||||
return getValuesAsGATKFeatures(rodBinding.getName());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* get all the GATK features associated with a specific track name
|
||||
* @param name the name of the track we're looking for
|
||||
|
|
@ -211,6 +288,7 @@ public class RefMetaDataTracker {
|
|||
*
|
||||
* Important: The list returned by this function is guaranteed not to be null, but may be empty!
|
||||
*/
|
||||
@Deprecated
|
||||
public List<GATKFeature> getValuesAsGATKFeatures(final String name) {
|
||||
return getTrackDataByName(name);
|
||||
}
|
||||
|
|
@ -264,33 +342,6 @@ 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. 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
|
||||
* 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 extends Feature> the type to parameterize on, matching the clazz argument
|
||||
* @return a record of type T, or null if no record is present.
|
||||
*/
|
||||
@Deprecated
|
||||
public <T extends Feature> T getFirstValue(final String name, final Class<T> clazz) {
|
||||
RODRecordList objects = getTrackDataByName(name);
|
||||
|
||||
if (objects.isEmpty()) return null;
|
||||
|
||||
Object obj = objects.get(0).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());
|
||||
else
|
||||
return (T)obj;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------
|
||||
//
|
||||
//
|
||||
|
|
@ -301,13 +352,15 @@ public class RefMetaDataTracker {
|
|||
|
||||
private <T extends Feature> List<T> addValues(final Collection<String> names,
|
||||
final Class<T> type,
|
||||
final List<T> values,
|
||||
List<T> values,
|
||||
final GenomeLoc curLocation,
|
||||
final boolean requireStartHere,
|
||||
final boolean takeFirstOnly ) {
|
||||
for ( String name : names ) {
|
||||
RODRecordList rodList = getTrackDataByName(name); // require that the name is an exact match
|
||||
addValues(name, type, values, rodList, curLocation, requireStartHere, takeFirstOnly );
|
||||
values = addValues(name, type, values, rodList, curLocation, requireStartHere, takeFirstOnly );
|
||||
if ( takeFirstOnly && ! values.isEmpty() )
|
||||
break;
|
||||
}
|
||||
|
||||
return values;
|
||||
|
|
@ -317,7 +370,7 @@ public class RefMetaDataTracker {
|
|||
|
||||
private <T extends Feature> List<T> addValues(final String name,
|
||||
final Class<T> type,
|
||||
final List<T> values,
|
||||
List<T> values,
|
||||
final RODRecordList rodList,
|
||||
final GenomeLoc curLocation,
|
||||
final boolean requireStartHere,
|
||||
|
|
@ -329,15 +382,23 @@ public class RefMetaDataTracker {
|
|||
throw new UserException.CommandLineException("Unable to cast track named " + name + " to type of " + type.toString()
|
||||
+ " it's of type " + obj.getClass());
|
||||
|
||||
values.add((T)obj);
|
||||
T objT = (T)obj;
|
||||
if ( takeFirstOnly ) {
|
||||
if ( values == null )
|
||||
values = Arrays.asList(objT);
|
||||
else
|
||||
values.add(objT);
|
||||
|
||||
if ( takeFirstOnly )
|
||||
// we only want the first passing instance, so break the loop over records in rodList
|
||||
break;
|
||||
} else {
|
||||
if ( values == null )
|
||||
values = new ArrayList<T>();
|
||||
values.add(objT);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return values;
|
||||
return values == null ? Collections.<T>emptyList() : values;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -358,6 +419,10 @@ public class RefMetaDataTracker {
|
|||
return l == null ? EMPTY_ROD_RECORD_LIST : l;
|
||||
}
|
||||
|
||||
private RODRecordList getTrackDataByName(final RodBinding binding) {
|
||||
return getTrackDataByName(binding.getName());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the canonical name of the rod name (lowercases it)
|
||||
* @param name the name of the rod
|
||||
|
|
|
|||
|
|
@ -26,7 +26,9 @@
|
|||
package org.broadinstitute.sting.gatk.walkers.qc;
|
||||
|
||||
import org.broadinstitute.sting.commandline.Argument;
|
||||
import org.broadinstitute.sting.commandline.Input;
|
||||
import org.broadinstitute.sting.commandline.Output;
|
||||
import org.broadinstitute.sting.commandline.RodBinding;
|
||||
import org.broadinstitute.sting.gatk.contexts.AlignmentContext;
|
||||
import org.broadinstitute.sting.gatk.contexts.ReferenceContext;
|
||||
import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker;
|
||||
|
|
@ -45,8 +47,11 @@ import java.util.Arrays;
|
|||
* each overlapping read, and quality score) to the reference pileup data generated by samtools. Samtools' pileup data
|
||||
* should be specified using the command-line argument '-B pileup,SAMPileup,<your sam pileup file>'.
|
||||
*/
|
||||
@Requires(value={DataSource.READS,DataSource.REFERENCE},referenceMetaData=@RMD(name="pileup",type=SAMPileupFeature.class))
|
||||
@Requires(value={DataSource.READS,DataSource.REFERENCE})
|
||||
public class ValidatingPileupWalker extends LocusWalker<Integer, ValidationStats> implements TreeReducible<ValidationStats> {
|
||||
@Input(fullName = "pileup", doc="The SAMPileup containing the expected output", required = true)
|
||||
RodBinding<SAMPileupFeature> pileup;
|
||||
|
||||
@Output
|
||||
private PrintStream out;
|
||||
|
||||
|
|
@ -130,17 +135,17 @@ public class ValidatingPileupWalker extends LocusWalker<Integer, ValidationStats
|
|||
* @return True pileup data.
|
||||
*/
|
||||
private SAMPileupFeature getTruePileup( RefMetaDataTracker tracker ) {
|
||||
SAMPileupFeature pileup = tracker.getFirstValue("pileup", SAMPileupFeature.class);
|
||||
SAMPileupFeature pileupArg = tracker.getFirstValue(pileup);
|
||||
|
||||
if( pileup == null)
|
||||
if( pileupArg == null)
|
||||
return null;
|
||||
|
||||
if( pileup.hasPointGenotype() )
|
||||
return pileup.getPointGenotype();
|
||||
else if( pileup.hasIndelGenotype() )
|
||||
return pileup.getIndelGenotype();
|
||||
if( pileupArg.hasPointGenotype() )
|
||||
return pileupArg.getPointGenotype();
|
||||
else if( pileupArg.hasIndelGenotype() )
|
||||
return pileupArg.getIndelGenotype();
|
||||
else
|
||||
throw new ReviewedStingException("Unsupported pileup type: " + pileup);
|
||||
throw new ReviewedStingException("Unsupported pileup type: " + pileupArg);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -8,7 +8,9 @@ import org.broadinstitute.sting.alignment.bwa.BWAConfiguration;
|
|||
import org.broadinstitute.sting.alignment.bwa.BWTFiles;
|
||||
import org.broadinstitute.sting.alignment.bwa.c.BWACAligner;
|
||||
import org.broadinstitute.sting.commandline.Argument;
|
||||
import org.broadinstitute.sting.commandline.Input;
|
||||
import org.broadinstitute.sting.commandline.Output;
|
||||
import org.broadinstitute.sting.commandline.RodBinding;
|
||||
import org.broadinstitute.sting.gatk.contexts.AlignmentContext;
|
||||
import org.broadinstitute.sting.gatk.contexts.ReferenceContext;
|
||||
import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker;
|
||||
|
|
@ -35,9 +37,17 @@ import java.util.List;
|
|||
* Time: 2:12 PM
|
||||
* To change this template use File | Settings | File Templates.
|
||||
*/
|
||||
@Requires(value={DataSource.REFERENCE}, referenceMetaData={@RMD(name="ProbeIntervals",type=TableFeature.class),
|
||||
@RMD(name="ValidateAlleles",type=VariantContext.class),@RMD(name="MaskAlleles",type=VariantContext.class)})
|
||||
@Requires(value={DataSource.REFERENCE})
|
||||
public class ValidationAmplicons extends RodWalker<Integer,Integer> {
|
||||
@Input(fullName = "ProbeIntervals", doc="Chris document me", required=true)
|
||||
RodBinding<TableFeature> probeIntervals;
|
||||
|
||||
@Input(fullName = "ValidateAlleles", doc="Chris document me", required=true)
|
||||
RodBinding<VariantContext> validateAlleles;
|
||||
|
||||
@Input(fullName = "MaskAlleles", doc="Chris document me", required=true)
|
||||
RodBinding<VariantContext> maskAlleles;
|
||||
|
||||
|
||||
@Argument(doc="Lower case SNPs rather than replacing with 'N'",fullName="lowerCaseSNPs",required=false)
|
||||
boolean lowerCaseSNPs = false;
|
||||
|
|
@ -99,9 +109,9 @@ public class ValidationAmplicons extends RodWalker<Integer,Integer> {
|
|||
}
|
||||
|
||||
public Integer map(RefMetaDataTracker tracker, ReferenceContext ref, AlignmentContext context) {
|
||||
if ( tracker == null || ! tracker.hasValues("ProbeIntervals")) { return null; }
|
||||
if ( tracker == null || ! tracker.hasValues(probeIntervals)) { return null; }
|
||||
|
||||
TableFeature feature = tracker.getFirstValue("ProbeIntervals", TableFeature.class);
|
||||
TableFeature feature = tracker.getFirstValue(probeIntervals);
|
||||
GenomeLoc interval = feature.getLocation();
|
||||
//logger.debug(interval);
|
||||
if ( prevInterval == null || ! interval.equals(prevInterval) ) {
|
||||
|
|
@ -138,8 +148,8 @@ public class ValidationAmplicons extends RodWalker<Integer,Integer> {
|
|||
// step 3 (or 1 if not new):
|
||||
// build up the sequence
|
||||
|
||||
VariantContext mask = tracker.getFirstValue(VariantContext.class, "MaskAlleles",ref.getLocus());
|
||||
VariantContext validate = tracker.getFirstValue(VariantContext.class, "ValidateAlleles",ref.getLocus());
|
||||
VariantContext mask = tracker.getFirstValue(maskAlleles, ref.getLocus());
|
||||
VariantContext validate = tracker.getFirstValue(validateAlleles,ref.getLocus());
|
||||
|
||||
if ( mask == null && validate == null ) {
|
||||
if ( indelCounter > 0 ) {
|
||||
|
|
|
|||
|
|
@ -88,7 +88,7 @@ public class ReferenceOrderedViewUnitTest extends BaseTest {
|
|||
ReferenceOrderedView view = new ManagingReferenceOrderedView( provider );
|
||||
|
||||
RefMetaDataTracker tracker = view.getReferenceOrderedDataAtLocus(genomeLocParser.createGenomeLoc("chrM",20), null);
|
||||
TableFeature datum = tracker.getFirstValue("tableTest", TableFeature.class);
|
||||
TableFeature datum = tracker.getFirstValue(TableFeature.class, "tableTest");
|
||||
|
||||
Assert.assertEquals(datum.get("COL1"),"C","datum parameter for COL1 is incorrect");
|
||||
Assert.assertEquals(datum.get("COL2"),"D","datum parameter for COL2 is incorrect");
|
||||
|
|
@ -114,13 +114,13 @@ public class ReferenceOrderedViewUnitTest extends BaseTest {
|
|||
ReferenceOrderedView view = new ManagingReferenceOrderedView( provider );
|
||||
|
||||
RefMetaDataTracker tracker = view.getReferenceOrderedDataAtLocus(genomeLocParser.createGenomeLoc("chrM",20), null);
|
||||
TableFeature datum1 = tracker.getFirstValue("tableTest1", TableFeature.class);
|
||||
TableFeature datum1 = tracker.getFirstValue(TableFeature.class, "tableTest1");
|
||||
|
||||
Assert.assertEquals(datum1.get("COL1"),"C","datum1 parameter for COL1 is incorrect");
|
||||
Assert.assertEquals(datum1.get("COL2"),"D","datum1 parameter for COL2 is incorrect");
|
||||
Assert.assertEquals(datum1.get("COL3"),"E","datum1 parameter for COL3 is incorrect");
|
||||
|
||||
TableFeature datum2 = tracker.getFirstValue("tableTest2", TableFeature.class);
|
||||
TableFeature datum2 = tracker.getFirstValue(TableFeature.class, "tableTest2");
|
||||
|
||||
Assert.assertEquals(datum2.get("COL1"),"C","datum2 parameter for COL1 is incorrect");
|
||||
Assert.assertEquals(datum2.get("COL2"),"D","datum2 parameter for COL2 is incorrect");
|
||||
|
|
|
|||
|
|
@ -76,6 +76,11 @@ public class RefMetaDataTrackerUnitTest {
|
|||
span10_20 = makeSpan(10, 20);
|
||||
}
|
||||
|
||||
@BeforeMethod
|
||||
public void reset() {
|
||||
RodBinding.resetNameCounter();
|
||||
}
|
||||
|
||||
private class MyTest extends BaseTest.TestDataProvider {
|
||||
public RODRecordList AValues, BValues;
|
||||
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ public class VariantAnnotatorIntegrationTest extends WalkerTest {
|
|||
@Test
|
||||
public void testHasAnnotsNotAsking1() {
|
||||
WalkerTestSpec spec = new WalkerTestSpec(
|
||||
baseTestString() + " -B:variant,VCF3 " + validationDataLocation + "vcfexample2.vcf -I " + validationDataLocation + "low_coverage_CEU.chr1.10k-11k.bam -L 1:10,020,000-10,021,000", 1,
|
||||
baseTestString() + " --variants:VCF3 " + validationDataLocation + "vcfexample2.vcf -I " + validationDataLocation + "low_coverage_CEU.chr1.10k-11k.bam -L 1:10,020,000-10,021,000", 1,
|
||||
Arrays.asList("8a105fa5eebdfffe7326bc5b3d8ffd1c"));
|
||||
executeTest("test file has annotations, not asking for annotations, #1", spec);
|
||||
}
|
||||
|
|
@ -22,7 +22,7 @@ public class VariantAnnotatorIntegrationTest extends WalkerTest {
|
|||
@Test
|
||||
public void testHasAnnotsNotAsking2() {
|
||||
WalkerTestSpec spec = new WalkerTestSpec(
|
||||
baseTestString() + " -B:variant,VCF3 " + validationDataLocation + "vcfexample3.vcf -I " + validationDataLocation + "NA12878.1kg.p2.chr1_10mb_11_mb.SLX.bam -L 1:10,000,000-10,050,000", 1,
|
||||
baseTestString() + " --variants:VCF3 " + validationDataLocation + "vcfexample3.vcf -I " + validationDataLocation + "NA12878.1kg.p2.chr1_10mb_11_mb.SLX.bam -L 1:10,000,000-10,050,000", 1,
|
||||
Arrays.asList("964f1016ec9a3c55333f62dd834c14d6"));
|
||||
executeTest("test file has annotations, not asking for annotations, #2", spec);
|
||||
}
|
||||
|
|
@ -30,7 +30,7 @@ public class VariantAnnotatorIntegrationTest extends WalkerTest {
|
|||
@Test
|
||||
public void testHasAnnotsAsking1() {
|
||||
WalkerTestSpec spec = new WalkerTestSpec(
|
||||
baseTestString() + " -G \"Standard\" -B:variant,VCF3 " + validationDataLocation + "vcfexample2.vcf -I " + validationDataLocation + "low_coverage_CEU.chr1.10k-11k.bam -L 1:10,020,000-10,021,000", 1,
|
||||
baseTestString() + " -G \"Standard\" --variants:VCF3 " + validationDataLocation + "vcfexample2.vcf -I " + validationDataLocation + "low_coverage_CEU.chr1.10k-11k.bam -L 1:10,020,000-10,021,000", 1,
|
||||
Arrays.asList("8e7de435105499cd71ffc099e268a83e"));
|
||||
executeTest("test file has annotations, asking for annotations, #1", spec);
|
||||
}
|
||||
|
|
@ -38,7 +38,7 @@ public class VariantAnnotatorIntegrationTest extends WalkerTest {
|
|||
@Test
|
||||
public void testHasAnnotsAsking2() {
|
||||
WalkerTestSpec spec = new WalkerTestSpec(
|
||||
baseTestString() + " -G \"Standard\" -B:variant,VCF3 " + validationDataLocation + "vcfexample3.vcf -I " + validationDataLocation + "NA12878.1kg.p2.chr1_10mb_11_mb.SLX.bam -L 1:10,000,000-10,050,000", 1,
|
||||
baseTestString() + " -G \"Standard\" --variants:VCF3 " + validationDataLocation + "vcfexample3.vcf -I " + validationDataLocation + "NA12878.1kg.p2.chr1_10mb_11_mb.SLX.bam -L 1:10,000,000-10,050,000", 1,
|
||||
Arrays.asList("64b6804cb1e27826e3a47089349be581"));
|
||||
executeTest("test file has annotations, asking for annotations, #2", spec);
|
||||
}
|
||||
|
|
@ -46,7 +46,7 @@ public class VariantAnnotatorIntegrationTest extends WalkerTest {
|
|||
@Test
|
||||
public void testNoAnnotsNotAsking1() {
|
||||
WalkerTestSpec spec = new WalkerTestSpec(
|
||||
baseTestString() + " -B:variant,VCF3 " + validationDataLocation + "vcfexample2empty.vcf -I " + validationDataLocation + "low_coverage_CEU.chr1.10k-11k.bam -L 1:10,020,000-10,021,000", 1,
|
||||
baseTestString() + " --variants:VCF3 " + validationDataLocation + "vcfexample2empty.vcf -I " + validationDataLocation + "low_coverage_CEU.chr1.10k-11k.bam -L 1:10,020,000-10,021,000", 1,
|
||||
Arrays.asList("42ccee09fa9f8c58f4a0d4f1139c094f"));
|
||||
executeTest("test file doesn't have annotations, not asking for annotations, #1", spec);
|
||||
}
|
||||
|
|
@ -54,7 +54,7 @@ public class VariantAnnotatorIntegrationTest extends WalkerTest {
|
|||
@Test
|
||||
public void testNoAnnotsNotAsking2() {
|
||||
WalkerTestSpec spec = new WalkerTestSpec(
|
||||
baseTestString() + " -B:variant,VCF3 " + validationDataLocation + "vcfexample3empty.vcf -I " + validationDataLocation + "NA12878.1kg.p2.chr1_10mb_11_mb.SLX.bam -L 1:10,000,000-10,050,000", 1,
|
||||
baseTestString() + " --variants:VCF3 " + validationDataLocation + "vcfexample3empty.vcf -I " + validationDataLocation + "NA12878.1kg.p2.chr1_10mb_11_mb.SLX.bam -L 1:10,000,000-10,050,000", 1,
|
||||
Arrays.asList("f2ddfa8105c290b1f34b7a261a02a1ac"));
|
||||
executeTest("test file doesn't have annotations, not asking for annotations, #2", spec);
|
||||
}
|
||||
|
|
@ -62,7 +62,7 @@ public class VariantAnnotatorIntegrationTest extends WalkerTest {
|
|||
@Test
|
||||
public void testNoAnnotsAsking1() {
|
||||
WalkerTestSpec spec = new WalkerTestSpec(
|
||||
baseTestString() + " -G \"Standard\" -B:variant,VCF3 " + validationDataLocation + "vcfexample2empty.vcf -I " + validationDataLocation + "low_coverage_CEU.chr1.10k-11k.bam -L 1:10,020,000-10,021,000", 1,
|
||||
baseTestString() + " -G \"Standard\" --variants:VCF3 " + validationDataLocation + "vcfexample2empty.vcf -I " + validationDataLocation + "low_coverage_CEU.chr1.10k-11k.bam -L 1:10,020,000-10,021,000", 1,
|
||||
Arrays.asList("fd1ffb669800c2e07df1e2719aa38e49"));
|
||||
executeTest("test file doesn't have annotations, asking for annotations, #1", spec);
|
||||
}
|
||||
|
|
@ -70,7 +70,7 @@ public class VariantAnnotatorIntegrationTest extends WalkerTest {
|
|||
@Test
|
||||
public void testNoAnnotsAsking2() {
|
||||
WalkerTestSpec spec = new WalkerTestSpec(
|
||||
baseTestString() + " -G \"Standard\" -B:variant,VCF3 " + validationDataLocation + "vcfexample3empty.vcf -I " + validationDataLocation + "NA12878.1kg.p2.chr1_10mb_11_mb.SLX.bam -L 1:10,000,000-10,050,000", 1,
|
||||
baseTestString() + " -G \"Standard\" --variants:VCF3 " + validationDataLocation + "vcfexample3empty.vcf -I " + validationDataLocation + "NA12878.1kg.p2.chr1_10mb_11_mb.SLX.bam -L 1:10,000,000-10,050,000", 1,
|
||||
Arrays.asList("09f8e840770a9411ff77508e0ed0837f"));
|
||||
executeTest("test file doesn't have annotations, asking for annotations, #2", spec);
|
||||
}
|
||||
|
|
@ -78,7 +78,7 @@ public class VariantAnnotatorIntegrationTest extends WalkerTest {
|
|||
@Test
|
||||
public void testOverwritingHeader() {
|
||||
WalkerTestSpec spec = new WalkerTestSpec(
|
||||
baseTestString() + " -G \"Standard\" -B:variant,VCF " + validationDataLocation + "vcfexample4.vcf -I " + validationDataLocation + "NA12878.1kg.p2.chr1_10mb_11_mb.SLX.bam -L 1:10,001,292", 1,
|
||||
baseTestString() + " -G \"Standard\" --variants:VCF " + validationDataLocation + "vcfexample4.vcf -I " + validationDataLocation + "NA12878.1kg.p2.chr1_10mb_11_mb.SLX.bam -L 1:10,001,292", 1,
|
||||
Arrays.asList("78d2c19f8107d865970dbaf3e12edd92"));
|
||||
executeTest("test overwriting header", spec);
|
||||
}
|
||||
|
|
@ -86,7 +86,7 @@ public class VariantAnnotatorIntegrationTest extends WalkerTest {
|
|||
@Test
|
||||
public void testNoReads() {
|
||||
WalkerTestSpec spec = new WalkerTestSpec(
|
||||
baseTestString() + " -G \"Standard\" -B:variant,VCF3 " + validationDataLocation + "vcfexample3empty.vcf -BTI variant", 1,
|
||||
baseTestString() + " -G \"Standard\" --variants:VCF3 " + validationDataLocation + "vcfexample3empty.vcf -BTI variants", 1,
|
||||
Arrays.asList("16e3a1403fc376320d7c69492cad9345"));
|
||||
executeTest("not passing it any reads", spec);
|
||||
}
|
||||
|
|
@ -94,7 +94,7 @@ public class VariantAnnotatorIntegrationTest extends WalkerTest {
|
|||
@Test
|
||||
public void testDBTagWithDbsnp() {
|
||||
WalkerTestSpec spec = new WalkerTestSpec(
|
||||
baseTestString() + " -B:dbsnp,vcf " + GATKDataLocation + "dbsnp_132.b36.excluding_sites_after_129.vcf -G \"Standard\" -B:variant,VCF3 " + validationDataLocation + "vcfexample3empty.vcf -BTI variant", 1,
|
||||
baseTestString() + " -B:dbsnp,vcf " + GATKDataLocation + "dbsnp_132.b36.excluding_sites_after_129.vcf -G \"Standard\" --variants:VCF3 " + validationDataLocation + "vcfexample3empty.vcf -BTI variants", 1,
|
||||
Arrays.asList("3da8ca2b6bdaf6e92d94a8c77a71313d"));
|
||||
executeTest("getting DB tag with dbSNP", spec);
|
||||
}
|
||||
|
|
@ -102,7 +102,7 @@ public class VariantAnnotatorIntegrationTest extends WalkerTest {
|
|||
@Test
|
||||
public void testDBTagWithHapMap() {
|
||||
WalkerTestSpec spec = new WalkerTestSpec(
|
||||
baseTestString() + " -B:compH3,VCF " + validationDataLocation + "fakeHM3.vcf -G \"Standard\" -B:variant,VCF3 " + validationDataLocation + "vcfexample3empty.vcf -BTI variant", 1,
|
||||
baseTestString() + " -B:compH3,VCF " + validationDataLocation + "fakeHM3.vcf -G \"Standard\" --variants:VCF3 " + validationDataLocation + "vcfexample3empty.vcf -BTI variants", 1,
|
||||
Arrays.asList("1bc01c5b3bd0b7aef75230310c3ce688"));
|
||||
executeTest("getting DB tag with HM3", spec);
|
||||
}
|
||||
|
|
@ -110,7 +110,7 @@ public class VariantAnnotatorIntegrationTest extends WalkerTest {
|
|||
@Test
|
||||
public void testUsingExpression() {
|
||||
WalkerTestSpec spec = new WalkerTestSpec(
|
||||
baseTestString() + " -B:foo,VCF " + validationDataLocation + "targetAnnotations.vcf -G \"Standard\" -B:variant,VCF3 " + validationDataLocation + "vcfexample3empty.vcf -E foo.AF -BTI variant", 1,
|
||||
baseTestString() + " -B:foo,VCF " + validationDataLocation + "targetAnnotations.vcf -G \"Standard\" --variants:VCF3 " + validationDataLocation + "vcfexample3empty.vcf -E foo.AF -BTI variants", 1,
|
||||
Arrays.asList("e9c0d832dc6b4ed06c955060f830c140"));
|
||||
executeTest("using expression", spec);
|
||||
}
|
||||
|
|
@ -120,7 +120,7 @@ public class VariantAnnotatorIntegrationTest extends WalkerTest {
|
|||
final String MD5 = "13269d5a2e16f06fd755cc0fb9271acf";
|
||||
for ( String file : Arrays.asList("CEU.exon.2010_03.sites.vcf", "CEU.exon.2010_03.sites.vcf.gz")) {
|
||||
WalkerTestSpec spec = new WalkerTestSpec(
|
||||
baseTestString() + " -A HomopolymerRun -B:variant,VCF " + validationDataLocation + "/" + file + " -BTI variant -NO_HEADER", 1,
|
||||
baseTestString() + " -A HomopolymerRun --variants:VCF " + validationDataLocation + "/" + file + " -BTI variants -NO_HEADER", 1,
|
||||
Arrays.asList(MD5));
|
||||
executeTest("Testing lookup vcf tabix vs. vcf tribble", spec);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -86,7 +86,7 @@ public class VariantFiltrationIntegrationTest extends WalkerTest {
|
|||
@Test
|
||||
public void testDeletions() {
|
||||
WalkerTestSpec spec = new WalkerTestSpec(
|
||||
baseTestString() + " --filterExpression 'QUAL < 100' --filterName foo --variants:VCF3 " + validationDataLocation + "twoDeletions.vcf", 1,
|
||||
baseTestString() + " --filterExpression 'QUAL < 100' --filterName foo --variants:VCF " + validationDataLocation + "twoDeletions.vcf", 1,
|
||||
Arrays.asList("569546fd798afa0e65c5b61b440d07ac"));
|
||||
executeTest("test deletions", spec);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ public class VCFIntegrationTest extends WalkerTest {
|
|||
|
||||
String baseCommand = "-R " + b37KGReference + " -NO_HEADER -o %s ";
|
||||
|
||||
String test1 = baseCommand + "-T VariantAnnotator -BTI variant --variants:vcf " + testVCF;
|
||||
String test1 = baseCommand + "-T VariantAnnotator -BTI variants --variants:vcf " + testVCF;
|
||||
WalkerTestSpec spec1 = new WalkerTestSpec(test1, 1, Arrays.asList(md5ofInputVCF));
|
||||
List<File> result = executeTest("Test Variant Annotator with no changes", spec1).getFirst();
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue