From df7a48233549598703bd07609d77ed57e2ced3bc Mon Sep 17 00:00:00 2001 From: Takuto Sato Date: Fri, 25 Sep 2015 15:35:06 -0400 Subject: [PATCH] VariantAnnotator now supports annotating FILTER field from an external resource. Updated the docs. --- .../annotator/VariantAnnotatorIntegrationTest.java | 9 +++++++++ .../tools/walkers/annotator/VariantAnnotator.java | 14 ++++++++++++++ .../walkers/annotator/VariantAnnotatorEngine.java | 6 ++++++ 3 files changed, 29 insertions(+) diff --git a/protected/gatk-tools-protected/src/test/java/org/broadinstitute/gatk/tools/walkers/annotator/VariantAnnotatorIntegrationTest.java b/protected/gatk-tools-protected/src/test/java/org/broadinstitute/gatk/tools/walkers/annotator/VariantAnnotatorIntegrationTest.java index 8315a28fb..515888a09 100644 --- a/protected/gatk-tools-protected/src/test/java/org/broadinstitute/gatk/tools/walkers/annotator/VariantAnnotatorIntegrationTest.java +++ b/protected/gatk-tools-protected/src/test/java/org/broadinstitute/gatk/tools/walkers/annotator/VariantAnnotatorIntegrationTest.java @@ -259,6 +259,15 @@ public class VariantAnnotatorIntegrationTest extends WalkerTest { executeTest("using expression with multi-alleles", spec); } + @Test + public void testFilterInExpression(){ + /* The order of filters in the output seems platform-dependent. May need to change htsjdk to make the order consistent across platforms. [Sato] */ + WalkerTestSpec spec = new WalkerTestSpec( + baseTestString() + " --resource:foo " + privateTestDir + "annotationResourceWithFilter.vcf" + STANDARD_ANNOTATIONS + "--variant " + privateTestDir + "vcfexample3empty-multiAllele.vcf -E foo.FILTER -L " + privateTestDir + "vcfexample3empty-multiAllele.vcf", 1, + Arrays.asList("77bc144fd432b8886ab19ed20bfb9396")); + executeTest("annotate a vcf with the FILTER field of another vcf", spec); + } + @Test public void testUsingExpressionWithID() { WalkerTestSpec spec = new WalkerTestSpec( diff --git a/public/gatk-tools-public/src/main/java/org/broadinstitute/gatk/tools/walkers/annotator/VariantAnnotator.java b/public/gatk-tools-public/src/main/java/org/broadinstitute/gatk/tools/walkers/annotator/VariantAnnotator.java index 1529ed71b..ca386e8d8 100644 --- a/public/gatk-tools-public/src/main/java/org/broadinstitute/gatk/tools/walkers/annotator/VariantAnnotator.java +++ b/public/gatk-tools-public/src/main/java/org/broadinstitute/gatk/tools/walkers/annotator/VariantAnnotator.java @@ -97,6 +97,19 @@ import java.util.*; * -E foo.AF * --resourceAlleleConcordance * + * + *

Annotate with AF and FILTER fields from an external resource

+ *
+ * java -jar GenomeAnalysisTK.jar \
+ *   -R reference.fasta \
+ *   -T VariantAnnotator \
+ *   -o output.vcf \
+ *   --resource:foo resource.vcf \
+ *   --expression foo.AF \
+ *   --expression foo.FILTER \
+ *   -V input.vcf \
+ * 
+ * */ @DocumentedGATKFeature( groupName = HelpConstants.DOCS_CAT_VARMANIP, extraDocs = {CommandLineGATK.class} ) @Requires(value={}) @@ -181,6 +194,7 @@ public class VariantAnnotator extends RodWalker implements Ann * 'resource_file.vcf', you tag it with '-resource:my_resource resource_file.vcf' (see the -resource argument, also * documented on this page) and you specify '-E my_resource.AC'. In the resulting output VCF, any records for * which there is a record at the same position in the resource file will be annotated with 'my_resource.AC=N'. + * INFO field data, ID, ALT, and FILTER fields may be used as expression values. * Note that if there are multiple records in the resource file that overlap the given position, one is chosen * randomly. */ diff --git a/public/gatk-tools-public/src/main/java/org/broadinstitute/gatk/tools/walkers/annotator/VariantAnnotatorEngine.java b/public/gatk-tools-public/src/main/java/org/broadinstitute/gatk/tools/walkers/annotator/VariantAnnotatorEngine.java index 3adcbac3f..a9d14c2ce 100644 --- a/public/gatk-tools-public/src/main/java/org/broadinstitute/gatk/tools/walkers/annotator/VariantAnnotatorEngine.java +++ b/public/gatk-tools-public/src/main/java/org/broadinstitute/gatk/tools/walkers/annotator/VariantAnnotatorEngine.java @@ -304,6 +304,12 @@ public class VariantAnnotatorEngine { infoAnnotations.put(expression.fullName, expressionVC.getID()); } else if (expression.fieldName.equals("ALT")) { infoAnnotations.put(expression.fullName, expressionVC.getAlternateAllele(0).getDisplayString()); + } else if (expression.fieldName.equals("FILTER")) { + if ( expressionVC.isFiltered() ) { + infoAnnotations.put(expression.fullName, expressionVC.getFilters().toString().replace("[", "").replace("]", "").replace(" ", "")); + } else { + infoAnnotations.put(expression.fullName, "PASS"); + } } else if ( expressionVC.hasAttribute(expression.fieldName) ) { // find the info field final VCFInfoHeaderLine hInfo = hInfoMap.get(expression.fullName);