All standard annotations now inherit from StandardVariantAnnotation. Users can specify whether they want all annotations, just the standard annotations, or specific annotations. When calling in from another walker, the default is just the standard ones.

git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@2134 348d0f76-0448-11de-a6fe-93d51630548a
This commit is contained in:
ebanks 2009-11-24 03:55:12 +00:00
parent ee5093d2c6
commit 36d493e645
11 changed files with 36 additions and 22 deletions

View File

@ -8,7 +8,7 @@ import java.util.List;
import java.util.ArrayList;
public class AlleleBalance implements VariantAnnotation {
public class AlleleBalance extends StandardVariantAnnotation {
public Pair<String, String> annotate(ReferenceContext ref, ReadBackedPileup pileup, List<Genotype> genotypes) {

View File

@ -8,7 +8,7 @@ import org.broadinstitute.sting.utils.genotype.Genotype;
import java.util.List;
public class DepthOfCoverage implements VariantAnnotation {
public class DepthOfCoverage extends StandardVariantAnnotation {
public Pair<String, String> annotate(ReferenceContext ref, ReadBackedPileup pileup, List<Genotype> genotypes) {
int depth = pileup.getReads().size();

View File

@ -11,7 +11,7 @@ import cern.jet.math.Arithmetic;
import java.util.List;
public class FisherStrand implements VariantAnnotation {
public class FisherStrand extends StandardVariantAnnotation {
public Pair<String, String> annotate(ReferenceContext ref, ReadBackedPileup pileup, List<Genotype> genotypes) {

View File

@ -9,7 +9,7 @@ import org.broadinstitute.sting.utils.genotype.Genotype;
import java.util.List;
public class HomopolymerRun implements VariantAnnotation {
public class HomopolymerRun extends StandardVariantAnnotation {
public Pair<String, String> annotate(ReferenceContext ref, ReadBackedPileup pileup, List<Genotype> genotypes) {

View File

@ -9,7 +9,7 @@ import net.sf.samtools.SAMRecord;
import java.util.List;
public class MappingQualityZero implements VariantAnnotation {
public class MappingQualityZero extends StandardVariantAnnotation {
public Pair<String, String> annotate(ReferenceContext ref, ReadBackedPileup pileup, List<Genotype> genotypes) {
List<SAMRecord> reads = pileup.getReads();

View File

@ -10,7 +10,7 @@ import org.broadinstitute.sting.utils.genotype.DiploidGenotype;
import java.util.List;
import java.util.ArrayList;
public class OnOffGenotype implements VariantAnnotation {
public class OnOffGenotype extends StandardVariantAnnotation {
public Pair<String, String> annotate(ReferenceContext ref, ReadBackedPileup pileup, List<Genotype> genotypes) {

View File

@ -10,7 +10,7 @@ import net.sf.samtools.SAMRecord;
import java.util.List;
public class RMSMappingQuality implements VariantAnnotation {
public class RMSMappingQuality extends StandardVariantAnnotation {
public Pair<String, String> annotate(ReferenceContext ref, ReadBackedPileup pileup, List<Genotype> genotypes) {
List<SAMRecord> reads = pileup.getReads();

View File

@ -8,7 +8,7 @@ import org.broadinstitute.sting.utils.genotype.Genotype;
import java.util.List;
public class SpanningDeletions implements VariantAnnotation {
public class SpanningDeletions extends StandardVariantAnnotation {
public Pair<String, String> annotate(ReferenceContext ref, ReadBackedPileup pileup, List<Genotype> genotypes) {
int deletions = 0;

View File

@ -0,0 +1,6 @@
package org.broadinstitute.sting.gatk.walkers.annotator;
public abstract class StandardVariantAnnotation implements VariantAnnotation {
}

View File

@ -31,6 +31,8 @@ public class VariantAnnotator extends RodWalker<Integer, Integer> {
protected String[] ANNOTATIONS;
@Argument(fullName="useAllAnnotations", shortName="all", doc="Use all possible annotations", required=false)
protected Boolean USE_ALL_ANNOTATIONS = false;
@Argument(fullName="useStandardAnnotations", shortName="standard", doc="Use all standard annotations", required=false)
protected Boolean USE_STANDARD_ANNOTATIONS = false;
@Argument(fullName="list", shortName="ls", doc="List the available annotations and exit")
protected Boolean LIST = false;
@ -43,15 +45,19 @@ public class VariantAnnotator extends RodWalker<Integer, Integer> {
// mapping from class name to class
private static HashMap<String, VariantAnnotation> allAnnotations = null;
private static HashMap<String, VariantAnnotation> standardAnnotations = null;
private static void determineAllAnnotations() {
allAnnotations = new HashMap<String, VariantAnnotation>();
standardAnnotations = new HashMap<String, VariantAnnotation>();
List<Class<? extends VariantAnnotation>> annotationClasses = PackageUtils.getClassesImplementingInterface(VariantAnnotation.class);
for ( Class c : annotationClasses ) {
try {
VariantAnnotation annot = (VariantAnnotation) c.newInstance();
allAnnotations.put(c.getSimpleName().toUpperCase(), annot);
if ( annot instanceof StandardVariantAnnotation )
standardAnnotations.put(c.getSimpleName().toUpperCase(), annot);
} catch (InstantiationException e) {
throw new StingException(String.format("Cannot instantiate annotation class '%s': must be concrete class", c.getSimpleName()));
} catch (IllegalAccessException e) {
@ -93,7 +99,9 @@ public class VariantAnnotator extends RodWalker<Integer, Integer> {
determineAllAnnotations();
if ( USE_ALL_ANNOTATIONS ) {
if ( USE_STANDARD_ANNOTATIONS ) {
requestedAnnotations = new ArrayList<VariantAnnotation>(standardAnnotations.values());
} else if ( USE_ALL_ANNOTATIONS ) {
requestedAnnotations = new ArrayList<VariantAnnotation>(allAnnotations.values());
} else {
requestedAnnotations = new ArrayList<VariantAnnotation>();
@ -170,9 +178,9 @@ public class VariantAnnotator extends RodWalker<Integer, Integer> {
}
public static Map<String, String> getAnnotations(ReferenceContext ref, AlignmentContext context, List<Genotype> genotypes) {
if ( allAnnotations == null )
if ( standardAnnotations == null )
determineAllAnnotations();
return getAnnotations(ref, context, genotypes, allAnnotations.values());
return getAnnotations(ref, context, genotypes, standardAnnotations.values());
}
public static Map<String, String> getAnnotations(ReferenceContext ref, AlignmentContext context, List<Genotype> genotypes, Collection<VariantAnnotation> annotations) {

View File

@ -47,7 +47,7 @@ public class UnifiedGenotyperIntegrationTest extends WalkerTest {
public void testMultiSamplePilot1PointEM() {
WalkerTest.WalkerTestSpec spec = new WalkerTest.WalkerTestSpec(
"-T UnifiedGenotyper -R /broad/1KG/reference/human_b36_both.fasta -I /humgen/gsa-scr1/GATK_Data/Validation_Data/low_coverage_CEU.chr1.10k-11k.bam -varout %s -L 1:10,023,400-10,024,000 -bm empirical -gm EM_POINT_ESTIMATE -confidence 30", 1,
Arrays.asList("623d98aa3ad025b4bace1f5f3fe48a91"));
Arrays.asList("fbb3ae6e835df5cf9b99dae5bf1fa8e5"));
executeTest("testMultiSamplePilot1 - Point Estimate EM", spec);
}
@ -81,7 +81,7 @@ public class UnifiedGenotyperIntegrationTest extends WalkerTest {
public void testMultiSamplePilot1Joint() {
WalkerTest.WalkerTestSpec spec = new WalkerTest.WalkerTestSpec(
"-T UnifiedGenotyper -R /broad/1KG/reference/human_b36_both.fasta -I /humgen/gsa-scr1/GATK_Data/Validation_Data/low_coverage_CEU.chr1.10k-11k.bam -varout %s -L 1:10,022,000-10,025,000 -bm empirical -gm JOINT_ESTIMATE -confidence 30", 1,
Arrays.asList("348e874b121ce663404344290dd63d42"));
Arrays.asList("e1a206a49982f7db5c3f4b65aa910b3a"));
executeTest("testMultiSamplePilot1 - Joint Estimate", spec);
}
@ -89,7 +89,7 @@ public class UnifiedGenotyperIntegrationTest extends WalkerTest {
public void testMultiSamplePilot2Joint() {
WalkerTest.WalkerTestSpec spec = new WalkerTest.WalkerTestSpec(
"-T UnifiedGenotyper -R /broad/1KG/reference/human_b36_both.fasta -I /humgen/gsa-scr1/GATK_Data/Validation_Data/pilot2_daughters.chr20.10k-11k.bam -varout %s -L 20:10,000,000-10,050,000 -bm empirical -gm JOINT_ESTIMATE -confidence 30", 1,
Arrays.asList("49653e64ac0999ff1c9c5b129c689dea"));
Arrays.asList("cec6081d89ada9b2924fe38c7a021921"));
executeTest("testMultiSamplePilot2 - Joint Estimate", spec);
}
@ -97,17 +97,17 @@ public class UnifiedGenotyperIntegrationTest extends WalkerTest {
public void testSingleSamplePilot2Joint() {
WalkerTest.WalkerTestSpec spec = new WalkerTest.WalkerTestSpec(
"-T UnifiedGenotyper -R /broad/1KG/reference/human_b36_both.fasta -I /humgen/gsa-scr1/GATK_Data/Validation_Data/NA12878.1kg.p2.chr1_10mb_11_mb.SLX.bam -varout %s -L 1:10,000,000-10,100,000 -bm empirical -gm JOINT_ESTIMATE -confidence 30", 1,
Arrays.asList("b2e037adb2c6967d5eb041ae7268e035"));
Arrays.asList("0cd57b2b6272202db0eca45376fdb01d"));
executeTest("testSingleSamplePilot2 - Joint Estimate", spec);
}
@Test
public void testGLF() {
WalkerTest.WalkerTestSpec spec = new WalkerTest.WalkerTestSpec(
"-T UnifiedGenotyper -R /broad/1KG/reference/human_b36_both.fasta -I /humgen/gsa-scr1/GATK_Data/Validation_Data/NA12878.1kg.p2.chr1_10mb_11_mb.SLX.bam -varout %s -L 1:10,000,000-10,050,000 -bm empirical -gm JOINT_ESTIMATE -confidence 10", 1,
Arrays.asList("c552f3adcad91ee5f3ce42c204026a68"));
executeTest("testGLF", spec);
}
//@Test
//public void testGLF() {
// WalkerTest.WalkerTestSpec spec = new WalkerTest.WalkerTestSpec(
// "-T UnifiedGenotyper -R /broad/1KG/reference/human_b36_both.fasta -I /humgen/gsa-scr1/GATK_Data/Validation_Data/NA12878.1kg.p2.chr1_10mb_11_mb.SLX.bam -varout %s -L 1:10,000,000-10,050,000 -bm empirical -gm JOINT_ESTIMATE -confidence 10", 1,
// Arrays.asList("a95b871bc0bc984f66815b20db7467fe"));
// executeTest("testGLF", spec);
//}
// --------------------------------------------------------------------------------------------------------------
//