From 9134bf31291459213d02391194fad170f78c56ad Mon Sep 17 00:00:00 2001 From: delangel Date: Wed, 13 Apr 2011 14:58:44 +0000 Subject: [PATCH] Long-forgotten change I neglected to commit a while back: add ability for SelectVariants to extracts either SNPs or Indels from combined vcf file. Not the ideal place to do it but it's important to at least have something to split vcfs now that we call snp's and indels combined. git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@5624 348d0f76-0448-11de-a6fe-93d51630548a --- .../walkers/variantutils/SelectVariants.java | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/java/src/org/broadinstitute/sting/gatk/walkers/variantutils/SelectVariants.java b/java/src/org/broadinstitute/sting/gatk/walkers/variantutils/SelectVariants.java index ec5ddfd64..e0415ce82 100755 --- a/java/src/org/broadinstitute/sting/gatk/walkers/variantutils/SelectVariants.java +++ b/java/src/org/broadinstitute/sting/gatk/walkers/variantutils/SelectVariants.java @@ -89,6 +89,12 @@ public class SelectVariants extends RodWalker { @Argument(fullName="select_random_fraction", shortName="fraction", doc="Selects a fraction (a number between 0 and 1) of the total variants at random from the variant track. Routine is based on probability, so the final result is not guaranteed to carry the exact fraction. Can be used for large fractions", required=false) private double fractionRandom = 0; + @Argument(fullName="selectSNPs", shortName="snps", doc="Select only SNPs.", required=false) + private boolean SELECT_SNPS = false; + + @Argument(fullName="selectIndels", shortName="indels", doc="Select only SNPs.", required=false) + private boolean SELECT_INDELS = false; + /* Private class used to store the intermediate variants in the integer random selection process */ private class RandomVariantStructure { @@ -211,7 +217,7 @@ public class SelectVariants extends RodWalker { // if the genotype of any of the samples we're looking it is HET or HomVar, we write this variant for (String sample : samples) { Genotype g = compVC.getGenotype(sample); - if ( g != null && (g.isHet() || g.isHomVar()) ) { + if ( g.isHet() || g.isHomVar() ) { vcfWriter.add(compVC, ref.getBase()); return 1; } @@ -240,6 +246,14 @@ public class SelectVariants extends RodWalker { } else { + // TODO - add ability to also select MNPs + // TODO - move variant selection arguments to the engine so other walkers can also do this + if (SELECT_INDELS && vc.isSNP()) + return 0; + + if (SELECT_SNPS && (vc.isIndel() || vc.isMixed())) + return 0; + VariantContext sub = subsetRecord(vc, samples); if ( (sub.isPolymorphic() || !EXCLUDE_NON_VARIANTS) && (!sub.isFiltered() || !EXCLUDE_FILTERED) ) { //System.out.printf("%s%n",sub.toString());