Annotation changes for M2:

Build a ReferenceContext in ActiveRegionWalkers to pass in to annotation engine so we can call the TandemRepeatAnnotator from M2
Make TandemRepeatAnnotator default annotation for M2.
Setup (but don't use yet) HC-style contamination downsampling.
New HC integration test with TandemRepeatAnnotator
This commit is contained in:
Laura Gauthier 2015-02-20 10:00:22 -05:00
parent 1f81c033f5
commit 5a10758e2e
5 changed files with 21 additions and 15 deletions

View File

@ -52,6 +52,7 @@
package org.broadinstitute.gatk.tools.walkers.annotator;
import org.apache.log4j.Logger;
import org.broadinstitute.gatk.tools.walkers.annotator.interfaces.ActiveRegionBasedAnnotation;
import org.broadinstitute.gatk.utils.contexts.AlignmentContext;
import org.broadinstitute.gatk.utils.contexts.ReferenceContext;
import org.broadinstitute.gatk.utils.refdata.RefMetaDataTracker;
@ -81,7 +82,7 @@ import java.util.*;
* </ul>
*
*/
public class TandemRepeatAnnotator extends InfoFieldAnnotation implements StandardAnnotation {
public class TandemRepeatAnnotator extends InfoFieldAnnotation implements StandardAnnotation, ActiveRegionBasedAnnotation {
private final static Logger logger = Logger.getLogger(TandemRepeatAnnotator.class);
private boolean walkerIdentityCheckWarningLogged = false;
@ -93,15 +94,6 @@ public class TandemRepeatAnnotator extends InfoFieldAnnotation implements Standa
final VariantContext vc,
final Map<String, PerReadAlleleLikelihoodMap> stratifiedPerReadAlleleLikelihoodMap) throws UserException {
// Can not be called from HaplotypeCaller
if ( walker instanceof HaplotypeCaller ) {
if ( !walkerIdentityCheckWarningLogged ) {
logger.warn("Annotation will not be calculated, can not be called from HaplotypeCaller");
walkerIdentityCheckWarningLogged = true;
}
return null;
}
if ( !vc.isIndel())
return null;

View File

@ -54,6 +54,7 @@ package org.broadinstitute.gatk.tools.walkers.haplotypecaller;
import com.google.java.contract.Ensures;
import com.google.java.contract.Requires;
import htsjdk.variant.variantcontext.*;
import org.broadinstitute.gatk.utils.contexts.ReferenceContext;
import org.broadinstitute.gatk.utils.genotyper.AlleleList;
import org.broadinstitute.gatk.utils.genotyper.IndexedAlleleList;
import org.broadinstitute.gatk.utils.genotyper.SampleList;
@ -272,7 +273,8 @@ public class HaplotypeCallerGenotypingEngine extends GenotypingEngine<HaplotypeC
readAlleleLikelihoods = prepareReadAlleleLikelihoodsForAnnotation(readLikelihoods, perSampleFilteredReadList,
genomeLocParser, emitReferenceConfidence, alleleMapper, readAlleleLikelihoods, call);
VariantContext annotatedCall = annotationEngine.annotateContextForActiveRegion(tracker,readAlleleLikelihoods, call);
ReferenceContext referenceContext = new ReferenceContext(genomeLocParser, genomeLocParser.createGenomeLoc(mergedVC.getChr(), mergedVC.getStart(), mergedVC.getEnd()), refLoc, ref);
VariantContext annotatedCall = annotationEngine.annotateContextForActiveRegion(referenceContext, tracker,readAlleleLikelihoods, call);
if( call.getAlleles().size() != mergedVC.getAlleles().size() )
annotatedCall = GATKVariantContextUtils.reverseTrimAlleles(annotatedCall);

View File

@ -443,4 +443,9 @@ public class HaplotypeCallerIntegrationTest extends WalkerTest {
" -o %s",
1, UserException.CommandLineException.class));
}
@Test
public void testHaplotypeCallerTandemRepeatAnnotator() throws IOException{
HCTest(NA12878_BAM, " -L 20:10001000-10010000 -A TandemRepeatAnnotator -XA MappingQualityZero -XA SpanningDeletions", "ab9907559e5b20dadbb6f24d02b8070c");
}
}

View File

@ -218,17 +218,19 @@ public class VariantAnnotatorEngine {
return annotateDBs(tracker, annotated);
}
public VariantContext annotateContextForActiveRegion(final RefMetaDataTracker tracker,
public VariantContext annotateContextForActiveRegion(final ReferenceContext referenceContext,
final RefMetaDataTracker tracker,
final ReadLikelihoods<Allele> readLikelihoods,
final VariantContext vc) {
//TODO we transform the read-likelihood into the Map^2 previous version for the sake of not changing of not changing annotation interface.
//TODO should we change those interfaces?
final Map<String, PerReadAlleleLikelihoodMap> annotationLikelihoods = readLikelihoods.toPerReadAlleleLikelihoodMap();
return annotateContextForActiveRegion(tracker, annotationLikelihoods, vc);
return annotateContextForActiveRegion(referenceContext, tracker, annotationLikelihoods, vc);
}
public VariantContext annotateContextForActiveRegion(final RefMetaDataTracker tracker,
public VariantContext annotateContextForActiveRegion(final ReferenceContext referenceContext,
final RefMetaDataTracker tracker,
final Map<String, PerReadAlleleLikelihoodMap> perReadAlleleLikelihoodMap,
final VariantContext vc) {
final Map<String, Object> infoAnnotations = new LinkedHashMap<>(vc.getAttributes());
@ -238,7 +240,7 @@ public class VariantAnnotatorEngine {
if ( !(annotationType instanceof ActiveRegionBasedAnnotation) )
continue;
final Map<String, Object> annotationsFromCurrentType = annotationType.annotate(perReadAlleleLikelihoodMap, vc);
final Map<String, Object> annotationsFromCurrentType = annotationType.annotate(referenceContext, perReadAlleleLikelihoodMap, vc);
if ( annotationsFromCurrentType != null ) {
infoAnnotations.putAll(annotationsFromCurrentType);
}

View File

@ -25,6 +25,7 @@
package org.broadinstitute.gatk.tools.walkers.annotator.interfaces;
import org.broadinstitute.gatk.utils.GenomeLoc;
import org.broadinstitute.gatk.utils.contexts.AlignmentContext;
import org.broadinstitute.gatk.utils.contexts.ReferenceContext;
import org.broadinstitute.gatk.utils.refdata.RefMetaDataTracker;
@ -51,6 +52,10 @@ public abstract class InfoFieldAnnotation extends VariantAnnotatorAnnotation {
return annotate(null, null, null, null, vc, perReadAlleleLikelihoodMap);
}
public Map<String, Object> annotate(ReferenceContext referenceContext, Map<String, PerReadAlleleLikelihoodMap> perReadAlleleLikelihoodMap, VariantContext vc) {
return annotate(null, null, referenceContext, null, vc, perReadAlleleLikelihoodMap);
}
public abstract Map<String, Object> annotate(final RefMetaDataTracker tracker,
final AnnotatorCompatible walker,