more cleanup
git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@1631 348d0f76-0448-11de-a6fe-93d51630548a
This commit is contained in:
parent
9f7cf73411
commit
542d817688
|
|
@ -3,10 +3,9 @@ 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;
|
||||
import org.broadinstitute.sting.utils.genotype.Genotype;
|
||||
import org.broadinstitute.sting.utils.Utils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
|
@ -23,7 +22,6 @@ import java.util.List;
|
|||
public class CallableBasesAnalysis extends BasicVariantAnalysis implements GenotypeAnalysis {
|
||||
long all_bases = 0;
|
||||
long all_calls = 0;
|
||||
//final static double[] Qthresholds = { 10, 20, 30, 40, 50, 100, 200, 500, 1000 };
|
||||
final static double[] thresholds = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 15, 20, 50, 100};
|
||||
long[] discoverable_bases = new long[thresholds.length];
|
||||
long[] genotypable_bases = new long[thresholds.length];
|
||||
|
|
@ -64,14 +62,14 @@ public class CallableBasesAnalysis extends BasicVariantAnalysis implements Genot
|
|||
|
||||
// we actually have a record here
|
||||
if (!(eval instanceof VariantBackedByGenotype)) { // evaluation record isn't a genotype, die!
|
||||
throw new RuntimeException("Evaluation track isn't an Genotype!");
|
||||
throw new RuntimeException("Evaluation track isn't backed by a Genotype!");
|
||||
}
|
||||
|
||||
all_calls++;
|
||||
// For every threshold, updated discoverable and callable
|
||||
for (int i = 0; i < thresholds.length; i++) {
|
||||
double threshold = thresholds[i];
|
||||
DiploidGenotype g = DiploidGenotype.valueOf(Utils.dupString(ref, 2));
|
||||
DiploidGenotype g = DiploidGenotype.createHomGenotype(ref);
|
||||
Genotype genotype = ((VariantBackedByGenotype) eval).getGenotype(g);
|
||||
// update discoverable
|
||||
if (eval.isSNP() && eval.getNegLog10PError() >= threshold)
|
||||
|
|
|
|||
|
|
@ -2,9 +2,8 @@ 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.StingException;
|
||||
import org.broadinstitute.sting.utils.Utils;
|
||||
import org.broadinstitute.sting.utils.genotype.DiploidGenotype;
|
||||
import org.broadinstitute.sting.utils.genotype.VariantBackedByGenotype;
|
||||
import org.broadinstitute.sting.utils.genotype.Variation;
|
||||
|
||||
|
|
@ -50,7 +49,7 @@ public class GenotypeConcordance extends BasicVariantAnalysis implements Genotyp
|
|||
if ((chip != null && !(chip instanceof VariantBackedByGenotype) || (eval != null && !(eval instanceof VariantBackedByGenotype))))
|
||||
throw new StingException("Failure: trying to analyze genotypes of non-genotype data");
|
||||
|
||||
DiploidGenotype g = DiploidGenotype.valueOf(Utils.dupString(ref, 2));
|
||||
DiploidGenotype g = DiploidGenotype.createHomGenotype(ref);
|
||||
int truthIndex, callIndex;
|
||||
if (chip == null)
|
||||
truthIndex = UNKNOWN;
|
||||
|
|
|
|||
|
|
@ -4,26 +4,38 @@ import org.broadinstitute.sting.utils.GenomeLoc;
|
|||
|
||||
|
||||
/**
|
||||
*
|
||||
* @author aaron
|
||||
*
|
||||
* Class BasicGenotype
|
||||
*
|
||||
* represents a basic genotype object
|
||||
* @author aaron
|
||||
* <p/>
|
||||
* Class BasicGenotype
|
||||
* <p/>
|
||||
* represents a basic genotype object. That means that is
|
||||
* an implementation for a basic genotype call, given the genotype
|
||||
* string, the ref base, the confidence score, and the location. This
|
||||
* class currently only represents point genotypes, not indels
|
||||
*/
|
||||
public class BasicGenotype implements Genotype {
|
||||
// the genotype string
|
||||
private String mGenotype;
|
||||
|
||||
// our location
|
||||
private GenomeLoc mLocation;
|
||||
|
||||
// the reference base.
|
||||
private char mRef;
|
||||
private double mNetLog10PError;
|
||||
|
||||
// the confidence score
|
||||
private double mNegLog10PError;
|
||||
|
||||
/**
|
||||
* create a basic genotype
|
||||
* @param genotype
|
||||
* create a basic genotype, given the following fields
|
||||
*
|
||||
* @param location the genomic location
|
||||
* @param genotype the genotype, as a string, where ploidy = string.length
|
||||
* @param ref the reference base as a char
|
||||
* @param negLog10PError the confidence score
|
||||
*/
|
||||
public BasicGenotype(GenomeLoc location, String genotype, char ref, double netLog10PError) {
|
||||
mNetLog10PError = netLog10PError;
|
||||
public BasicGenotype(GenomeLoc location, String genotype, char ref, double negLog10PError) {
|
||||
mNegLog10PError = negLog10PError;
|
||||
mGenotype = genotype;
|
||||
mLocation = location;
|
||||
mRef = ref;
|
||||
|
|
@ -32,15 +44,15 @@ public class BasicGenotype implements Genotype {
|
|||
/**
|
||||
* get the -1 * (log 10 of the error value)
|
||||
*
|
||||
* @return the log based error estimate
|
||||
* @return the negitive log based error estimate
|
||||
*/
|
||||
@Override
|
||||
public double getNegLog10PError() {
|
||||
return mNetLog10PError;
|
||||
return mNegLog10PError;
|
||||
}
|
||||
|
||||
/**
|
||||
* get the bases that represent this
|
||||
* get the bases that represent this genotype
|
||||
*
|
||||
* @return the bases, as a string
|
||||
*/
|
||||
|
|
@ -60,7 +72,7 @@ public class BasicGenotype implements Genotype {
|
|||
}
|
||||
|
||||
/**
|
||||
* Returns true if both observed alleles are the same (regardless of whether they are ref or alt)
|
||||
* Returns true if both observed allele bases are the same (regardless of whether they are ref or alt)
|
||||
*
|
||||
* @return true if we're homozygous, false otherwise
|
||||
*/
|
||||
|
|
@ -79,7 +91,7 @@ public class BasicGenotype implements Genotype {
|
|||
}
|
||||
|
||||
/**
|
||||
* Returns true if observed alleles differ (regardless of whether they are ref or alt)
|
||||
* Returns true if observed allele bases differ (regardless of whether they are ref or alt)
|
||||
*
|
||||
* @return true if we're het, false otherwise
|
||||
*/
|
||||
|
|
@ -138,6 +150,6 @@ public class BasicGenotype implements Genotype {
|
|||
@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,mNetLog10PError);
|
||||
return new BasicVariation(this.getBases(), String.valueOf(mRef), this.getBases().length(), mLocation, mNegLog10PError);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,23 +3,31 @@ package org.broadinstitute.sting.utils.genotype;
|
|||
import org.broadinstitute.sting.utils.GenomeLoc;
|
||||
|
||||
/**
|
||||
* Created by IntelliJ IDEA.
|
||||
* User: aaronmckenna
|
||||
* User: aaron
|
||||
* Date: Sep 9, 2009
|
||||
* Time: 9:32:34 PM
|
||||
* <p/>
|
||||
* a basic implementation of variant
|
||||
* a basic implementation of the Variation interface.
|
||||
*/
|
||||
public class BasicVariation implements Variation {
|
||||
|
||||
// the bases that make up this variant
|
||||
protected final String mBases;
|
||||
|
||||
// the reference base
|
||||
protected final String mRef;
|
||||
|
||||
// the length of the event, 0 for a SNP, negitive for deletions, positive for insertions
|
||||
protected final int mLength;
|
||||
|
||||
// the location on the genome of the event
|
||||
protected final GenomeLoc mLocation;
|
||||
|
||||
// our confidence in this event, and a -(log10(Error))
|
||||
protected final double mConfidence;
|
||||
|
||||
/**
|
||||
* the constructor
|
||||
* create a basic variation, given the following parameters:
|
||||
*
|
||||
* @param bases the bases that this variant represents
|
||||
* @param reference the reference bases
|
||||
|
|
@ -34,11 +42,21 @@ public class BasicVariation implements Variation {
|
|||
mConfidence = confidence;
|
||||
}
|
||||
|
||||
/**
|
||||
* we don't know the minor allele freq. is this implementation
|
||||
*
|
||||
* @return -1.0. If the freq is less than zero it means we don't know
|
||||
*/
|
||||
@Override
|
||||
public double getNonRefAlleleFrequency() {
|
||||
return -1.0;
|
||||
}
|
||||
|
||||
/**
|
||||
* get the type of variation we are
|
||||
*
|
||||
* @return VARIANT_TYPE
|
||||
*/
|
||||
@Override
|
||||
public VARIANT_TYPE getType() {
|
||||
if (mLength > 0) return VARIANT_TYPE.INDEL;
|
||||
|
|
@ -84,7 +102,7 @@ public class BasicVariation implements Variation {
|
|||
|
||||
@Override
|
||||
public boolean isReference() {
|
||||
if (mLength != 0) return true;
|
||||
if (mLength != 0) return false;
|
||||
int refIndex = 0;
|
||||
for (char c : mBases.toCharArray()) {
|
||||
if (mRef.charAt(refIndex) != c) return false;
|
||||
|
|
@ -93,7 +111,7 @@ public class BasicVariation implements Variation {
|
|||
}
|
||||
|
||||
/**
|
||||
* are we an insertion or a deletion? yes, then return true. No? Well, false it is.
|
||||
* are we an insertion or a deletion? yes, then return true.
|
||||
*
|
||||
* @return true if we're an insertion or deletion
|
||||
*/
|
||||
|
|
@ -111,6 +129,8 @@ public class BasicVariation implements Variation {
|
|||
@Override
|
||||
public char getAlternativeBaseForSNP() {
|
||||
if (!this.isSNP()) throw new IllegalStateException("we're not a SNP");
|
||||
|
||||
// we know that if we're a snp, the reference is a single base, so charAt(0) is safe
|
||||
if (getAlternateBases().charAt(0) == this.getReference().charAt(0))
|
||||
return getAlternateBases().charAt(1);
|
||||
return getAlternateBases().charAt(0);
|
||||
|
|
@ -124,6 +144,8 @@ public class BasicVariation implements Variation {
|
|||
@Override
|
||||
public char getReferenceForSNP() {
|
||||
if (!this.isSNP()) throw new IllegalStateException("we're not a SNP");
|
||||
|
||||
// we know that if we're a snp, the reference is a single base, so charAt(0) is safe
|
||||
if (getAlternateBases().charAt(0) == this.getReference().charAt(0))
|
||||
return getAlternateBases().charAt(0);
|
||||
return getAlternateBases().charAt(1);
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ public enum DiploidGenotype {
|
|||
* @param hom the character to turn into a hom genotype, i.e. if it is A, then returned will be AA
|
||||
* @return the diploid genotype
|
||||
*/
|
||||
public static DiploidGenotype createGenotype(char hom) {
|
||||
public static DiploidGenotype createHomGenotype(char hom) {
|
||||
return DiploidGenotype.valueOf((String.valueOf(hom) + String.valueOf(hom)).toUpperCase());
|
||||
}
|
||||
}
|
||||
|
|
@ -83,19 +83,19 @@ public class DiploidGenotypeTest extends BaseTest {
|
|||
@Test
|
||||
public void testCreateGenotype() {
|
||||
char ref = 'A';
|
||||
DiploidGenotype g = DiploidGenotype.createGenotype(ref);
|
||||
DiploidGenotype g = DiploidGenotype.createHomGenotype(ref);
|
||||
Assert.assertTrue("AA".equals(g.toString()));
|
||||
|
||||
ref = 'a';
|
||||
g = DiploidGenotype.createGenotype(ref);
|
||||
g = DiploidGenotype.createHomGenotype(ref);
|
||||
Assert.assertTrue("AA".equals(g.toString()));
|
||||
|
||||
ref = 't';
|
||||
g = DiploidGenotype.createGenotype(ref);
|
||||
g = DiploidGenotype.createHomGenotype(ref);
|
||||
Assert.assertTrue("TT".equals(g.toString()));
|
||||
|
||||
ref = 'T';
|
||||
g = DiploidGenotype.createGenotype(ref);
|
||||
g = DiploidGenotype.createHomGenotype(ref);
|
||||
Assert.assertTrue("TT".equals(g.toString()));
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue