fixing the build
git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@1705 348d0f76-0448-11de-a6fe-93d51630548a
This commit is contained in:
parent
540e1b971f
commit
63f3d45ca4
|
|
@ -2,11 +2,9 @@ package org.broadinstitute.sting.playground.gatk.walkers.Recalibration;
|
|||
|
||||
import org.broadinstitute.sting.gatk.walkers.LocusWalker;
|
||||
import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker;
|
||||
import org.broadinstitute.sting.gatk.refdata.rodDbSNP;
|
||||
import org.broadinstitute.sting.gatk.contexts.ReferenceContext;
|
||||
import org.broadinstitute.sting.gatk.contexts.AlignmentContext;
|
||||
import org.broadinstitute.sting.utils.Pair;
|
||||
import org.broadinstitute.sting.utils.GenomeLoc;
|
||||
import org.broadinstitute.sting.utils.QualityUtils;
|
||||
import net.sf.samtools.SAMRecord;
|
||||
|
||||
import java.util.List;
|
||||
|
|
@ -18,7 +16,7 @@ import java.util.List;
|
|||
* Time: 1:37:44 PM
|
||||
* To change this template use File | Settings | File Templates.
|
||||
*/
|
||||
public class NQSMismatchCovariantWalker extends LocusWalker<int[][], long[][]> {
|
||||
public class NQSMismatchCovariantWalker extends LocusWalker<LocalMapType, long[][][]> {
|
||||
public static final int NQS_GROUPS = 35;
|
||||
public static final int NQS_RESOLUTION = 1;
|
||||
public static final int NQS_DIFFERENCE = 5;
|
||||
|
|
@ -27,47 +25,43 @@ public class NQSMismatchCovariantWalker extends LocusWalker<int[][], long[][]> {
|
|||
public static final int MM_OFFSET = 0;
|
||||
public static final int COUNT_OFFSET = 1;
|
||||
public static final int FAIL_OFFSET = 2;
|
||||
public static final String DATA_FORMAT = "%d %d %d %d %d%n";
|
||||
public static final String HEADER_FORMAT = "%s %s %s %s %s%n";
|
||||
public static final String DATA_FORMAT = "%d %d %d %d %d %d%n";
|
||||
public static final String HEADER_FORMAT = "%s %s %s %s %s %s%n";
|
||||
|
||||
public long[][] reduceInit() {
|
||||
long[][] mismatchesByNQS = new long[this.numNQSGroups()][3];
|
||||
for ( int nqsGroup = 0; nqsGroup < mismatchesByNQS.length; nqsGroup++ ) {
|
||||
mismatchesByNQS[nqsGroup][MM_OFFSET] = 0;
|
||||
mismatchesByNQS[nqsGroup][COUNT_OFFSET] = 0;
|
||||
public long[][][] reduceInit() {
|
||||
long[][][] mismatchesByNQS = new long[(int)QualityUtils.MAX_QUAL_SCORE+1][this.numNQSGroups()+1][2];
|
||||
for ( int qualityScore = 0; qualityScore <= (int) QualityUtils.MAX_QUAL_SCORE; qualityScore ++) {
|
||||
for ( int nqsGroup = 0; nqsGroup <= numNQSGroups(); nqsGroup++ ) {
|
||||
mismatchesByNQS[qualityScore][nqsGroup][MM_OFFSET] = 0;
|
||||
mismatchesByNQS[qualityScore][nqsGroup][COUNT_OFFSET] = 0;
|
||||
}
|
||||
}
|
||||
return mismatchesByNQS;
|
||||
}
|
||||
|
||||
public int[][] map(RefMetaDataTracker tracker, ReferenceContext ref, AlignmentContext context) {
|
||||
int[][] mismatchesByNQSAtLocation = initializeMismatchMatrix();
|
||||
public LocalMapType map(RefMetaDataTracker tracker, ReferenceContext ref, AlignmentContext context) {
|
||||
|
||||
if (! isDBSNP(tracker) ) {
|
||||
for( int read = 0; read < context.numReads(); read++ ) {
|
||||
int bestNQSRelativeToStart = getBestNQSRelativeToStart(context, read, nqsDifference(), nqsResolution(),
|
||||
centerBaseQualityStart(), windowSize());
|
||||
return new LocalMapType(context,ref,tracker);
|
||||
}
|
||||
|
||||
public long[][][] reduce(LocalMapType rawMapData, long[][][] cumMismatchArray) {
|
||||
if ( ! isDBSNP(rawMapData.tracker) ) {
|
||||
for( int read = 0; read < rawMapData.numReads(); read ++ ) {
|
||||
int bestNQSRelativeToStart = getBestNQSRelativeToStart(rawMapData.context, read, nqsDifference(),
|
||||
nqsResolution(), centerBaseQualityStart(), windowSize());
|
||||
if( isValidRelativeNQS(bestNQSRelativeToStart) ) {
|
||||
mismatchesByNQSAtLocation[bestNQSRelativeToStart][COUNT_OFFSET]++;
|
||||
if( isMismatch(read,context,ref) ) {
|
||||
mismatchesByNQSAtLocation[bestNQSRelativeToStart][MM_OFFSET]++;
|
||||
cumMismatchArray[rawMapData.qScore(read)][bestNQSRelativeToStart][COUNT_OFFSET]++;
|
||||
if( isMismatch(read, rawMapData.context, rawMapData.ref) ) {
|
||||
cumMismatchArray[rawMapData.qScore(read)][bestNQSRelativeToStart][MM_OFFSET]++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return mismatchesByNQSAtLocation;
|
||||
}
|
||||
|
||||
public long[][] reduce(int[][] mismatchArrayAtLoc, long[][] cumMismatchArray) {
|
||||
for( int nqsGroup = 0; nqsGroup < this.numNQSGroups(); nqsGroup++ ) {
|
||||
cumMismatchArray[nqsGroup][0] += mismatchArrayAtLoc[nqsGroup][0];
|
||||
cumMismatchArray[nqsGroup][1] += mismatchArrayAtLoc[nqsGroup][1];
|
||||
}
|
||||
|
||||
return cumMismatchArray;
|
||||
}
|
||||
|
||||
public void onTraversalDone(long[][] cumulativeCounts) {
|
||||
public void onTraversalDone(long[][][] cumulativeCounts) {
|
||||
printNQSMismatchTable(cumulativeCounts);
|
||||
}
|
||||
|
||||
|
|
@ -75,8 +69,8 @@ public class NQSMismatchCovariantWalker extends LocusWalker<int[][], long[][]> {
|
|||
int ctrBaseQStart, int windSize) {
|
||||
int minNeighborhoodQualityScore = findMinQScoreInWindow(context, readNum, windSize);
|
||||
int centerQScore = getQualityScore(context,readNum);
|
||||
int stepsToCutoffNeighborhood = (int) Math.floor((minNeighborhoodQualityScore - (ctrBaseQStart + 1 - ctrNghdNQSDif))/nqsStepSize);
|
||||
int stepsToCutoffCenter = (int) Math.floor((centerQScore-ctrBaseQStart - 1 )/nqsStepSize);
|
||||
int stepsToCutoffNeighborhood = (int) Math.floor((minNeighborhoodQualityScore - (ctrBaseQStart - ctrNghdNQSDif))/nqsStepSize);
|
||||
int stepsToCutoffCenter = (int) Math.floor((centerQScore-ctrBaseQStart )/nqsStepSize);
|
||||
|
||||
if(stepsToCutoffNeighborhood < stepsToCutoffCenter) {
|
||||
return stepsToCutoffNeighborhood;
|
||||
|
|
@ -85,21 +79,23 @@ public class NQSMismatchCovariantWalker extends LocusWalker<int[][], long[][]> {
|
|||
}
|
||||
}
|
||||
|
||||
protected void printNQSMismatchTable(long[][] cumulativeCounts) {
|
||||
protected void printNQSMismatchTable(long[][][] cumulativeCounts) {
|
||||
out.printf("%s", createHeader() );
|
||||
for( int nqsGroup = 0; nqsGroup < numNQSGroups(); nqsGroup ++ ) {
|
||||
out.printf("%s", formatNQSMismatchCountString(cumulativeCounts, nqsGroup));
|
||||
for ( int qscore = 0; qscore <= QualityUtils.MAX_QUAL_SCORE; qscore ++ ) {
|
||||
for( int nqsGroup = 0; nqsGroup <= numNQSGroups(); nqsGroup ++ ) {
|
||||
out.printf("%s", formatNQSMismatchCountString(cumulativeCounts, nqsGroup, qscore));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected String createHeader() {
|
||||
return String.format(HEADER_FORMAT,"Qscore Threshold at Locus", "Minimum Neighborhood Quality", "NQS Group",
|
||||
return String.format(HEADER_FORMAT,"Qscore Reported","Qscore Threshold at Locus", "Minimum Neighborhood Quality", "NQS Group",
|
||||
"# Non-dbSNP Mismatches", "Total Non-dbSNP Counts");
|
||||
}
|
||||
|
||||
protected String formatNQSMismatchCountString(long[][] counts, int nqsGroup) {
|
||||
return String.format(DATA_FORMAT,getCenterThreshold(nqsGroup),getNeighborhoodThreshold(nqsGroup),nqsGroup,
|
||||
counts[nqsGroup][MM_OFFSET], counts[nqsGroup][COUNT_OFFSET]);
|
||||
protected String formatNQSMismatchCountString(long[][][] counts, int nqsGroup, int qscore) {
|
||||
return String.format(DATA_FORMAT,qscore,getCenterThreshold(nqsGroup),getNeighborhoodThreshold(nqsGroup),nqsGroup,
|
||||
counts[qscore][nqsGroup][MM_OFFSET], counts[qscore][nqsGroup][COUNT_OFFSET]);
|
||||
}
|
||||
|
||||
protected int getCenterThreshold(int nqsGroup) {
|
||||
|
|
@ -122,26 +118,18 @@ public class NQSMismatchCovariantWalker extends LocusWalker<int[][], long[][]> {
|
|||
return NQS_DIFFERENCE;
|
||||
}
|
||||
|
||||
protected int[][] initializeMismatchMatrix() {
|
||||
int[][] mismatchesByNQS = new int[this.numNQSGroups()][2];
|
||||
for ( int nqsGroup = 0; nqsGroup < numNQSGroups(); nqsGroup++ ) {
|
||||
mismatchesByNQS[nqsGroup][MM_OFFSET] = 0;
|
||||
mismatchesByNQS[nqsGroup][COUNT_OFFSET] = 0;
|
||||
}
|
||||
return mismatchesByNQS;
|
||||
}
|
||||
|
||||
protected boolean isValidRelativeNQS(int relNQS) {
|
||||
return relNQS >= 0;
|
||||
}
|
||||
|
||||
protected boolean isDBSNP(RefMetaDataTracker tracker) {
|
||||
|
||||
return ( tracker.lookup("dbSNP",null) != null );
|
||||
|
||||
return false;
|
||||
// return ( tracker.lookup("dbSNP",null) != null );
|
||||
}
|
||||
|
||||
protected boolean isMismatch(int readNum, AlignmentContext context, ReferenceContext ref) {
|
||||
return ( (char) getBases(context,readNum)[ getOffset(context,readNum) ] ) == ref.getBase();
|
||||
return ( (char) getBases(context,readNum)[ getOffset(context,readNum) ] ) != ref.getBase();
|
||||
}
|
||||
|
||||
protected byte[] getBases(AlignmentContext context, int offset) {
|
||||
|
|
@ -198,3 +186,25 @@ public class NQSMismatchCovariantWalker extends LocusWalker<int[][], long[][]> {
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
class LocalMapType {
|
||||
|
||||
public AlignmentContext context;
|
||||
public ReferenceContext ref;
|
||||
public RefMetaDataTracker tracker;
|
||||
|
||||
public LocalMapType(AlignmentContext context, ReferenceContext ref, RefMetaDataTracker tracker) {
|
||||
this.context = context;
|
||||
this.ref = ref;
|
||||
this.tracker = tracker;
|
||||
}
|
||||
|
||||
public int numReads() {
|
||||
return context.numReads();
|
||||
}
|
||||
|
||||
public int qScore(int read) {
|
||||
return (int) context.getReads().get(read).getBaseQualities()[context.getOffsets().get(read)];
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue