Moving VF to vcf 4.0. Still need to fix genotype filters.

git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@3777 348d0f76-0448-11de-a6fe-93d51630548a
This commit is contained in:
ebanks 2010-07-13 11:39:51 +00:00
parent 76b3b39720
commit d896d03554
2 changed files with 14 additions and 14 deletions

View File

@ -46,7 +46,7 @@ import java.util.*;
/** /**
* Filters variant calls using a number of user-selectable, parameterizable criteria. * Filters variant calls using a number of user-selectable, parameterizable criteria.
*/ */
@Requires(value={},referenceMetaData=@RMD(name="variant",type= ReferenceOrderedDatum.class)) @Requires(value={},referenceMetaData=@RMD(name="variant", type=ReferenceOrderedDatum.class))
@Reference(window=@Window(start=-50,stop=50)) @Reference(window=@Window(start=-50,stop=50))
public class VariantFiltrationWalker extends RodWalker<Integer, Integer> { public class VariantFiltrationWalker extends RodWalker<Integer, Integer> {
@ -84,7 +84,7 @@ public class VariantFiltrationWalker extends RodWalker<Integer, Integer> {
private ArrayList<FiltrationContext> windowInitializer = new ArrayList<FiltrationContext>(); private ArrayList<FiltrationContext> windowInitializer = new ArrayList<FiltrationContext>();
private void initializeVcfWriter(VCFRecord rec) { private void initializeVcfWriter(VariantContext vc) {
// setup the header fields // setup the header fields
Set<VCFHeaderLine> hInfo = new HashSet<VCFHeaderLine>(); Set<VCFHeaderLine> hInfo = new HashSet<VCFHeaderLine>();
hInfo.addAll(VCFUtils.getHeaderFields(getToolkit())); hInfo.addAll(VCFUtils.getHeaderFields(getToolkit()));
@ -110,8 +110,8 @@ public class VariantFiltrationWalker extends RodWalker<Integer, Integer> {
} }
} }
writer = new VCFWriter(out); writer = new VCFWriter(out, true);
writer.writeHeader(new VCFHeader(hInfo, new TreeSet<String>(Arrays.asList(rec.getSampleNames())))); writer.writeHeader(new VCFHeader(hInfo, new TreeSet<String>(vc.getSampleNames())));
} }
public void initialize() { public void initialize() {
@ -210,13 +210,13 @@ public class VariantFiltrationWalker extends RodWalker<Integer, Integer> {
VariantContext filteredVC = new VariantContext(vc.getName(), vc.getLocation(), vc.getAlleles(), genotypes, vc.getNegLog10PError(), filters, vc.getAttributes()); VariantContext filteredVC = new VariantContext(vc.getName(), vc.getLocation(), vc.getAlleles(), genotypes, vc.getNegLog10PError(), filters, vc.getAttributes());
writeVCF(VariantContextAdaptors.toVCF(filteredVC, context.getReferenceContext().getBase(), null, true, genotypeFilterExps.size() > 0)); writeVCF(filteredVC, context.getReferenceContext().getBase());
} }
private void writeVCF(VCFRecord rec) { private void writeVCF(VariantContext vc, byte ref) {
if ( writer == null ) if ( writer == null )
initializeVcfWriter(rec); initializeVcfWriter(vc);
writer.addRecord(rec); writer.add(vc, new byte[]{ref});
} }
public Integer reduce(Integer value, Integer sum) { public Integer reduce(Integer value, Integer sum) {

View File

@ -16,7 +16,7 @@ public class VariantFiltrationIntegrationTest extends WalkerTest {
public void testNoAction() { public void testNoAction() {
WalkerTestSpec spec = new WalkerTestSpec( WalkerTestSpec spec = new WalkerTestSpec(
baseTestString() + " -B variant,VCF," + validationDataLocation + "vcfexample2.vcf -L 1:10,020,000-10,021,000", 1, baseTestString() + " -B variant,VCF," + validationDataLocation + "vcfexample2.vcf -L 1:10,020,000-10,021,000", 1,
Arrays.asList("d2f0a3c6e598d9054de9ea7bd914a12d")); Arrays.asList("d1aec615dba4d91991f4c67cadf3d56a"));
executeTest("test no action", spec); executeTest("test no action", spec);
} }
@ -24,7 +24,7 @@ public class VariantFiltrationIntegrationTest extends WalkerTest {
public void testClusteredSnps() { public void testClusteredSnps() {
WalkerTestSpec spec = new WalkerTestSpec( WalkerTestSpec spec = new WalkerTestSpec(
baseTestString() + " -window 10 -B variant,VCF," + validationDataLocation + "vcfexample2.vcf -L 1:10,020,000-10,021,000", 1, baseTestString() + " -window 10 -B variant,VCF," + validationDataLocation + "vcfexample2.vcf -L 1:10,020,000-10,021,000", 1,
Arrays.asList("4dad2ddfb74785c5c80c2a73709e543a")); Arrays.asList("fa522e5b8c89c5a465ca03dd88bc2b8f"));
executeTest("test clustered SNPs", spec); executeTest("test clustered SNPs", spec);
} }
@ -32,7 +32,7 @@ public class VariantFiltrationIntegrationTest extends WalkerTest {
public void testMask() { public void testMask() {
WalkerTestSpec spec = new WalkerTestSpec( WalkerTestSpec spec = new WalkerTestSpec(
baseTestString() + " -mask foo -B mask,VCF," + validationDataLocation + "vcfexample2.vcf -B variant,VCF," + validationDataLocation + "vcfexample2.vcf -L 1:10,020,000-10,021,000", 1, baseTestString() + " -mask foo -B mask,VCF," + validationDataLocation + "vcfexample2.vcf -B variant,VCF," + validationDataLocation + "vcfexample2.vcf -L 1:10,020,000-10,021,000", 1,
Arrays.asList("70fc964e73fda55ed3f2c0b0ae4bcec1")); Arrays.asList("4d8a184417289c325410a5e545d9fc80"));
executeTest("test mask", spec); executeTest("test mask", spec);
} }
@ -40,7 +40,7 @@ public class VariantFiltrationIntegrationTest extends WalkerTest {
public void testFilter1() { public void testFilter1() {
WalkerTestSpec spec = new WalkerTestSpec( WalkerTestSpec spec = new WalkerTestSpec(
baseTestString() + " -filter 'DoC < 20 || FisherStrand > 20.0' -filterName foo -B variant,VCF," + validationDataLocation + "vcfexample2.vcf -L 1:10,020,000-10,021,000", 1, baseTestString() + " -filter 'DoC < 20 || FisherStrand > 20.0' -filterName foo -B variant,VCF," + validationDataLocation + "vcfexample2.vcf -L 1:10,020,000-10,021,000", 1,
Arrays.asList("bde496530822a81197df31f5ecf98033")); Arrays.asList("d48062f139d853a61e4f0bfb76bd695d"));
executeTest("test filter #1", spec); executeTest("test filter #1", spec);
} }
@ -48,7 +48,7 @@ public class VariantFiltrationIntegrationTest extends WalkerTest {
public void testFilter2() { public void testFilter2() {
WalkerTestSpec spec = new WalkerTestSpec( WalkerTestSpec spec = new WalkerTestSpec(
baseTestString() + " -filter 'AlleleBalance < 70.0 && FisherStrand == 1.4' -filterName bar -B variant,VCF," + validationDataLocation + "vcfexample2.vcf -L 1:10,020,000-10,021,000", 1, baseTestString() + " -filter 'AlleleBalance < 70.0 && FisherStrand == 1.4' -filterName bar -B variant,VCF," + validationDataLocation + "vcfexample2.vcf -L 1:10,020,000-10,021,000", 1,
Arrays.asList("750f5076e906901dabec78f804f035fa")); Arrays.asList("791f89c6da7bdde79913754d9ddb72eb"));
executeTest("test filter #2", spec); executeTest("test filter #2", spec);
} }
@ -56,7 +56,7 @@ public class VariantFiltrationIntegrationTest extends WalkerTest {
public void testFilterWithSeparateNames() { public void testFilterWithSeparateNames() {
WalkerTestSpec spec = new WalkerTestSpec( WalkerTestSpec spec = new WalkerTestSpec(
baseTestString() + " --filterName ABF -filter 'AlleleBalance < 70.0' --filterName FSF -filter 'FisherStrand == 1.4' -B variant,VCF," + validationDataLocation + "vcfexample2.vcf -L 1:10,020,000-10,021,000", 1, baseTestString() + " --filterName ABF -filter 'AlleleBalance < 70.0' --filterName FSF -filter 'FisherStrand == 1.4' -B variant,VCF," + validationDataLocation + "vcfexample2.vcf -L 1:10,020,000-10,021,000", 1,
Arrays.asList("7f876c9187948d27c0cd39f5a0395e0e")); Arrays.asList("174caf880477f3edf68fe6722f227017"));
executeTest("test filter with separate names #2", spec); executeTest("test filter with separate names #2", spec);
} }
} }