Permalink
Browse files

Fix 3rd-party library dependency issues in the HC/PairHMM tests

In general, test classes cannot use 3rd-party libraries that are not
also dependencies of the GATK proper without causing problems when,
at release time, we test that the GATK jar has been packaged correctly
with all required dependencies.

If a test class needs to use a 3rd-party library that is not a GATK
dependency, write wrapper methods in the GATK utils/* classes, and
invoke those wrapper methods from the test class.
  • Loading branch information...
droazen committed Dec 6, 2013
1 parent 742b44e commit d4a25ad9c5bf35b363756ce18d4e38e20d308b02
@@ -27,6 +27,8 @@
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 static double dirichletMultinomial(double[] params, int[] counts) {
return dirichletMultinomial(params,sum(params),counts,(int) sum(counts));
}
+ public static ExponentialDistribution exponentialDistribution( final double mean ) {
+ return new ExponentialDistributionImpl(mean);
+ }
}
@@ -744,7 +744,7 @@ public static String formattedRatio(final long num, final long denom) {
/**
* @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 static String calcMD5(final String s) throws NoSuchAlgorithmException {
*
* @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");
+ }
}
/**

0 comments on commit d4a25ad

Please sign in to comment.