Fixes to VE for obscure bug, as well as disabled integration test for CombineVariants

git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@3749 348d0f76-0448-11de-a6fe-93d51630548a
This commit is contained in:
depristo 2010-07-09 00:13:07 +00:00
parent 67f1589652
commit 45fb614296
4 changed files with 81 additions and 7 deletions

View File

@ -89,7 +89,7 @@ class VCF4Parser implements VCFLineParser {
switch (c) {
case ('<') : if (index == 0) break; // if we see a open bracket at the beginning, ignore it
case ('>') : if (index == valueLine.length()-1) ret.put(key,builder.toString().trim()); break; // if we see a close bracket, and we're at the end, add an entry to our list
case ('=') : key = builder.toString().trim(); builder = new StringBuilder(); break; // at an equals, copy the key and reset the builder
case ('=') : if (!inQuote) { key = builder.toString().trim(); builder = new StringBuilder(); } else { builder.append(c); } break; // at an equals, copy the key and reset the builder
case ('\"') : inQuote = !inQuote; break; // a quote means we ignore ',' in our strings, keep track of it
case (',') : if (!inQuote) { ret.put(key,builder.toString().trim()); builder = new StringBuilder(); break; } // drop the current key value to the return map
default: builder.append(c); // otherwise simply append to the current string

View File

@ -203,7 +203,7 @@ public class VariantEvalWalker extends RodWalker<Integer, Integer> {
public boolean isSelected() { return selectExp == null; }
public String getDisplayName() {
return Utils.join(".", Arrays.asList(evalTrackName, compTrackName, selectExp == null ? "all" : selectExp.name, filtered, novelty));
return Utils.join(CONTEXT_SEPARATOR, Arrays.asList(evalTrackName, compTrackName, selectExp == null ? "all" : selectExp.name, filtered, novelty));
}
public int compareTo(EvaluationContext other) {
@ -238,12 +238,14 @@ public class VariantEvalWalker extends RodWalker<Integer, Integer> {
private static String NO_COMP_NAME = "N/A";
private final static String CONTEXT_HEADER = "eval.comp.select.filter.novelty";
private final static int N_CONTEXT_NAME_PARTS = CONTEXT_HEADER.split("\\.").length;
private final static String CONTEXT_SEPARATOR = "XXX";
//private final static String CONTEXT_SEPARATOR = "\\.";
private final static String CONTEXT_HEADER = Utils.join(CONTEXT_SEPARATOR, Arrays.asList("eval", "comp", "select", "filter", "novelty"));
private final static int N_CONTEXT_NAME_PARTS = CONTEXT_HEADER.split(CONTEXT_SEPARATOR).length;
private static int[] nameSizes = new int[N_CONTEXT_NAME_PARTS];
static {
int i = 0;
for ( String elt : CONTEXT_HEADER.split("\\.") )
for ( String elt : CONTEXT_HEADER.split(CONTEXT_SEPARATOR) )
nameSizes[i++] = elt.length();
}
@ -642,7 +644,7 @@ public class VariantEvalWalker extends RodWalker<Integer, Integer> {
private void determineContextNamePartSizes() {
for ( EvaluationContext group : contexts ) {
String[] parts = group.getDisplayName().split("\\.");
String[] parts = group.getDisplayName().split(CONTEXT_SEPARATOR);
if ( parts.length != N_CONTEXT_NAME_PARTS ) {
throw new StingException("Unexpected number of eval name parts " + group.getDisplayName() + " length = " + parts.length + ", expected " + N_CONTEXT_NAME_PARTS);
} else {

View File

@ -99,6 +99,7 @@ public class CombineVariants extends RodWalker<Integer, Integer> {
HashMap<String, VCFHeaderLine> map = new HashMap<String, VCFHeaderLine>(); // from KEY.NAME -> line
HashSet<VCFHeaderLine> lines = new HashSet<VCFHeaderLine>();
// todo -- needs to remove all version headers from sources and add its own VCF version line
for ( VCFHeader source : headers ) {
//System.out.printf("Merging in header %s%n", source);
for ( VCFHeaderLine line : source.getMetaData()) {
@ -145,7 +146,7 @@ public class CombineVariants extends RodWalker<Integer, Integer> {
private void validateAnnotateUnionArguments(List<String> priority) {
Set<String> rodNames = SampleUtils.getRodsNamesWithVCFHeader(getToolkit(), null);
if ( priority == null || rodNames.size() != priority.size() )
throw new StingException("A complete priority list must be provided when annotateUnion is provided");
throw new StingException("The priority list must contain exactly one rod binding per ROD provided to the GATK: rodNames=" + rodNames + " priority=" + priority);
if ( ! rodNames.containsAll(rodNames) )
throw new StingException("Not all priority elements provided as input RODs: " + PRIORITY_STRING);

View File

@ -0,0 +1,71 @@
/*
* Copyright (c) 2010, The Broad Institute
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following
* conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*/
package org.broadinstitute.sting.gatk.walkers.variantutils;
import org.broadinstitute.sting.WalkerTest;
import org.junit.Test;
import java.io.File;
import java.util.Arrays;
/**
* Tests CombineVariants
*/
public class CombineVariantsIntegrationTest extends WalkerTest {
public static String baseTestString(String args) {
return "-T CombineVariants -L 1:1-50,000,000 -o %s -R " + oneKGLocation + "reference/human_b36_both.fasta" + args;
}
// todo -- merge with one file should be identical to input
public void test1InOut(String file, String type, String md5) {
WalkerTestSpec spec = new WalkerTestSpec(
baseTestString(" -priority v1 -B v1," + type + "," + validationDataLocation + file),
1,
Arrays.asList(md5));
executeTest("testInOut1--" + file, spec);
}
public void combine2(String file1, String type1, String file2, String type2, String md5) {
WalkerTestSpec spec = new WalkerTestSpec(
baseTestString(" -priority v1,v2 -B v1," + type1 + "," + validationDataLocation + file1 + " -B v2," + type2 + "," + validationDataLocation + file2),
1,
Arrays.asList(md5));
executeTest("combine2 1:" + new File(file1).getName() + " 2:" + new File(file2).getName(), spec);
}
@Test public void test1SNP() { test1InOut("pilot2.snps.vcf4.genotypes.vcf", "VCF", ""); }
@Test public void test1Indel1() { test1InOut("CEU.dindel.vcf4.trio.2010_06.indel.genotypes.vcf", "VCF4", ""); }
@Test public void test1Indel2() { test1InOut("CEU.dindel.vcf4.low_coverage.2010_06.indel.genotypes.vcf", "VCF4", ""); }
@Test public void combineSNPsAndIndels() { combine2("pilot2.snps.vcf4.genotypes.vcf", "VCF", "CEU.dindel.vcf4.low_coverage.2010_06.indel.genotypes.vcf", "VCF4", ""); }
@Test public void combine2Indels() { combine2("CEU.dindel.vcf4.low_coverage.2010_06.indel.genotypes.vcf", "VCF4", "CEU.dindel.vcf4.low_coverage.2010_06.indel.genotypes.vcf", "VCF4", ""); }
@Test public void uniqueSNPs() { combine2("pilot2.snps.vcf4.genotypes.vcf", "VCF", "yri.trio.gatk_glftrio.intersection.annotated.filtered.chr1.vcf", "VCF", ""); }
}