Midi2UdpThread::~Midi2UdpThread() { mutex.lock(); abort = true; mutex.unlock(); wait(); freeSeq(); }
int main(int argc, char **argv) { const char* s= "aacaaaccggguuuguu"; initSeq("../vienna/rna_turner2004.par",s); /* printf("%d -- /\n",ext_mismatch_energy(0, 9)); // dlr printf("%d -- /\n",termau_energy(0,9)); printf("%d -- %d\n",sr_energy(0,9), E_stack(0,9)); // stack printf("%d -- %d\n",sr_energy(1,8), E_stack(1,8)); // hairpin printf("%d -- %d\n",hl_energy(2,7), E_Hairpin(4,_bp(2,7),3,6,"CUCAGG",c_P)); */ /* int r = ext_mismatch_energy(0, 9) + termau_energy(0,9) + // dlr(0,9) sr_energy(0,9) + // stack(0,9) sr_energy(1,8) + hl_energy(2,7); // hairpin (1,8) printf("Result = %d (goal = -130)\n",r); */ printf("CPU Result = %d\n", ext_mismatch_energy(1,16) + termau_energy(1,16) ); printf("GPU Result = %d\n", ext_mismatch_energy(0,17) + termau_energy(0,17) + sr_energy(1,16) ); freeSeq(); return 0; }
void determineLineHighlighting(bstring a, bstring b, int ** maskPtrA, int ** maskPtrB) { seq alignA = initSeq(a->slen * 1.5); seq alignB = initSeq(b->slen * 1.5); seq seqA = stringToSeq(a); seq seqB = stringToSeq(b); determineAlignment(seqA, seqB, &compareChars, &alignA, &alignB); assert(alignA.alen == alignB.alen); int len = alignA.alen; // Both sequences should be the same length. We'll just get the length of // one, which should be the upper limit needed for the masks. // Allocate memory for two integer masks. int * maskA = malloc(len * sizeof(int)); if (maskA == NULL) { free(maskA); printf("Memory allocation error.\n"); exit(-1); } int * maskB = malloc(len * sizeof(int)); if (maskB == NULL) { free(maskB); printf("Memory allocation error.\n"); exit(-1); } int i; // Position along the aligned sequences. int firstValueInBlockA = -1; int firstPosInBlockA = -1; int lastComparisonA = MASK_SAME; // Positions in each mask. int posA = 0; int posB = 0; for (i = 0; i < len; i++) { int currentComparisonA = compareStringPositions(alignA, alignB, i); int currentComparisonB = compareStringPositions(alignB, alignA, i); // Look ahead and back a place in the strings to see if we have an // isolated matching character among differences. if (currentComparisonA == MASK_SAME && i > 0 && i < len - 1 && compareStringPositions(alignA, alignB, i - 1) != MASK_SAME && compareStringPositions(alignA, alignB, i + 1) != MASK_SAME) { if (firstPosInBlockA > 0 && firstValueInBlockA == seqA.val[posA]) { // Special case for when the char we are about to smooth is // actually at the beginning of the highlighted block. maskA[firstPosInBlockA] = MASK_SAME; currentComparisonA = MASK_DIFFERENT; //printf("%c|%c\n", seqA.val[posA-1], seqA.val[posA]); } else { // Pretend the matching characters are different to make the diff // look more readable. //printf("S"); if (currentComparisonA != MASK_GAP) currentComparisonA = MASK_DIFFERENT; if (currentComparisonB != MASK_GAP) currentComparisonB = MASK_DIFFERENT; } } else { //printf("-"); } // Entering region of difference. if (currentComparisonA != lastComparisonA && currentComparisonA == MASK_DIFFERENT) { // Record position and value. firstValueInBlockA = seqA.val[posA]; firstPosInBlockA = posA; } if (currentComparisonA != MASK_GAP) { maskA[posA] = currentComparisonA; posA++; } if (currentComparisonB != MASK_GAP) { maskB[posB] = currentComparisonB; posB++; } if (currentComparisonA != MASK_GAP) { lastComparisonA = currentComparisonA; } } //printf("\n"); *maskPtrA = maskA; *maskPtrB = maskB; freeSeq(&seqA); freeSeq(&seqB); freeSeq(&alignA); freeSeq(&alignB); }