diff --git a/protected/java/test/org/broadinstitute/sting/gatk/walkers/haplotypecaller/ActiveRegionTestDataSetUnitTest.java b/protected/java/test/org/broadinstitute/sting/gatk/walkers/haplotypecaller/ActiveRegionTestDataSetUnitTest.java index 697186463..d8c3a3ebd 100644 --- a/protected/java/test/org/broadinstitute/sting/gatk/walkers/haplotypecaller/ActiveRegionTestDataSetUnitTest.java +++ b/protected/java/test/org/broadinstitute/sting/gatk/walkers/haplotypecaller/ActiveRegionTestDataSetUnitTest.java @@ -47,7 +47,8 @@ package org.broadinstitute.sting.gatk.walkers.haplotypecaller; import com.google.caliper.Param; -import org.apache.commons.codec.digest.DigestUtils; +import org.broadinstitute.sting.BaseTest; +import org.broadinstitute.sting.utils.Utils; import org.broadinstitute.sting.utils.haplotype.Haplotype; import org.broadinstitute.sting.utils.pairhmm.ActiveRegionTestDataSet; import org.broadinstitute.sting.utils.sam.GATKSAMRecord; @@ -64,7 +65,7 @@ import java.util.*; * Time: 2:48 PM * To change this template use File | Settings | File Templates. */ -public class ActiveRegionTestDataSetUnitTest { +public class ActiveRegionTestDataSetUnitTest extends BaseTest { @@ -419,6 +420,6 @@ public class ActiveRegionTestDataSetUnitTest { "CTGGGAGCCTAAGGCATCACTCAAGATACAGGCTCGGTAACGTACGCTCTAGCCATCTAA" + "CTATCCCCTATGTCTTATAGGGACCTACGTTATCTGCCTG"; - protected final static String REF_MD5 = new String(DigestUtils.md5(REF)); + protected final static String REF_MD5 = Utils.calcMD5(REF); } \ No newline at end of file diff --git a/protected/java/test/org/broadinstitute/sting/gatk/walkers/haplotypecaller/graphs/MultiSampleEdgeUnitTest.java b/protected/java/test/org/broadinstitute/sting/gatk/walkers/haplotypecaller/graphs/MultiSampleEdgeUnitTest.java index fc40edc42..c1d822eec 100644 --- a/protected/java/test/org/broadinstitute/sting/gatk/walkers/haplotypecaller/graphs/MultiSampleEdgeUnitTest.java +++ b/protected/java/test/org/broadinstitute/sting/gatk/walkers/haplotypecaller/graphs/MultiSampleEdgeUnitTest.java @@ -46,7 +46,6 @@ package org.broadinstitute.sting.gatk.walkers.haplotypecaller.graphs; -import org.apache.commons.lang.ArrayUtils; import org.broadinstitute.sting.BaseTest; import org.broadinstitute.sting.utils.MathUtils; import org.broadinstitute.sting.utils.Utils; diff --git a/protected/java/test/org/broadinstitute/sting/utils/pairhmm/ActiveRegionTestDataSet.java b/protected/java/test/org/broadinstitute/sting/utils/pairhmm/ActiveRegionTestDataSet.java index cee8d358e..84b995749 100644 --- a/protected/java/test/org/broadinstitute/sting/utils/pairhmm/ActiveRegionTestDataSet.java +++ b/protected/java/test/org/broadinstitute/sting/utils/pairhmm/ActiveRegionTestDataSet.java @@ -49,14 +49,13 @@ package org.broadinstitute.sting.utils.pairhmm; import net.sf.samtools.SAMFileHeader; import net.sf.samtools.SAMSequenceDictionary; import net.sf.samtools.SAMSequenceRecord; -import org.apache.commons.math.MathException; import org.apache.commons.math.distribution.ExponentialDistribution; -import org.apache.commons.math.distribution.ExponentialDistributionImpl; import org.broadinstitute.sting.gatk.walkers.haplotypecaller.AssemblyResult; import org.broadinstitute.sting.gatk.walkers.haplotypecaller.AssemblyResultSet; import org.broadinstitute.sting.gatk.walkers.haplotypecaller.Civar; import org.broadinstitute.sting.gatk.walkers.haplotypecaller.readthreading.ReadThreadingGraph; import org.broadinstitute.sting.utils.GenomeLocParser; +import org.broadinstitute.sting.utils.MathUtils; import org.broadinstitute.sting.utils.QualityUtils; import org.broadinstitute.sting.utils.haplotype.Haplotype; import org.broadinstitute.sting.utils.sam.ArtificialSAMUtils; @@ -325,7 +324,7 @@ public class ActiveRegionTestDataSet { this.setReadName(r.getReadName()); } - ExponentialDistribution indelLengthDist = new ExponentialDistributionImpl(1.0/0.9); + ExponentialDistribution indelLengthDist = MathUtils.exponentialDistribution(1.0 / 0.9); public MyGATKSAMRecord(final GATKSAMRecord r, final Random rnd) { super(r.getHeader(), r.getReferenceIndex(), r.getAlignmentStart(), (short) r.getReadNameLength(), @@ -390,7 +389,7 @@ public class ActiveRegionTestDataSet { final int length; try { length = (int) Math.round(indelLengthDist.inverseCumulativeProbability(rnd.nextDouble()) + 1); - } catch (MathException e) { + } catch (Exception e) { throw new RuntimeException(e); } return length; diff --git a/public/java/src/org/broadinstitute/sting/utils/MathUtils.java b/public/java/src/org/broadinstitute/sting/utils/MathUtils.java index 0b6cd4b1d..82c9fe751 100644 --- a/public/java/src/org/broadinstitute/sting/utils/MathUtils.java +++ b/public/java/src/org/broadinstitute/sting/utils/MathUtils.java @@ -27,6 +27,8 @@ package org.broadinstitute.sting.utils; import com.google.java.contract.Ensures; import com.google.java.contract.Requires; +import org.apache.commons.math.distribution.ExponentialDistribution; +import org.apache.commons.math.distribution.ExponentialDistributionImpl; import org.broadinstitute.sting.gatk.GenomeAnalysisEngine; import org.broadinstitute.sting.utils.exceptions.ReviewedStingException; @@ -1510,4 +1512,7 @@ public class MathUtils { return dirichletMultinomial(params,sum(params),counts,(int) sum(counts)); } + public static ExponentialDistribution exponentialDistribution( final double mean ) { + return new ExponentialDistributionImpl(mean); + } } diff --git a/public/java/src/org/broadinstitute/sting/utils/Utils.java b/public/java/src/org/broadinstitute/sting/utils/Utils.java index 41a36c235..9657bc403 100644 --- a/public/java/src/org/broadinstitute/sting/utils/Utils.java +++ b/public/java/src/org/broadinstitute/sting/utils/Utils.java @@ -744,7 +744,7 @@ public class Utils { /** * @see #calcMD5(byte[]) */ - public static String calcMD5(final String s) throws NoSuchAlgorithmException { + public static String calcMD5(final String s) { return calcMD5(s.getBytes()); } @@ -753,17 +753,21 @@ public class Utils { * * @param bytes the bytes to calculate the md5 of * @return the md5 of bytes, as a 32-character long string - * @throws NoSuchAlgorithmException */ @Ensures({"result != null", "result.length() == 32"}) - public static String calcMD5(final byte[] bytes) throws NoSuchAlgorithmException { + public static String calcMD5(final byte[] bytes) { if ( bytes == null ) throw new IllegalArgumentException("bytes cannot be null"); - final byte[] thedigest = MessageDigest.getInstance("MD5").digest(bytes); - final BigInteger bigInt = new BigInteger(1, thedigest); + try { + final byte[] thedigest = MessageDigest.getInstance("MD5").digest(bytes); + final BigInteger bigInt = new BigInteger(1, thedigest); - String md5String = bigInt.toString(16); - while (md5String.length() < 32) md5String = "0" + md5String; // pad to length 32 - return md5String; + String md5String = bigInt.toString(16); + while (md5String.length() < 32) md5String = "0" + md5String; // pad to length 32 + return md5String; + } + catch ( NoSuchAlgorithmException e ) { + throw new IllegalStateException("MD5 digest algorithm not present"); + } } /**