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.contexts.AlignmentContext;
|
||||||
import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker;
|
import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker;
|
||||||
import org.broadinstitute.sting.utils.genotype.DiploidGenotype;
|
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.VariantBackedByGenotype;
|
||||||
import org.broadinstitute.sting.utils.genotype.Variation;
|
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.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
@ -23,7 +22,6 @@ import java.util.List;
|
||||||
public class CallableBasesAnalysis extends BasicVariantAnalysis implements GenotypeAnalysis {
|
public class CallableBasesAnalysis extends BasicVariantAnalysis implements GenotypeAnalysis {
|
||||||
long all_bases = 0;
|
long all_bases = 0;
|
||||||
long all_calls = 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};
|
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[] discoverable_bases = new long[thresholds.length];
|
||||||
long[] genotypable_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
|
// we actually have a record here
|
||||||
if (!(eval instanceof VariantBackedByGenotype)) { // evaluation record isn't a genotype, die!
|
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++;
|
all_calls++;
|
||||||
// For every threshold, updated discoverable and callable
|
// For every threshold, updated discoverable and callable
|
||||||
for (int i = 0; i < thresholds.length; i++) {
|
for (int i = 0; i < thresholds.length; i++) {
|
||||||
double threshold = thresholds[i];
|
double threshold = thresholds[i];
|
||||||
DiploidGenotype g = DiploidGenotype.valueOf(Utils.dupString(ref, 2));
|
DiploidGenotype g = DiploidGenotype.createHomGenotype(ref);
|
||||||
Genotype genotype = ((VariantBackedByGenotype) eval).getGenotype(g);
|
Genotype genotype = ((VariantBackedByGenotype) eval).getGenotype(g);
|
||||||
// update discoverable
|
// update discoverable
|
||||||
if (eval.isSNP() && eval.getNegLog10PError() >= threshold)
|
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.contexts.AlignmentContext;
|
||||||
import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker;
|
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.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.VariantBackedByGenotype;
|
||||||
import org.broadinstitute.sting.utils.genotype.Variation;
|
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))))
|
if ((chip != null && !(chip instanceof VariantBackedByGenotype) || (eval != null && !(eval instanceof VariantBackedByGenotype))))
|
||||||
throw new StingException("Failure: trying to analyze genotypes of non-genotype data");
|
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;
|
int truthIndex, callIndex;
|
||||||
if (chip == null)
|
if (chip == null)
|
||||||
truthIndex = UNKNOWN;
|
truthIndex = UNKNOWN;
|
||||||
|
|
|
||||||
|
|
@ -4,26 +4,38 @@ import org.broadinstitute.sting.utils.GenomeLoc;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* @author aaron
|
||||||
* @author aaron
|
* <p/>
|
||||||
*
|
* Class BasicGenotype
|
||||||
* Class BasicGenotype
|
* <p/>
|
||||||
*
|
* represents a basic genotype object. That means that is
|
||||||
* represents a basic genotype object
|
* 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 {
|
public class BasicGenotype implements Genotype {
|
||||||
// the genotype string
|
// the genotype string
|
||||||
private String mGenotype;
|
private String mGenotype;
|
||||||
|
|
||||||
|
// our location
|
||||||
private GenomeLoc mLocation;
|
private GenomeLoc mLocation;
|
||||||
|
|
||||||
|
// the reference base.
|
||||||
private char mRef;
|
private char mRef;
|
||||||
private double mNetLog10PError;
|
|
||||||
|
// the confidence score
|
||||||
|
private double mNegLog10PError;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* create a basic genotype
|
* create a basic genotype, given the following fields
|
||||||
* @param genotype
|
*
|
||||||
|
* @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) {
|
public BasicGenotype(GenomeLoc location, String genotype, char ref, double negLog10PError) {
|
||||||
mNetLog10PError = netLog10PError;
|
mNegLog10PError = negLog10PError;
|
||||||
mGenotype = genotype;
|
mGenotype = genotype;
|
||||||
mLocation = location;
|
mLocation = location;
|
||||||
mRef = ref;
|
mRef = ref;
|
||||||
|
|
@ -32,15 +44,15 @@ public class BasicGenotype implements Genotype {
|
||||||
/**
|
/**
|
||||||
* get the -1 * (log 10 of the error value)
|
* get the -1 * (log 10 of the error value)
|
||||||
*
|
*
|
||||||
* @return the log based error estimate
|
* @return the negitive log based error estimate
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public double getNegLog10PError() {
|
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
|
* @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
|
* @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
|
* @return true if we're het, false otherwise
|
||||||
*/
|
*/
|
||||||
|
|
@ -138,6 +150,6 @@ public class BasicGenotype implements Genotype {
|
||||||
@Override
|
@Override
|
||||||
public Variation toVariation() {
|
public Variation toVariation() {
|
||||||
if (!isVariant(this.mRef)) throw new IllegalStateException("this genotype is not a variant");
|
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;
|
import org.broadinstitute.sting.utils.GenomeLoc;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by IntelliJ IDEA.
|
* User: aaron
|
||||||
* User: aaronmckenna
|
|
||||||
* Date: Sep 9, 2009
|
* Date: Sep 9, 2009
|
||||||
* Time: 9:32:34 PM
|
* Time: 9:32:34 PM
|
||||||
* <p/>
|
* <p/>
|
||||||
* a basic implementation of variant
|
* a basic implementation of the Variation interface.
|
||||||
*/
|
*/
|
||||||
public class BasicVariation implements Variation {
|
public class BasicVariation implements Variation {
|
||||||
|
|
||||||
|
// the bases that make up this variant
|
||||||
protected final String mBases;
|
protected final String mBases;
|
||||||
|
|
||||||
|
// the reference base
|
||||||
protected final String mRef;
|
protected final String mRef;
|
||||||
|
|
||||||
|
// the length of the event, 0 for a SNP, negitive for deletions, positive for insertions
|
||||||
protected final int mLength;
|
protected final int mLength;
|
||||||
|
|
||||||
|
// the location on the genome of the event
|
||||||
protected final GenomeLoc mLocation;
|
protected final GenomeLoc mLocation;
|
||||||
|
|
||||||
|
// our confidence in this event, and a -(log10(Error))
|
||||||
protected final double mConfidence;
|
protected final double mConfidence;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* the constructor
|
* create a basic variation, given the following parameters:
|
||||||
*
|
*
|
||||||
* @param bases the bases that this variant represents
|
* @param bases the bases that this variant represents
|
||||||
* @param reference the reference bases
|
* @param reference the reference bases
|
||||||
|
|
@ -34,11 +42,21 @@ public class BasicVariation implements Variation {
|
||||||
mConfidence = confidence;
|
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
|
@Override
|
||||||
public double getNonRefAlleleFrequency() {
|
public double getNonRefAlleleFrequency() {
|
||||||
return -1.0;
|
return -1.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get the type of variation we are
|
||||||
|
*
|
||||||
|
* @return VARIANT_TYPE
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public VARIANT_TYPE getType() {
|
public VARIANT_TYPE getType() {
|
||||||
if (mLength > 0) return VARIANT_TYPE.INDEL;
|
if (mLength > 0) return VARIANT_TYPE.INDEL;
|
||||||
|
|
@ -84,7 +102,7 @@ public class BasicVariation implements Variation {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isReference() {
|
public boolean isReference() {
|
||||||
if (mLength != 0) return true;
|
if (mLength != 0) return false;
|
||||||
int refIndex = 0;
|
int refIndex = 0;
|
||||||
for (char c : mBases.toCharArray()) {
|
for (char c : mBases.toCharArray()) {
|
||||||
if (mRef.charAt(refIndex) != c) return false;
|
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
|
* @return true if we're an insertion or deletion
|
||||||
*/
|
*/
|
||||||
|
|
@ -111,6 +129,8 @@ public class BasicVariation implements Variation {
|
||||||
@Override
|
@Override
|
||||||
public char getAlternativeBaseForSNP() {
|
public char getAlternativeBaseForSNP() {
|
||||||
if (!this.isSNP()) throw new IllegalStateException("we're not a SNP");
|
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))
|
if (getAlternateBases().charAt(0) == this.getReference().charAt(0))
|
||||||
return getAlternateBases().charAt(1);
|
return getAlternateBases().charAt(1);
|
||||||
return getAlternateBases().charAt(0);
|
return getAlternateBases().charAt(0);
|
||||||
|
|
@ -124,6 +144,8 @@ public class BasicVariation implements Variation {
|
||||||
@Override
|
@Override
|
||||||
public char getReferenceForSNP() {
|
public char getReferenceForSNP() {
|
||||||
if (!this.isSNP()) throw new IllegalStateException("we're not a SNP");
|
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))
|
if (getAlternateBases().charAt(0) == this.getReference().charAt(0))
|
||||||
return getAlternateBases().charAt(0);
|
return getAlternateBases().charAt(0);
|
||||||
return getAlternateBases().charAt(1);
|
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
|
* @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
|
* @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());
|
return DiploidGenotype.valueOf((String.valueOf(hom) + String.valueOf(hom)).toUpperCase());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -83,19 +83,19 @@ public class DiploidGenotypeTest extends BaseTest {
|
||||||
@Test
|
@Test
|
||||||
public void testCreateGenotype() {
|
public void testCreateGenotype() {
|
||||||
char ref = 'A';
|
char ref = 'A';
|
||||||
DiploidGenotype g = DiploidGenotype.createGenotype(ref);
|
DiploidGenotype g = DiploidGenotype.createHomGenotype(ref);
|
||||||
Assert.assertTrue("AA".equals(g.toString()));
|
Assert.assertTrue("AA".equals(g.toString()));
|
||||||
|
|
||||||
ref = 'a';
|
ref = 'a';
|
||||||
g = DiploidGenotype.createGenotype(ref);
|
g = DiploidGenotype.createHomGenotype(ref);
|
||||||
Assert.assertTrue("AA".equals(g.toString()));
|
Assert.assertTrue("AA".equals(g.toString()));
|
||||||
|
|
||||||
ref = 't';
|
ref = 't';
|
||||||
g = DiploidGenotype.createGenotype(ref);
|
g = DiploidGenotype.createHomGenotype(ref);
|
||||||
Assert.assertTrue("TT".equals(g.toString()));
|
Assert.assertTrue("TT".equals(g.toString()));
|
||||||
|
|
||||||
ref = 'T';
|
ref = 'T';
|
||||||
g = DiploidGenotype.createGenotype(ref);
|
g = DiploidGenotype.createHomGenotype(ref);
|
||||||
Assert.assertTrue("TT".equals(g.toString()));
|
Assert.assertTrue("TT".equals(g.toString()));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue