Skip to content

Commit

Permalink
Make InfoFieldAnnotation/GenotypeAnnotation into interfaces. (#7041)
Browse files Browse the repository at this point in the history
Allows PedigreeAnnotation to be used as both an InfoFieldAnnotation and a GenotypeAnnotation.
  • Loading branch information
bbimber committed Feb 23, 2021
1 parent 1f7fade commit 66d1614
Show file tree
Hide file tree
Showing 34 changed files with 47 additions and 60 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.broadinstitute.hellbender.engine.ReferenceContext;
import org.broadinstitute.hellbender.tools.walkers.annotator.allelespecific.AS_StrandBiasTest;
import org.broadinstitute.hellbender.tools.walkers.annotator.allelespecific.AlleleSpecificAnnotation;
import org.broadinstitute.hellbender.tools.walkers.annotator.allelespecific.AlleleSpecificAnnotationData;
import org.broadinstitute.hellbender.tools.walkers.annotator.allelespecific.StrandBiasUtils;
import org.broadinstitute.hellbender.utils.Utils;
import org.broadinstitute.hellbender.utils.genotyper.AlleleLikelihoods;
Expand All @@ -22,7 +20,7 @@
/**
* Adds the strand bias table annotation for use in mutect filters
*/
public class AS_StrandBiasMutectAnnotation extends InfoFieldAnnotation implements StandardMutectAnnotation, AlleleSpecificAnnotation {
public class AS_StrandBiasMutectAnnotation implements InfoFieldAnnotation, StandardMutectAnnotation, AlleleSpecificAnnotation {
private final static Logger logger = LogManager.getLogger(StrandBiasBySample.class);

@Override
Expand All @@ -37,11 +35,6 @@ public Map<String, Object> annotate(ReferenceContext ref, VariantContext vc, All
return StrandBiasUtils.computeSBAnnotation(vc, likelihoods, GATKVCFConstants.AS_SB_TABLE_KEY);
}

@Override
public List<VCFInfoHeaderLine> getDescriptions() {
return super.getDescriptions();
}

@Override
public List<String> getKeyNames() {
return Collections.singletonList(GATKVCFConstants.AS_SB_TABLE_KEY);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
*/
@DocumentedFeature(groupName= HelpConstants.DOC_CAT_ANNOTATORS, groupSummary=HelpConstants.DOC_CAT_ANNOTATORS_SUMMARY, summary="Variant allele fraction for a genotype")

public final class AlleleFraction extends GenotypeAnnotation {
public final class AlleleFraction implements GenotypeAnnotation {
@Override
public void annotate(final ReferenceContext ref,
final VariantContext vc,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import java.util.*;
import java.util.stream.Collectors;

public class BaseQualityHistogram extends InfoFieldAnnotation {
public class BaseQualityHistogram implements InfoFieldAnnotation {

public static final String KEY = "BQHIST";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
*
*/
@DocumentedFeature(groupName=HelpConstants.DOC_CAT_ANNOTATORS, groupSummary=HelpConstants.DOC_CAT_ANNOTATORS_SUMMARY, summary="Counts and frequency of alleles in called genotypes (AC, AF, AN)")
public final class ChromosomeCounts extends InfoFieldAnnotation implements StandardAnnotation {
public final class ChromosomeCounts implements InfoFieldAnnotation, StandardAnnotation {

public static final String[] keyNames = {
VCFConstants.ALLELE_NUMBER_KEY,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,11 @@
import htsjdk.variant.variantcontext.Allele;
import htsjdk.variant.variantcontext.VariantContext;
import htsjdk.variant.vcf.VCFInfoHeaderLine;
import org.apache.commons.lang3.tuple.Pair;
import org.broadinstitute.barclay.help.DocumentedFeature;
import org.broadinstitute.hellbender.engine.ReferenceContext;
import org.broadinstitute.hellbender.utils.Utils;
import org.broadinstitute.hellbender.utils.genotyper.AlleleLikelihoods;
import org.broadinstitute.hellbender.utils.help.HelpConstants;
import org.broadinstitute.hellbender.utils.read.AlignmentUtils;
import org.broadinstitute.hellbender.utils.read.GATKRead;
import org.broadinstitute.hellbender.utils.read.ReadUtils;
import org.broadinstitute.hellbender.utils.variant.GATKVCFConstants;
Expand All @@ -25,7 +23,7 @@
* Apply a read-based annotation that reports the number of Ns seen at a given site. This is intended for use on consensus called data.
*/
@DocumentedFeature(groupName= HelpConstants.DOC_CAT_ANNOTATORS, groupSummary=HelpConstants.DOC_CAT_ANNOTATORS_SUMMARY, summary="Number of Ns at the pileup")
public class CountNs extends InfoFieldAnnotation {
public class CountNs implements InfoFieldAnnotation {
/**
* Calculate annotations for each allele based on given VariantContext and likelihoods for a given genotype's sample
* and add the annotations to the GenotypeBuilder. By default annotations are only calculated for alt alleles but
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
* </ul>
*/
@DocumentedFeature(groupName=HelpConstants.DOC_CAT_ANNOTATORS, groupSummary=HelpConstants.DOC_CAT_ANNOTATORS_SUMMARY, summary="Total depth of coverage per sample and over all samples (DP)")
public final class Coverage extends InfoFieldAnnotation implements StandardAnnotation, StandardMutectAnnotation {
public final class Coverage implements InfoFieldAnnotation, StandardAnnotation, StandardMutectAnnotation {

@Override
public Map<String, Object> annotate(final ReferenceContext ref,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import org.broadinstitute.hellbender.utils.Utils;
import org.broadinstitute.hellbender.utils.genotyper.AlleleLikelihoods;
import org.broadinstitute.hellbender.utils.help.HelpConstants;
import org.broadinstitute.hellbender.utils.pileup.PileupElement;
import org.broadinstitute.hellbender.utils.read.GATKRead;

import java.util.*;
Expand All @@ -37,7 +36,7 @@
* </ul>
*/
@DocumentedFeature(groupName=HelpConstants.DOC_CAT_ANNOTATORS, groupSummary=HelpConstants.DOC_CAT_ANNOTATORS_SUMMARY, summary="Depth of coverage of each allele per sample (AD)")
public final class DepthPerAlleleBySample extends GenotypeAnnotation implements StandardAnnotation, StandardMutectAnnotation {
public final class DepthPerAlleleBySample implements GenotypeAnnotation, StandardAnnotation, StandardMutectAnnotation {

@Override
public void annotate(final ReferenceContext ref,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import org.broadinstitute.hellbender.utils.Utils;
import org.broadinstitute.hellbender.utils.genotyper.AlleleLikelihoods;
import org.broadinstitute.hellbender.utils.help.HelpConstants;
import org.broadinstitute.hellbender.utils.logging.OneShotLogger;
import org.broadinstitute.hellbender.utils.read.GATKRead;

import java.util.*;
Expand All @@ -41,7 +40,7 @@
*
*/
@DocumentedFeature(groupName=HelpConstants.DOC_CAT_ANNOTATORS, groupSummary=HelpConstants.DOC_CAT_ANNOTATORS_SUMMARY, summary="Depth of informative coverage for each sample (DP)")
public final class DepthPerSampleHC extends GenotypeAnnotation implements StandardHCAnnotation, StandardMutectAnnotation {
public final class DepthPerSampleHC implements GenotypeAnnotation, StandardHCAnnotation, StandardMutectAnnotation {
private final static Logger logger = LogManager.getLogger(DepthPerSampleHC.class);

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
* <p><b>InbreedingCoeff</b> also describes the heterozygosity of the called samples, though without explicitly taking into account the number of samples</p>
*/
@DocumentedFeature(groupName=HelpConstants.DOC_CAT_ANNOTATORS, groupSummary=HelpConstants.DOC_CAT_ANNOTATORS_SUMMARY, summary="Phred-scaled p-value for exact test of excess heterozygosity (ExcessHet)")
public final class ExcessHet extends PedigreeAnnotation implements StandardAnnotation {
public final class ExcessHet extends PedigreeAnnotation implements InfoFieldAnnotation, StandardAnnotation {

private static final double MIN_NEEDED_VALUE = 1.0E-16;
private static final boolean ROUND_GENOTYPE_COUNTS = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
/**
* Represents an annotation that is computed for a single genotype.
*/
public abstract class GenotypeAnnotation extends VariantAnnotation{
public interface GenotypeAnnotation extends VariantAnnotation {

/**
* Computes the annotation for the given genotype and the likelihoods per read.
Expand All @@ -26,7 +26,7 @@ public abstract class GenotypeAnnotation extends VariantAnnotation{
* @param g the genotype to annotate. May be null.
* @param gb the builder to modify and annotations to. Not null.
*/
public abstract void annotate(final ReferenceContext ref,
public void annotate(final ReferenceContext ref,
final VariantContext vc,
final Genotype g,
final GenotypeBuilder gb,
Expand All @@ -36,5 +36,5 @@ public abstract void annotate(final ReferenceContext ref,
* Return the descriptions used for the VCF FORMAT meta field.
* Subclasses must ensure that this list is not null and does not contain null.
*/
public abstract List<VCFFormatHeaderLine> getDescriptions();
public List<VCFFormatHeaderLine> getDescriptions();
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
* <p>These summaries can all be recomputed from the genotypes on the fly but it is a lot faster to add them here as INFO field annotations.</p>
*/
@DocumentedFeature(groupName=HelpConstants.DOC_CAT_ANNOTATORS, groupSummary=HelpConstants.DOC_CAT_ANNOTATORS_SUMMARY, summary="Summary of genotype statistics from all samples (NCC, GQ_MEAN, GQ_STDDEV)")
public final class GenotypeSummaries extends InfoFieldAnnotation {
public final class GenotypeSummaries implements InfoFieldAnnotation {

@Override
public Map<String, Object> annotate(final ReferenceContext ref,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
* <p><b>ExcessHet</b> also describes the heterozygosity of the called samples, giving a probability of excess heterozygosity being observed</p>
*/
@DocumentedFeature(groupName=HelpConstants.DOC_CAT_ANNOTATORS, groupSummary=HelpConstants.DOC_CAT_ANNOTATORS_SUMMARY, summary="Likelihood-based test for the consanguinity among samples (InbreedingCoeff)")
public final class InbreedingCoeff extends PedigreeAnnotation implements StandardAnnotation {
public final class InbreedingCoeff extends PedigreeAnnotation implements InfoFieldAnnotation, StandardAnnotation {

private static final OneShotLogger oneShotLogger = new OneShotLogger(InbreedingCoeff.class);
private static final int MIN_SAMPLES = 10;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
/**
* Annotations relevant to the INFO field of the variant file (ie annotations for sites).
*/
public abstract class InfoFieldAnnotation extends VariantAnnotation{
public interface InfoFieldAnnotation extends VariantAnnotation {

/**
* Computes the annotation for the given variant and the likelihoods per read.
Expand All @@ -25,15 +25,15 @@ public abstract class InfoFieldAnnotation extends VariantAnnotation{
* @param vc Variant to be annotated. Not null.
* @param likelihoods likelihoods indexed by sample, allele, and read within sample
*/
public abstract Map<String, Object> annotate(final ReferenceContext ref,
public Map<String, Object> annotate(final ReferenceContext ref,
final VariantContext vc,
final AlleleLikelihoods<GATKRead, Allele> likelihoods);

/**
* Returns the descriptions used for the VCF INFO meta field.
* Subclasses must ensure that this list is not null and does not contain null.
*/
public List<VCFInfoHeaderLine> getDescriptions() {
default List<VCFInfoHeaderLine> getDescriptions() {
final List<VCFInfoHeaderLine> lines = new ArrayList<>(getKeyNames().size());
for (final String key : getKeyNames()) {
lines.add(GATKVCFHeaderLines.getInfoLine(key));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
*
*/
@DocumentedFeature(groupName=HelpConstants.DOC_CAT_ANNOTATORS, groupSummary=HelpConstants.DOC_CAT_ANNOTATORS_SUMMARY, summary="Count of all reads with MAPQ = 0 across all samples (MQ0)")
public final class MappingQualityZero extends InfoFieldAnnotation {
public final class MappingQualityZero implements InfoFieldAnnotation {

@Override
public Map<String, Object> annotate(final ReferenceContext ref,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
* by Costello et al, doi: 10.1093/nar/gks1443</a></p>
*/
@DocumentedFeature(groupName=HelpConstants.DOC_CAT_ANNOTATORS, groupSummary=HelpConstants.DOC_CAT_ANNOTATORS_SUMMARY, summary="Count of read pairs in the F1R2 and F2R1 configurations supporting REF and ALT alleles (F1R2, F2R1)")
public final class OrientationBiasReadCounts extends GenotypeAnnotation implements StandardMutectAnnotation {
public final class OrientationBiasReadCounts implements GenotypeAnnotation, StandardMutectAnnotation {

private static final Logger logger = LogManager.getLogger(OrientationBiasReadCounts.class);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
import org.broadinstitute.hellbender.engine.ReferenceContext;
import org.broadinstitute.hellbender.tools.AddOriginalAlignmentTags;
import org.broadinstitute.hellbender.tools.walkers.mutect.filtering.Mutect2FilteringEngine;
import org.broadinstitute.hellbender.utils.*;
import org.broadinstitute.hellbender.utils.MathUtils;
import org.broadinstitute.hellbender.utils.Utils;
import org.broadinstitute.hellbender.utils.genotyper.AlleleLikelihoods;
import org.broadinstitute.hellbender.utils.help.HelpConstants;
import org.broadinstitute.hellbender.utils.logging.OneShotLogger;
Expand All @@ -35,7 +36,7 @@
*
*/
@DocumentedFeature(groupName= HelpConstants.DOC_CAT_ANNOTATORS, groupSummary=HelpConstants.DOC_CAT_ANNOTATORS_SUMMARY, summary="Number of alt reads with an OA tag that doesn't match the current alignment contig.")
public class OriginalAlignment extends InfoFieldAnnotation {
public class OriginalAlignment implements InfoFieldAnnotation {
protected final OneShotLogger warning = new OneShotLogger(this.getClass());
public static final String KEY = GATKVCFConstants.ORIGINAL_CONTIG_MISMATCH_KEY;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
* Alternatively, if a pedigree file has been supplied (not founderIDs) then extending classes can call getTrios() to
* return a set of Trio objects corresponding to a parsing of pedigree file.
*/
public abstract class PedigreeAnnotation extends InfoFieldAnnotation {
public abstract class PedigreeAnnotation implements VariantAnnotation {
private Collection<String> founderIds;
private GATKPath pedigreeFile = null;
private boolean hasAddedPedigreeFounders = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
/**
* Apply an annotation based on aggregation data from all reads supporting each allele.
*/
public abstract class PerAlleleAnnotation extends InfoFieldAnnotation{
public abstract class PerAlleleAnnotation implements InfoFieldAnnotation {

/**
* Calculate annotations for each allele based on given VariantContext and likelihoods for a given genotype's sample
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
* </ul>
*/
@DocumentedFeature(groupName=HelpConstants.DOC_CAT_ANNOTATORS, groupSummary=HelpConstants.DOC_CAT_ANNOTATORS_SUMMARY, summary="Existence of a de novo mutation in at least one of the given families (hiConfDeNovo, loConfDeNovo)")
public final class PossibleDeNovo extends PedigreeAnnotation {
public final class PossibleDeNovo extends PedigreeAnnotation implements InfoFieldAnnotation {
protected final Logger warning = LogManager.getLogger(this.getClass());
private final MendelianViolation mendelianViolation;
private Set<Trio> trios;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
* </ul>
*/
@DocumentedFeature(groupName=HelpConstants.DOC_CAT_ANNOTATORS, groupSummary=HelpConstants.DOC_CAT_ANNOTATORS_SUMMARY, summary="Variant confidence normalized by unfiltered depth of variant samples (QD)")
public final class QualByDepth extends InfoFieldAnnotation implements StandardAnnotation {
public final class QualByDepth implements InfoFieldAnnotation, StandardAnnotation {

@VisibleForTesting
static final double MAX_QD_BEFORE_FIXING = 35;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
*
*/
@DocumentedFeature(groupName=HelpConstants.DOC_CAT_ANNOTATORS, groupSummary=HelpConstants.DOC_CAT_ANNOTATORS_SUMMARY, summary="Root mean square of the mapping quality of reads across all samples (MQ)")
public final class RMSMappingQuality extends InfoFieldAnnotation implements StandardAnnotation, ReducibleAnnotation {
public final class RMSMappingQuality implements InfoFieldAnnotation, StandardAnnotation, ReducibleAnnotation {
private static final OneShotLogger logger = new OneShotLogger(RMSMappingQuality.class);
private static final RMSMappingQuality instance = new RMSMappingQuality();
private static final int NUM_LIST_ENTRIES = 2;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
/**
* Abstract root for all RankSum based annotations
*/
public abstract class RankSumTest extends InfoFieldAnnotation implements Annotation {
public abstract class RankSumTest implements InfoFieldAnnotation, Annotation {
protected final static double INVALID_ELEMENT_FROM_READ = Double.NEGATIVE_INFINITY;

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
*
*/
@DocumentedFeature(groupName=HelpConstants.DOC_CAT_ANNOTATORS, groupSummary=HelpConstants.DOC_CAT_ANNOTATORS_SUMMARY, summary="Annotate with local reference bases (REF_BASES)")
public class ReferenceBases extends InfoFieldAnnotation {
public class ReferenceBases implements InfoFieldAnnotation {
public static final String REFERENCE_BASES_KEY = "REF_BASES";

private int NUM_BASES_ON_EITHER_SIDE = 10;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
* difficult to manually match with sample names.</p>
*/
@DocumentedFeature(groupName=HelpConstants.DOC_CAT_ANNOTATORS, groupSummary=HelpConstants.DOC_CAT_ANNOTATORS_SUMMARY, summary="List of samples that are not homozygous reference at a variant site (Samples)")
public final class SampleList extends InfoFieldAnnotation {
public final class SampleList implements InfoFieldAnnotation {

@Override
public Map<String, Object> annotate(final ReferenceContext ref,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
* </ul>
*/
@DocumentedFeature(groupName=HelpConstants.DOC_CAT_ANNOTATORS, groupSummary=HelpConstants.DOC_CAT_ANNOTATORS_SUMMARY, summary="Number of forward and reverse reads that support REF and ALT alleles (SB)")
public final class StrandBiasBySample extends GenotypeAnnotation implements StandardMutectAnnotation {
public final class StrandBiasBySample implements GenotypeAnnotation, StandardMutectAnnotation {
private final static Logger logger = LogManager.getLogger(StrandBiasBySample.class);

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import org.broadinstitute.hellbender.exceptions.GATKException;
import org.broadinstitute.hellbender.utils.Utils;
import org.broadinstitute.hellbender.utils.genotyper.AlleleLikelihoods;
import org.broadinstitute.hellbender.utils.pileup.PileupElement;
import org.broadinstitute.hellbender.utils.read.GATKRead;
import org.broadinstitute.hellbender.utils.variant.GATKVCFConstants;

Expand All @@ -17,7 +16,7 @@
/**
* Class of tests to detect strand bias.
*/
public abstract class StrandBiasTest extends InfoFieldAnnotation {
public abstract class StrandBiasTest implements InfoFieldAnnotation {

protected static final int ARRAY_DIM = 2;
protected static final int ARRAY_SIZE = ARRAY_DIM * ARRAY_DIM;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
* <p>A tandem repeat unit is composed of one or more nucleotides that are repeated multiple times in series. Repetitive sequences are difficult to map to the reference because they are associated with multiple alignment possibilities. Knowing the number of repeat units in a set of tandem repeats tells you the number of different positions the tandem repeat can be placed in. The observation of many tandem repeat units multiplies the number of possible representations that can be made of the region.
*/
@DocumentedFeature(groupName=HelpConstants.DOC_CAT_ANNOTATORS, groupSummary=HelpConstants.DOC_CAT_ANNOTATORS_SUMMARY, summary="Tandem repeat unit composition and counts per allele (STR, RU, RPA)")
public final class TandemRepeat extends InfoFieldAnnotation implements StandardMutectAnnotation {
public final class TandemRepeat implements InfoFieldAnnotation, StandardMutectAnnotation {

@Override
public Map<String, Object> annotate(final ReferenceContext ref,
Expand Down
Loading

0 comments on commit 66d1614

Please sign in to comment.