From 3a487dd64e2ab3cba6f09bcb1423a7e467149699 Mon Sep 17 00:00:00 2001 From: aaron Date: Fri, 18 Sep 2009 22:38:51 +0000 Subject: [PATCH] little fixes; also fixed a tyPo git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@1662 348d0f76-0448-11de-a6fe-93d51630548a --- .../sting/gatk/refdata/RodGeliText.java | 2 +- .../gatk/refdata/RodGenotypeChipAsGFF.java | 2 +- .../sting/gatk/refdata/RodVCF.java | 27 +++++++++++++++++-- .../sting/gatk/refdata/rodDbSNP.java | 2 +- .../varianteval/CallableBasesAnalysis.java | 3 +-- .../genotype/VariantBackedByGenotype.java | 2 +- 6 files changed, 30 insertions(+), 8 deletions(-) diff --git a/java/src/org/broadinstitute/sting/gatk/refdata/RodGeliText.java b/java/src/org/broadinstitute/sting/gatk/refdata/RodGeliText.java index 2206f4b79..d84bac130 100755 --- a/java/src/org/broadinstitute/sting/gatk/refdata/RodGeliText.java +++ b/java/src/org/broadinstitute/sting/gatk/refdata/RodGeliText.java @@ -352,7 +352,7 @@ public class RodGeliText extends BasicReferenceOrderedDatum implements Variation * @return a map in lexigraphical order of the genotypes */ @Override - public Genotype getCallexGenotype() { + public Genotype getCalledGenotype() { 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 12afd2054..97f79db9e 100644 --- a/java/src/org/broadinstitute/sting/gatk/refdata/RodGenotypeChipAsGFF.java +++ b/java/src/org/broadinstitute/sting/gatk/refdata/RodGenotypeChipAsGFF.java @@ -265,7 +265,7 @@ public class RodGenotypeChipAsGFF extends BasicReferenceOrderedDatum implements * @return a map in lexigraphical order of the genotypes */ @Override - public Genotype getCallexGenotype() { + public Genotype getCalledGenotype() { return new BasicGenotype(this.getLocation(),this.feature,this.getRefSnpFWD(),this.getConsensusConfidence()); } diff --git a/java/src/org/broadinstitute/sting/gatk/refdata/RodVCF.java b/java/src/org/broadinstitute/sting/gatk/refdata/RodVCF.java index c2d776568..17766e430 100755 --- a/java/src/org/broadinstitute/sting/gatk/refdata/RodVCF.java +++ b/java/src/org/broadinstitute/sting/gatk/refdata/RodVCF.java @@ -255,7 +255,7 @@ public class RodVCF extends BasicReferenceOrderedDatum implements Variation, Var * @return a map in lexigraphical order of the genotypes */ @Override - public Genotype getCallexGenotype() { + public Genotype getCalledGenotype() { throw new UnsupportedOperationException("We don't support this right now"); } @@ -283,6 +283,27 @@ public class RodVCF extends BasicReferenceOrderedDatum implements Variation, Var return genotypes; } + /** + * a private helper method + * + * @return an array in lexigraphical order of the likelihoods + */ + private 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. @@ -293,7 +314,9 @@ public class RodVCF extends BasicReferenceOrderedDatum implements Variation, Var */ @Override public boolean hasGenotype(DiploidGenotype x) { - return (this.getAlternateBases().contains(x.toString())); + if (getGenotype(x) != null) + return true; + return false; } @Override diff --git a/java/src/org/broadinstitute/sting/gatk/refdata/rodDbSNP.java b/java/src/org/broadinstitute/sting/gatk/refdata/rodDbSNP.java index 6547c5489..00f36ad9c 100644 --- a/java/src/org/broadinstitute/sting/gatk/refdata/rodDbSNP.java +++ b/java/src/org/broadinstitute/sting/gatk/refdata/rodDbSNP.java @@ -358,7 +358,7 @@ public class rodDbSNP extends BasicReferenceOrderedDatum implements Variation, V * @return a map in lexigraphical order of the genotypes */ @Override - public org.broadinstitute.sting.utils.genotype.Genotype getCallexGenotype() { + public org.broadinstitute.sting.utils.genotype.Genotype getCalledGenotype() { return new BasicGenotype(this.getLocation(), this.getAltBasesFWD(), this.getRefSnpFWD(), this.getConsensusConfidence()); } diff --git a/java/src/org/broadinstitute/sting/playground/gatk/walkers/varianteval/CallableBasesAnalysis.java b/java/src/org/broadinstitute/sting/playground/gatk/walkers/varianteval/CallableBasesAnalysis.java index 2ccf4da4d..765b3eaed 100755 --- a/java/src/org/broadinstitute/sting/playground/gatk/walkers/varianteval/CallableBasesAnalysis.java +++ b/java/src/org/broadinstitute/sting/playground/gatk/walkers/varianteval/CallableBasesAnalysis.java @@ -2,7 +2,6 @@ package org.broadinstitute.sting.playground.gatk.walkers.varianteval; import org.broadinstitute.sting.gatk.contexts.AlignmentContext; import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker; -import org.broadinstitute.sting.utils.genotype.DiploidGenotype; import org.broadinstitute.sting.utils.genotype.Genotype; import org.broadinstitute.sting.utils.genotype.VariantBackedByGenotype; import org.broadinstitute.sting.utils.genotype.Variation; @@ -69,7 +68,7 @@ public class CallableBasesAnalysis extends BasicVariantAnalysis implements Genot // For every threshold, updated discoverable and callable for (int i = 0; i < thresholds.length; i++) { double threshold = thresholds[i]; - Genotype genotype = ((VariantBackedByGenotype)eval).getGenotypes().get(0); + Genotype genotype = ((VariantBackedByGenotype)eval).getCalledGenotype(); // update discoverable if ( eval.isSNP() && eval.getNegLog10PError() >= threshold) diff --git a/java/src/org/broadinstitute/sting/utils/genotype/VariantBackedByGenotype.java b/java/src/org/broadinstitute/sting/utils/genotype/VariantBackedByGenotype.java index 6aa7f89d9..3cb98e9f7 100644 --- a/java/src/org/broadinstitute/sting/utils/genotype/VariantBackedByGenotype.java +++ b/java/src/org/broadinstitute/sting/utils/genotype/VariantBackedByGenotype.java @@ -15,7 +15,7 @@ public interface VariantBackedByGenotype { * * @return a specific genotype that represents the called genotype */ - public Genotype getCallexGenotype(); + public Genotype getCalledGenotype(); /** * get the genotype