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.
This commit is contained in:
parent
70e2d21e12
commit
932cd3ada7
|
|
@ -47,7 +47,8 @@
|
||||||
package org.broadinstitute.sting.gatk.walkers.haplotypecaller;
|
package org.broadinstitute.sting.gatk.walkers.haplotypecaller;
|
||||||
|
|
||||||
import com.google.caliper.Param;
|
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.haplotype.Haplotype;
|
||||||
import org.broadinstitute.sting.utils.pairhmm.ActiveRegionTestDataSet;
|
import org.broadinstitute.sting.utils.pairhmm.ActiveRegionTestDataSet;
|
||||||
import org.broadinstitute.sting.utils.sam.GATKSAMRecord;
|
import org.broadinstitute.sting.utils.sam.GATKSAMRecord;
|
||||||
|
|
@ -64,7 +65,7 @@ import java.util.*;
|
||||||
* Time: 2:48 PM
|
* Time: 2:48 PM
|
||||||
* To change this template use File | Settings | File Templates.
|
* 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" +
|
"CTGGGAGCCTAAGGCATCACTCAAGATACAGGCTCGGTAACGTACGCTCTAGCCATCTAA" +
|
||||||
"CTATCCCCTATGTCTTATAGGGACCTACGTTATCTGCCTG";
|
"CTATCCCCTATGTCTTATAGGGACCTACGTTATCTGCCTG";
|
||||||
|
|
||||||
protected final static String REF_MD5 = new String(DigestUtils.md5(REF));
|
protected final static String REF_MD5 = Utils.calcMD5(REF);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -46,7 +46,6 @@
|
||||||
|
|
||||||
package org.broadinstitute.sting.gatk.walkers.haplotypecaller.graphs;
|
package org.broadinstitute.sting.gatk.walkers.haplotypecaller.graphs;
|
||||||
|
|
||||||
import org.apache.commons.lang.ArrayUtils;
|
|
||||||
import org.broadinstitute.sting.BaseTest;
|
import org.broadinstitute.sting.BaseTest;
|
||||||
import org.broadinstitute.sting.utils.MathUtils;
|
import org.broadinstitute.sting.utils.MathUtils;
|
||||||
import org.broadinstitute.sting.utils.Utils;
|
import org.broadinstitute.sting.utils.Utils;
|
||||||
|
|
|
||||||
|
|
@ -49,14 +49,13 @@ package org.broadinstitute.sting.utils.pairhmm;
|
||||||
import net.sf.samtools.SAMFileHeader;
|
import net.sf.samtools.SAMFileHeader;
|
||||||
import net.sf.samtools.SAMSequenceDictionary;
|
import net.sf.samtools.SAMSequenceDictionary;
|
||||||
import net.sf.samtools.SAMSequenceRecord;
|
import net.sf.samtools.SAMSequenceRecord;
|
||||||
import org.apache.commons.math.MathException;
|
|
||||||
import org.apache.commons.math.distribution.ExponentialDistribution;
|
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.AssemblyResult;
|
||||||
import org.broadinstitute.sting.gatk.walkers.haplotypecaller.AssemblyResultSet;
|
import org.broadinstitute.sting.gatk.walkers.haplotypecaller.AssemblyResultSet;
|
||||||
import org.broadinstitute.sting.gatk.walkers.haplotypecaller.Civar;
|
import org.broadinstitute.sting.gatk.walkers.haplotypecaller.Civar;
|
||||||
import org.broadinstitute.sting.gatk.walkers.haplotypecaller.readthreading.ReadThreadingGraph;
|
import org.broadinstitute.sting.gatk.walkers.haplotypecaller.readthreading.ReadThreadingGraph;
|
||||||
import org.broadinstitute.sting.utils.GenomeLocParser;
|
import org.broadinstitute.sting.utils.GenomeLocParser;
|
||||||
|
import org.broadinstitute.sting.utils.MathUtils;
|
||||||
import org.broadinstitute.sting.utils.QualityUtils;
|
import org.broadinstitute.sting.utils.QualityUtils;
|
||||||
import org.broadinstitute.sting.utils.haplotype.Haplotype;
|
import org.broadinstitute.sting.utils.haplotype.Haplotype;
|
||||||
import org.broadinstitute.sting.utils.sam.ArtificialSAMUtils;
|
import org.broadinstitute.sting.utils.sam.ArtificialSAMUtils;
|
||||||
|
|
@ -325,7 +324,7 @@ public class ActiveRegionTestDataSet {
|
||||||
this.setReadName(r.getReadName());
|
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) {
|
public MyGATKSAMRecord(final GATKSAMRecord r, final Random rnd) {
|
||||||
super(r.getHeader(), r.getReferenceIndex(), r.getAlignmentStart(), (short) r.getReadNameLength(),
|
super(r.getHeader(), r.getReferenceIndex(), r.getAlignmentStart(), (short) r.getReadNameLength(),
|
||||||
|
|
@ -390,7 +389,7 @@ public class ActiveRegionTestDataSet {
|
||||||
final int length;
|
final int length;
|
||||||
try {
|
try {
|
||||||
length = (int) Math.round(indelLengthDist.inverseCumulativeProbability(rnd.nextDouble()) + 1);
|
length = (int) Math.round(indelLengthDist.inverseCumulativeProbability(rnd.nextDouble()) + 1);
|
||||||
} catch (MathException e) {
|
} catch (Exception e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
return length;
|
return length;
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,8 @@ package org.broadinstitute.sting.utils;
|
||||||
|
|
||||||
import com.google.java.contract.Ensures;
|
import com.google.java.contract.Ensures;
|
||||||
import com.google.java.contract.Requires;
|
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.gatk.GenomeAnalysisEngine;
|
||||||
import org.broadinstitute.sting.utils.exceptions.ReviewedStingException;
|
import org.broadinstitute.sting.utils.exceptions.ReviewedStingException;
|
||||||
|
|
||||||
|
|
@ -1510,4 +1512,7 @@ public class MathUtils {
|
||||||
return dirichletMultinomial(params,sum(params),counts,(int) sum(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 class Utils {
|
||||||
/**
|
/**
|
||||||
* @see #calcMD5(byte[])
|
* @see #calcMD5(byte[])
|
||||||
*/
|
*/
|
||||||
public static String calcMD5(final String s) throws NoSuchAlgorithmException {
|
public static String calcMD5(final String s) {
|
||||||
return calcMD5(s.getBytes());
|
return calcMD5(s.getBytes());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -753,17 +753,21 @@ public class Utils {
|
||||||
*
|
*
|
||||||
* @param bytes the bytes to calculate the md5 of
|
* @param bytes the bytes to calculate the md5 of
|
||||||
* @return the md5 of bytes, as a 32-character long string
|
* @return the md5 of bytes, as a 32-character long string
|
||||||
* @throws NoSuchAlgorithmException
|
|
||||||
*/
|
*/
|
||||||
@Ensures({"result != null", "result.length() == 32"})
|
@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");
|
if ( bytes == null ) throw new IllegalArgumentException("bytes cannot be null");
|
||||||
final byte[] thedigest = MessageDigest.getInstance("MD5").digest(bytes);
|
try {
|
||||||
final BigInteger bigInt = new BigInteger(1, thedigest);
|
final byte[] thedigest = MessageDigest.getInstance("MD5").digest(bytes);
|
||||||
|
final BigInteger bigInt = new BigInteger(1, thedigest);
|
||||||
|
|
||||||
String md5String = bigInt.toString(16);
|
String md5String = bigInt.toString(16);
|
||||||
while (md5String.length() < 32) md5String = "0" + md5String; // pad to length 32
|
while (md5String.length() < 32) md5String = "0" + md5String; // pad to length 32
|
||||||
return md5String;
|
return md5String;
|
||||||
|
}
|
||||||
|
catch ( NoSuchAlgorithmException e ) {
|
||||||
|
throw new IllegalStateException("MD5 digest algorithm not present");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue