diff --git a/java/src/org/broadinstitute/sting/playground/gatk/walkers/CoverageEvalWalker.java b/java/src/org/broadinstitute/sting/playground/gatk/walkers/CoverageEvalWalker.java index 3f82cc9b8..2ad0f70a6 100755 --- a/java/src/org/broadinstitute/sting/playground/gatk/walkers/CoverageEvalWalker.java +++ b/java/src/org/broadinstitute/sting/playground/gatk/walkers/CoverageEvalWalker.java @@ -8,9 +8,8 @@ import org.broadinstitute.sting.gatk.walkers.LocusWalker; import org.broadinstitute.sting.utils.BaseUtils; import org.broadinstitute.sting.utils.ListUtils; import org.broadinstitute.sting.utils.cmdLine.Argument; -import org.broadinstitute.sting.utils.genotype.Genotype; -import org.broadinstitute.sting.utils.genotype.GenotypeCall; -import org.broadinstitute.sting.utils.genotype.SSGGenotypeCall; +import org.broadinstitute.sting.utils.genotype.calls.GenotypeCall; +import org.broadinstitute.sting.utils.genotype.calls.SSGGenotypeCall; import java.io.File; import java.io.FileNotFoundException; diff --git a/java/src/org/broadinstitute/sting/playground/gatk/walkers/SingleSampleGenotyper.java b/java/src/org/broadinstitute/sting/playground/gatk/walkers/SingleSampleGenotyper.java index cab357269..4e5dc9c09 100644 --- a/java/src/org/broadinstitute/sting/playground/gatk/walkers/SingleSampleGenotyper.java +++ b/java/src/org/broadinstitute/sting/playground/gatk/walkers/SingleSampleGenotyper.java @@ -19,7 +19,7 @@ import org.broadinstitute.sting.utils.genotype.*; import java.io.File; @ReadFilters(ZeroMappingQualityReadFilter.class) -public class SingleSampleGenotyper extends LocusWalker { +public class SingleSampleGenotyper extends LocusWalker { // Control output settings @Argument(fullName = "variants_out", shortName = "varout", doc = "File to which variants should be written", required = true) public File VARIANTS_FILE; @Argument(fullName = "metrics_out", shortName = "metout", doc = "File to which metrics should be written", required = false) public File METRICS_FILE = new File("/dev/stderr"); @@ -123,14 +123,14 @@ public class SingleSampleGenotyper extends LocusWalker LOD_THRESHOLD) sum.addGenotypeCall(call); diff --git a/java/src/org/broadinstitute/sting/playground/utils/AlleleMetrics.java b/java/src/org/broadinstitute/sting/playground/utils/AlleleMetrics.java index b7af829a0..464cbf386 100755 --- a/java/src/org/broadinstitute/sting/playground/utils/AlleleMetrics.java +++ b/java/src/org/broadinstitute/sting/playground/utils/AlleleMetrics.java @@ -4,11 +4,8 @@ import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker; import org.broadinstitute.sting.gatk.refdata.ReferenceOrderedDatum; import org.broadinstitute.sting.gatk.refdata.rodDbSNP; import org.broadinstitute.sting.gatk.refdata.rodGFF; -import org.broadinstitute.sting.utils.Pair; -import org.broadinstitute.sting.utils.genotype.confidence.ConfidenceScore; -import org.broadinstitute.sting.utils.genotype.Genotype; -import org.broadinstitute.sting.utils.genotype.GenotypeCall; -import org.broadinstitute.sting.utils.genotype.SSGGenotypeCall; +import org.broadinstitute.sting.utils.genotype.calls.GenotypeCall; +import org.broadinstitute.sting.utils.genotype.calls.SSGGenotypeCall; import java.io.File; import java.io.FileNotFoundException; diff --git a/java/src/org/broadinstitute/sting/playground/utils/GenotypeLikelihoods.java b/java/src/org/broadinstitute/sting/playground/utils/GenotypeLikelihoods.java index bb2ae19a8..1158365e9 100644 --- a/java/src/org/broadinstitute/sting/playground/utils/GenotypeLikelihoods.java +++ b/java/src/org/broadinstitute/sting/playground/utils/GenotypeLikelihoods.java @@ -2,15 +2,21 @@ package org.broadinstitute.sting.playground.utils; import net.sf.samtools.SAMRecord; import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker; -import org.broadinstitute.sting.utils.*; -import org.broadinstitute.sting.utils.genotype.*; +import org.broadinstitute.sting.utils.MathUtils; +import org.broadinstitute.sting.utils.ReadBackedPileup; +import org.broadinstitute.sting.utils.Utils; +import org.broadinstitute.sting.utils.genotype.BasicGenotype; +import org.broadinstitute.sting.utils.genotype.Genotype; +import org.broadinstitute.sting.utils.genotype.GenotypeGenerator; +import org.broadinstitute.sting.utils.genotype.calls.GenotypeCall; +import org.broadinstitute.sting.utils.genotype.calls.SSGGenotypeCall; import org.broadinstitute.sting.utils.genotype.confidence.BayesianConfidenceScore; import static java.lang.Math.log10; import static java.lang.Math.pow; +import java.util.ArrayList; import java.util.HashMap; import java.util.List; -import java.util.ArrayList; public class GenotypeLikelihoods implements GenotypeGenerator { // precalculate these for performance (pow/log10 is expensive!) diff --git a/java/src/org/broadinstitute/sting/utils/genotype/BasicGenotype.java b/java/src/org/broadinstitute/sting/utils/genotype/BasicGenotype.java index 1623bf853..149ad8843 100644 --- a/java/src/org/broadinstitute/sting/utils/genotype/BasicGenotype.java +++ b/java/src/org/broadinstitute/sting/utils/genotype/BasicGenotype.java @@ -6,12 +6,11 @@ import org.broadinstitute.sting.utils.genotype.confidence.ConfidenceScore; /** - * - * @author aaron - * - * Class BasicGenotype - * - * A basic implementation of the genotype interface + * @author aaron + *

+ * Class BasicGenotype + *

+ * A basic implementation of the genotype interface */ public class BasicGenotype implements Genotype { @@ -30,7 +29,7 @@ public class BasicGenotype implements Genotype { /** * construct a genotypeLikelihood, given the bases, the confidence score, and the ploidy * - * @param loc the location of the genotype + * @param loc the location of the genotype * @param bases the bases that make up this genotype * @param ploidy the ploidy of this genotype * @param score the confidence score @@ -49,7 +48,7 @@ public class BasicGenotype implements Genotype { * construct a genotypeLikelihood, given the bases and the confidence score, and assume the * ploidy is 2. * - * @param loc the location of the genotype + * @param loc the location of the genotype * @param bases the bases that make up this genotype * @param score the confidence score */ @@ -64,6 +63,7 @@ public class BasicGenotype implements Genotype { /** * get the confidence score + * * @return get the confidence score that we're based on */ public ConfidenceScore getConfidenceScore() { @@ -81,6 +81,7 @@ public class BasicGenotype implements Genotype { /** * get the ploidy + * * @return the ploidy value */ public int getPloidy() { @@ -117,6 +118,7 @@ public class BasicGenotype implements Genotype { /** * get the genotype's location + * * @return a GenomeLoc representing the location */ public GenomeLoc getLocation() { @@ -142,7 +144,7 @@ public class BasicGenotype implements Genotype { */ @Override public boolean isVariant(char ref) { - String ret = Utils.dupString(ref,this.getPloidy()); + String ret = Utils.dupString(ref, this.getPloidy()); return !this.getBases().equals(ret); } @@ -155,4 +157,13 @@ public class BasicGenotype implements Genotype { public Variant toVariant() { return null; } + + /** + * set the confidence score + * @param confidenceScore + */ + public void setConfidenceScore(ConfidenceScore confidenceScore) { + this.mConfidenceScore = confidenceScore; + } + } diff --git a/java/src/org/broadinstitute/sting/utils/genotype/ConfidenceScoreComparator.java b/java/src/org/broadinstitute/sting/utils/genotype/ConfidenceScoreComparator.java new file mode 100644 index 000000000..7e30e3b00 --- /dev/null +++ b/java/src/org/broadinstitute/sting/utils/genotype/ConfidenceScoreComparator.java @@ -0,0 +1,20 @@ +package org.broadinstitute.sting.utils.genotype; + +import java.util.Comparator; + + +/** + * + * @author aaron + * + * Class ConfidenceScoreComparator + * + * A descriptions should go here. Blame aaron if it's missing. + */ + +public class ConfidenceScoreComparator implements Comparator { + @Override + public int compare(Genotype genotype, Genotype genotype1) { + return genotype.getConfidenceScore().compareTo(genotype1.getConfidenceScore()); + } +} \ No newline at end of file diff --git a/java/src/org/broadinstitute/sting/utils/genotype/GenotypeGenerator.java b/java/src/org/broadinstitute/sting/utils/genotype/GenotypeGenerator.java index d99a40a81..231a4f1bb 100644 --- a/java/src/org/broadinstitute/sting/utils/genotype/GenotypeGenerator.java +++ b/java/src/org/broadinstitute/sting/utils/genotype/GenotypeGenerator.java @@ -22,5 +22,5 @@ public interface GenotypeGenerator { * @param pileup a pileup of the reads, containing the reads and their offsets * @return a GenotypeLocus, containing each of the genotypes and their associated likelihood and posterior prob values */ - public GenotypeCall callGenotypes(RefMetaDataTracker tracker, char ref, ReadBackedPileup pileup); + public org.broadinstitute.sting.utils.genotype.calls.GenotypeCall callGenotypes(RefMetaDataTracker tracker, char ref, ReadBackedPileup pileup); } diff --git a/java/src/org/broadinstitute/sting/utils/genotype/GenotypeWriter.java b/java/src/org/broadinstitute/sting/utils/genotype/GenotypeWriter.java index 78a191b6d..d74a06e5a 100644 --- a/java/src/org/broadinstitute/sting/utils/genotype/GenotypeWriter.java +++ b/java/src/org/broadinstitute/sting/utils/genotype/GenotypeWriter.java @@ -38,7 +38,7 @@ public interface GenotypeWriter { * Add a genotype, given a genotype locus * @param locus the locus to add */ - public void addGenotypeCall(GenotypeCall locus); + public void addGenotypeCall(org.broadinstitute.sting.utils.genotype.calls.GenotypeCall locus); /** * add a no call to the genotype file, if supported. diff --git a/java/src/org/broadinstitute/sting/utils/genotype/LexigraphicalComparator.java b/java/src/org/broadinstitute/sting/utils/genotype/LexigraphicalComparator.java new file mode 100644 index 000000000..6568bc22a --- /dev/null +++ b/java/src/org/broadinstitute/sting/utils/genotype/LexigraphicalComparator.java @@ -0,0 +1,22 @@ +package org.broadinstitute.sting.utils.genotype; + +import java.util.Comparator; + + +/** + * + * @author aaron + * + * Class LexigraphicalComparator + * + * A descriptions should go here. Blame aaron if it's missing. + */ + +public class LexigraphicalComparator implements Comparator { + private final Double EPSILON = 1.0e-15; + + @Override + public int compare(Genotype genotype, Genotype genotype1) { + return genotype.getBases().compareTo(genotype1.getBases()); + } +} diff --git a/java/src/org/broadinstitute/sting/utils/genotype/TabularLFWriter.java b/java/src/org/broadinstitute/sting/utils/genotype/TabularLFWriter.java index 0fe66affd..eb7036704 100644 --- a/java/src/org/broadinstitute/sting/utils/genotype/TabularLFWriter.java +++ b/java/src/org/broadinstitute/sting/utils/genotype/TabularLFWriter.java @@ -1,6 +1,7 @@ package org.broadinstitute.sting.utils.genotype; import org.broadinstitute.sting.utils.StingException; +import org.broadinstitute.sting.utils.genotype.calls.GenotypeCall; import java.io.File; import java.io.FileNotFoundException; diff --git a/java/src/org/broadinstitute/sting/utils/genotype/GenotypeCall.java b/java/src/org/broadinstitute/sting/utils/genotype/calls/GenotypeCall.java similarity index 71% rename from java/src/org/broadinstitute/sting/utils/genotype/GenotypeCall.java rename to java/src/org/broadinstitute/sting/utils/genotype/calls/GenotypeCall.java index 91c4d0ab5..23ba60427 100644 --- a/java/src/org/broadinstitute/sting/utils/genotype/GenotypeCall.java +++ b/java/src/org/broadinstitute/sting/utils/genotype/calls/GenotypeCall.java @@ -1,8 +1,8 @@ -package org.broadinstitute.sting.utils.genotype; +package org.broadinstitute.sting.utils.genotype.calls; import org.broadinstitute.sting.utils.GenomeLoc; +import org.broadinstitute.sting.utils.genotype.Genotype; -import java.util.Comparator; import java.util.List; /** @@ -51,19 +51,3 @@ public interface GenotypeCall extends Genotype { public List getLexigraphicallySortedGenotypes(); } - -class LexigraphicalComparator implements Comparator { - private final Double EPSILON = 1.0e-15; - - @Override - public int compare(Genotype genotype, Genotype genotype1) { - return genotype.getBases().compareTo(genotype1.getBases()); - } -} - -class ConfidenceScoreSort implements Comparator { - @Override - public int compare(Genotype genotype, Genotype genotype1) { - return genotype.getConfidenceScore().compareTo(genotype1.getConfidenceScore()); - } -} \ No newline at end of file diff --git a/java/src/org/broadinstitute/sting/utils/genotype/SSGGenotypeCall.java b/java/src/org/broadinstitute/sting/utils/genotype/calls/SSGGenotypeCall.java similarity index 90% rename from java/src/org/broadinstitute/sting/utils/genotype/SSGGenotypeCall.java rename to java/src/org/broadinstitute/sting/utils/genotype/calls/SSGGenotypeCall.java index 46cbe9075..d3519c573 100644 --- a/java/src/org/broadinstitute/sting/utils/genotype/SSGGenotypeCall.java +++ b/java/src/org/broadinstitute/sting/utils/genotype/calls/SSGGenotypeCall.java @@ -1,14 +1,20 @@ -package org.broadinstitute.sting.utils.genotype; +package org.broadinstitute.sting.utils.genotype.calls; +import net.sf.samtools.SAMRecord; import org.broadinstitute.sting.utils.GenomeLoc; import org.broadinstitute.sting.utils.ReadBackedPileup; import org.broadinstitute.sting.utils.Utils; -import org.broadinstitute.sting.utils.genotype.confidence.ConfidenceScore; +import org.broadinstitute.sting.utils.genotype.BasicGenotype; +import org.broadinstitute.sting.utils.genotype.Genotype; +import org.broadinstitute.sting.utils.genotype.LexigraphicalComparator; +import org.broadinstitute.sting.utils.genotype.Variant; import org.broadinstitute.sting.utils.genotype.confidence.BayesianConfidenceScore; +import org.broadinstitute.sting.utils.genotype.confidence.ConfidenceScore; -import java.util.*; - -import net.sf.samtools.SAMRecord; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.TreeMap; /** @@ -22,7 +28,7 @@ import net.sf.samtools.SAMRecord; public class SSGGenotypeCall implements GenotypeCall { // TODO: make SSG into a more robust Genotype call interface // our stored genotype locus - private final char mRefBase; + private final String mRefBase; private final int mPloidy; private final GenomeLoc mLoc; private TreeMap mGenotypes = new TreeMap(); @@ -34,7 +40,7 @@ public class SSGGenotypeCall implements GenotypeCall { private double rmsMapping; public SSGGenotypeCall(char mRefBase, int mPloidy, GenomeLoc mLoc, List genotypes, double likelihoods[], ReadBackedPileup pileup) { - this.mRefBase = mRefBase; + this.mRefBase = String.valueOf(mRefBase).toUpperCase(); this.mPloidy = mPloidy; this.mLoc = mLoc; if (genotypes.size() < 1) throw new IllegalArgumentException("Genotypes list size must be greater than 0"); @@ -56,7 +62,7 @@ public class SSGGenotypeCall implements GenotypeCall { mLikelihoods = likelihoods; index = 0; for (Genotype g : genotypes) { - ((BasicGenotype)g).mConfidenceScore = new BayesianConfidenceScore(Math.abs(likelihoods[index] - ref)); + ((BasicGenotype)g).setConfidenceScore( new BayesianConfidenceScore(Math.abs(likelihoods[index] - ref))); mGenotypes.put(likelihoods[index],g); index++; } @@ -80,7 +86,7 @@ public class SSGGenotypeCall implements GenotypeCall { */ @Override public char getReferencebase() { - return mRefBase; + return mRefBase.charAt(0); } /** @@ -90,7 +96,7 @@ public class SSGGenotypeCall implements GenotypeCall { */ @Override public boolean isVariation() { - return mGenotypes.get(mGenotypes.descendingKeySet().first()).isVariant(mRefBase); + return mGenotypes.get(mGenotypes.descendingKeySet().first()).isVariant(mRefBase.charAt(0)); } /** diff --git a/java/src/org/broadinstitute/sting/utils/genotype/geli/GeliAdapter.java b/java/src/org/broadinstitute/sting/utils/genotype/geli/GeliAdapter.java index e273cbe96..84d19a30e 100644 --- a/java/src/org/broadinstitute/sting/utils/genotype/geli/GeliAdapter.java +++ b/java/src/org/broadinstitute/sting/utils/genotype/geli/GeliAdapter.java @@ -3,10 +3,10 @@ package org.broadinstitute.sting.utils.genotype.geli; import edu.mit.broad.picard.genotype.geli.GeliFileWriter; import net.sf.samtools.SAMFileHeader; import net.sf.samtools.SAMSequenceRecord; -import org.broadinstitute.sting.utils.genotype.GenotypeCall; import org.broadinstitute.sting.utils.genotype.GenotypeWriter; import org.broadinstitute.sting.utils.genotype.IndelLikelihood; import org.broadinstitute.sting.utils.genotype.LikelihoodObject; +import org.broadinstitute.sting.utils.genotype.calls.GenotypeCall; import java.io.File; @@ -101,7 +101,7 @@ public class GeliAdapter implements GenotypeWriter { */ @Override public void addGenotypeCall(GenotypeCall locus) { - //To change body of implemented methods use File | Settings | File Templates. + // TODO: add code here } /** diff --git a/java/src/org/broadinstitute/sting/utils/genotype/geli/GeliTextWriter.java b/java/src/org/broadinstitute/sting/utils/genotype/geli/GeliTextWriter.java index a146a9148..04f4c1952 100644 --- a/java/src/org/broadinstitute/sting/utils/genotype/geli/GeliTextWriter.java +++ b/java/src/org/broadinstitute/sting/utils/genotype/geli/GeliTextWriter.java @@ -1,9 +1,9 @@ package org.broadinstitute.sting.utils.genotype.geli; import org.broadinstitute.sting.utils.StingException; -import org.broadinstitute.sting.utils.genotype.GenotypeCall; +import org.broadinstitute.sting.utils.genotype.calls.GenotypeCall; import org.broadinstitute.sting.utils.genotype.GenotypeWriter; -import org.broadinstitute.sting.utils.genotype.SSGGenotypeCall; +import org.broadinstitute.sting.utils.genotype.calls.SSGGenotypeCall; import java.io.File; import java.io.FileNotFoundException; @@ -50,8 +50,8 @@ public class GeliTextWriter implements GenotypeWriter { call.getReadDepth(), -1, locus.getBases(), - call.getConfidenceScore().getScore(), - locus.getConfidenceScore().getScore(), + call.getBestRef(), + call.getBestNext(), call.getLikelihoods()[0], call.getLikelihoods()[1], call.getLikelihoods()[2], diff --git a/java/src/org/broadinstitute/sting/utils/genotype/glf/GLFWriter.java b/java/src/org/broadinstitute/sting/utils/genotype/glf/GLFWriter.java index 96acb6569..7af77998a 100755 --- a/java/src/org/broadinstitute/sting/utils/genotype/glf/GLFWriter.java +++ b/java/src/org/broadinstitute/sting/utils/genotype/glf/GLFWriter.java @@ -4,7 +4,11 @@ import net.sf.samtools.SAMSequenceRecord; import net.sf.samtools.util.BinaryCodec; import net.sf.samtools.util.BlockCompressedOutputStream; import org.broadinstitute.sting.utils.GenomeLocParser; -import org.broadinstitute.sting.utils.genotype.*; +import org.broadinstitute.sting.utils.genotype.GenotypeWriter; +import org.broadinstitute.sting.utils.genotype.IndelLikelihood; +import org.broadinstitute.sting.utils.genotype.LikelihoodObject; +import org.broadinstitute.sting.utils.genotype.calls.GenotypeCall; +import org.broadinstitute.sting.utils.genotype.calls.SSGGenotypeCall; import java.io.DataOutputStream; import java.io.File;