The four-probs for all bases in a single read. Some utility functions for generating the primary and secondary base strings, as well as generating the SQ tag byte array in a manner that's consistent with the Bustard base calls (meaning the primary Bustard call and the secondary Four-Prob call are not permitted to be the same).

git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@704 348d0f76-0448-11de-a6fe-93d51630548a
This commit is contained in:
kiran 2009-05-14 16:55:49 +00:00
parent fdd123fe16
commit e4770885fd
1 changed files with 53 additions and 0 deletions

View File

@ -0,0 +1,53 @@
package org.broadinstitute.sting.secondarybase;
import org.broadinstitute.sting.utils.BaseUtils;
import org.broadinstitute.sting.utils.QualityUtils;
import java.util.ArrayList;
public class FourProbRead extends ArrayList<FourProb> {
public FourProbRead(int initialCapacity) {
super(initialCapacity);
}
public String getBaseSequenceAtGivenRank(int rank) {
String pseq = "";
for (int cycle = 0; cycle < this.size(); cycle++) {
FourProb fp = this.get(cycle);
pseq += fp.baseAtRank(rank);
}
return pseq;
}
public String getPrimaryBaseSequence() {
return getBaseSequenceAtGivenRank(0);
}
public String getSecondaryBaseSequence() {
return getBaseSequenceAtGivenRank(1);
}
public byte[] getSQTag(RawRead rr) {
byte[] sqtag = new byte[this.size()];
for (int cycle = 0; cycle < this.size(); cycle++) {
FourProb fp = this.get(cycle);
int fpPrimaryBaseIndex = fp.indexAtRank(0);
int rawPrimaryBaseIndex = BaseUtils.simpleBaseToBaseIndex(rr.getSequenceAsString().charAt(cycle));
int fpSecondaryBaseIndex = (fpPrimaryBaseIndex == rawPrimaryBaseIndex) ? fp.indexAtRank(1) : fpPrimaryBaseIndex;
double qualdiff = -10.0*Math.log10(fp.probAtRank(2)/fp.probAtRank(1));
sqtag[cycle] = QualityUtils.baseAndProbDiffToCompressedQuality(fpSecondaryBaseIndex, qualdiff);
//System.out.println("SQTAG: " + qualdiff + " " + sqtag[cycle] + " " + QualityUtils.compressedQualityToProbDiff(sqtag[cycle]));
}
return sqtag;
}
}