quick indentation fixes to FPGA code
This commit is contained in:
parent
5d198d3400
commit
31ab0824b1
|
|
@ -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<Haplotype> haplotypes, final List<GATKSAMRecord> 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<GATKSAMRecord> batchedReads = new Vector<GATKSAMRecord>(reads.size());
|
||||
final BatchPairHMM batchPairHMM = (pairHMM.get() instanceof BatchPairHMM) ? (BatchPairHMM)pairHMM.get() : null;
|
||||
final Vector<GATKSAMRecord> batchedReads = new Vector<GATKSAMRecord>(reads.size());
|
||||
final int numHaplotypes = haplotypes.size();
|
||||
final Map<Haplotype, Allele> 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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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<Haplotype> haplotypes;
|
||||
public byte[] readBases;
|
||||
public byte[] readQuals;
|
||||
public byte[] insertionGOP;
|
||||
public byte[] deletionGOP;
|
||||
public byte[] overallGCP;
|
||||
public List<Haplotype> haplotypes;
|
||||
};
|
||||
|
||||
private static class ResultQueue {
|
||||
private int offset;
|
||||
private List<double[]> batchResults;
|
||||
|
||||
public ResultQueue() {
|
||||
batchResults = new LinkedList<double[]>();
|
||||
offset = 0;
|
||||
}
|
||||
private int offset;
|
||||
private List<double[]> 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<double[]>();
|
||||
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<Haplotype> haplotypes,
|
||||
final byte[] readBases,
|
||||
final byte[] readQuals,
|
||||
final byte[] insertionGOP,
|
||||
final byte[] deletionGOP,
|
||||
final byte[] overallGCP) {
|
||||
public void batchAdd(final List<Haplotype> 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) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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<Haplotype> haplotypes,
|
||||
final byte[] readBases,
|
||||
final byte[] readQuals,
|
||||
final byte[] insertionGOP,
|
||||
final byte[] deletionGOP,
|
||||
final byte[] overallGCP);
|
||||
public void batchAdd(final List<Haplotype> haplotypes,
|
||||
final byte[] readBases,
|
||||
final byte[] readQuals,
|
||||
final byte[] insertionGOP,
|
||||
final byte[] deletionGOP,
|
||||
final byte[] overallGCP);
|
||||
|
||||
public double[] batchGetResult();
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue