From fb01bf36f21948e6531e16f69ae0fe13d9f7abe5 Mon Sep 17 00:00:00 2001 From: Marton Kanasz-Nagy Date: Fri, 30 Nov 2018 13:18:06 -0500 Subject: [PATCH] Completes #5260 on GitHub. (#5464) * Changed SelectVariants so that it van handle multiple rsIDs separated by ';' in a VCF file. * The tests testKeepSelectionIDLiteral and testKeepSelectionIDFromFile broke due to the change in the test file complexExample1.vcf. I modified the file testSelectVariants_KeepSelectionID.vcf appropriately so that the tests pass as they should. * Changes due to review by David Benjamin and Phil Shapiro. * Made the code in VariantIDsVariantFilter's test function more concise. --- .../hellbender/engine/filters/VariantIDsVariantFilter.java | 4 +++- .../walkers/variantutils/SelectVariants/complexExample1.vcf | 1 + .../expected/testSelectVariants_KeepSelectionID.vcf | 1 + 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/broadinstitute/hellbender/engine/filters/VariantIDsVariantFilter.java b/src/main/java/org/broadinstitute/hellbender/engine/filters/VariantIDsVariantFilter.java index 32d07e82d70..1298c8b87e5 100644 --- a/src/main/java/org/broadinstitute/hellbender/engine/filters/VariantIDsVariantFilter.java +++ b/src/main/java/org/broadinstitute/hellbender/engine/filters/VariantIDsVariantFilter.java @@ -5,6 +5,8 @@ import java.util.Set; import java.util.LinkedHashSet; +import java.util.*; +import java.util.stream.*; /** * Keep only variants with any of these IDs. @@ -22,6 +24,6 @@ public VariantIDsVariantFilter(Set keepIDs) { @Override public boolean test(final VariantContext vc) { - return includeIDs.contains(vc.getID()); + return Arrays.stream(vc.getID().split(";")).anyMatch(includeIDs::contains); } } diff --git a/src/test/resources/org/broadinstitute/hellbender/tools/walkers/variantutils/SelectVariants/complexExample1.vcf b/src/test/resources/org/broadinstitute/hellbender/tools/walkers/variantutils/SelectVariants/complexExample1.vcf index 6e8deacc026..7fd5f353b99 100644 --- a/src/test/resources/org/broadinstitute/hellbender/tools/walkers/variantutils/SelectVariants/complexExample1.vcf +++ b/src/test/resources/org/broadinstitute/hellbender/tools/walkers/variantutils/SelectVariants/complexExample1.vcf @@ -29,5 +29,6 @@ 1 10044557 . C T 62.22 . AF=0.50;AlleleBalance=0.68;DoC=31;HomopolymerRun=16;MAPQ0=0;NS=1;RMSMAPQ=85.34;SB=-0.00;SpanningDeletions=0 GT:DP:GQ ./. ./. 0/1:31:15 1 10045603 . AAAA A 40.26 PASS AF=0.50 GT:DP:GQ 0/1:15:8 0/0:15:8 1/1:15:8 1 10045604 . A ACAT 41.26 PASS AF=0.50 GT:DP:GQ 1/1:14:7 0/0:15:8 1/0:15:8 +1 10046982 testid0;testid1 C T 32.01 PASS AF=0.40;AlleleBalance=0.37;DoC=21;HomopolymerRun=0;MAPQ0=8;NS=1;RMSMAPQ=12.31;SB=-4.2;SpanningDeletions=0 GT:DP:GQ 1/0:3:49 ./. ./. 1 10048142 . A G 126.81 foo AF=1.00;DoC=36;HomopolymerRun=4;MAPQ0=0;NS=1;RMSMAPQ=82.11;SB=-85.45;SpanningDeletions=0 GT:DP:GQ 0/1:15:8 0/0:15:8 1/1:15:8 1 10048580 . T A 72.22 bar;baz AF=0.50;AlleleBalance=0.69;DoC=33;HomopolymerRun=6;MAPQ0=0;NS=1;RMSMAPQ=84.45;SB=-27.41;SpanningDeletions=0 GT:DP:GQ 0/1:15:8 0/0:15:8 1/1:15:8 diff --git a/src/test/resources/org/broadinstitute/hellbender/tools/walkers/variantutils/SelectVariants/expected/testSelectVariants_KeepSelectionID.vcf b/src/test/resources/org/broadinstitute/hellbender/tools/walkers/variantutils/SelectVariants/expected/testSelectVariants_KeepSelectionID.vcf index 9d41d7d9f6a..ee1dbfa312a 100644 --- a/src/test/resources/org/broadinstitute/hellbender/tools/walkers/variantutils/SelectVariants/expected/testSelectVariants_KeepSelectionID.vcf +++ b/src/test/resources/org/broadinstitute/hellbender/tools/walkers/variantutils/SelectVariants/expected/testSelectVariants_KeepSelectionID.vcf @@ -23,3 +23,4 @@ ##source=ArbitrarySource #CHROM POS ID REF ALT QUAL FILTER INFO FORMAT NA00001 NA00002 NA00003 1 10001292 testid1 G A 12.22 PASS AF=0.50;AlleleBalance=0.57;DoC=23;HomopolymerRun=0;MAPQ0=8;NS=1;RMSMAPQ=46.31;SB=-24.92;SpanningDeletions=0 GT:DP:GQ 1/0:23:19 ./. ./. +1 10046982 testid0;testid1 C T 32.01 PASS AF=0.40;AlleleBalance=0.37;DoC=21;HomopolymerRun=0;MAPQ0=8;NS=1;RMSMAPQ=12.31;SB=-4.2;SpanningDeletions=0 GT:DP:GQ 1/0:3:49 ./. ./.