diff --git a/public/java/src/org/broadinstitute/sting/utils/BaseUtils.java b/public/java/src/org/broadinstitute/sting/utils/BaseUtils.java index de8c81031..673b1524d 100644 --- a/public/java/src/org/broadinstitute/sting/utils/BaseUtils.java +++ b/public/java/src/org/broadinstitute/sting/utils/BaseUtils.java @@ -436,6 +436,18 @@ public class BaseUtils { return mostFrequentBaseIndex; } + static public int mostFrequentBaseIndexNotRef(int[] baseCounts, int refBaseIndex) { + int tmp = baseCounts[refBaseIndex]; + baseCounts[refBaseIndex] = -1; + int result = mostFrequentBaseIndex(baseCounts); + baseCounts[refBaseIndex] = tmp; + return result; + } + + static public int mostFrequentBaseIndexNotRef(int[] baseCounts, byte refSimpleBase) { + return mostFrequentBaseIndexNotRef(baseCounts, simpleBaseToBaseIndex(refSimpleBase)); + } + /** * Returns the most common base in the basecounts array. To be used with pileup.getBaseCounts. * diff --git a/public/java/src/org/broadinstitute/sting/utils/MathUtils.java b/public/java/src/org/broadinstitute/sting/utils/MathUtils.java index 9bd3f603c..a0b970dbc 100755 --- a/public/java/src/org/broadinstitute/sting/utils/MathUtils.java +++ b/public/java/src/org/broadinstitute/sting/utils/MathUtils.java @@ -360,6 +360,23 @@ public class MathUtils { return Math.pow(10,log10MultinomialProbability(n, k, log10P)); } + /** + * calculate the Root Mean Square of an array of integers + * @param x an byte[] of numbers + * @return the RMS of the specified numbers. + */ + public static double rms(byte[] x) { + if ( x.length == 0 ) + return 0.0; + + double rms = 0.0; + for (int i : x) + rms += i * i; + rms /= x.length; + return Math.sqrt(rms); + } + + /** * calculate the Root Mean Square of an array of integers * @param x an int[] of numbers @@ -1074,6 +1091,11 @@ public class MathUtils { return ((-q)/10.0); } + /** + * Returns the phred scaled value of probability p + * @param p probability (between 0 and 1). + * @return phred scaled probability of p + */ public static byte probabilityToPhredScale (double p) { return (byte) ((-10) * Math.log10(p)); }