Skip to content

Commit

Permalink
Unified HaplotypeCaller's force-calling mode with Mutect2's
Browse files Browse the repository at this point in the history
  • Loading branch information
davidbenjamin committed Aug 20, 2019
1 parent 69391bf commit 5a02caa
Show file tree
Hide file tree
Showing 35 changed files with 167 additions and 680 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.broadinstitute.hellbender.engine;

import htsjdk.samtools.util.Locatable;
import htsjdk.tribble.Feature;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
Expand Down Expand Up @@ -150,7 +151,7 @@ public void fill( final Iterator<CACHED_FEATURE> featureIter, final SimpleInterv
* @param interval the interval to check against the contents of our cache
* @return true if all records overlapping the provided interval are already contained in our cache, otherwise false
*/
public boolean cacheHit( final SimpleInterval interval ) {
public boolean cacheHit( final Locatable interval ) {
final boolean cacheHit = cachedInterval != null && cachedInterval.contains(interval);

if ( cacheHit ) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.broadinstitute.hellbender.engine;

import com.google.common.annotations.VisibleForTesting;
import htsjdk.samtools.util.Locatable;
import htsjdk.tribble.Feature;
import org.broadinstitute.hellbender.cmdline.CommandLineProgram;
import org.broadinstitute.hellbender.utils.SimpleInterval;
Expand Down Expand Up @@ -165,7 +166,7 @@ public <T extends Feature> List<T> getValues(final FeatureInput<T> featureDescri
* this FeatureContext's query interval as expanded by the specified number of leading/trailing bases.
* Empty List if there is no backing data source and/or interval.
*/
public <T extends Feature> List<T> getValues(final FeatureInput<T> featureDescriptor, final SimpleInterval queryInterval) {
public <T extends Feature> List<T> getValues(final FeatureInput<T> featureDescriptor, final Locatable queryInterval) {
if (featureManager == null || queryInterval == null || featureDescriptor == null) {
return Collections.emptyList();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import htsjdk.samtools.SAMSequenceDictionary;
import htsjdk.samtools.util.IOUtil;
import htsjdk.samtools.util.Locatable;
import htsjdk.tribble.*;
import htsjdk.variant.variantcontext.VariantContext;
import htsjdk.variant.vcf.VCFHeader;
Expand Down Expand Up @@ -509,7 +510,7 @@ public Iterator<T> query(final SimpleInterval interval) {
* @param interval retrieve all Features overlapping this interval
* @return a List of all Features in this data source that overlap the provided interval
*/
public List<T> queryAndPrefetch(final SimpleInterval interval) {
public List<T> queryAndPrefetch(final Locatable interval) {
if (!supportsRandomAccess) {
throw new UserException("Input " + featureInput.getFeaturePath() + " must support random access to enable queries by interval. " +
"If it's a file, please index it using the bundled tool " + IndexFeatureFile.class.getSimpleName());
Expand Down Expand Up @@ -540,7 +541,7 @@ public List<T> queryAndPrefetch(final SimpleInterval interval) {
*
* @param interval the query interval that produced a cache miss
*/
private void refillQueryCache(final SimpleInterval interval) {
private void refillQueryCache(final Locatable interval) {
// Tribble documentation states that having multiple iterators open simultaneously over the same FeatureReader
// results in undefined behavior
closeOpenIterationIfNecessary();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.google.common.annotations.VisibleForTesting;
import htsjdk.samtools.SAMSequenceDictionary;
import htsjdk.samtools.util.Locatable;
import htsjdk.tribble.Feature;
import htsjdk.tribble.FeatureCodec;
import htsjdk.variant.vcf.VCFHeader;
Expand Down Expand Up @@ -342,7 +343,7 @@ public List<SAMSequenceDictionary> getAllSequenceDictionaries() {
* @return A List of all Features in the backing data source for the provided FeatureInput that overlap
* the provided interval (may be empty if there are none, but never null)
*/
public <T extends Feature> List<T> getFeatures( final FeatureInput<T> featureDescriptor, final SimpleInterval interval ) {
public <T extends Feature> List<T> getFeatures( final FeatureInput<T> featureDescriptor, final Locatable interval ) {
final FeatureDataSource<T> dataSource = lookupDataSource(featureDescriptor);

// No danger of a ClassCastException here, since we verified that the FeatureDataSource for this
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import htsjdk.samtools.SAMSequenceRecord;
import htsjdk.samtools.reference.ReferenceSequence;
import htsjdk.samtools.util.Locatable;
import org.broadinstitute.hellbender.exceptions.GATKException;
import org.broadinstitute.hellbender.exceptions.UserException;
import org.broadinstitute.hellbender.utils.SimpleInterval;
Expand Down Expand Up @@ -30,7 +31,7 @@
* return empty arrays / iterators. You can determine whether there is a backing source of reference
* data via {@link #hasBackingDataSource()}, and whether there is an interval via {@link #getInterval}.
*/
public final class ReferenceContext implements Iterable<Byte> {
public final class ReferenceContext implements Iterable<Byte>, Locatable {

/**
* Backing data source. Null if there is no reference data.
Expand Down Expand Up @@ -142,6 +143,16 @@ public ReferenceContext( final ReferenceDataSource dataSource, final SimpleInter
}
}

@Override
public String getContig() { return interval.getContig(); }

@Override
public int getStart() { return interval.getStart(); }

@Override
public int getEnd() { return interval.getEnd(); }


/**
* Determines whether this ReferenceContext has a backing reference data source. A ReferenceContext with
* no backing data source will always return an empty bases array from {@link #getBases()} and an
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ private VariantContext calculateGenotypes(VariantContext vc){
final GenotypeLikelihoodsCalculationModel model = vc.getType() == VariantContext.Type.INDEL
? GenotypeLikelihoodsCalculationModel.INDEL
: GenotypeLikelihoodsCalculationModel.SNP;
return genotypingEngine.calculateGenotypes(vc, model, null);
return genotypingEngine.calculateGenotypes(vc, model);
}

/**
Expand Down
Loading

0 comments on commit 5a02caa

Please sign in to comment.