diff --git a/java/src/org/broadinstitute/sting/gatk/refdata/RodGeliText.java b/java/src/org/broadinstitute/sting/gatk/refdata/RodGeliText.java index 73e048213..2206f4b79 100755 --- a/java/src/org/broadinstitute/sting/gatk/refdata/RodGeliText.java +++ b/java/src/org/broadinstitute/sting/gatk/refdata/RodGeliText.java @@ -266,7 +266,6 @@ public class RodGeliText extends BasicReferenceOrderedDatum implements Variation public List getGenotype() throws IllegalStateException { return Arrays.asList(getBestGenotype()); - //throw new IllegalStateException("huh?"); } public int getPloidy() throws IllegalStateException { @@ -348,14 +347,13 @@ public class RodGeliText extends BasicReferenceOrderedDatum implements Variation /** - * get the likelihoods + * get the genotype * - * @return an array in lexigraphical order of the likelihoods + * @return a map in lexigraphical order of the genotypes */ @Override - public Genotype getGenotype(DiploidGenotype x) { - if (x.toString() != this.getAltBasesFWD()) throw new IllegalStateException("We don't contain genotype " + x); - return new BasicGenotype(getLocation(), x.toString(), refBase, lodBtnb); + public Genotype getCallexGenotype() { + return new BasicGenotype(getLocation(), this.getAltBasesFWD(), refBase, lodBtnb); } /** diff --git a/java/src/org/broadinstitute/sting/gatk/refdata/RodGenotypeChipAsGFF.java b/java/src/org/broadinstitute/sting/gatk/refdata/RodGenotypeChipAsGFF.java index ff0189587..12afd2054 100644 --- a/java/src/org/broadinstitute/sting/gatk/refdata/RodGenotypeChipAsGFF.java +++ b/java/src/org/broadinstitute/sting/gatk/refdata/RodGenotypeChipAsGFF.java @@ -259,6 +259,16 @@ public class RodGenotypeChipAsGFF extends BasicReferenceOrderedDatum implements public boolean isBiallelic() { return true; } public int length() { return 1; } + /** + * get the genotype + * + * @return a map in lexigraphical order of the genotypes + */ + @Override + public Genotype getCallexGenotype() { + return new BasicGenotype(this.getLocation(),this.feature,this.getRefSnpFWD(),this.getConsensusConfidence()); + } + /** * get the likelihoods * @@ -270,17 +280,6 @@ public class RodGenotypeChipAsGFF extends BasicReferenceOrderedDatum implements ret.add(new BasicGenotype(this.getLocation(),this.feature,this.getRefSnpFWD(),this.getConsensusConfidence())); return ret; } - - /** - * get the likelihoods - * - * @return an array in lexigraphical order of the likelihoods - */ - @Override - public Genotype getGenotype(DiploidGenotype x) { - if (!x.toString().equals(this.getAltBasesFWD())) throw new IllegalStateException("Unable to retrieve genotype"); - return new BasicGenotype(this.getLocation(),this.feature,this.getRefSnpFWD(),this.getConsensusConfidence()); - } /** * do we have the specified genotype? not all backedByGenotypes diff --git a/java/src/org/broadinstitute/sting/gatk/refdata/RodVCF.java b/java/src/org/broadinstitute/sting/gatk/refdata/RodVCF.java index 74622e77f..c2d776568 100755 --- a/java/src/org/broadinstitute/sting/gatk/refdata/RodVCF.java +++ b/java/src/org/broadinstitute/sting/gatk/refdata/RodVCF.java @@ -249,6 +249,16 @@ public class RodVCF extends BasicReferenceOrderedDatum implements Variation, Var return mCurrentRecord.getReferenceBase(); } + /** + * get the genotype + * + * @return a map in lexigraphical order of the genotypes + */ + @Override + public Genotype getCallexGenotype() { + throw new UnsupportedOperationException("We don't support this right now"); + } + /** * get the genotypes * @@ -273,29 +283,6 @@ public class RodVCF extends BasicReferenceOrderedDatum implements Variation, Var return genotypes; } - - /** - * get the likelihoods - * - * @return an array in lexigraphical order of the likelihoods - */ - @Override - public Genotype getGenotype(DiploidGenotype x) { - if (x.toString().equals(getReference())) - return new BasicGenotype(this.getLocation(), getReference(), this.getReference().charAt(0), 0); - for (VCFGenotypeRecord record : mCurrentRecord.getVCFGenotypeRecords()) { - if (Utils.join("", record.getAlleles()).equals(x.toString())) { - double qual = 0.0; - if (record.getAlleles().equals(this.getReference())) - qual = this.getNegLog10PError(); - else if (record.getFields().containsKey("GQ")) - qual = Double.valueOf(record.getFields().get("GQ")) / 10.0; - return new BasicGenotype(this.getLocation(), Utils.join("", record.getAlleles()), this.getReference().charAt(0), qual); - } - } - return null; - } - /** * do we have the specified genotype? not all backedByGenotypes * have all the genotype data. @@ -306,9 +293,7 @@ public class RodVCF extends BasicReferenceOrderedDatum implements Variation, Var */ @Override public boolean hasGenotype(DiploidGenotype x) { - if (getGenotype(x) != null) - return true; - return false; + return (this.getAlternateBases().contains(x.toString())); } @Override diff --git a/java/src/org/broadinstitute/sting/gatk/refdata/rodDbSNP.java b/java/src/org/broadinstitute/sting/gatk/refdata/rodDbSNP.java index 37200a9c0..6547c5489 100644 --- a/java/src/org/broadinstitute/sting/gatk/refdata/rodDbSNP.java +++ b/java/src/org/broadinstitute/sting/gatk/refdata/rodDbSNP.java @@ -2,10 +2,7 @@ package org.broadinstitute.sting.gatk.refdata; import net.sf.picard.util.SequenceUtil; import org.broadinstitute.sting.utils.*; -import org.broadinstitute.sting.utils.genotype.BasicGenotype; -import org.broadinstitute.sting.utils.genotype.DiploidGenotype; -import org.broadinstitute.sting.utils.genotype.VariantBackedByGenotype; -import org.broadinstitute.sting.utils.genotype.Variation; +import org.broadinstitute.sting.utils.genotype.*; import java.util.ArrayList; import java.util.Arrays; @@ -355,6 +352,16 @@ public class rodDbSNP extends BasicReferenceOrderedDatum implements Variation, V return (int) (loc.getStop() - loc.getStart() + 1); } + /** + * get the genotype + * + * @return a map in lexigraphical order of the genotypes + */ + @Override + public org.broadinstitute.sting.utils.genotype.Genotype getCallexGenotype() { + return new BasicGenotype(this.getLocation(), this.getAltBasesFWD(), this.getRefSnpFWD(), this.getConsensusConfidence()); + } + /** * get the likelihoods * @@ -367,17 +374,6 @@ public class rodDbSNP extends BasicReferenceOrderedDatum implements Variation, V return list; } - /** - * get the likelihoods - * - * @return an array in lexigraphical order of the likelihoods - */ - @Override - public org.broadinstitute.sting.utils.genotype.Genotype getGenotype(DiploidGenotype x) { - if (!x.toString().equals(this.getAltBasesFWD())) throw new IllegalStateException("Unable to retrieve genotype"); - return new BasicGenotype(this.getLocation(), this.getAltBasesFWD(), this.getRefSnpFWD(), this.getConsensusConfidence()); - } - /** * do we have the specified genotype? not all backedByGenotypes * have all the genotype data. diff --git a/java/src/org/broadinstitute/sting/utils/genotype/VariantBackedByGenotype.java b/java/src/org/broadinstitute/sting/utils/genotype/VariantBackedByGenotype.java index f6833696c..6aa7f89d9 100644 --- a/java/src/org/broadinstitute/sting/utils/genotype/VariantBackedByGenotype.java +++ b/java/src/org/broadinstitute/sting/utils/genotype/VariantBackedByGenotype.java @@ -11,18 +11,18 @@ import java.util.List; */ public interface VariantBackedByGenotype { /** - * get the likelihoods + * get the genotype * - * @return a map in lexigraphical order of the likelihoods + * @return a specific genotype that represents the called genotype */ - public List getGenotypes(); + public Genotype getCallexGenotype(); /** - * get the likelihoods + * get the genotype * - * @return a map in lexigraphical order of the likelihoods + * @return a map in lexigraphical order of the genotypes */ - public Genotype getGenotype(DiploidGenotype x); + public List getGenotypes(); /** * do we have the specified genotype? not all backedByGenotypes * have all the genotype data. diff --git a/java/test/org/broadinstitute/sting/playground/gatk/walkers/varianteval/VariantEvalWalkerIntegrationTest.java b/java/test/org/broadinstitute/sting/playground/gatk/walkers/varianteval/VariantEvalWalkerIntegrationTest.java index 1f44d2a78..1542a91fe 100644 --- a/java/test/org/broadinstitute/sting/playground/gatk/walkers/varianteval/VariantEvalWalkerIntegrationTest.java +++ b/java/test/org/broadinstitute/sting/playground/gatk/walkers/varianteval/VariantEvalWalkerIntegrationTest.java @@ -114,7 +114,7 @@ public class VariantEvalWalkerIntegrationTest extends WalkerTest { @Test public void testEvalGenotypeROD() { List md5 = new ArrayList(); - md5.add("439c2983a6e1250cd845c686a0e5a085"); + md5.add("d337f22057d2e9cfda03af3be70ce35a"); /** * the above MD5 was calculated after running the following command: * @@ -144,5 +144,32 @@ public class VariantEvalWalkerIntegrationTest extends WalkerTest { md5); List result = executeTest("testEvalGenotypeROD", spec).getFirst(); } + + @Test + public void testEvalMarksGenotypingExample() { + List md5 = new ArrayList(); + md5.add("39ea64299cad44f816f033db54c8e622"); + /** + * Run with the following commands: + * + * java -Xmx2048m -jar /humgen/gsa-hphome1/depristo/dev/GenomeAnalysisTK/trunk/dist/GenomeAnalysisTK.jar + * -T VariantEval -R /broad/1KG/reference/human_b36_both.fasta -l INFO + * -B eval,Variants,/humgen/gsa-scr1/ebanks/concordanceForMark/UMichVsBroad.venn.set1Only.calls + * -D /humgen/gsa-scr1/GATK_Data/dbsnp_129_b36.rod -hc /humgen/gsa-scr1/GATK_Data/1KG_gffs/NA12878.1kg.gff + * -G -L 1 -o /humgen/gsa-scr1/ebanks/concordanceForMark/UMichVsBroad.venn.set1Only.calls.eval + */ + + WalkerTest.WalkerTestSpec spec = new WalkerTest.WalkerTestSpec( + "-T VariantEval -R /broad/1KG/reference/human_b36_both.fasta " + + "-B eval,Variants,/humgen/gsa-scr1/GATK_Data/Validation_Data/UMichVsBroad.venn.set1Only.calls " + + "-D /humgen/gsa-scr1/GATK_Data/dbsnp_129_b36.rod -hc /humgen/gsa-scr1/GATK_Data/1KG_gffs/NA12878.1kg.gff " + + "-G " + + "--supressDateInformation " + + "-L 1:1-10,000,000 " + + "--outerr %s", + 1, // just one output file + md5); + List result = executeTest("testEvalMarksGenotypingExample", spec).getFirst(); + } }