From d79b5f0931db2a65138c636c23c67d602688e480 Mon Sep 17 00:00:00 2001 From: sathibault Date: Wed, 8 May 2013 11:01:20 -0500 Subject: [PATCH 01/11] Adding Convey HC-1 HMM acceleration --- .../LikelihoodCalculationEngine.java | 38 ++++++++---- .../sting/utils/pairhmm/CnyPairHMM.java | 59 +++++++++++++++++++ .../sting/utils/pairhmm/BatchPairHMM.java | 16 +++++ 3 files changed, 103 insertions(+), 10 deletions(-) create mode 100644 protected/java/src/org/broadinstitute/sting/utils/pairhmm/CnyPairHMM.java create mode 100644 public/java/src/org/broadinstitute/sting/utils/pairhmm/BatchPairHMM.java diff --git a/protected/java/src/org/broadinstitute/sting/gatk/walkers/haplotypecaller/LikelihoodCalculationEngine.java b/protected/java/src/org/broadinstitute/sting/gatk/walkers/haplotypecaller/LikelihoodCalculationEngine.java index 8697833a6..62d4d17fd 100644 --- a/protected/java/src/org/broadinstitute/sting/gatk/walkers/haplotypecaller/LikelihoodCalculationEngine.java +++ b/protected/java/src/org/broadinstitute/sting/gatk/walkers/haplotypecaller/LikelihoodCalculationEngine.java @@ -90,7 +90,10 @@ public class LikelihoodCalculationEngine { pairHMM = new Log10PairHMM(false); break; case LOGLESS_CACHING: - pairHMM = new LoglessPairHMM(); + if (CnyPairHMM.isAvailable()) + pairHMM = new CnyPairHMM(); + else + pairHMM = new LoglessPairHMM(); break; default: throw new UserException.BadArgumentValue("pairHMM", "Specified pairHMM implementation is unrecognized or incompatible with the HaplotypeCaller. Acceptable options are ORIGINAL, EXACT, CACHING, and LOGLESS_CACHING."); @@ -151,6 +154,8 @@ public class LikelihoodCalculationEngine { private PerReadAlleleLikelihoodMap computeReadLikelihoods( final List haplotypes, final List reads) { // first, a little set up to get copies of the Haplotypes that are Alleles (more efficient than creating them each time) + final BatchPairHMM batchPairHMM = (pairHMM instanceof BatchPairHMM) ? (BatchPairHMM)pairHMM : null; + final Vector batchedReads = new Vector(reads.size()); final int numHaplotypes = haplotypes.size(); final Map alleleVersions = new HashMap(numHaplotypes); for ( final Haplotype haplotype : haplotypes ) { @@ -177,16 +182,29 @@ public class LikelihoodCalculationEngine { readQuals[kkk] = ( readQuals[kkk] < (byte) 18 ? QualityUtils.MIN_USABLE_Q_SCORE : readQuals[kkk] ); } - for( int jjj = 0; jjj < numHaplotypes; jjj++ ) { - final Haplotype haplotype = haplotypes.get(jjj); - final boolean isFirstHaplotype = jjj == 0; - final double log10l = pairHMM.computeReadLikelihoodGivenHaplotypeLog10(haplotype.getBases(), - read.getReadBases(), readQuals, readInsQuals, readDelQuals, overallGCP, isFirstHaplotype); - - perReadAlleleLikelihoodMap.add(read, alleleVersions.get(haplotype), log10l); - } + if ( batchPairHMM != null ) { + batchPairHMM.batchAdd(haplotypes, read.getReadBases(), readQuals, readInsQuals, readDelQuals, overallGCP); + batchedReads.add(read); + } else { + for( int jjj = 0; jjj < numHaplotypes; jjj++ ) { + final Haplotype haplotype = haplotypes.get(jjj); + final boolean isFirstHaplotype = jjj == 0; + final double log10l = pairHMM.computeReadLikelihoodGivenHaplotypeLog10(haplotype.getBases(), + read.getReadBases(), readQuals, readInsQuals, readDelQuals, overallGCP, isFirstHaplotype); + + perReadAlleleLikelihoodMap.add(read, alleleVersions.get(haplotype), log10l); + } + } } - + if ( batchPairHMM != null ) { + for( final GATKSAMRecord read : batchedReads ) { + final double[] likelihoods = batchPairHMM.batchResult(); + for( int jjj = 0; jjj < numHaplotypes; jjj++ ) { + final Haplotype haplotype = haplotypes.get(jjj); + perReadAlleleLikelihoodMap.add(read, alleleVersions.get(haplotype), likelihoods[jjj]); + } + } + } return perReadAlleleLikelihoodMap; } diff --git a/protected/java/src/org/broadinstitute/sting/utils/pairhmm/CnyPairHMM.java b/protected/java/src/org/broadinstitute/sting/utils/pairhmm/CnyPairHMM.java new file mode 100644 index 000000000..51611bb08 --- /dev/null +++ b/protected/java/src/org/broadinstitute/sting/utils/pairhmm/CnyPairHMM.java @@ -0,0 +1,59 @@ +package org.broadinstitute.sting.utils.pairhmm; + +import java.util.*; + +import org.broadinstitute.sting.utils.haplotype.Haplotype; + +public final class CnyPairHMM extends PairHMM implements BatchPairHMM { + private static class HmmInput { + public List haplotypes; + public byte[] readBases; + public byte[] readQuals; + public byte[] insertionGOP; + public byte[] deletionGOP; + public byte[] overallGCP; + }; + + private static boolean loaded = false; + private List pending = new LinkedList(); + + static public boolean isAvailable() { + return true; + } + + public void batchAdd(final List haplotypes, + final byte[] readBases, + final byte[] readQuals, + final byte[] insertionGOP, + final byte[] deletionGOP, + final byte[] overallGCP) { + HmmInput test=new HmmInput(); + test.haplotypes=haplotypes; + test.readBases=readBases; + test.readQuals=readQuals; + test.insertionGOP=insertionGOP; + test.deletionGOP=deletionGOP; + test.overallGCP=overallGCP; + pending.add(test); + } + + public double[] batchResult() { + HmmInput test=pending.remove(0); + double[] results=new double[test.haplotypes.size()]; + for (int i=0; i haplotypes, + final byte[] readBases, + final byte[] readQuals, + final byte[] insertionGOP, + final byte[] deletionGOP, + final byte[] overallGCP); + + public double[] batchResult(); +} From 195f0c3e983abbeb22ec1fbbcec4862ca789121e Mon Sep 17 00:00:00 2001 From: sathibault Date: Fri, 17 May 2013 08:30:23 -0500 Subject: [PATCH 02/11] Disable CnyPairHMM --- .../sting/utils/pairhmm/CnyPairHMM.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/protected/java/src/org/broadinstitute/sting/utils/pairhmm/CnyPairHMM.java b/protected/java/src/org/broadinstitute/sting/utils/pairhmm/CnyPairHMM.java index 51611bb08..a8f07a2ea 100644 --- a/protected/java/src/org/broadinstitute/sting/utils/pairhmm/CnyPairHMM.java +++ b/protected/java/src/org/broadinstitute/sting/utils/pairhmm/CnyPairHMM.java @@ -18,7 +18,16 @@ public final class CnyPairHMM extends PairHMM implements BatchPairHMM { private List pending = new LinkedList(); static public boolean isAvailable() { - return true; + return false; + } + + public void initialize( final int READ_MAX_LENGTH, final int HAPLOTYPE_MAX_LENGTH ) { + if (!loaded) { + // System.loadLibrary("gmvhdl_gatk_hmm"); + // initFpga(); + loaded = true; + } + System.out.println("FPGA HMM Initialized"); } public void batchAdd(final List haplotypes, From de2a2a4cc752e671d7e3a5bb7ddbb19d57257f4f Mon Sep 17 00:00:00 2001 From: sathibault Date: Mon, 3 Jun 2013 07:30:32 -0500 Subject: [PATCH 03/11] Added command-line flag to disble FPGA Completed integration with FPGA driver --- .../haplotypecaller/HaplotypeCaller.java | 6 +- .../LikelihoodCalculationEngine.java | 13 +- .../sting/utils/pairhmm/CnyPairHMM.java | 164 +++++++++++++++--- .../sting/utils/pairhmm/BatchPairHMM.java | 2 +- 4 files changed, 159 insertions(+), 26 deletions(-) diff --git a/protected/java/src/org/broadinstitute/sting/gatk/walkers/haplotypecaller/HaplotypeCaller.java b/protected/java/src/org/broadinstitute/sting/gatk/walkers/haplotypecaller/HaplotypeCaller.java index 6ea543f25..cf6fa20ca 100644 --- a/protected/java/src/org/broadinstitute/sting/gatk/walkers/haplotypecaller/HaplotypeCaller.java +++ b/protected/java/src/org/broadinstitute/sting/gatk/walkers/haplotypecaller/HaplotypeCaller.java @@ -315,6 +315,10 @@ public class HaplotypeCaller extends ActiveRegionWalker implem @Argument(fullName="allowCyclesInKmerGraphToGeneratePaths", shortName="allowCyclesInKmerGraphToGeneratePaths", doc="If specified, we will allow cycles in the kmer graphs to generate paths with multiple copies of the path sequenece rather than just the shortest paths", required = false) protected boolean allowCyclesInKmerGraphToGeneratePaths = false; + @Hidden + @Argument(fullName="noFpga", shortName="noFpga", doc="If provided, disables the use of the FPGA HMM implementation", required = false) + protected boolean noFpga = false; + // the UG engines private UnifiedGenotyperEngine UG_engine = null; @@ -435,7 +439,7 @@ public class HaplotypeCaller extends ActiveRegionWalker implem if ( graphWriter != null ) assemblyEngine.setGraphWriter(graphWriter); if ( useLowQualityBasesForAssembly ) assemblyEngine.setMinBaseQualityToUseInAssembly((byte)1); - likelihoodCalculationEngine = new LikelihoodCalculationEngine( (byte)gcpHMM, DEBUG, pairHMM ); + likelihoodCalculationEngine = new LikelihoodCalculationEngine( (byte)gcpHMM, DEBUG, pairHMM, noFpga ); final MergeVariantsAcrossHaplotypes variantMerger = mergeVariantsViaLD ? new LDMerger(DEBUG, 10, 1) : new MergeVariantsAcrossHaplotypes(); diff --git a/protected/java/src/org/broadinstitute/sting/gatk/walkers/haplotypecaller/LikelihoodCalculationEngine.java b/protected/java/src/org/broadinstitute/sting/gatk/walkers/haplotypecaller/LikelihoodCalculationEngine.java index 62d4d17fd..d4bec64c7 100644 --- a/protected/java/src/org/broadinstitute/sting/gatk/walkers/haplotypecaller/LikelihoodCalculationEngine.java +++ b/protected/java/src/org/broadinstitute/sting/gatk/walkers/haplotypecaller/LikelihoodCalculationEngine.java @@ -80,7 +80,11 @@ public class LikelihoodCalculationEngine { */ private final double EXPECTED_ERROR_RATE_PER_BASE = 0.02; - public LikelihoodCalculationEngine( final byte constantGCP, final boolean debug, final PairHMM.HMM_IMPLEMENTATION hmmType ) { + public LikelihoodCalculationEngine( final byte constantGCP, final boolean debug, final PairHMM.HMM_IMPLEMENTATION hmmType) { + this(constantGCP, debug, hmmType, false); + } + + public LikelihoodCalculationEngine( final byte constantGCP, final boolean debug, final PairHMM.HMM_IMPLEMENTATION hmmType, final boolean noFpga) { switch (hmmType) { case EXACT: @@ -90,7 +94,7 @@ public class LikelihoodCalculationEngine { pairHMM = new Log10PairHMM(false); break; case LOGLESS_CACHING: - if (CnyPairHMM.isAvailable()) + if (!noFpga && CnyPairHMM.isAvailable()) pairHMM = new CnyPairHMM(); else pairHMM = new LoglessPairHMM(); @@ -191,16 +195,17 @@ public class LikelihoodCalculationEngine { final boolean isFirstHaplotype = jjj == 0; final double log10l = pairHMM.computeReadLikelihoodGivenHaplotypeLog10(haplotype.getBases(), read.getReadBases(), readQuals, readInsQuals, readDelQuals, overallGCP, isFirstHaplotype); - + System.err.println(Integer.toString(jjj) + ": " + Double.toString(log10l)); perReadAlleleLikelihoodMap.add(read, alleleVersions.get(haplotype), log10l); } } } if ( batchPairHMM != null ) { for( final GATKSAMRecord read : batchedReads ) { - final double[] likelihoods = batchPairHMM.batchResult(); + final double[] likelihoods = batchPairHMM.batchGetResult(); for( int jjj = 0; jjj < numHaplotypes; jjj++ ) { final Haplotype haplotype = haplotypes.get(jjj); + System.err.println(Integer.toString(jjj) + ": " + Double.toString(likelihoods[jjj])); perReadAlleleLikelihoodMap.add(read, alleleVersions.get(haplotype), likelihoods[jjj]); } } diff --git a/protected/java/src/org/broadinstitute/sting/utils/pairhmm/CnyPairHMM.java b/protected/java/src/org/broadinstitute/sting/utils/pairhmm/CnyPairHMM.java index a8f07a2ea..746c0add1 100644 --- a/protected/java/src/org/broadinstitute/sting/utils/pairhmm/CnyPairHMM.java +++ b/protected/java/src/org/broadinstitute/sting/utils/pairhmm/CnyPairHMM.java @@ -1,33 +1,91 @@ package org.broadinstitute.sting.utils.pairhmm; +import java.io.File; import java.util.*; +import java.lang.reflect.*; import org.broadinstitute.sting.utils.haplotype.Haplotype; public final class CnyPairHMM extends PairHMM implements BatchPairHMM { private static class HmmInput { - public List haplotypes; public byte[] readBases; public byte[] readQuals; public byte[] insertionGOP; public byte[] deletionGOP; public byte[] overallGCP; + public List haplotypes; }; + private static class ResultQueue { + private int offset; + private List batchResults; + + public ResultQueue() { + batchResults = new LinkedList(); + offset = 0; + } + + public void push(double[] results) { + batchResults.add(results); + } + + public double pop() { + double[] results = batchResults.get(0); + double top = results[offset++]; + if (offset == results.length) { + batchResults.remove(0); + offset = 0; + } + return top; + } + } + + final static String libPath = "/opt/convey/personalities/32100.1.1.1.0"; + final static String libName = "gmvhdl_gatk_hmm"; + private static boolean loaded = false; - private List pending = new LinkedList(); + private List batchRequests = new LinkedList(); + private ResultQueue resultQueue = new ResultQueue(); static public boolean isAvailable() { - return false; + if (!loaded) { + File library = new File(libPath + "/lib" + libName + ".so"); + return library.exists(); + } + return true; } + private native void initFpga(); + private native int dequeueRequirement(int reflen, int readlen); + private native int enqueue(byte[] haplotypeBases, + byte[] readBases, + byte[] readQuals, + byte[] insertionGOP, + byte[] deletionGOP, + byte[] overallGCP, + int hapStartIndex, + boolean recacheReadValues); + private native int flushQueue(); + private native int dequeue(double[] results); + private native double softHmm(byte[] haplotypeBases, + byte[] readBases, + byte[] readQuals, + byte[] insertionGOP, + byte[] deletionGOP, + byte[] overallGCP, + int hapStartIndex, + boolean recacheReadValues); + + public native void reportStats(); + public void initialize( final int READ_MAX_LENGTH, final int HAPLOTYPE_MAX_LENGTH ) { if (!loaded) { - // System.loadLibrary("gmvhdl_gatk_hmm"); - // initFpga(); + addLibraryPath(libPath); + System.loadLibrary(libName); + initFpga(); loaded = true; + System.out.println("FPGA HMM Initialized"); } - System.out.println("FPGA HMM Initialized"); } public void batchAdd(final List haplotypes, @@ -36,21 +94,44 @@ public final class CnyPairHMM extends PairHMM implements BatchPairHMM { final byte[] insertionGOP, final byte[] deletionGOP, final byte[] overallGCP) { - HmmInput test=new HmmInput(); - test.haplotypes=haplotypes; - test.readBases=readBases; - test.readQuals=readQuals; - test.insertionGOP=insertionGOP; - test.deletionGOP=deletionGOP; - test.overallGCP=overallGCP; - pending.add(test); + final int numHaplotypes = haplotypes.size(); + HmmInput test = new HmmInput(); + test.readBases = readBases; + test.readQuals = readQuals; + test.insertionGOP = insertionGOP; + test.deletionGOP = deletionGOP; + test.overallGCP = overallGCP; + test.haplotypes = haplotypes; + batchRequests.add(test); + for (int jjj = 0; jjj < numHaplotypes; jjj++) { + final boolean recacheReadValues = (jjj == 0); + final Haplotype haplotype = haplotypes.get(jjj); + enqueuePrepare(haplotype.getBases(), readBases); + if (enqueue(haplotype.getBases(), readBases, readQuals, insertionGOP, deletionGOP, overallGCP, 0, recacheReadValues) == 0) + throw new RuntimeException("FPGA queue overflow in batchAdd"); + } } - public double[] batchResult() { - HmmInput test=pending.remove(0); - double[] results=new double[test.haplotypes.size()]; - for (int i=0; i 0) { + results = new double[n]; + if (dequeue(results) != n) + System.out.println("queue underflow in enqueuePrepare"); + resultQueue.push(results); + } + + final HmmInput test = batchRequests.remove(0); + final int numHaplotypes = test.haplotypes.size(); + results = new double[numHaplotypes]; + for (int jjj = 0; jjj < numHaplotypes; jjj++) { + results[jjj] = resultQueue.pop(); + if (results[jjj]<-60.0) { + final Haplotype haplotype = test.haplotypes.get(jjj); + results[jjj]=softHmm(haplotype.getBases(), test.readBases, test.readQuals, test.insertionGOP, test.deletionGOP, test.overallGCP, 0, true); + } } return results; } @@ -64,5 +145,48 @@ public final class CnyPairHMM extends PairHMM implements BatchPairHMM { final int hapStartIndex, final boolean recacheReadValues ) { return 0.0; - } + } + + private void enqueuePrepare(byte[] haplotypeBases, byte[] readBases) { + double[] results = null; + int n = dequeueRequirement(haplotypeBases.length, readBases.length); + if (n>0) { + results = new double[n]; + if (dequeue(results)!=n) + System.out.println("queue underflow in enqueuePrepare"); + } else if (n<0) { + n = flushQueue(); + if (n > 0) { + results = new double[n]; + if (dequeue(results) != n) + System.out.println("queue underflow in enqueuePrepare"); + } + } + + if (results != null) + resultQueue.push(results); + } + + public static void addLibraryPath(String pathToAdd) { + try { + final Field usrPathsField = ClassLoader.class.getDeclaredField("usr_paths"); + usrPathsField.setAccessible(true); + + //get array of paths + final String[] paths = (String[])usrPathsField.get(null); + + //check if the path to add is already present + for(String path : paths) { + if(path.equals(pathToAdd)) { + return; + } + } + + //add the new path + final String[] newPaths = Arrays.copyOf(paths, paths.length + 1); + newPaths[newPaths.length-1] = pathToAdd; + usrPathsField.set(null, newPaths); + } catch (Exception ex) { + } + } } diff --git a/public/java/src/org/broadinstitute/sting/utils/pairhmm/BatchPairHMM.java b/public/java/src/org/broadinstitute/sting/utils/pairhmm/BatchPairHMM.java index 8f9ae22ae..3b794b00e 100644 --- a/public/java/src/org/broadinstitute/sting/utils/pairhmm/BatchPairHMM.java +++ b/public/java/src/org/broadinstitute/sting/utils/pairhmm/BatchPairHMM.java @@ -12,5 +12,5 @@ public interface BatchPairHMM { final byte[] deletionGOP, final byte[] overallGCP); - public double[] batchResult(); + public double[] batchGetResult(); } From 3db8908ae8fcbff7b5a0e8073aae9c1b2e240d6d Mon Sep 17 00:00:00 2001 From: sathibault Date: Thu, 20 Jun 2013 08:28:58 -0500 Subject: [PATCH 04/11] Remove debug print statement --- .../walkers/haplotypecaller/LikelihoodCalculationEngine.java | 1 - 1 file changed, 1 deletion(-) diff --git a/protected/java/src/org/broadinstitute/sting/gatk/walkers/haplotypecaller/LikelihoodCalculationEngine.java b/protected/java/src/org/broadinstitute/sting/gatk/walkers/haplotypecaller/LikelihoodCalculationEngine.java index 2359840dd..60abc6a68 100644 --- a/protected/java/src/org/broadinstitute/sting/gatk/walkers/haplotypecaller/LikelihoodCalculationEngine.java +++ b/protected/java/src/org/broadinstitute/sting/gatk/walkers/haplotypecaller/LikelihoodCalculationEngine.java @@ -250,7 +250,6 @@ public class LikelihoodCalculationEngine { final double[] likelihoods = batchPairHMM.batchGetResult(); for( int jjj = 0; jjj < numHaplotypes; jjj++ ) { final Haplotype haplotype = haplotypes.get(jjj); - System.err.println(Integer.toString(jjj) + ": " + Double.toString(likelihoods[jjj])); if ( haplotype.isNonReference() ) bestNonReflog10L = Math.max(bestNonReflog10L, likelihoods[jjj]); else From e691fa3e1985f558e832f6da26960a64ce6c7f7f Mon Sep 17 00:00:00 2001 From: Scott Thibault Date: Fri, 28 Jun 2013 08:52:09 -0500 Subject: [PATCH 05/11] FPGA null pointer bug fix --- .../walkers/haplotypecaller/LikelihoodCalculationEngine.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/protected/java/src/org/broadinstitute/sting/gatk/walkers/haplotypecaller/LikelihoodCalculationEngine.java b/protected/java/src/org/broadinstitute/sting/gatk/walkers/haplotypecaller/LikelihoodCalculationEngine.java index 60abc6a68..3cdad37ea 100644 --- a/protected/java/src/org/broadinstitute/sting/gatk/walkers/haplotypecaller/LikelihoodCalculationEngine.java +++ b/protected/java/src/org/broadinstitute/sting/gatk/walkers/haplotypecaller/LikelihoodCalculationEngine.java @@ -180,7 +180,7 @@ public class LikelihoodCalculationEngine { private PerReadAlleleLikelihoodMap computeReadLikelihoods( final List haplotypes, final List reads) { // first, a little set up to get copies of the Haplotypes that are Alleles (more efficient than creating them each time) - final BatchPairHMM batchPairHMM = (pairHMM instanceof BatchPairHMM) ? (BatchPairHMM)pairHMM : null; + final BatchPairHMM batchPairHMM = (pairHMM.get() instanceof BatchPairHMM) ? (BatchPairHMM)pairHMM.get() : null; final Vector batchedReads = new Vector(reads.size()); final int numHaplotypes = haplotypes.size(); final Map alleleVersions = new LinkedHashMap<>(numHaplotypes); @@ -456,4 +456,4 @@ public class LikelihoodCalculationEngine { } throw new ReviewedStingException( "No reference haplotype found in the list of haplotypes!" ); } -} \ No newline at end of file +} From 7458b59bb3b973fb3321c76a0ab1e67bfcaa6c5e Mon Sep 17 00:00:00 2001 From: sathibault Date: Thu, 11 Jul 2013 11:08:46 -0500 Subject: [PATCH 06/11] Fixed batching bug. --- .../sting/utils/pairhmm/CnyPairHMM.java | 26 ++++++++++++++----- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/protected/java/src/org/broadinstitute/sting/utils/pairhmm/CnyPairHMM.java b/protected/java/src/org/broadinstitute/sting/utils/pairhmm/CnyPairHMM.java index 746c0add1..8de29dc16 100644 --- a/protected/java/src/org/broadinstitute/sting/utils/pairhmm/CnyPairHMM.java +++ b/protected/java/src/org/broadinstitute/sting/utils/pairhmm/CnyPairHMM.java @@ -113,6 +113,7 @@ public final class CnyPairHMM extends PairHMM implements BatchPairHMM { } public double[] batchGetResult() { + int iii, numHaplotypes; double[] results; int n = flushQueue(); @@ -123,16 +124,27 @@ public final class CnyPairHMM extends PairHMM implements BatchPairHMM { resultQueue.push(results); } - final HmmInput test = batchRequests.remove(0); - final int numHaplotypes = test.haplotypes.size(); + numHaplotypes = 0; + for (Iterator it=batchRequests.listIterator(); it.hasNext(); ) { + HmmInput h = it.next(); + numHaplotypes += h.haplotypes.size(); + } + results = new double[numHaplotypes]; - for (int jjj = 0; jjj < numHaplotypes; jjj++) { - results[jjj] = resultQueue.pop(); - if (results[jjj]<-60.0) { - final Haplotype haplotype = test.haplotypes.get(jjj); - results[jjj]=softHmm(haplotype.getBases(), test.readBases, test.readQuals, test.insertionGOP, test.deletionGOP, test.overallGCP, 0, true); + iii = 0; + while (!batchRequests.isEmpty()) { + HmmInput test = batchRequests.remove(0); + int testSize = test.haplotypes.size(); + for (int jjj = 0; jjj < testSize; jjj++) { + results[iii] = resultQueue.pop(); + if (results[iii]<-60.0) { + final Haplotype haplotype = test.haplotypes.get(jjj); + results[iii] = softHmm(haplotype.getBases(), test.readBases, test.readQuals, test.insertionGOP, test.deletionGOP, test.overallGCP, 0, true); + } + iii++; } } + return results; } From 23fe3e449a82a8b82094b1175a339f94a7ac0dc3 Mon Sep 17 00:00:00 2001 From: sathibault Date: Thu, 11 Jul 2013 11:30:37 -0500 Subject: [PATCH 07/11] Revert "Fixed batching bug." This reverts commit 3e56c83d0eec7c374e5f187d1ef124d42ecc071e. --- .../sting/utils/pairhmm/CnyPairHMM.java | 26 +++++-------------- 1 file changed, 7 insertions(+), 19 deletions(-) diff --git a/protected/java/src/org/broadinstitute/sting/utils/pairhmm/CnyPairHMM.java b/protected/java/src/org/broadinstitute/sting/utils/pairhmm/CnyPairHMM.java index 8de29dc16..746c0add1 100644 --- a/protected/java/src/org/broadinstitute/sting/utils/pairhmm/CnyPairHMM.java +++ b/protected/java/src/org/broadinstitute/sting/utils/pairhmm/CnyPairHMM.java @@ -113,7 +113,6 @@ public final class CnyPairHMM extends PairHMM implements BatchPairHMM { } public double[] batchGetResult() { - int iii, numHaplotypes; double[] results; int n = flushQueue(); @@ -124,27 +123,16 @@ public final class CnyPairHMM extends PairHMM implements BatchPairHMM { resultQueue.push(results); } - numHaplotypes = 0; - for (Iterator it=batchRequests.listIterator(); it.hasNext(); ) { - HmmInput h = it.next(); - numHaplotypes += h.haplotypes.size(); - } - + final HmmInput test = batchRequests.remove(0); + final int numHaplotypes = test.haplotypes.size(); results = new double[numHaplotypes]; - iii = 0; - while (!batchRequests.isEmpty()) { - HmmInput test = batchRequests.remove(0); - int testSize = test.haplotypes.size(); - for (int jjj = 0; jjj < testSize; jjj++) { - results[iii] = resultQueue.pop(); - if (results[iii]<-60.0) { - final Haplotype haplotype = test.haplotypes.get(jjj); - results[iii] = softHmm(haplotype.getBases(), test.readBases, test.readQuals, test.insertionGOP, test.deletionGOP, test.overallGCP, 0, true); - } - iii++; + for (int jjj = 0; jjj < numHaplotypes; jjj++) { + results[jjj] = resultQueue.pop(); + if (results[jjj]<-60.0) { + final Haplotype haplotype = test.haplotypes.get(jjj); + results[jjj]=softHmm(haplotype.getBases(), test.readBases, test.readQuals, test.insertionGOP, test.deletionGOP, test.overallGCP, 0, true); } } - return results; } From 5d198d340021c87e17520b76c1adb2f989040494 Mon Sep 17 00:00:00 2001 From: Scott Thibault Date: Mon, 15 Jul 2013 10:16:39 -0500 Subject: [PATCH 08/11] Added write to likelihoods.txt for batch hmm --- .../LikelihoodCalculationEngine.java | 38 ++++++++++++++++--- 1 file changed, 33 insertions(+), 5 deletions(-) diff --git a/protected/java/src/org/broadinstitute/sting/gatk/walkers/haplotypecaller/LikelihoodCalculationEngine.java b/protected/java/src/org/broadinstitute/sting/gatk/walkers/haplotypecaller/LikelihoodCalculationEngine.java index e6fa64e52..e44aedd66 100644 --- a/protected/java/src/org/broadinstitute/sting/gatk/walkers/haplotypecaller/LikelihoodCalculationEngine.java +++ b/protected/java/src/org/broadinstitute/sting/gatk/walkers/haplotypecaller/LikelihoodCalculationEngine.java @@ -290,12 +290,39 @@ public class LikelihoodCalculationEngine { final double[] likelihoods = batchPairHMM.batchGetResult(); for( int jjj = 0; jjj < numHaplotypes; jjj++ ) { final Haplotype haplotype = haplotypes.get(jjj); - if ( haplotype.isNonReference() ) - bestNonReflog10L = Math.max(bestNonReflog10L, likelihoods[jjj]); - else - refLog10l = likelihoods[jjj]; + final double log10l = likelihoods[jjj]; - perReadAlleleLikelihoodMap.add(read, alleleVersions.get(haplotype), likelihoods[jjj]); + if ( WRITE_LIKELIHOODS_TO_FILE ) { + final byte[] overallGCP = new byte[read.getReadLength()]; + Arrays.fill( overallGCP, constantGCP ); // Is there a way to derive empirical estimates for this from the data? + // NOTE -- must clone anything that gets modified here so we don't screw up future uses of the read + final byte[] readQuals = read.getBaseQualities().clone(); + final byte[] readInsQuals = read.getBaseInsertionQualities(); + final byte[] readDelQuals = read.getBaseDeletionQualities(); + for( int kkk = 0; kkk < readQuals.length; kkk++ ) { + readQuals[kkk] = (byte) Math.min( 0xff & readQuals[kkk], read.getMappingQuality()); // cap base quality by mapping quality, as in UG + //readQuals[kkk] = ( readQuals[kkk] > readInsQuals[kkk] ? readInsQuals[kkk] : readQuals[kkk] ); // cap base quality by base insertion quality, needs to be evaluated + //readQuals[kkk] = ( readQuals[kkk] > readDelQuals[kkk] ? readDelQuals[kkk] : readQuals[kkk] ); // cap base quality by base deletion quality, needs to be evaluated + // TODO -- why is Q18 hard-coded here??? + readQuals[kkk] = ( readQuals[kkk] < (byte) 18 ? QualityUtils.MIN_USABLE_Q_SCORE : readQuals[kkk] ); + } + likelihoodsStream.printf("%s %s %s %s %s %s %f%n", + haplotype.getBaseString(), + new String(read.getReadBases()), + SAMUtils.phredToFastq(readQuals), + SAMUtils.phredToFastq(readInsQuals), + SAMUtils.phredToFastq(readDelQuals), + SAMUtils.phredToFastq(overallGCP), + log10l); + } + + if ( haplotype.isNonReference() ) + bestNonReflog10L = Math.max(bestNonReflog10L, log10l); + else + refLog10l = log10l; + + + perReadAlleleLikelihoodMap.add(read, alleleVersions.get(haplotype), log10l); } final double worstRefLog10Allowed = bestNonReflog10L + log10globalReadMismappingRate; @@ -304,6 +331,7 @@ public class LikelihoodCalculationEngine { } } } + return perReadAlleleLikelihoodMap; } From 31ab0824b1fb5d774ebff61ff54f0adfe0f6f38c Mon Sep 17 00:00:00 2001 From: Mauricio Carneiro Date: Wed, 24 Jul 2013 14:09:49 -0400 Subject: [PATCH 09/11] quick indentation fixes to FPGA code --- .../LikelihoodCalculationEngine.java | 106 +++--- .../sting/utils/pairhmm/CnyPairHMM.java | 332 ++++++++++-------- .../sting/utils/pairhmm/BatchPairHMM.java | 41 ++- 3 files changed, 276 insertions(+), 203 deletions(-) diff --git a/protected/java/src/org/broadinstitute/sting/gatk/walkers/haplotypecaller/LikelihoodCalculationEngine.java b/protected/java/src/org/broadinstitute/sting/gatk/walkers/haplotypecaller/LikelihoodCalculationEngine.java index e44aedd66..8bbe23afc 100644 --- a/protected/java/src/org/broadinstitute/sting/gatk/walkers/haplotypecaller/LikelihoodCalculationEngine.java +++ b/protected/java/src/org/broadinstitute/sting/gatk/walkers/haplotypecaller/LikelihoodCalculationEngine.java @@ -90,10 +90,10 @@ public class LikelihoodCalculationEngine { case EXACT: return new Log10PairHMM(true); case ORIGINAL: return new Log10PairHMM(false); case LOGLESS_CACHING: - if (noFpga || !CnyPairHMM.isAvailable()) - return new LoglessPairHMM(); - else - return new CnyPairHMM(); + if (noFpga || !CnyPairHMM.isAvailable()) + return new LoglessPairHMM(); + else + return new CnyPairHMM(); default: throw new UserException.BadArgumentValue("pairHMM", "Specified pairHMM implementation is unrecognized or incompatible with the HaplotypeCaller. Acceptable options are ORIGINAL, EXACT, CACHING, and LOGLESS_CACHING."); } @@ -132,7 +132,7 @@ public class LikelihoodCalculationEngine { this.constantGCP = constantGCP; this.DEBUG = debug; this.log10globalReadMismappingRate = log10globalReadMismappingRate; - this.noFpga = noFpga; + this.noFpga = noFpga; if ( WRITE_LIKELIHOODS_TO_FILE ) { try { @@ -146,7 +146,7 @@ public class LikelihoodCalculationEngine { } public LikelihoodCalculationEngine( final byte constantGCP, final boolean debug, final PairHMM.HMM_IMPLEMENTATION hmmType, final double log10globalReadMismappingRate ) { - this(constantGCP, debug, hmmType, log10globalReadMismappingRate, false); + this(constantGCP, debug, hmmType, log10globalReadMismappingRate, false); } public LikelihoodCalculationEngine() { @@ -209,8 +209,8 @@ public class LikelihoodCalculationEngine { private PerReadAlleleLikelihoodMap computeReadLikelihoods( final List haplotypes, final List reads) { // first, a little set up to get copies of the Haplotypes that are Alleles (more efficient than creating them each time) - final BatchPairHMM batchPairHMM = (pairHMM.get() instanceof BatchPairHMM) ? (BatchPairHMM)pairHMM.get() : null; - final Vector batchedReads = new Vector(reads.size()); + final BatchPairHMM batchPairHMM = (pairHMM.get() instanceof BatchPairHMM) ? (BatchPairHMM)pairHMM.get() : null; + final Vector batchedReads = new Vector(reads.size()); final int numHaplotypes = haplotypes.size(); final Map alleleVersions = new LinkedHashMap<>(numHaplotypes); Allele refAllele = null; @@ -236,11 +236,11 @@ public class LikelihoodCalculationEngine { readQuals[kkk] = ( readQuals[kkk] < (byte) 18 ? QualityUtils.MIN_USABLE_Q_SCORE : readQuals[kkk] ); } - if ( batchPairHMM != null ) { - batchPairHMM.batchAdd(haplotypes, read.getReadBases(), readQuals, readInsQuals, readDelQuals, overallGCP); - batchedReads.add(read); - continue; - } + if ( batchPairHMM != null ) { + batchPairHMM.batchAdd(haplotypes, read.getReadBases(), readQuals, readInsQuals, readDelQuals, overallGCP); + batchedReads.add(read); + continue; + } // keep track of the reference likelihood and the best non-ref likelihood double refLog10l = Double.NEGATIVE_INFINITY; @@ -283,54 +283,54 @@ public class LikelihoodCalculationEngine { } } - if ( batchPairHMM != null ) { - for( final GATKSAMRecord read : batchedReads ) { - double refLog10l = Double.NEGATIVE_INFINITY; - double bestNonReflog10L = Double.NEGATIVE_INFINITY; - final double[] likelihoods = batchPairHMM.batchGetResult(); - for( int jjj = 0; jjj < numHaplotypes; jjj++ ) { - final Haplotype haplotype = haplotypes.get(jjj); - final double log10l = likelihoods[jjj]; + if ( batchPairHMM != null ) { + for( final GATKSAMRecord read : batchedReads ) { + double refLog10l = Double.NEGATIVE_INFINITY; + double bestNonReflog10L = Double.NEGATIVE_INFINITY; + final double[] likelihoods = batchPairHMM.batchGetResult(); + for( int jjj = 0; jjj < numHaplotypes; jjj++ ) { + final Haplotype haplotype = haplotypes.get(jjj); + final double log10l = likelihoods[jjj]; - if ( WRITE_LIKELIHOODS_TO_FILE ) { - final byte[] overallGCP = new byte[read.getReadLength()]; - Arrays.fill( overallGCP, constantGCP ); // Is there a way to derive empirical estimates for this from the data? - // NOTE -- must clone anything that gets modified here so we don't screw up future uses of the read - final byte[] readQuals = read.getBaseQualities().clone(); - final byte[] readInsQuals = read.getBaseInsertionQualities(); - final byte[] readDelQuals = read.getBaseDeletionQualities(); - for( int kkk = 0; kkk < readQuals.length; kkk++ ) { - readQuals[kkk] = (byte) Math.min( 0xff & readQuals[kkk], read.getMappingQuality()); // cap base quality by mapping quality, as in UG - //readQuals[kkk] = ( readQuals[kkk] > readInsQuals[kkk] ? readInsQuals[kkk] : readQuals[kkk] ); // cap base quality by base insertion quality, needs to be evaluated - //readQuals[kkk] = ( readQuals[kkk] > readDelQuals[kkk] ? readDelQuals[kkk] : readQuals[kkk] ); // cap base quality by base deletion quality, needs to be evaluated - // TODO -- why is Q18 hard-coded here??? - readQuals[kkk] = ( readQuals[kkk] < (byte) 18 ? QualityUtils.MIN_USABLE_Q_SCORE : readQuals[kkk] ); - } - likelihoodsStream.printf("%s %s %s %s %s %s %f%n", - haplotype.getBaseString(), - new String(read.getReadBases()), - SAMUtils.phredToFastq(readQuals), - SAMUtils.phredToFastq(readInsQuals), + if ( WRITE_LIKELIHOODS_TO_FILE ) { + final byte[] overallGCP = new byte[read.getReadLength()]; + Arrays.fill( overallGCP, constantGCP ); // Is there a way to derive empirical estimates for this from the data? + // NOTE -- must clone anything that gets modified here so we don't screw up future uses of the read + final byte[] readQuals = read.getBaseQualities().clone(); + final byte[] readInsQuals = read.getBaseInsertionQualities(); + final byte[] readDelQuals = read.getBaseDeletionQualities(); + for( int kkk = 0; kkk < readQuals.length; kkk++ ) { + readQuals[kkk] = (byte) Math.min( 0xff & readQuals[kkk], read.getMappingQuality()); // cap base quality by mapping quality, as in UG + //readQuals[kkk] = ( readQuals[kkk] > readInsQuals[kkk] ? readInsQuals[kkk] : readQuals[kkk] ); // cap base quality by base insertion quality, needs to be evaluated + //readQuals[kkk] = ( readQuals[kkk] > readDelQuals[kkk] ? readDelQuals[kkk] : readQuals[kkk] ); // cap base quality by base deletion quality, needs to be evaluated + // TODO -- why is Q18 hard-coded here??? + readQuals[kkk] = ( readQuals[kkk] < (byte) 18 ? QualityUtils.MIN_USABLE_Q_SCORE : readQuals[kkk] ); + } + likelihoodsStream.printf("%s %s %s %s %s %s %f%n", + haplotype.getBaseString(), + new String(read.getReadBases()), + SAMUtils.phredToFastq(readQuals), + SAMUtils.phredToFastq(readInsQuals), SAMUtils.phredToFastq(readDelQuals), SAMUtils.phredToFastq(overallGCP), log10l); - } + } - if ( haplotype.isNonReference() ) - bestNonReflog10L = Math.max(bestNonReflog10L, log10l); - else - refLog10l = log10l; + if ( haplotype.isNonReference() ) + bestNonReflog10L = Math.max(bestNonReflog10L, log10l); + else + refLog10l = log10l; - perReadAlleleLikelihoodMap.add(read, alleleVersions.get(haplotype), log10l); - } + perReadAlleleLikelihoodMap.add(read, alleleVersions.get(haplotype), log10l); + } - final double worstRefLog10Allowed = bestNonReflog10L + log10globalReadMismappingRate; - if ( refLog10l < (worstRefLog10Allowed) ) { - perReadAlleleLikelihoodMap.add(read, refAllele, worstRefLog10Allowed); - } - } - } + final double worstRefLog10Allowed = bestNonReflog10L + log10globalReadMismappingRate; + if ( refLog10l < (worstRefLog10Allowed) ) { + perReadAlleleLikelihoodMap.add(read, refAllele, worstRefLog10Allowed); + } + } + } return perReadAlleleLikelihoodMap; } diff --git a/protected/java/src/org/broadinstitute/sting/utils/pairhmm/CnyPairHMM.java b/protected/java/src/org/broadinstitute/sting/utils/pairhmm/CnyPairHMM.java index 746c0add1..8353d3282 100644 --- a/protected/java/src/org/broadinstitute/sting/utils/pairhmm/CnyPairHMM.java +++ b/protected/java/src/org/broadinstitute/sting/utils/pairhmm/CnyPairHMM.java @@ -1,43 +1,91 @@ -package org.broadinstitute.sting.utils.pairhmm; +/* +* By downloading the PROGRAM you agree to the following terms of use: +* +* BROAD INSTITUTE - SOFTWARE LICENSE AGREEMENT - FOR ACADEMIC NON-COMMERCIAL RESEARCH PURPOSES ONLY +* +* This Agreement is made between the Broad Institute, Inc. with a principal address at 7 Cambridge Center, Cambridge, MA 02142 (BROAD) and the LICENSEE and is effective at the date the downloading is completed (EFFECTIVE DATE). +* +* WHEREAS, LICENSEE desires to license the PROGRAM, as defined hereinafter, and BROAD wishes to have this PROGRAM utilized in the public interest, subject only to the royalty-free, nonexclusive, nontransferable license rights of the United States Government pursuant to 48 CFR 52.227-14; and +* WHEREAS, LICENSEE desires to license the PROGRAM and BROAD desires to grant a license on the following terms and conditions. +* NOW, THEREFORE, in consideration of the promises and covenants made herein, the parties hereto agree as follows: +* +* 1. DEFINITIONS +* 1.1 PROGRAM shall mean copyright in the object code and source code known as GATK2 and related documentation, if any, as they exist on the EFFECTIVE DATE and can be downloaded from http://www.broadinstitute/GATK on the EFFECTIVE DATE. +* +* 2. LICENSE +* 2.1 Grant. Subject to the terms of this Agreement, BROAD hereby grants to LICENSEE, solely for academic non-commercial research purposes, a non-exclusive, non-transferable license to: (a) download, execute and display the PROGRAM and (b) create bug fixes and modify the PROGRAM. +* The LICENSEE may apply the PROGRAM in a pipeline to data owned by users other than the LICENSEE and provide these users the results of the PROGRAM provided LICENSEE does so for academic non-commercial purposes only. For clarification purposes, academic sponsored research is not a commercial use under the terms of this Agreement. +* 2.2 No Sublicensing or Additional Rights. LICENSEE shall not sublicense or distribute the PROGRAM, in whole or in part, without prior written permission from BROAD. LICENSEE shall ensure that all of its users agree to the terms of this Agreement. LICENSEE further agrees that it shall not put the PROGRAM on a network, server, or other similar technology that may be accessed by anyone other than the LICENSEE and its employees and users who have agreed to the terms of this agreement. +* 2.3 License Limitations. Nothing in this Agreement shall be construed to confer any rights upon LICENSEE by implication, estoppel, or otherwise to any computer software, trademark, intellectual property, or patent rights of BROAD, or of any other entity, except as expressly granted herein. LICENSEE agrees that the PROGRAM, in whole or part, shall not be used for any commercial purpose, including without limitation, as the basis of a commercial software or hardware product or to provide services. LICENSEE further agrees that the PROGRAM shall not be copied or otherwise adapted in order to circumvent the need for obtaining a license for use of the PROGRAM. +* +* 3. OWNERSHIP OF INTELLECTUAL PROPERTY +* LICENSEE acknowledges that title to the PROGRAM shall remain with BROAD. The PROGRAM is marked with the following BROAD copyright notice and notice of attribution to contributors. LICENSEE shall retain such notice on all copies. LICENSEE agrees to include appropriate attribution if any results obtained from use of the PROGRAM are included in any publication. +* Copyright 2012 Broad Institute, Inc. +* Notice of attribution: The GATK2 program was made available through the generosity of Medical and Population Genetics program at the Broad Institute, Inc. +* LICENSEE shall not use any trademark or trade name of BROAD, or any variation, adaptation, or abbreviation, of such marks or trade names, or any names of officers, faculty, students, employees, or agents of BROAD except as states above for attribution purposes. +* +* 4. INDEMNIFICATION +* LICENSEE shall indemnify, defend, and hold harmless BROAD, and their respective officers, faculty, students, employees, associated investigators and agents, and their respective successors, heirs and assigns, (Indemnitees), against any liability, damage, loss, or expense (including reasonable attorneys fees and expenses) incurred by or imposed upon any of the Indemnitees in connection with any claims, suits, actions, demands or judgments arising out of any theory of liability (including, without limitation, actions in the form of tort, warranty, or strict liability and regardless of whether such action has any factual basis) pursuant to any right or license granted under this Agreement. +* +* 5. NO REPRESENTATIONS OR WARRANTIES +* THE PROGRAM IS DELIVERED AS IS. BROAD MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND CONCERNING THE PROGRAM OR THE COPYRIGHT, EXPRESS OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, OR THE ABSENCE OF LATENT OR OTHER DEFECTS, WHETHER OR NOT DISCOVERABLE. BROAD EXTENDS NO WARRANTIES OF ANY KIND AS TO PROGRAM CONFORMITY WITH WHATEVER USER MANUALS OR OTHER LITERATURE MAY BE ISSUED FROM TIME TO TIME. +* IN NO EVENT SHALL BROAD OR ITS RESPECTIVE DIRECTORS, OFFICERS, EMPLOYEES, AFFILIATED INVESTIGATORS AND AFFILIATES BE LIABLE FOR INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, INCLUDING, WITHOUT LIMITATION, ECONOMIC DAMAGES OR INJURY TO PROPERTY AND LOST PROFITS, REGARDLESS OF WHETHER BROAD SHALL BE ADVISED, SHALL HAVE OTHER REASON TO KNOW, OR IN FACT SHALL KNOW OF THE POSSIBILITY OF THE FOREGOING. +* +* 6. ASSIGNMENT +* This Agreement is personal to LICENSEE and any rights or obligations assigned by LICENSEE without the prior written consent of BROAD shall be null and void. +* +* 7. MISCELLANEOUS +* 7.1 Export Control. LICENSEE gives assurance that it will comply with all United States export control laws and regulations controlling the export of the PROGRAM, including, without limitation, all Export Administration Regulations of the United States Department of Commerce. Among other things, these laws and regulations prohibit, or require a license for, the export of certain types of software to specified countries. +* 7.2 Termination. LICENSEE shall have the right to terminate this Agreement for any reason upon prior written notice to BROAD. If LICENSEE breaches any provision hereunder, and fails to cure such breach within thirty (30) days, BROAD may terminate this Agreement immediately. Upon termination, LICENSEE shall provide BROAD with written assurance that the original and all copies of the PROGRAM have been destroyed, except that, upon prior written authorization from BROAD, LICENSEE may retain a copy for archive purposes. +* 7.3 Survival. The following provisions shall survive the expiration or termination of this Agreement: Articles 1, 3, 4, 5 and Sections 2.2, 2.3, 7.3, and 7.4. +* 7.4 Notice. Any notices under this Agreement shall be in writing, shall specifically refer to this Agreement, and shall be sent by hand, recognized national overnight courier, confirmed facsimile transmission, confirmed electronic mail, or registered or certified mail, postage prepaid, return receipt requested. All notices under this Agreement shall be deemed effective upon receipt. +* 7.5 Amendment and Waiver; Entire Agreement. This Agreement may be amended, supplemented, or otherwise modified only by means of a written instrument signed by all parties. Any waiver of any rights or failure to act in a specific instance shall relate only to such instance and shall not be construed as an agreement to waive any rights or fail to act in any other instance, whether or not similar. This Agreement constitutes the entire agreement among the parties with respect to its subject matter and supersedes prior agreements or understandings between the parties relating to its subject matter. +* 7.6 Binding Effect; Headings. This Agreement shall be binding upon and inure to the benefit of the parties and their respective permitted successors and assigns. All headings are for convenience only and shall not affect the meaning of any provision of this Agreement. +* 7.7 Governing Law. This Agreement shall be construed, governed, interpreted and applied in accordance with the internal laws of the Commonwealth of Massachusetts, U.S.A., without regard to conflict of laws principles. +*/ -import java.io.File; -import java.util.*; -import java.lang.reflect.*; +package org.broadinstitute.sting.utils.pairhmm; import org.broadinstitute.sting.utils.haplotype.Haplotype; +import java.io.File; +import java.lang.reflect.Field; +import java.util.Arrays; +import java.util.LinkedList; +import java.util.List; + public final class CnyPairHMM extends PairHMM implements BatchPairHMM { private static class HmmInput { - public byte[] readBases; - public byte[] readQuals; - public byte[] insertionGOP; - public byte[] deletionGOP; - public byte[] overallGCP; - public List haplotypes; + public byte[] readBases; + public byte[] readQuals; + public byte[] insertionGOP; + public byte[] deletionGOP; + public byte[] overallGCP; + public List haplotypes; }; private static class ResultQueue { - private int offset; - private List batchResults; - - public ResultQueue() { - batchResults = new LinkedList(); - offset = 0; - } + private int offset; + private List batchResults; - public void push(double[] results) { - batchResults.add(results); - } - - public double pop() { - double[] results = batchResults.get(0); - double top = results[offset++]; - if (offset == results.length) { - batchResults.remove(0); - offset = 0; - } - return top; - } + public ResultQueue() { + batchResults = new LinkedList(); + offset = 0; + } + + public void push(double[] results) { + batchResults.add(results); + } + + public double pop() { + double[] results = batchResults.get(0); + double top = results[offset++]; + if (offset == results.length) { + batchResults.remove(0); + offset = 0; + } + return top; + } } final static String libPath = "/opt/convey/personalities/32100.1.1.1.0"; @@ -48,145 +96,145 @@ public final class CnyPairHMM extends PairHMM implements BatchPairHMM { private ResultQueue resultQueue = new ResultQueue(); static public boolean isAvailable() { - if (!loaded) { - File library = new File(libPath + "/lib" + libName + ".so"); - return library.exists(); - } - return true; + if (!loaded) { + File library = new File(libPath + "/lib" + libName + ".so"); + return library.exists(); + } + return true; } private native void initFpga(); private native int dequeueRequirement(int reflen, int readlen); private native int enqueue(byte[] haplotypeBases, - byte[] readBases, - byte[] readQuals, - byte[] insertionGOP, - byte[] deletionGOP, - byte[] overallGCP, - int hapStartIndex, - boolean recacheReadValues); + byte[] readBases, + byte[] readQuals, + byte[] insertionGOP, + byte[] deletionGOP, + byte[] overallGCP, + int hapStartIndex, + boolean recacheReadValues); private native int flushQueue(); private native int dequeue(double[] results); private native double softHmm(byte[] haplotypeBases, - byte[] readBases, - byte[] readQuals, - byte[] insertionGOP, - byte[] deletionGOP, - byte[] overallGCP, - int hapStartIndex, - boolean recacheReadValues); - + byte[] readBases, + byte[] readQuals, + byte[] insertionGOP, + byte[] deletionGOP, + byte[] overallGCP, + int hapStartIndex, + boolean recacheReadValues); + public native void reportStats(); public void initialize( final int READ_MAX_LENGTH, final int HAPLOTYPE_MAX_LENGTH ) { - if (!loaded) { - addLibraryPath(libPath); - System.loadLibrary(libName); - initFpga(); - loaded = true; - System.out.println("FPGA HMM Initialized"); - } + if (!loaded) { + addLibraryPath(libPath); + System.loadLibrary(libName); + initFpga(); + loaded = true; + System.out.println("FPGA HMM Initialized"); + } } - public void batchAdd(final List haplotypes, - final byte[] readBases, - final byte[] readQuals, - final byte[] insertionGOP, - final byte[] deletionGOP, - final byte[] overallGCP) { + public void batchAdd(final List haplotypes, + final byte[] readBases, + final byte[] readQuals, + final byte[] insertionGOP, + final byte[] deletionGOP, + final byte[] overallGCP) { final int numHaplotypes = haplotypes.size(); - HmmInput test = new HmmInput(); - test.readBases = readBases; - test.readQuals = readQuals; - test.insertionGOP = insertionGOP; - test.deletionGOP = deletionGOP; - test.overallGCP = overallGCP; - test.haplotypes = haplotypes; - batchRequests.add(test); - for (int jjj = 0; jjj < numHaplotypes; jjj++) { - final boolean recacheReadValues = (jjj == 0); - final Haplotype haplotype = haplotypes.get(jjj); - enqueuePrepare(haplotype.getBases(), readBases); - if (enqueue(haplotype.getBases(), readBases, readQuals, insertionGOP, deletionGOP, overallGCP, 0, recacheReadValues) == 0) - throw new RuntimeException("FPGA queue overflow in batchAdd"); - } + HmmInput test = new HmmInput(); + test.readBases = readBases; + test.readQuals = readQuals; + test.insertionGOP = insertionGOP; + test.deletionGOP = deletionGOP; + test.overallGCP = overallGCP; + test.haplotypes = haplotypes; + batchRequests.add(test); + for (int jjj = 0; jjj < numHaplotypes; jjj++) { + final boolean recacheReadValues = (jjj == 0); + final Haplotype haplotype = haplotypes.get(jjj); + enqueuePrepare(haplotype.getBases(), readBases); + if (enqueue(haplotype.getBases(), readBases, readQuals, insertionGOP, deletionGOP, overallGCP, 0, recacheReadValues) == 0) + throw new RuntimeException("FPGA queue overflow in batchAdd"); + } } - + public double[] batchGetResult() { - double[] results; + double[] results; - int n = flushQueue(); - if (n > 0) { - results = new double[n]; - if (dequeue(results) != n) - System.out.println("queue underflow in enqueuePrepare"); - resultQueue.push(results); - } + int n = flushQueue(); + if (n > 0) { + results = new double[n]; + if (dequeue(results) != n) + System.out.println("queue underflow in enqueuePrepare"); + resultQueue.push(results); + } - final HmmInput test = batchRequests.remove(0); + final HmmInput test = batchRequests.remove(0); final int numHaplotypes = test.haplotypes.size(); - results = new double[numHaplotypes]; - for (int jjj = 0; jjj < numHaplotypes; jjj++) { - results[jjj] = resultQueue.pop(); - if (results[jjj]<-60.0) { - final Haplotype haplotype = test.haplotypes.get(jjj); - results[jjj]=softHmm(haplotype.getBases(), test.readBases, test.readQuals, test.insertionGOP, test.deletionGOP, test.overallGCP, 0, true); - } - } - return results; + results = new double[numHaplotypes]; + for (int jjj = 0; jjj < numHaplotypes; jjj++) { + results[jjj] = resultQueue.pop(); + if (results[jjj]<-60.0) { + final Haplotype haplotype = test.haplotypes.get(jjj); + results[jjj]=softHmm(haplotype.getBases(), test.readBases, test.readQuals, test.insertionGOP, test.deletionGOP, test.overallGCP, 0, true); + } + } + return results; } protected double subComputeReadLikelihoodGivenHaplotypeLog10( final byte[] haplotypeBases, - final byte[] readBases, - final byte[] readQuals, - final byte[] insertionGOP, - final byte[] deletionGOP, - final byte[] overallGCP, - final int hapStartIndex, - final boolean recacheReadValues ) { - return 0.0; + final byte[] readBases, + final byte[] readQuals, + final byte[] insertionGOP, + final byte[] deletionGOP, + final byte[] overallGCP, + final int hapStartIndex, + final boolean recacheReadValues ) { + return 0.0; } private void enqueuePrepare(byte[] haplotypeBases, byte[] readBases) { - double[] results = null; - int n = dequeueRequirement(haplotypeBases.length, readBases.length); - if (n>0) { - results = new double[n]; - if (dequeue(results)!=n) - System.out.println("queue underflow in enqueuePrepare"); - } else if (n<0) { - n = flushQueue(); - if (n > 0) { - results = new double[n]; - if (dequeue(results) != n) - System.out.println("queue underflow in enqueuePrepare"); - } - } - - if (results != null) - resultQueue.push(results); + double[] results = null; + int n = dequeueRequirement(haplotypeBases.length, readBases.length); + if (n>0) { + results = new double[n]; + if (dequeue(results)!=n) + System.out.println("queue underflow in enqueuePrepare"); + } else if (n<0) { + n = flushQueue(); + if (n > 0) { + results = new double[n]; + if (dequeue(results) != n) + System.out.println("queue underflow in enqueuePrepare"); + } + } + + if (results != null) + resultQueue.push(results); } public static void addLibraryPath(String pathToAdd) { - try { - final Field usrPathsField = ClassLoader.class.getDeclaredField("usr_paths"); - usrPathsField.setAccessible(true); - - //get array of paths - final String[] paths = (String[])usrPathsField.get(null); - - //check if the path to add is already present - for(String path : paths) { - if(path.equals(pathToAdd)) { - return; - } - } - - //add the new path - final String[] newPaths = Arrays.copyOf(paths, paths.length + 1); - newPaths[newPaths.length-1] = pathToAdd; - usrPathsField.set(null, newPaths); - } catch (Exception ex) { - } + try { + final Field usrPathsField = ClassLoader.class.getDeclaredField("usr_paths"); + usrPathsField.setAccessible(true); + + //get array of paths + final String[] paths = (String[])usrPathsField.get(null); + + //check if the path to add is already present + for(String path : paths) { + if(path.equals(pathToAdd)) { + return; + } + } + + //add the new path + final String[] newPaths = Arrays.copyOf(paths, paths.length + 1); + newPaths[newPaths.length-1] = pathToAdd; + usrPathsField.set(null, newPaths); + } catch (Exception ex) { + } } } diff --git a/public/java/src/org/broadinstitute/sting/utils/pairhmm/BatchPairHMM.java b/public/java/src/org/broadinstitute/sting/utils/pairhmm/BatchPairHMM.java index 3b794b00e..6468753d2 100644 --- a/public/java/src/org/broadinstitute/sting/utils/pairhmm/BatchPairHMM.java +++ b/public/java/src/org/broadinstitute/sting/utils/pairhmm/BatchPairHMM.java @@ -1,16 +1,41 @@ -package org.broadinstitute.sting.utils.pairhmm; +/* +* Copyright (c) 2012 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. +*/ -import java.util.List; +package org.broadinstitute.sting.utils.pairhmm; import org.broadinstitute.sting.utils.haplotype.Haplotype; +import java.util.List; + public interface BatchPairHMM { - public void batchAdd(final List haplotypes, - final byte[] readBases, - final byte[] readQuals, - final byte[] insertionGOP, - final byte[] deletionGOP, - final byte[] overallGCP); + public void batchAdd(final List haplotypes, + final byte[] readBases, + final byte[] readQuals, + final byte[] insertionGOP, + final byte[] deletionGOP, + final byte[] overallGCP); public double[] batchGetResult(); } From 71eb944e629ea2c9bf37ff9a2b59f7c3988c1fcf Mon Sep 17 00:00:00 2001 From: sathibault Date: Thu, 25 Jul 2013 14:19:50 -0500 Subject: [PATCH 10/11] Adding CnyPairHMMUnitTest --- .../sting/utils/pairhmm/CnyPairHMM.java | 2 +- .../utils/pairhmm/CnyPairHMMUnitTest.java | 101 ++++++++++++++++++ 2 files changed, 102 insertions(+), 1 deletion(-) create mode 100644 protected/java/test/org/broadinstitute/sting/utils/pairhmm/CnyPairHMMUnitTest.java diff --git a/protected/java/src/org/broadinstitute/sting/utils/pairhmm/CnyPairHMM.java b/protected/java/src/org/broadinstitute/sting/utils/pairhmm/CnyPairHMM.java index 8353d3282..0afd4afe2 100644 --- a/protected/java/src/org/broadinstitute/sting/utils/pairhmm/CnyPairHMM.java +++ b/protected/java/src/org/broadinstitute/sting/utils/pairhmm/CnyPairHMM.java @@ -64,7 +64,7 @@ public final class CnyPairHMM extends PairHMM implements BatchPairHMM { public List haplotypes; }; - private static class ResultQueue { + public static class ResultQueue { private int offset; private List batchResults; diff --git a/protected/java/test/org/broadinstitute/sting/utils/pairhmm/CnyPairHMMUnitTest.java b/protected/java/test/org/broadinstitute/sting/utils/pairhmm/CnyPairHMMUnitTest.java new file mode 100644 index 000000000..bdc06a6f0 --- /dev/null +++ b/protected/java/test/org/broadinstitute/sting/utils/pairhmm/CnyPairHMMUnitTest.java @@ -0,0 +1,101 @@ +/* +* By downloading the PROGRAM you agree to the following terms of use: +* +* BROAD INSTITUTE - SOFTWARE LICENSE AGREEMENT - FOR ACADEMIC NON-COMMERCIAL RESEARCH PURPOSES ONLY +* +* This Agreement is made between the Broad Institute, Inc. with a principal address at 7 Cambridge Center, Cambridge, MA 02142 (BROAD) and the LICENSEE and is effective at the date the downloading is completed (EFFECTIVE DATE). +* +* WHEREAS, LICENSEE desires to license the PROGRAM, as defined hereinafter, and BROAD wishes to have this PROGRAM utilized in the public interest, subject only to the royalty-free, nonexclusive, nontransferable license rights of the United States Government pursuant to 48 CFR 52.227-14; and +* WHEREAS, LICENSEE desires to license the PROGRAM and BROAD desires to grant a license on the following terms and conditions. +* NOW, THEREFORE, in consideration of the promises and covenants made herein, the parties hereto agree as follows: +* +* 1. DEFINITIONS +* 1.1 PROGRAM shall mean copyright in the object code and source code known as GATK2 and related documentation, if any, as they exist on the EFFECTIVE DATE and can be downloaded from http://www.broadinstitute/GATK on the EFFECTIVE DATE. +* +* 2. LICENSE +* 2.1 Grant. Subject to the terms of this Agreement, BROAD hereby grants to LICENSEE, solely for academic non-commercial research purposes, a non-exclusive, non-transferable license to: (a) download, execute and display the PROGRAM and (b) create bug fixes and modify the PROGRAM. +* The LICENSEE may apply the PROGRAM in a pipeline to data owned by users other than the LICENSEE and provide these users the results of the PROGRAM provided LICENSEE does so for academic non-commercial purposes only. For clarification purposes, academic sponsored research is not a commercial use under the terms of this Agreement. +* 2.2 No Sublicensing or Additional Rights. LICENSEE shall not sublicense or distribute the PROGRAM, in whole or in part, without prior written permission from BROAD. LICENSEE shall ensure that all of its users agree to the terms of this Agreement. LICENSEE further agrees that it shall not put the PROGRAM on a network, server, or other similar technology that may be accessed by anyone other than the LICENSEE and its employees and users who have agreed to the terms of this agreement. +* 2.3 License Limitations. Nothing in this Agreement shall be construed to confer any rights upon LICENSEE by implication, estoppel, or otherwise to any computer software, trademark, intellectual property, or patent rights of BROAD, or of any other entity, except as expressly granted herein. LICENSEE agrees that the PROGRAM, in whole or part, shall not be used for any commercial purpose, including without limitation, as the basis of a commercial software or hardware product or to provide services. LICENSEE further agrees that the PROGRAM shall not be copied or otherwise adapted in order to circumvent the need for obtaining a license for use of the PROGRAM. +* +* 3. OWNERSHIP OF INTELLECTUAL PROPERTY +* LICENSEE acknowledges that title to the PROGRAM shall remain with BROAD. The PROGRAM is marked with the following BROAD copyright notice and notice of attribution to contributors. LICENSEE shall retain such notice on all copies. LICENSEE agrees to include appropriate attribution if any results obtained from use of the PROGRAM are included in any publication. +* Copyright 2012 Broad Institute, Inc. +* Notice of attribution: The GATK2 program was made available through the generosity of Medical and Population Genetics program at the Broad Institute, Inc. +* LICENSEE shall not use any trademark or trade name of BROAD, or any variation, adaptation, or abbreviation, of such marks or trade names, or any names of officers, faculty, students, employees, or agents of BROAD except as states above for attribution purposes. +* +* 4. INDEMNIFICATION +* LICENSEE shall indemnify, defend, and hold harmless BROAD, and their respective officers, faculty, students, employees, associated investigators and agents, and their respective successors, heirs and assigns, (Indemnitees), against any liability, damage, loss, or expense (including reasonable attorneys fees and expenses) incurred by or imposed upon any of the Indemnitees in connection with any claims, suits, actions, demands or judgments arising out of any theory of liability (including, without limitation, actions in the form of tort, warranty, or strict liability and regardless of whether such action has any factual basis) pursuant to any right or license granted under this Agreement. +* +* 5. NO REPRESENTATIONS OR WARRANTIES +* THE PROGRAM IS DELIVERED AS IS. BROAD MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND CONCERNING THE PROGRAM OR THE COPYRIGHT, EXPRESS OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, OR THE ABSENCE OF LATENT OR OTHER DEFECTS, WHETHER OR NOT DISCOVERABLE. BROAD EXTENDS NO WARRANTIES OF ANY KIND AS TO PROGRAM CONFORMITY WITH WHATEVER USER MANUALS OR OTHER LITERATURE MAY BE ISSUED FROM TIME TO TIME. +* IN NO EVENT SHALL BROAD OR ITS RESPECTIVE DIRECTORS, OFFICERS, EMPLOYEES, AFFILIATED INVESTIGATORS AND AFFILIATES BE LIABLE FOR INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, INCLUDING, WITHOUT LIMITATION, ECONOMIC DAMAGES OR INJURY TO PROPERTY AND LOST PROFITS, REGARDLESS OF WHETHER BROAD SHALL BE ADVISED, SHALL HAVE OTHER REASON TO KNOW, OR IN FACT SHALL KNOW OF THE POSSIBILITY OF THE FOREGOING. +* +* 6. ASSIGNMENT +* This Agreement is personal to LICENSEE and any rights or obligations assigned by LICENSEE without the prior written consent of BROAD shall be null and void. +* +* 7. MISCELLANEOUS +* 7.1 Export Control. LICENSEE gives assurance that it will comply with all United States export control laws and regulations controlling the export of the PROGRAM, including, without limitation, all Export Administration Regulations of the United States Department of Commerce. Among other things, these laws and regulations prohibit, or require a license for, the export of certain types of software to specified countries. +* 7.2 Termination. LICENSEE shall have the right to terminate this Agreement for any reason upon prior written notice to BROAD. If LICENSEE breaches any provision hereunder, and fails to cure such breach within thirty (30) days, BROAD may terminate this Agreement immediately. Upon termination, LICENSEE shall provide BROAD with written assurance that the original and all copies of the PROGRAM have been destroyed, except that, upon prior written authorization from BROAD, LICENSEE may retain a copy for archive purposes. +* 7.3 Survival. The following provisions shall survive the expiration or termination of this Agreement: Articles 1, 3, 4, 5 and Sections 2.2, 2.3, 7.3, and 7.4. +* 7.4 Notice. Any notices under this Agreement shall be in writing, shall specifically refer to this Agreement, and shall be sent by hand, recognized national overnight courier, confirmed facsimile transmission, confirmed electronic mail, or registered or certified mail, postage prepaid, return receipt requested. All notices under this Agreement shall be deemed effective upon receipt. +* 7.5 Amendment and Waiver; Entire Agreement. This Agreement may be amended, supplemented, or otherwise modified only by means of a written instrument signed by all parties. Any waiver of any rights or failure to act in a specific instance shall relate only to such instance and shall not be construed as an agreement to waive any rights or fail to act in any other instance, whether or not similar. This Agreement constitutes the entire agreement among the parties with respect to its subject matter and supersedes prior agreements or understandings between the parties relating to its subject matter. +* 7.6 Binding Effect; Headings. This Agreement shall be binding upon and inure to the benefit of the parties and their respective permitted successors and assigns. All headings are for convenience only and shall not affect the meaning of any provision of this Agreement. +* 7.7 Governing Law. This Agreement shall be construed, governed, interpreted and applied in accordance with the internal laws of the Commonwealth of Massachusetts, U.S.A., without regard to conflict of laws principles. +*/ + +package org.broadinstitute.sting.utils.pairhmm; + +import org.broadinstitute.sting.BaseTest; +import org.testng.Assert; +import org.testng.annotations.DataProvider; +import org.testng.annotations.Test; + +import java.util.ArrayList; +import java.util.List; + +public class CnyPairHMMUnitTest extends BaseTest { + private native void puts(String text); + + @Test(enabled = true) + public void testResultQueue() { + final double[] row1 = new double[] { 4.5, 53.1, 6.4 }; + final double[] row2 = new double[] { 1.0, 5.9, 6.9, 6.1, 19.8 }; + final double[] row3 = new double[] { 10.4, 9.101, 89.5, 9.8}; + final double[] row4 = new double[] { 7.3, 1.4, 5.67, 56.32 }; + CnyPairHMM.ResultQueue queue = new CnyPairHMM.ResultQueue(); + + // Test inter-mixed push/pop operations produce the correct output + queue.push(row1); + queue.push(row2); + + for (int i=0; i Date: Tue, 30 Jul 2013 13:59:58 -0400 Subject: [PATCH 11/11] Removed native method call and fixed indentation. --- .../utils/pairhmm/CnyPairHMMUnitTest.java | 51 ++++++++----------- 1 file changed, 21 insertions(+), 30 deletions(-) diff --git a/protected/java/test/org/broadinstitute/sting/utils/pairhmm/CnyPairHMMUnitTest.java b/protected/java/test/org/broadinstitute/sting/utils/pairhmm/CnyPairHMMUnitTest.java index bdc06a6f0..14ab552e5 100644 --- a/protected/java/test/org/broadinstitute/sting/utils/pairhmm/CnyPairHMMUnitTest.java +++ b/protected/java/test/org/broadinstitute/sting/utils/pairhmm/CnyPairHMMUnitTest.java @@ -48,54 +48,45 @@ package org.broadinstitute.sting.utils.pairhmm; import org.broadinstitute.sting.BaseTest; import org.testng.Assert; -import org.testng.annotations.DataProvider; import org.testng.annotations.Test; -import java.util.ArrayList; -import java.util.List; - public class CnyPairHMMUnitTest extends BaseTest { - private native void puts(String text); @Test(enabled = true) public void testResultQueue() { - final double[] row1 = new double[] { 4.5, 53.1, 6.4 }; - final double[] row2 = new double[] { 1.0, 5.9, 6.9, 6.1, 19.8 }; - final double[] row3 = new double[] { 10.4, 9.101, 89.5, 9.8}; - final double[] row4 = new double[] { 7.3, 1.4, 5.67, 56.32 }; - CnyPairHMM.ResultQueue queue = new CnyPairHMM.ResultQueue(); + final double[] row1 = new double[] { 4.5, 53.1, 6.4 }; + final double[] row2 = new double[] { 1.0, 5.9, 6.9, 6.1, 19.8 }; + final double[] row3 = new double[] { 10.4, 9.101, 89.5, 9.8}; + final double[] row4 = new double[] { 7.3, 1.4, 5.67, 56.32 }; + CnyPairHMM.ResultQueue queue = new CnyPairHMM.ResultQueue(); - // Test inter-mixed push/pop operations produce the correct output - queue.push(row1); - queue.push(row2); + // Test inter-mixed push/pop operations produce the correct output + queue.push(row1); + queue.push(row2); - for (int i=0; i