VariantFiltration now details the filters it has used in the header of the VCF it produces.

git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@2292 348d0f76-0448-11de-a6fe-93d51630548a
This commit is contained in:
ebanks 2009-12-09 15:36:15 +00:00
parent 7a76e13459
commit fb900b12e1
2 changed files with 20 additions and 5 deletions

View File

@ -3,6 +3,7 @@ package org.broadinstitute.sting.gatk.walkers.filters;
import org.broadinstitute.sting.gatk.contexts.*;
import org.broadinstitute.sting.gatk.refdata.*;
import org.broadinstitute.sting.gatk.walkers.*;
import org.broadinstitute.sting.gatk.datasources.simpleDataSources.ReferenceOrderedDataSource;
import org.broadinstitute.sting.utils.*;
import org.broadinstitute.sting.utils.genotype.vcf.*;
import org.broadinstitute.sting.utils.cmdLine.Argument;
@ -29,6 +30,9 @@ public class VariantFiltrationWalker extends RodWalker<Integer, Integer> {
@Argument(fullName="maskName", shortName="mask", doc="The text to put in the FILTER field if a 'mask' rod is provided and overlaps with a variant call", required=false)
protected String MASK_NAME = "Mask";
public static final String CLUSTERED_SNP_FILTER_NAME = "SnpCluster";
private VCFWriter writer = null;
private ClusteredSnps clusteredSNPs = null;
@ -47,6 +51,17 @@ public class VariantFiltrationWalker extends RodWalker<Integer, Integer> {
hInfo.addAll(VCFUtils.getHeaderFields(getToolkit()));
hInfo.add("source=" + "VariantFiltration");
hInfo.add("reference=" + getToolkit().getArguments().referenceFile.getName());
if ( clusterWindow > 0 )
hInfo.add("FILTER=" + CLUSTERED_SNP_FILTER_NAME + ",\"SNPs found in clusters\"");
if ( filterExpression != null )
hInfo.add("FILTER=" + FILTER_NAME + ",\"" + FILTER_STRING + "\"");
List<ReferenceOrderedDataSource> dataSources = getToolkit().getRodDataSources();
for ( ReferenceOrderedDataSource source : dataSources ) {
if ( source.getReferenceOrderedData().getName().equals("mask") ) {
hInfo.add("FILTER=" + MASK_NAME + ",\"Overlaps a user-input mask\"");
break;
}
}
VCFHeader header = new VCFHeader(hInfo, rod.getHeader().getGenotypeSamples());
writer = new VCFWriter(header, out);
@ -116,7 +131,7 @@ public class VariantFiltrationWalker extends RodWalker<Integer, Integer> {
// test for clustered SNPs if requested
if ( clusteredSNPs != null && clusteredSNPs.filter(variantContextWindow) )
addFilter(filterString, "SnpCluster");
addFilter(filterString, CLUSTERED_SNP_FILTER_NAME);
if ( filterExpression != null ) {
Map<String, String> infoMap = new HashMap<String, String>(context.second.mCurrentRecord.getInfoValues());

View File

@ -24,7 +24,7 @@ public class VariantFiltrationIntegrationTest extends WalkerTest {
public void testClusteredSnps() {
WalkerTestSpec spec = new WalkerTestSpec(
baseTestString() + " -window 10 -B variant,VCF,/humgen/gsa-scr1/GATK_Data/Validation_Data/vcfexample2.vcf -L 1:10,020,000-10,021,000", 1,
Arrays.asList("ee5e4e00bf25a912e8cab3e768fa0e7d"));
Arrays.asList("7a1e834a372c3f3acfde82942be8c86c"));
executeTest("test clustered SNPs", spec);
}
@ -32,7 +32,7 @@ public class VariantFiltrationIntegrationTest extends WalkerTest {
public void testMask() {
WalkerTestSpec spec = new WalkerTestSpec(
baseTestString() + " -mask foo -B mask,VCF,/humgen/gsa-scr1/GATK_Data/Validation_Data/vcfexample2.vcf -B variant,VCF,/humgen/gsa-scr1/GATK_Data/Validation_Data/vcfexample2.vcf -L 1:10,020,000-10,021,000", 1,
Arrays.asList("77451c3ba8a070343e69157cdaf2be92"));
Arrays.asList("6b33aab1f199bd7856256dabdf729e1a"));
executeTest("test mask", spec);
}
@ -40,7 +40,7 @@ public class VariantFiltrationIntegrationTest extends WalkerTest {
public void testFilter1() {
WalkerTestSpec spec = new WalkerTestSpec(
baseTestString() + " -filter 'DoC < 20 || FisherStrand > 20.0' -filterName foo -B variant,VCF,/humgen/gsa-scr1/GATK_Data/Validation_Data/vcfexample2.vcf -L 1:10,020,000-10,021,000", 1,
Arrays.asList("3b44be79d676536bd6c0f32774091fee"));
Arrays.asList("7757178f6337e4c49097f62e8949f986"));
executeTest("test filter #1", spec);
}
@ -48,7 +48,7 @@ public class VariantFiltrationIntegrationTest extends WalkerTest {
public void testFilter2() {
WalkerTestSpec spec = new WalkerTestSpec(
baseTestString() + " -filter 'AlleleBalance < 70.0 && FisherStrand == 1.4' -filterName bar -B variant,VCF,/humgen/gsa-scr1/GATK_Data/Validation_Data/vcfexample2.vcf -L 1:10,020,000-10,021,000", 1,
Arrays.asList("baa425fa8e0761a05733a1a9d62d02ff"));
Arrays.asList("25354adffa90857be2900a0369cb2709"));
executeTest("test filter #2", spec);
}
}