2009-03-24 07:19:54 +08:00
|
|
|
package org.broadinstitute.sting.playground.utils;
|
2009-03-20 06:06:01 +08:00
|
|
|
|
2009-03-24 07:19:54 +08:00
|
|
|
import org.broadinstitute.sting.playground.gatk.walkers.AlleleFrequencyWalker;
|
2009-03-20 06:06:01 +08:00
|
|
|
|
|
|
|
|
public class AlleleFrequencyEstimate {
|
|
|
|
|
//AlleleFrequencyEstimate();
|
2009-03-23 00:47:49 +08:00
|
|
|
public String location;
|
2009-03-21 00:44:17 +08:00
|
|
|
public char ref;
|
|
|
|
|
public char alt;
|
|
|
|
|
public int N;
|
|
|
|
|
public double qhat;
|
|
|
|
|
public double qstar;
|
2009-03-26 10:10:18 +08:00
|
|
|
public double lodVsRef;
|
|
|
|
|
public double lodVsNextBest;
|
2009-03-23 00:47:49 +08:00
|
|
|
public int depth;
|
2009-03-25 23:18:10 +08:00
|
|
|
public String notes;
|
2009-03-20 06:06:01 +08:00
|
|
|
|
2009-03-26 10:10:18 +08:00
|
|
|
public AlleleFrequencyEstimate(String location, char ref, char alt, int N, double qhat, double qstar, double lodVsRef, double lodVsNextBest, int depth)
|
2009-03-23 00:47:49 +08:00
|
|
|
{
|
|
|
|
|
this.location = location;
|
2009-03-20 06:06:01 +08:00
|
|
|
this.ref = ref;
|
|
|
|
|
this.alt = alt;
|
|
|
|
|
this.N = N;
|
|
|
|
|
this.qhat = qhat;
|
|
|
|
|
this.qstar = qstar;
|
2009-03-26 10:10:18 +08:00
|
|
|
this.lodVsRef = lodVsRef;
|
|
|
|
|
this.lodVsNextBest = lodVsNextBest;
|
2009-03-23 00:47:49 +08:00
|
|
|
this.depth = depth;
|
2009-03-25 23:18:10 +08:00
|
|
|
this.notes = "";
|
2009-03-20 06:06:01 +08:00
|
|
|
}
|
|
|
|
|
|
2009-03-31 01:47:35 +08:00
|
|
|
public String asGFFString()
|
|
|
|
|
{
|
|
|
|
|
String[] tokens;
|
|
|
|
|
tokens = location.split(":");
|
|
|
|
|
return String.format("%s\tCALLER\tVARIANT\t%s\t%s\t%f\t.\t.\tREF \"%c\"\t;\tALT \"%c\"\t;\tFREQ %f\n",
|
|
|
|
|
tokens[0],
|
|
|
|
|
tokens[1],
|
|
|
|
|
tokens[1],
|
|
|
|
|
lodVsRef,
|
|
|
|
|
ref,
|
|
|
|
|
alt,
|
|
|
|
|
qhat);
|
|
|
|
|
}
|
|
|
|
|
|
2009-03-25 09:12:05 +08:00
|
|
|
public String asTabularString() {
|
2009-03-26 10:10:18 +08:00
|
|
|
return String.format("RESULT %s %c %c %f %f %f %f %d %s\n",
|
2009-03-25 09:12:05 +08:00
|
|
|
location,
|
|
|
|
|
ref,
|
|
|
|
|
alt,
|
|
|
|
|
qhat,
|
|
|
|
|
qstar,
|
2009-03-26 10:10:18 +08:00
|
|
|
lodVsRef,
|
|
|
|
|
lodVsNextBest,
|
2009-03-25 23:18:10 +08:00
|
|
|
depth,
|
|
|
|
|
notes);
|
2009-03-25 09:12:05 +08:00
|
|
|
}
|
|
|
|
|
|
2009-03-20 06:06:01 +08:00
|
|
|
public String asString() {
|
|
|
|
|
// Print out the called bases
|
|
|
|
|
// Notes: switched from qhat to qstar because qhat doesn't work at n=1 (1 observed base) where having a single non-ref
|
|
|
|
|
// base has you calculate qstar = 0.0 and qhat = 0.49 and that leads to a genotype predicition of AG according
|
|
|
|
|
// to qhat, but AA according to qstar. This needs to be further investigated to see whether we really want
|
|
|
|
|
// to use qstar, but make N (number of chormosomes) switch to n (number of reads at locus) for n=1
|
|
|
|
|
long numNonrefBases = Math.round(qstar * N);
|
|
|
|
|
long numRefBases = N - numNonrefBases;
|
2009-03-24 11:58:03 +08:00
|
|
|
if (ref < alt) { // order bases alphabetically
|
|
|
|
|
return AlleleFrequencyWalker.repeat(ref, numRefBases) + AlleleFrequencyWalker.repeat(alt, numNonrefBases);
|
|
|
|
|
}else{
|
|
|
|
|
return AlleleFrequencyWalker.repeat(alt, numNonrefBases) + AlleleFrequencyWalker.repeat(ref, numRefBases);
|
|
|
|
|
}
|
2009-03-20 06:06:01 +08:00
|
|
|
}
|
2009-03-21 00:44:17 +08:00
|
|
|
}
|