From f99586f91bfca9c197ca60c6c77bb0de511cca53 Mon Sep 17 00:00:00 2001 From: ebanks Date: Wed, 13 Jan 2010 03:55:24 +0000 Subject: [PATCH] Added integration test for beagle and verbose output in UG. Minor cleanup of VCFRecord code. git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@2570 348d0f76-0448-11de-a6fe-93d51630548a --- .../sting/utils/genotype/vcf/VCFRecord.java | 32 +++++++++---------- .../UnifiedGenotyperIntegrationTest.java | 25 +++++++++++++++ 2 files changed, 41 insertions(+), 16 deletions(-) diff --git a/java/src/org/broadinstitute/sting/utils/genotype/vcf/VCFRecord.java b/java/src/org/broadinstitute/sting/utils/genotype/vcf/VCFRecord.java index fdbb45ed3..db8f258db 100644 --- a/java/src/org/broadinstitute/sting/utils/genotype/vcf/VCFRecord.java +++ b/java/src/org/broadinstitute/sting/utils/genotype/vcf/VCFRecord.java @@ -36,6 +36,7 @@ public class VCFRecord implements Variation, VariantBackedByGenotype { public static final String PASSES_FILTERS = "0"; public static final String EMPTY_INFO_FIELD = "."; public static final String EMPTY_ID_FIELD = "."; + public static final String EMPTY_ALLELE_FIELD = "."; public static final String DOUBLE_PRECISION_FORMAT_STRING = "%.2f"; // the reference base @@ -75,13 +76,13 @@ public class VCFRecord implements Variation, VariantBackedByGenotype { * given the values for each of the columns, create a VCF record. * * @param columnValues a mapping of header strings to values - * @param formatString the format string for the genotype records + * @param genotypeFormatString the format string for the genotype records * @param genotypeRecords the genotype records */ - public VCFRecord(Map columnValues, String formatString, List genotypeRecords) { + public VCFRecord(Map columnValues, String genotypeFormatString, List genotypeRecords) { extractFields(columnValues); mGenotypeRecords.addAll(genotypeRecords); - mGenotypeFormatString = formatString; + mGenotypeFormatString = genotypeFormatString; } /** @@ -385,14 +386,6 @@ public class VCFRecord implements Variation, VariantBackedByGenotype { return mInfoFields; } - /** - * @return the number of columnsof data we're storing - */ - public int getColumnCount() { - if (hasGenotypeData()) return mGenotypeRecords.size() + VCFHeader.HEADER_FIELDS.values().length; - return VCFHeader.HEADER_FIELDS.values().length; - } - public List getVCFGenotypeRecords() { ArrayList list = new ArrayList(); for ( Genotype g : mGenotypeRecords ) @@ -450,8 +443,7 @@ public class VCFRecord implements Variation, VariantBackedByGenotype { }// the formatting string for our genotype records public void setReferenceBase(char referenceBase) { - // upppercase the character - referenceBase = (char) ((referenceBase > 96) ? referenceBase - 32 : referenceBase); + referenceBase = Character.toUpperCase(referenceBase); if (referenceBase != 'A' && referenceBase != 'C' && referenceBase != 'T' && referenceBase != 'G' && referenceBase != 'N') throw new IllegalArgumentException("Reference base must be one of A,C,G,T,N, we saw: " + referenceBase); mReferenceBase = referenceBase; @@ -558,9 +550,17 @@ public class VCFRecord implements Variation, VariantBackedByGenotype { builder.append(FIELD_SEPERATOR); builder.append(getReferenceBase()); builder.append(FIELD_SEPERATOR); - String alts = ""; - for (VCFGenotypeEncoding str : getAlternateAlleles()) alts += str.toString() + ","; - builder.append((alts.length() > 0) ? alts.substring(0, alts.length() - 1) + FIELD_SEPERATOR : "." + FIELD_SEPERATOR); + List alts = getAlternateAlleles(); + if ( alts.size() > 0 ) { + builder.append(alts.get(0)); + for ( int i = 1; i < alts.size(); i++ ) { + builder.append(","); + builder.append(alts.get(i)); + } + } else { + builder.append(EMPTY_ALLELE_FIELD); + } + builder.append(FIELD_SEPERATOR); builder.append(String.format(DOUBLE_PRECISION_FORMAT_STRING, getQual())); builder.append(FIELD_SEPERATOR); builder.append(Utils.join(FILTER_CODE_SEPERATOR, getFilteringCodes())); diff --git a/java/test/org/broadinstitute/sting/gatk/walkers/genotyper/UnifiedGenotyperIntegrationTest.java b/java/test/org/broadinstitute/sting/gatk/walkers/genotyper/UnifiedGenotyperIntegrationTest.java index c4a54e75b..a78887043 100755 --- a/java/test/org/broadinstitute/sting/gatk/walkers/genotyper/UnifiedGenotyperIntegrationTest.java +++ b/java/test/org/broadinstitute/sting/gatk/walkers/genotyper/UnifiedGenotyperIntegrationTest.java @@ -204,4 +204,29 @@ public class UnifiedGenotyperIntegrationTest extends WalkerTest { executeTest(String.format("testMultiTechnologies"), spec); } + + // -------------------------------------------------------------------------------------------------------------- + // + // testing verbose and beagle output + // + // -------------------------------------------------------------------------------------------------------------- + @Test + public void testOtherOutput() { + String[] md5s = {"a5dce541f00d3fe364d110f1cae53538", "677963a26f867fbbd5f030cc3df55075", "cea954546a304aa98fc3a18d4305090a"}; + WalkerTest.WalkerTestSpec spec = new WalkerTest.WalkerTestSpec( + "-T UnifiedGenotyper" + + " -R " + oneKGLocation + "reference/human_b36_both.fasta" + + " -I " + validationDataLocation + "low_coverage_CEU.chr1.10k-11k.bam" + + " -varout %s" + + " -verbose %s" + + " -beagle %s" + + " -L 1:10,023,400-10,024,000" + + " -bm empirical" + + " -gm JOINT_ESTIMATE" + + " -vf GELI", + 3, + Arrays.asList(md5s)); + + executeTest(String.format("testOtherOutput"), spec); + } }