#include "headers.h" #include "jni_common.h" #include "org_broadinstitute_sting_utils_pairhmm_DebugJNILoglessPairHMM.h" #include "template.h" #include "utils.h" #include "LoadTimeInitializer.h" #include "jnidebug.h" DataHolder g_double_dataholder; using namespace std; JNIEXPORT void JNICALL Java_org_broadinstitute_sting_utils_pairhmm_DebugJNILoglessPairHMM_jniInitialize (JNIEnv* env, jobject thisObject, jint readMaxLength, jint haplotypeMaxLength) { static int g_num_init_calls = 0; #ifdef DEBUG3 cout << "Entered alloc initialized .. readMaxLength "<GetArrayLength(insertionGOP); #ifdef DEBUG3 cout << "Entered initializeProbabilities .. length "<GetByteArrayElements(insertionGOP, &is_copy); jbyte* deletionGOPArray = (env)->GetByteArrayElements(deletionGOP, &is_copy); jbyte* overallGCPArray = (env)->GetByteArrayElements(overallGCP, &is_copy); #ifdef DEBUG if(insertionGOPArray == 0) cerr << "insertionGOP array not initialized in JNI\n"; ////assert(insertionGOPArray && "insertionGOP array not initialized in JNI"); if(deletionGOPArray == 0) cerr << "deletionGOP array not initialized in JNI\n"; ////assert(deletionGOPArray && "deletionGOP array not initialized in JNI"); assert(overallGCPArray && "OverallGCP array not initialized in JNI"); #endif g_double_dataholder.initializeProbabilities(length, insertionGOPArray, deletionGOPArray, overallGCPArray); env->ReleaseByteArrayElements(overallGCP, overallGCPArray, JNI_ABORT); env->ReleaseByteArrayElements(deletionGOP, deletionGOPArray, JNI_ABORT); env->ReleaseByteArrayElements(insertionGOP, insertionGOPArray, JNI_ABORT); } JNIEXPORT jdouble JNICALL Java_org_broadinstitute_sting_utils_pairhmm_DebugJNILoglessPairHMM_jniInitializePriorsAndUpdateCells( JNIEnv* env, jobject thisObject, jboolean doInitialization, jint paddedReadLength, jint paddedHaplotypeLength, jbyteArray readBases, jbyteArray haplotypeBases, jbyteArray readQuals, jint hapStartIndex ) { #ifdef DEBUG3 cout << "Entered mainCompute .. doInitialization "<<(doInitialization == JNI_TRUE)<<" hapStartIndex "<GetByteArrayElements(readBases, &is_copy); jbyte* haplotypeBasesArray = (env)->GetByteArrayElements(haplotypeBases, &is_copy); jbyte* readQualsArray = (env)->GetByteArrayElements(readQuals, &is_copy); #ifdef DEBUG assert(readBasesArray && "readBasesArray not initialized in JNI"); assert(haplotypeBasesArray && "haplotypeBasesArray not initialized in JNI"); assert(readQualsArray && "readQualsArray not initialized in JNI"); #endif testcase tc; tc.rslen = paddedReadLength-1; tc.haplen = paddedHaplotypeLength-1; tc.rs = (char*)readBasesArray; tc.hap = (char*)haplotypeBasesArray; tc.q = (char*)readQualsArray; //TOASK - q is now char* compute_full_prob(&tc, g_double_dataholder.m_matchMatrix, g_double_dataholder.m_insertionMatrix, g_double_dataholder.m_deletionMatrix, g_double_dataholder.m_transition, doInitialization == JNI_TRUE, hapStartIndex, NULL); env->ReleaseByteArrayElements(readBases, readBasesArray, JNI_ABORT); env->ReleaseByteArrayElements(haplotypeBases, haplotypeBasesArray, JNI_ABORT); env->ReleaseByteArrayElements(readQuals, readQualsArray, JNI_ABORT); return 0.0; } JNIEXPORT jdouble JNICALL Java_org_broadinstitute_sting_utils_pairhmm_DebugJNILoglessPairHMM_jniSubComputeReadLikelihoodGivenHaplotypeLog10( JNIEnv* env, jobject thisObject, jint readLength, jint haplotypeLength, jbyteArray readBases, jbyteArray haplotypeBases, jbyteArray readQuals, jbyteArray insertionGOP, jbyteArray deletionGOP, jbyteArray overallGCP, jint hapStartIndex ) { jboolean is_copy = JNI_FALSE; jbyte* readBasesArray = (jbyte*)GET_BYTE_ARRAY_ELEMENTS(readBases, &is_copy); jbyte* haplotypeBasesArray = (jbyte*)GET_BYTE_ARRAY_ELEMENTS(haplotypeBases, &is_copy); jbyte* readQualsArray = (jbyte*)GET_BYTE_ARRAY_ELEMENTS(readQuals, &is_copy); jbyte* insertionGOPArray = (jbyte*)GET_BYTE_ARRAY_ELEMENTS(insertionGOP, &is_copy); jbyte* deletionGOPArray = (jbyte*)GET_BYTE_ARRAY_ELEMENTS(deletionGOP, &is_copy); jbyte* overallGCPArray = (jbyte*)GET_BYTE_ARRAY_ELEMENTS(overallGCP, &is_copy); #ifdef DEBUG assert(readBasesArray && "readBasesArray not initialized in JNI"); assert(haplotypeBasesArray && "haplotypeBasesArray not initialized in JNI"); assert(readQualsArray && "readQualsArray not initialized in JNI"); assert(insertionGOPArray && "insertionGOP array not initialized in JNI"); assert(deletionGOPArray && "deletionGOP array not initialized in JNI"); assert(overallGCPArray && "OverallGCP array not initialized in JNI"); assert(readLength < MROWS); #endif testcase tc; tc.rslen = readLength; tc.haplen = haplotypeLength; tc.rs = (char*)readBasesArray; tc.hap = (char*)haplotypeBasesArray; for(unsigned i=0;i