From 234bb7174776e6c71eaf8ca89e0274b94ec494c5 Mon Sep 17 00:00:00 2001 From: aaron Date: Fri, 13 Nov 2009 06:54:38 +0000 Subject: [PATCH] changed the toVariation() method to take a reference base, instead of using the reference base loaded from the underlying data source (if it was reference aware). Also changed some isVariant() methods which weren't using the passed in ref base. git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@2034 348d0f76-0448-11de-a6fe-93d51630548a --- .../sting/gatk/walkers/concordance/IndelSubsets.java | 2 +- .../sting/gatk/walkers/concordance/SimpleVenn.java | 4 ++-- .../sting/utils/genotype/BasicGenotype.java | 6 +++--- .../broadinstitute/sting/utils/genotype/Genotype.java | 3 ++- .../sting/utils/genotype/geli/GeliGenotypeCall.java | 6 +++--- .../sting/utils/genotype/glf/GLFGenotypeCall.java | 11 +---------- .../sting/utils/genotype/vcf/VCFGenotypeCall.java | 6 +++--- 7 files changed, 15 insertions(+), 23 deletions(-) diff --git a/java/src/org/broadinstitute/sting/gatk/walkers/concordance/IndelSubsets.java b/java/src/org/broadinstitute/sting/gatk/walkers/concordance/IndelSubsets.java index c3ee233d7..041256c29 100755 --- a/java/src/org/broadinstitute/sting/gatk/walkers/concordance/IndelSubsets.java +++ b/java/src/org/broadinstitute/sting/gatk/walkers/concordance/IndelSubsets.java @@ -66,7 +66,7 @@ public class IndelSubsets implements ConcordanceType { return null; // only deal with a valid indel - Variation indel = ( indel1 != null ? indel1.toVariation() : indel2.toVariation() ); + Variation indel = ( indel1 != null ? indel1.toVariation(ref.getBase()) : indel2.toVariation(ref.getBase()) ); // we only deal with the first allele int size = ( indel.getAlternateAlleleList().get(0).length() <= sizeCutoff ? 0 : 1 ); diff --git a/java/src/org/broadinstitute/sting/gatk/walkers/concordance/SimpleVenn.java b/java/src/org/broadinstitute/sting/gatk/walkers/concordance/SimpleVenn.java index 43e22840c..3a4a97bea 100755 --- a/java/src/org/broadinstitute/sting/gatk/walkers/concordance/SimpleVenn.java +++ b/java/src/org/broadinstitute/sting/gatk/walkers/concordance/SimpleVenn.java @@ -42,8 +42,8 @@ public class SimpleVenn implements ConcordanceType { return sample2 + "_only"; // at this point we know that neither is null, so now we need to test for alternate allele concordance - Variation callV1 = call1.toVariation(); - Variation callV2 = call2.toVariation(); + Variation callV1 = call1.toVariation(ref.getBase()); + Variation callV2 = call2.toVariation(ref.getBase()); // we can't really deal with multi-allelic variants if ( callV1.isBiallelic() && callV2.isBiallelic() ) { diff --git a/java/src/org/broadinstitute/sting/utils/genotype/BasicGenotype.java b/java/src/org/broadinstitute/sting/utils/genotype/BasicGenotype.java index 2082d127a..94a44d9d7 100644 --- a/java/src/org/broadinstitute/sting/utils/genotype/BasicGenotype.java +++ b/java/src/org/broadinstitute/sting/utils/genotype/BasicGenotype.java @@ -151,9 +151,9 @@ public class BasicGenotype implements Genotype { * @return the variant */ @Override - public Variation toVariation() { - if (!isVariant(this.mRef)) throw new IllegalStateException("this genotype is not a variant"); - return new BasicVariation(this.getBases(), String.valueOf(mRef), this.getBases().length(), mLocation, mNegLog10PError); + public Variation toVariation(char ref) { + if (!isVariant(ref)) throw new IllegalStateException("this genotype is not a variant"); + return new BasicVariation(this.getBases(), String.valueOf(ref), this.getBases().length(), mLocation, mNegLog10PError); } /** diff --git a/java/src/org/broadinstitute/sting/utils/genotype/Genotype.java b/java/src/org/broadinstitute/sting/utils/genotype/Genotype.java index cc0ad15be..1adf93399 100644 --- a/java/src/org/broadinstitute/sting/utils/genotype/Genotype.java +++ b/java/src/org/broadinstitute/sting/utils/genotype/Genotype.java @@ -77,8 +77,9 @@ public interface Genotype { /** * return this genotype as a variant * + * @param ref the reference base * @return the variant */ - public Variation toVariation(); + public Variation toVariation(char ref); } diff --git a/java/src/org/broadinstitute/sting/utils/genotype/geli/GeliGenotypeCall.java b/java/src/org/broadinstitute/sting/utils/genotype/geli/GeliGenotypeCall.java index 150fdf4e7..b23cf7901 100755 --- a/java/src/org/broadinstitute/sting/utils/genotype/geli/GeliGenotypeCall.java +++ b/java/src/org/broadinstitute/sting/utils/genotype/geli/GeliGenotypeCall.java @@ -201,7 +201,7 @@ public class GeliGenotypeCall implements Genotype, ReadBacked, PosteriorsBacked * @return true if we're a variant */ public boolean isVariant(char ref) { - return !Utils.dupString(this.getReference(), 2).equals(getBestGenotype().toString()); + return !Utils.dupString(ref, 2).equals(getBestGenotype().toString()); } /** @@ -217,9 +217,9 @@ public class GeliGenotypeCall implements Genotype, ReadBacked, PosteriorsBacked * * @return return this genotype as a variant */ - public Variation toVariation() { + public Variation toVariation(char ref) { double bestRef = Math.abs(mPosteriors[getBestGenotype().ordinal()] - mPosteriors[getRefGenotype().ordinal()]); - return new BasicVariation(this.getBases(), String.valueOf(this.getReference()), 0, this.mLocation, bestRef); + return new BasicVariation(this.getBases(), String.valueOf(ref), 0, this.mLocation, bestRef); } /** diff --git a/java/src/org/broadinstitute/sting/utils/genotype/glf/GLFGenotypeCall.java b/java/src/org/broadinstitute/sting/utils/genotype/glf/GLFGenotypeCall.java index 8186d5a28..999e58a05 100755 --- a/java/src/org/broadinstitute/sting/utils/genotype/glf/GLFGenotypeCall.java +++ b/java/src/org/broadinstitute/sting/utils/genotype/glf/GLFGenotypeCall.java @@ -120,7 +120,7 @@ public class GLFGenotypeCall implements Genotype, ReadBacked, LikelihoodsBacked * * @return return this genotype as a variant */ - public Variation toVariation() { + public Variation toVariation(char ref) { throw new UnsupportedOperationException("GLF call doesn't support conversion to Variation"); } @@ -154,15 +154,6 @@ public class GLFGenotypeCall implements Genotype, ReadBacked, LikelihoodsBacked return !Utils.dupString(mRefBase, 2).equals(mGenotype); } - /** - * are we a variant? (non-ref) - * - * @return true if we're a variant - */ - public boolean isVariant() { - return isVariant(mRefBase); - } - /** * get the SAM records that back this genotype call * diff --git a/java/src/org/broadinstitute/sting/utils/genotype/vcf/VCFGenotypeCall.java b/java/src/org/broadinstitute/sting/utils/genotype/vcf/VCFGenotypeCall.java index 6473e2cd5..c36a217ac 100755 --- a/java/src/org/broadinstitute/sting/utils/genotype/vcf/VCFGenotypeCall.java +++ b/java/src/org/broadinstitute/sting/utils/genotype/vcf/VCFGenotypeCall.java @@ -207,7 +207,7 @@ public class VCFGenotypeCall implements Genotype, ReadBacked, PosteriorsBacked, * @return true if we're a variant */ public boolean isVariant(char ref) { - return !Utils.dupString(this.getReference(), 2).equals(getBestGenotype().toString()); + return !Utils.dupString(ref, 2).equals(getBestGenotype().toString()); } /** @@ -223,9 +223,9 @@ public class VCFGenotypeCall implements Genotype, ReadBacked, PosteriorsBacked, * * @return return this genotype as a variant */ - public Variation toVariation() { + public Variation toVariation(char ref) { double bestRef = Math.abs(mPosteriors[getBestGenotype().ordinal()] - mPosteriors[getRefGenotype().ordinal()]); - return new BasicVariation(this.getBases(), String.valueOf(this.getReference()), 0, this.mLocation, bestRef); + return new BasicVariation(this.getBases(), String.valueOf(ref), 0, this.mLocation, bestRef); } /**