diff --git a/java/src/org/broadinstitute/sting/playground/gatk/walkers/Recalibration/CovariateCounterWalker.java b/java/src/org/broadinstitute/sting/playground/gatk/walkers/Recalibration/CovariateCounterWalker.java index bbe90c862..36ad4b0b1 100755 --- a/java/src/org/broadinstitute/sting/playground/gatk/walkers/Recalibration/CovariateCounterWalker.java +++ b/java/src/org/broadinstitute/sting/playground/gatk/walkers/Recalibration/CovariateCounterWalker.java @@ -126,7 +126,7 @@ public class CovariateCounterWalker extends LocusWalker { private void updateDataFromRead(SAMRecord read, int offset, ReferenceContext ref) { - ArrayList> key = new ArrayList>(); + List> key = new ArrayList>(); Comparable keyElement; // preallocate for use in for loop below boolean badKey = false; for( Covariate covariate : requestedCovariates ) { diff --git a/java/src/org/broadinstitute/sting/playground/gatk/walkers/Recalibration/CycleCovariate.java b/java/src/org/broadinstitute/sting/playground/gatk/walkers/Recalibration/CycleCovariate.java index a8e905ab5..f6acbcdd3 100755 --- a/java/src/org/broadinstitute/sting/playground/gatk/walkers/Recalibration/CycleCovariate.java +++ b/java/src/org/broadinstitute/sting/playground/gatk/walkers/Recalibration/CycleCovariate.java @@ -21,7 +21,7 @@ public class CycleCovariate implements Covariate { public Comparable getValue(SAMRecord read, int offset, char[] refBases) { //BUGBUG: assumes Solexia platform - int cycle = offset; + Integer cycle = offset; if( read.getReadNegativeStrandFlag() ) { cycle = read.getReadLength() - (offset + 1); } diff --git a/java/src/org/broadinstitute/sting/playground/gatk/walkers/Recalibration/MappingQualityCovariate.java b/java/src/org/broadinstitute/sting/playground/gatk/walkers/Recalibration/MappingQualityCovariate.java index c66234572..f258822a5 100755 --- a/java/src/org/broadinstitute/sting/playground/gatk/walkers/Recalibration/MappingQualityCovariate.java +++ b/java/src/org/broadinstitute/sting/playground/gatk/walkers/Recalibration/MappingQualityCovariate.java @@ -13,7 +13,7 @@ public class MappingQualityCovariate implements Covariate { } public Comparable getValue(SAMRecord read, int offset, char[] refBases) { - return read.getMappingQuality(); + return (Integer)(read.getMappingQuality()); } public Comparable getValue(String str) { diff --git a/java/src/org/broadinstitute/sting/playground/gatk/walkers/Recalibration/MinimumNQSCovariate.java b/java/src/org/broadinstitute/sting/playground/gatk/walkers/Recalibration/MinimumNQSCovariate.java index 14522ebb9..f18454bce 100644 --- a/java/src/org/broadinstitute/sting/playground/gatk/walkers/Recalibration/MinimumNQSCovariate.java +++ b/java/src/org/broadinstitute/sting/playground/gatk/walkers/Recalibration/MinimumNQSCovariate.java @@ -32,7 +32,7 @@ public class MinimumNQSCovariate implements Covariate { } } - int minQual = quals[0]; + Integer minQual = (int)(quals[0]); for ( int qual : quals ) { if( qual < minQual ) { minQual = qual; diff --git a/java/src/org/broadinstitute/sting/playground/gatk/walkers/Recalibration/QualityScoreCovariate.java b/java/src/org/broadinstitute/sting/playground/gatk/walkers/Recalibration/QualityScoreCovariate.java index cc2cda0bc..2e1097e49 100644 --- a/java/src/org/broadinstitute/sting/playground/gatk/walkers/Recalibration/QualityScoreCovariate.java +++ b/java/src/org/broadinstitute/sting/playground/gatk/walkers/Recalibration/QualityScoreCovariate.java @@ -32,7 +32,7 @@ public class QualityScoreCovariate implements Covariate { } } - return quals[offset]; + return ((Integer)((int)quals[offset])); } public Comparable getValue(String str) { diff --git a/java/src/org/broadinstitute/sting/playground/gatk/walkers/Recalibration/RecalDataManager.java b/java/src/org/broadinstitute/sting/playground/gatk/walkers/Recalibration/RecalDataManager.java index b9a02f2d1..7e257a148 100755 --- a/java/src/org/broadinstitute/sting/playground/gatk/walkers/Recalibration/RecalDataManager.java +++ b/java/src/org/broadinstitute/sting/playground/gatk/walkers/Recalibration/RecalDataManager.java @@ -56,7 +56,7 @@ public class RecalDataManager { } else { collapsedDatum.increment( thisDatum ); } - + newKey = new ArrayList>(); newKey.add( key.get(0) ); // make a new key with just the read group sumExpectedErrors = dataSumExpectedErrors.get( newKey ); @@ -75,6 +75,7 @@ public class RecalDataManager { newKey.add( key.get(1) ); // and quality score collapsedDatum = dataCollapsedQualityScore.get( newKey ); if( collapsedDatum == null ) { + //System.out.println("Added: " + newKey + " " + newKey.hashCode()); dataCollapsedQualityScore.put( newKey, new RecalDatum( thisDatum ) ); } else { collapsedDatum.increment( thisDatum ); @@ -85,7 +86,7 @@ public class RecalDataManager { newKey = new ArrayList>(); newKey.add( key.get(0) ); // make a new key with the read group ... newKey.add( key.get(1) ); // and quality score ... - newKey.add( key.get(iii) ); // and the given covariate + newKey.add( key.get(iii + 2) ); // and the given covariate collapsedDatum = dataCollapsedByCovariate.get(iii).get( newKey ); if( collapsedDatum == null ) { dataCollapsedByCovariate.get(iii).put( newKey, new RecalDatum( thisDatum ) ); diff --git a/java/src/org/broadinstitute/sting/playground/gatk/walkers/Recalibration/RecalDatum.java b/java/src/org/broadinstitute/sting/playground/gatk/walkers/Recalibration/RecalDatum.java index 8b6082a71..098ed5a2e 100755 --- a/java/src/org/broadinstitute/sting/playground/gatk/walkers/Recalibration/RecalDatum.java +++ b/java/src/org/broadinstitute/sting/playground/gatk/walkers/Recalibration/RecalDatum.java @@ -104,4 +104,8 @@ public class RecalDatum { public Long getNumObservations() { return numObservations; } + + public String toString() { + return String.format( "RecalDatum: %d,%d,%d", numObservations, numMismatches, (int)empiricalQualByte() ); + } } diff --git a/java/src/org/broadinstitute/sting/playground/gatk/walkers/Recalibration/TableRecalibrationWalker.java b/java/src/org/broadinstitute/sting/playground/gatk/walkers/Recalibration/TableRecalibrationWalker.java index 26f183273..0876e9f57 100755 --- a/java/src/org/broadinstitute/sting/playground/gatk/walkers/Recalibration/TableRecalibrationWalker.java +++ b/java/src/org/broadinstitute/sting/playground/gatk/walkers/Recalibration/TableRecalibrationWalker.java @@ -43,8 +43,8 @@ public class TableRecalibrationWalker extends ReadWalker requestedCovariates; + protected RecalDataManager dataManager; + protected ArrayList requestedCovariates; private static Pattern COVARIATE_PATTERN = Pattern.compile("^@!.*"); public final static String ORIGINAL_QUAL_ATTRIBUTE_TAG = "OQ"; @@ -117,11 +117,13 @@ public class TableRecalibrationWalker extends ReadWalker> key = new ArrayList>(); + ArrayList> key = new ArrayList>(); Covariate cov; // preallocated for use in for loop below int iii; for( iii = 0; iii < requestedCovariates.size(); iii++ ) { @@ -192,17 +194,18 @@ public class TableRecalibrationWalker extends ReadWalker> newKey; - + newKey = new ArrayList>(); newKey.add( key.get(0) ); // read group RecalDatum globalDeltaQDatum = dataManager.getCollapsedTable(0).get( newKey ); double globalDeltaQ = 0.0; + double aggregrateQreported = 0.0; if( globalDeltaQDatum != null ) { - globalDeltaQ = globalDeltaQDatum.empiricalQualDouble( SMOOTHING ) - ( dataManager.dataSumExpectedErrors.get( newKey ) / ((double) globalDeltaQDatum.getNumObservations()) ); + aggregrateQreported = QualityUtils.phredScaleErrorRate( dataManager.dataSumExpectedErrors.get( newKey ) / ((double) globalDeltaQDatum.getNumObservations()) ); + globalDeltaQ = globalDeltaQDatum.empiricalQualDouble( SMOOTHING ) - aggregrateQreported; } - //System.out.printf("Global quality score shift is %.2f - %.2f = %.2f%n", - // globalDeltaQDatum.empiricalQualDouble( SMOOTHING ), ( dataManager.dataSumExpectedErrors.get( newKey ) / ((double) globalDeltaQDatum.getNumObservations())), globalDeltaQ); - + + newKey = new ArrayList>(); newKey.add( key.get(0) ); // read group newKey.add( key.get(1) ); // quality score @@ -211,7 +214,8 @@ public class TableRecalibrationWalker extends ReadWalker %d + %.2f + %.2f + %.2f = %d", qualFromRead, globalDeltaQ, deltaQReported, deltaQCovariates, newQualityByte ) ); if( newQualityByte <= 0 && newQualityByte >= QualityUtils.MAX_REASONABLE_Q_SCORE ) { throw new StingException( "Illegal base quality score calculated: " + key + @@ -260,7 +260,4 @@ public class TableRecalibrationWalker extends ReadWalker