diff --git a/java/src/org/broadinstitute/sting/gatk/walkers/recalibration/TileCovariate.java b/java/src/org/broadinstitute/sting/gatk/walkers/recalibration/TileCovariate.java index b02820581..60b5d4652 100644 --- a/java/src/org/broadinstitute/sting/gatk/walkers/recalibration/TileCovariate.java +++ b/java/src/org/broadinstitute/sting/gatk/walkers/recalibration/TileCovariate.java @@ -34,7 +34,7 @@ import net.sf.picard.util.IlluminaUtil; public class TileCovariate implements ExperimentalCovariate { - private static boolean exceptionWhenNoTile = false; + private boolean exceptionWhenNoTile = false; // Initialize any member variables using the command-line arguments passed to the walkers public void initialize( final RecalibrationArgumentCollection RAC ) { diff --git a/java/src/org/broadinstitute/sting/gatk/walkers/varianteval/VariantQualityScore.java b/java/src/org/broadinstitute/sting/gatk/walkers/varianteval/VariantQualityScore.java index c178c877e..4e2436b90 100755 --- a/java/src/org/broadinstitute/sting/gatk/walkers/varianteval/VariantQualityScore.java +++ b/java/src/org/broadinstitute/sting/gatk/walkers/varianteval/VariantQualityScore.java @@ -53,8 +53,8 @@ public class VariantQualityScore extends VariantEvaluator { @DataPoint(name="Quality by Allele Count", description = "average variant quality for each allele count") AlleleCountStats alleleCountStats = null; - class TiTvStats implements TableType { - final int NUM_BINS = 20; + static class TiTvStats implements TableType { + final static int NUM_BINS = 20; final HashMap> qualByIsTransition = new HashMap>(); // A hashMap holds all the qualities until we are able to bin them appropriately final long transitionByQuality[] = new long[NUM_BINS]; final long transversionByQuality[] = new long[NUM_BINS]; @@ -81,13 +81,14 @@ public class VariantQualityScore extends VariantEvaluator { } public String toString() { - String returnString = ""; + StringBuffer returnString = new StringBuffer(); // output the ti/tv array - returnString += "titvByQuality: "; + returnString.append("titvByQuality: "); for( int iii = 0; iii < NUM_BINS; iii++ ) { - returnString += titvByQuality[iii] + " "; + returnString.append(titvByQuality[iii]); + returnString.append(" "); } - return returnString; + return returnString.toString(); } public void incrValue( final double qual, final boolean isTransition ) { diff --git a/java/src/org/broadinstitute/sting/gatk/walkers/variantrecalibration/VariantGaussianMixtureModel.java b/java/src/org/broadinstitute/sting/gatk/walkers/variantrecalibration/VariantGaussianMixtureModel.java index 6ae1f43d8..cc7bcc5e1 100755 --- a/java/src/org/broadinstitute/sting/gatk/walkers/variantrecalibration/VariantGaussianMixtureModel.java +++ b/java/src/org/broadinstitute/sting/gatk/walkers/variantrecalibration/VariantGaussianMixtureModel.java @@ -586,6 +586,7 @@ public final class VariantGaussianMixtureModel extends VariantOptimizationModel } annIndex++; + outputFile.close(); } // BUGBUG: next output the actual cluster on top by integrating out every other annotation diff --git a/java/src/org/broadinstitute/sting/gatk/walkers/variantrecalibration/VariantNearestNeighborsModel.java b/java/src/org/broadinstitute/sting/gatk/walkers/variantrecalibration/VariantNearestNeighborsModel.java deleted file mode 100755 index f7867502c..000000000 --- a/java/src/org/broadinstitute/sting/gatk/walkers/variantrecalibration/VariantNearestNeighborsModel.java +++ /dev/null @@ -1,78 +0,0 @@ -package org.broadinstitute.sting.gatk.walkers.variantrecalibration; - -import org.broadinstitute.sting.utils.StingException; - -import java.io.PrintStream; - -/* - * Copyright (c) 2010 The Broad Institute - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, - * copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following - * conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES - * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT - * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, - * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR - * OTHER DEALINGS IN THE SOFTWARE. - */ - -/** - * Created by IntelliJ IDEA. - * User: rpoplin - * Date: Mar 1, 2010 - */ - -public final class VariantNearestNeighborsModel extends VariantOptimizationModel { - - private final int numKNN; - - public VariantNearestNeighborsModel( VariantDataManager _dataManager, final double _targetTITV, final int _numKNN ) { - super( _targetTITV ); - //dataManager = _dataManager; - numKNN = _numKNN; - } - - public void run( final String outputPrefix ) { - - throw new StingException( "Nearest Neighbors model hasn't been updated yet." ); - /* - final int numVariants = dataManager.numVariants; - - final double[] pTrueVariant = new double[numVariants]; - - final VariantTree vTree = new VariantTree( numKNN ); - vTree.createTreeFromData( dataManager.data ); - - System.out.println("Finished creating the kd-tree."); - - for(int iii = 0; iii < numVariants; iii++) { - pTrueVariant[iii] = calcTruePositiveRateFromTITV( vTree.calcNeighborhoodTITV( dataManager.data[iii] ) ); - } - - PrintStream outputFile; - try { - outputFile = new PrintStream( outputPrefix + ".knn.optimize" ); - } catch (Exception e) { - throw new StingException( "Unable to create output file: " + outputPrefix + ".knn.optimize" ); - } - for(int iii = 0; iii < numVariants; iii++) { - outputFile.print(String.format("%.4f",pTrueVariant[iii]) + ","); - outputFile.println( (dataManager.data[iii].isTransition ? 1 : 0) - + "," + (dataManager.data[iii].isKnown? 1 : 0)); - } - */ - } -} diff --git a/java/src/org/broadinstitute/sting/gatk/walkers/variantrecalibration/VariantTree.java b/java/src/org/broadinstitute/sting/gatk/walkers/variantrecalibration/VariantTree.java deleted file mode 100755 index 54a4606a4..000000000 --- a/java/src/org/broadinstitute/sting/gatk/walkers/variantrecalibration/VariantTree.java +++ /dev/null @@ -1,144 +0,0 @@ -package org.broadinstitute.sting.gatk.walkers.variantrecalibration; - -import org.broadinstitute.sting.utils.StingException; - -/* - * Copyright (c) 2010 The Broad Institute - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, - * copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following - * conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES - * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT - * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, - * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR - * OTHER DEALINGS IN THE SOFTWARE. - */ - -/** - * Created by IntelliJ IDEA. - * User: rpoplin - * Date: Feb 24, 2010 - */ - -public class VariantTree { - private final VariantTreeNode root; - private final int numKNN; - - public VariantTree( final int _numKNN ) { - root = new VariantTreeNode(); - numKNN = _numKNN; - } - - public void createTreeFromData( VariantDatum[] data ) { - root.cutData( data, 0, 0, data[0].annotations.length ); - } - - public double calcNeighborhoodTITV( final VariantDatum variant ) { - - double[] distances; - - // Grab the subset of points that are approximately near this point - final VariantDatum[] data = getBin( variant.annotations, root ); - if( data.length < numKNN ) { - throw new StingException( "Bin is too small. Should be > " + numKNN ); - } - - // Find the X nearest points in the subset - final double[] originalDistances = calcDistances( variant.annotations, data ); - distances = originalDistances.clone(); - quickSort( distances, 0, distances.length-1 ); // BUGBUG: distances.length or distances.length-1 - - final double minDistance = distances[numKNN - 1]; - - // Calculate probability of being true based on this set of SNPs - int numTi = 0; - int numTv = 0; - for( int iii = 0; iii < distances.length; iii++ ) { - if( originalDistances[iii] <= minDistance ) { - if( data[iii].isTransition ) { numTi++; } - else { numTv++; } - } - } - - return ((double) numTi) / ((double) numTv); - } - - private VariantDatum[] getBin( final double[] variant, final VariantTreeNode node ) { - if( node.variants != null ) { - return node.variants; - } else { - if( variant[node.cutDim] < node.cutValue ) { - return getBin( variant, node.left ); - } else { - return getBin( variant, node.right ); - } - } - } - - private double[] calcDistances( final double[] variant, final VariantDatum[] data ) { - final double[] distSquared = new double[data.length]; - int iii = 0; - for( final VariantDatum variantDatum : data ) { - distSquared[iii] = 0.0; - int jjj = 0; - for( final double value : variantDatum.annotations) { - final double diff = variant[jjj] - value; - distSquared[iii] += ( diff * diff ); - jjj++; - } - iii++; - } - - return distSquared; - } - - public static int partition(final double arr[], final int left, final int right) - { - int i = left, j = right; - double tmp; - final double pivot = arr[(left + right) / 2]; - - while (i <= j) { - while (arr[i] < pivot) { - i++; - } - while (arr[j] > pivot) { - j--; - } - if (i <= j) { - tmp = arr[i]; - arr[i] = arr[j]; - arr[j] = tmp; - i++; - j--; - } - } - - return i; - } - - public static void quickSort(final double arr[], final int left, final int right) { - final int index = partition(arr, left, right); - if (left < index - 1) { - quickSort(arr, left, index - 1); - } - if (index < right) { - quickSort(arr, index, right); - } - } - - -} diff --git a/java/src/org/broadinstitute/sting/gatk/walkers/variantrecalibration/VariantTreeNode.java b/java/src/org/broadinstitute/sting/gatk/walkers/variantrecalibration/VariantTreeNode.java deleted file mode 100755 index e3257bc25..000000000 --- a/java/src/org/broadinstitute/sting/gatk/walkers/variantrecalibration/VariantTreeNode.java +++ /dev/null @@ -1,104 +0,0 @@ -package org.broadinstitute.sting.gatk.walkers.variantrecalibration; - -/* - * Copyright (c) 2010 The Broad Institute - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, - * copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following - * conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES - * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT - * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, - * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR - * OTHER DEALINGS IN THE SOFTWARE. - */ - -/** - * Created by IntelliJ IDEA. - * User: rpoplin - * Date: Feb 24, 2010 - */ - -public class VariantTreeNode { - - public VariantTreeNode left; - public VariantTreeNode right; - public int cutDim; - public double cutValue; - public VariantDatum[] variants; - - private final int minBinSize = 8000; // BUGBUG: must be larger than number of kNN - - public VariantTreeNode() { - left = null; - right = null; - variants = null; - cutDim = -1; - cutValue = -1; - } - - public final void cutData( final VariantDatum[] data, final int depth, final int lastCutDepth, final int numAnnotations ) { - - cutDim = depth % numAnnotations; - - if( depth != lastCutDepth && (cutDim == (lastCutDepth % numAnnotations)) ) { // Base case: we've tried to cut on all the annotations - variants = data; - return; - } - - final double[] values = new double[data.length]; - for( int iii = 0; iii < data.length; iii++ ) { - values[iii] = data[iii].annotations[cutDim]; - } - - final double[] sortedValues = values.clone(); - VariantTree.quickSort( sortedValues, 0, values.length-1 ); // BUGBUG: values.length or values.length-1 - - final int lowPivotIndex = Math.round(0.40f * sortedValues.length); - final int highPivotIndex = Math.round(0.60f * sortedValues.length); - final double lowPivot = sortedValues[lowPivotIndex]; - final double highPivot = sortedValues[highPivotIndex]; - cutValue = highPivot; - - int numLow = 0; - int numHigh = 0; - for( int iii = 0; iii < data.length; iii++ ) { - if( values[iii] < highPivot ) { numLow++; } - if( values[iii] >= lowPivot ) { numHigh++; } - } - - // If cutting here makes the bin too small then don't cut - if( numLow < minBinSize || numHigh < minBinSize || (numLow == numHigh && numLow == data.length) ) { - cutValue = sortedValues[0]; - right = new VariantTreeNode(); - right.cutData(data, depth+1, lastCutDepth, numAnnotations); - } else { - final VariantDatum[] leftData = new VariantDatum[numLow]; - final VariantDatum[] rightData = new VariantDatum[numHigh]; - int leftIndex = 0; - int rightIndex = 0; - for( int iii = 0; iii < data.length; iii++ ) { - if( values[iii] < highPivot ) { leftData[leftIndex++] = data[iii]; } - if( values[iii] >= lowPivot ) { rightData[rightIndex++] = data[iii]; } - } - - left = new VariantTreeNode(); - right = new VariantTreeNode(); - left.cutData(leftData, depth+1, depth, numAnnotations); - right.cutData(rightData, depth+1, depth, numAnnotations); - } - } - -} diff --git a/java/src/org/broadinstitute/sting/oneoffprojects/walkers/ReadQualityScoreWalker.java b/java/src/org/broadinstitute/sting/oneoffprojects/walkers/ReadQualityScoreWalker.java index 5e6e4266f..4933b80c6 100755 --- a/java/src/org/broadinstitute/sting/oneoffprojects/walkers/ReadQualityScoreWalker.java +++ b/java/src/org/broadinstitute/sting/oneoffprojects/walkers/ReadQualityScoreWalker.java @@ -68,8 +68,8 @@ public class ReadQualityScoreWalker extends ReadWalker @Argument(fullName = "threshold", shortName = "th", doc="Flag reads whose read quality score is below this threshold", required = false) protected int qualityThreshold = 13; - protected static BufferedReader inputReader = null; - protected static String line = null; + private BufferedReader inputReader = null; + private static String line = null; public SAMRecord map( ReferenceContext ref, SAMRecord read, ReadMetaDataTracker metaDataTracker ) { return read; // all the work is done in the reduce step for this walker