From 5f8a3f95efd335fee13fca7ed6608ca17f970d7f Mon Sep 17 00:00:00 2001 From: aaron Date: Fri, 25 Jun 2010 21:03:05 +0000 Subject: [PATCH] The GT field once again reigns supreme (it must be the first genotype field). Thanks for the catch Eric. git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@3645 348d0f76-0448-11de-a6fe-93d51630548a --- .../gatk/refdata/features/vcf4/VCF4Codec.java | 4 ++-- .../gatk/refdata/features/vcf4/VCF4UnitTest.java | 15 ++++++++++++--- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/java/src/org/broadinstitute/sting/gatk/refdata/features/vcf4/VCF4Codec.java b/java/src/org/broadinstitute/sting/gatk/refdata/features/vcf4/VCF4Codec.java index 82921e6f4..1444d8ae5 100644 --- a/java/src/org/broadinstitute/sting/gatk/refdata/features/vcf4/VCF4Codec.java +++ b/java/src/org/broadinstitute/sting/gatk/refdata/features/vcf4/VCF4Codec.java @@ -425,8 +425,8 @@ public class VCF4Codec implements FeatureCodec { if (i >= GTValueSplitSize) gtAttributes.put(genotypeKeyArray[i],"."); else if (genotypeKeyArray[i].equals("GT")) - if (genotypeAlleleLocation >= 0) - throw new StingException("Saw two GT fields in record at position " + locAndAlleles.first); + if (i != 0) + throw new StingException("Saw GT at position " + i + ", it must be at the first position for genotypes. At location = " + locAndAlleles.first); else genotypeAlleleLocation = i; else if (genotypeKeyArray[i].equals("GQ")) diff --git a/java/test/org/broadinstitute/sting/gatk/refdata/features/vcf4/VCF4UnitTest.java b/java/test/org/broadinstitute/sting/gatk/refdata/features/vcf4/VCF4UnitTest.java index 763087440..bd999067d 100644 --- a/java/test/org/broadinstitute/sting/gatk/refdata/features/vcf4/VCF4UnitTest.java +++ b/java/test/org/broadinstitute/sting/gatk/refdata/features/vcf4/VCF4UnitTest.java @@ -174,21 +174,30 @@ public class VCF4UnitTest extends BaseTest { // test too many info fields - NOT a valid test with validation turned off in the VCF4 reader - String twoManyInfoLine = "20\t14370\trs6054257\tG\tA\t29\tPASS\tNS=3;DP=14;AF=0.5;DB;H2;HH\tGT:GQ:DP:HQ\t0|0:48:1:51,51\t1|0:48:8:51,51\t1/1:43:5:.,."; + String twoManyInfoLine = "20\t14370\trs6054257\tG\tA\t29\tPASS\tNS=3;DP=14;AF=0.5;DB;H2;HH\tGT:GQ:DP:HQ\t0|0:48:1:51,51\t1|0:48:8:51,51\t1/1:43:5:0,0"; //@Test(expected=StingException.class) public void testCheckTooManyInfoFields() { TestSetup testSetup = new TestSetup().invoke(vcfGenotypeFile); testSetup.codec.decode(twoManyInfoLine); } // test a regular line - String regularLine = "20\t14370\trs6054257\tG\tA\t29\tPASS\tNS=3;DP=14;AF=0.5;DB;H2\tGT:GQ:DP:HQ\t0|0:48:1:51,51\t1|0:48:8:51,51\t1/1:43:5:.,."; + String regularLine = "20\t14370\trs6054257\tG\tA\t29\tPASS\tNS=3;DP=14;AF=0.5;DB;H2\tGT:GQ:DP:HQ\t0|0:48:1:51,51\t1|0:48:8:51,51\t1/1:43:5:0,0"; @Test public void testCheckInfoValidation() { TestSetup testSetup = new TestSetup().invoke(vcfGenotypeFile); testSetup.codec.decode(regularLine); } // test too few info lines, we don't provide the DP in this line - String twoFewInfoLine = "20\t14370\trs6054257\tG\tA\t29\tPASS\tNS=3;AF=0.5;DB;H2\tGT:GQ:DP:HQ\t0|0:48:1:51,51\t1|0:48:8:51,51\t1/1:43:5:.,."; + // test GT field in the incorrect position (!= 0) + String GTFieldInTheWrongPosition = "20\t14370\trs6054257\tG\tA\t29\tPASS\tNS=3;AF=0.5;DB;H2\tGQ:DP:HQ:GT\t48:1:51,51:0|0\t48:8:51,51:0|0\t43:5:0,0:0|0"; + @Test(expected=StingException.class) + public void testCheckGTFieldOrdering() { + TestSetup testSetup = new TestSetup().invoke(vcfGenotypeFile); + testSetup.codec.decode(GTFieldInTheWrongPosition); + } + + // test too few info lines, we don't provide the DP in this line + String twoFewInfoLine = "20\t14370\trs6054257\tG\tA\t29\tPASS\tNS=3;AF=0.5;DB;H2\tGT:GQ:DP:HQ\t0|0:48:1:51,51\t0|0:48:1:51,51\t0|0:48:1:51,51"; @Test public void testCheckTwoFewInfoValidation() { TestSetup testSetup = new TestSetup().invoke(vcfGenotypeFile);