From d2af26e81f60dfd7dbd9520639643380b32be0f6 Mon Sep 17 00:00:00 2001 From: aaron Date: Thu, 24 Sep 2009 16:33:11 +0000 Subject: [PATCH] Pooled EM SNP Rod converted over to the Variation interface git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@1719 348d0f76-0448-11de-a6fe-93d51630548a --- .../sting/gatk/refdata/PooledEMSNPROD.java | 104 +++++++++++++++--- 1 file changed, 89 insertions(+), 15 deletions(-) diff --git a/java/src/org/broadinstitute/sting/gatk/refdata/PooledEMSNPROD.java b/java/src/org/broadinstitute/sting/gatk/refdata/PooledEMSNPROD.java index d3f44faa0..77baf3fef 100755 --- a/java/src/org/broadinstitute/sting/gatk/refdata/PooledEMSNPROD.java +++ b/java/src/org/broadinstitute/sting/gatk/refdata/PooledEMSNPROD.java @@ -1,19 +1,7 @@ package org.broadinstitute.sting.gatk.refdata; -import java.util.*; -import java.util.regex.MatchResult; -import java.util.regex.Pattern; -import java.util.regex.Matcher; -import java.io.File; -import java.io.FileNotFoundException; -import java.io.IOException; - -import org.broadinstitute.sting.gatk.refdata.ReferenceOrderedDatum; -import org.broadinstitute.sting.utils.GenomeLoc; -import org.broadinstitute.sting.utils.Utils; -import org.broadinstitute.sting.utils.xReadLines; -import org.broadinstitute.sting.utils.cmdLine.Argument; -import org.apache.log4j.Logger; +import java.util.ArrayList; +import java.util.List; /** * loc ref alt EM_alt_freq discovery_likelihood discovery_null discovery_prior discovery_lod EM_N n_ref n_het n_hom @@ -22,7 +10,7 @@ import org.apache.log4j.Logger; * chr1:1104842 A N 0.000000 -84.816002 -84.816002 0.000000 0.000000 324.000000 162 0 0 * */ -public class PooledEMSNPROD extends TabularROD implements SNPCallFromGenotypes { +public class PooledEMSNPROD extends TabularROD implements SNPCallFromGenotypes, VariationRod { public PooledEMSNPROD(final String name) { super(name); } @@ -33,10 +21,85 @@ public class PooledEMSNPROD extends TabularROD implements SNPCallFromGenotypes { public String getAltBasesFWD() { return this.get("alt"); } public char getAltSnpFWD() throws IllegalStateException { return getAltBasesFWD().charAt(0); } public boolean isReference() { return getVariationConfidence() < 0.01; } + + /** + * gets the alternate base. Use this method if we're biallelic + * + * @return + */ + @Override + public String getAlternateBase() { + return getAltBasesFWD(); + } + + /** + * gets the alternate bases. Use this method if the allele count is greater then 2 + * + * @return + */ + @Override + public List getAlternateBases() { + List str = new ArrayList(); + str.add(this.getAltBasesFWD()); + return str; + } + + /** + * get the frequency of this variant + * + * @return VariantFrequency with the stored frequency + */ + @Override + public double getNonRefAlleleFrequency() { + return this.getMAF(); + } + + /** @return the VARIANT_TYPE of the current variant */ + @Override + public VARIANT_TYPE getType() { + if (isSNP()) { + return VARIANT_TYPE.SNP; + } + return VARIANT_TYPE.REFERENCE; + } + public boolean isSNP() { return ! isReference(); } public boolean isInsertion() { return false; } public boolean isDeletion() { return false; } + + /** + * get the reference base(s) at this position + * + * @return the reference base or bases, as a string + */ + @Override + public String getReference() { + return this.get("ref"); + } + public boolean isIndel() { return false; } + + /** + * gets the alternate base is the case of a SNP. Throws an IllegalStateException if we're not a SNP + * of + * + * @return a char, representing the alternate base + */ + @Override + public char getAlternativeBaseForSNP() { + return this.getAltSnpFWD(); + } + + /** + * gets the reference base is the case of a SNP. Throws an IllegalStateException if we're not a SNP + * + * @return a char, representing the alternate base + */ + @Override + public char getReferenceForSNP() { + return this.getRefSnpFWD(); + } + public double getMAF() { return Double.parseDouble(this.get("EM_alt_freq")); } public double getHeterozygosity() { return 2 * getMAF() * (1 - getMAF()); } public boolean isGenotype() { return false; } @@ -45,6 +108,17 @@ public class PooledEMSNPROD extends TabularROD implements SNPCallFromGenotypes { public List getGenotype() throws IllegalStateException { throw new IllegalStateException(); } public int getPloidy() throws IllegalStateException { return 2; } public boolean isBiallelic() { return true; } + + /** + * get the -1 * (log 10 of the error value) + * + * @return the log based error estimate + */ + @Override + public double getNegLog10PError() { + return this.getVariationConfidence(); + } + public int length() { return 1; } // SNPCallFromGenotypes interface