static void chopKmer4read ( int t, int threadID ) { char * src_seq = seqBuffer[t]; char * bal_seq = rcSeq[threadID]; int len_seq = lenBuffer[t]; int j, bal_j; ubyte8 hash_ban, bal_hash_ban; Kmer word, bal_word; int index; char InvalidCh = 4; #ifdef MER127 word.high1 = word.low1 = word.high2 = word.low2 = 0; for ( index = 0; index < overlaplen; index++ ) { word = KmerLeftBitMoveBy2 ( word ); word.low2 |= src_seq[index]; } #else word.high = word.low = 0; for ( index = 0; index < overlaplen; index++ ) { word = KmerLeftBitMoveBy2 ( word ); word.low |= src_seq[index]; } #endif reverseComplementSeq ( src_seq, len_seq, bal_seq ); // complementary node bal_word = reverseComplement ( word, overlaplen ); bal_j = len_seq - overlaplen; index = indexArray[t]; if ( KmerSmaller ( word, bal_word ) ) { hash_ban = hash_kmer ( word ); hashBanBuffer[index] = hash_ban; kmerBuffer[index] = word; prevcBuffer[index] = InvalidCh; nextcBuffer[index++] = src_seq[0 + overlaplen]; } else { bal_hash_ban = hash_kmer ( bal_word ); hashBanBuffer[index] = bal_hash_ban; kmerBuffer[index] = bal_word; prevcBuffer[index] = bal_seq[bal_j - 1]; nextcBuffer[index++] = InvalidCh; } for ( j = 1; j <= len_seq - overlaplen; j++ ) { word = nextKmer ( word, src_seq[j - 1 + overlaplen] ); bal_j = len_seq - j - overlaplen; bal_word = prevKmer ( bal_word, bal_seq[bal_j] ); if ( KmerSmaller ( word, bal_word ) ) { hash_ban = hash_kmer ( word ); hashBanBuffer[index] = hash_ban; kmerBuffer[index] = word; prevcBuffer[index] = src_seq[j - 1]; if ( j < len_seq - overlaplen ) { nextcBuffer[index++] = src_seq[j + overlaplen]; } else { nextcBuffer[index++] = InvalidCh; } //printf("%dth: %p with %p\n",kmer_c-1,word,hashBanBuffer[kmer_c-1]); } else { // complementary node bal_hash_ban = hash_kmer ( bal_word ); hashBanBuffer[index] = bal_hash_ban; kmerBuffer[index] = bal_word; if ( bal_j > 0 ) { prevcBuffer[index] = bal_seq[bal_j - 1]; } else { prevcBuffer[index] = InvalidCh; } nextcBuffer[index++] = bal_seq[bal_j + overlaplen]; //printf("%dth: %p with %p\n",kmer_c-1,bal_word,hashBanBuffer[kmer_c-1]); } } }
static void chopKmer4read (int t, int threadID) { char *src_seq = seqBuffer[t]; char *bal_seq = rcSeq[threadID]; int len_seq = lenBuffer[t]; int j, bal_j; ubyte8 hash_ban, bal_hash_ban; Kmer word, bal_word; int index; //mao 2011 10 8 Kmer InvalidKmer ; InvalidKmer=kmerZero; int n_num; word = kmerZero; for (index = 0; index < overlaplen; index++) { #ifdef MER127 word = KmerLeftBitMoveBy2(word); word.low2 |= src_seq[index]; #endif #ifdef MER63 word = KmerLeftBitMoveBy2(word); word.low |= src_seq[index]; #endif #ifdef MER31 word = KmerLeftBitMoveBy2(word); word += src_seq[index]; #endif //mao 2011 10 8 if(src_seq[index] == 4) n_num = overlaplen; else if(n_num >0) n_num--; } reverseComplementSeq (src_seq, len_seq, bal_seq); // complementary node bal_word = reverseComplement (word, overlaplen); bal_j = len_seq - 0 - overlaplen; // 0; index = indexArray[t]; //mao 2011 10 8 if(n_num > 0 && N_kmer) { hash_ban = hash_kmer (InvalidKmer); hashBanBuffer[index] = hash_ban; kmerBuffer[index] = InvalidKmer; smallerBuffer[index] = 1; } else if (KmerSmaller (word, bal_word)) { hash_ban = hash_kmer (word); kmerBuffer[index] = word; smallerBuffer[index] = 1; hashBanBuffer[index++] = hash_ban; } else { bal_hash_ban = hash_kmer (bal_word); kmerBuffer[index] = bal_word; smallerBuffer[index] = 0; hashBanBuffer[index++] = bal_hash_ban; } //printf("%dth: %p with %p\n",kmer_c-1,bal_word,bal_hash_ban); for (j = 1; j <= len_seq - overlaplen; j++) { word = nextKmer (word, src_seq[j - 1 + overlaplen]); bal_j = len_seq - j - overlaplen; // j; bal_word = reverseComplement (word, overlaplen); //mao 2011 10 8 if(src_seq[j - 1 + overlaplen] == 4) n_num = overlaplen; else if(n_num >0) n_num--; //mao 2011 10 8 if(n_num > 0 && N_kmer) { hash_ban = hash_kmer (InvalidKmer); hashBanBuffer[index] = hash_ban; kmerBuffer[index] = InvalidKmer; smallerBuffer[index] = 1; } else if (KmerSmaller (word, bal_word)) { hash_ban = hash_kmer (word); kmerBuffer[index] = word; smallerBuffer[index] = 1; hashBanBuffer[index++] = hash_ban; //printf("%dth: %p with %p\n",kmer_c-1,word,hashBanBuffer[kmer_c-1]); } else { // complementary node bal_hash_ban = hash_kmer (bal_word); kmerBuffer[index] = bal_word; smallerBuffer[index] = 0; hashBanBuffer[index++] = bal_hash_ban; //printf("%dth: %p with %p\n",kmer_c-1,bal_word,hashBanBuffer[kmer_c-1]); } } }
static void chopKmer4read (int t, int threadID) { char *src_seq = seqBuffer + seqBreakers[t]; char *bal_seq = rcSeq[threadID]; int len_seq = lenBuffer[t]; int j, bal_j; ubyte8 hash_ban, bal_hash_ban; Kmer word, bal_word; int index; word=kmerZero; for (index = 0; index < overlaplen; index++) { word = KmerLeftBitMoveBy2 (word); #ifdef MER127 word.low2 |= src_seq[index]; #endif #ifdef MER63 word.low|= src_seq[index]; #endif #ifdef MER31 word |= src_seq[index]; #endif } reverseComplementSeq (src_seq, len_seq, bal_seq); // complementary node bal_word = reverseComplement (word, overlaplen); bal_j = len_seq - 0 - overlaplen; // 0; index = indexArray[t]; if (KmerSmaller (word, bal_word)) { hash_ban = hash_kmer (word); kmerBuffer[index] = word; hashBanBuffer[index] = hash_ban; smallerBuffer[index++] = 1; } else { bal_hash_ban = hash_kmer (bal_word); kmerBuffer[index] = bal_word; hashBanBuffer[index] = bal_hash_ban; smallerBuffer[index++] = 0; } //printf("%dth: %p with %p\n",kmer_c-1,bal_word,bal_hash_ban); for (j = 1; j <= len_seq - overlaplen; j++) { word = nextKmer (word, src_seq[j - 1 + overlaplen]); bal_j = len_seq - j - overlaplen; // j; bal_word = prevKmer (bal_word, bal_seq[bal_j]); if (KmerSmaller (word, bal_word)) { hash_ban = hash_kmer (word); kmerBuffer[index] = word; hashBanBuffer[index] = hash_ban; smallerBuffer[index++] = 1; //printf("%dth: %p with %p\n",kmer_c-1,word,hashBanBuffer[kmer_c-1]); } else { // complementary node bal_hash_ban = hash_kmer (bal_word); kmerBuffer[index] = bal_word; hashBanBuffer[index] = bal_hash_ban; smallerBuffer[index++] = 0; //printf("%dth: %p with %p\n",kmer_c-1,bal_word,hashBanBuffer[kmer_c-1]); } } }
static void stringBeads ( KMER_PT * firstBead, char nextch, int * node_c ) { boolean smaller, found; Kmer tempKmer, bal_word; Kmer word = firstBead->kmer; ubyte8 hash_ban; kmer_t * outgoing_node; int nodeCounter = 1, setPicker; char ch; unsigned char flag; KMER_PT * temp_pt, *prev_pt = firstBead; word = prev_pt->kmer; nodeCounter = 1; word = nextKmer ( word, nextch ); bal_word = reverseComplement ( word, overlaplen ); if ( KmerLarger ( word, bal_word ) ) { tempKmer = bal_word; bal_word = word; word = tempKmer; smaller = 0; } else { smaller = 1; } hash_ban = hash_kmer ( word ); setPicker = hash_ban % thrd_num; found = search_kmerset ( KmerSets[setPicker], word, &outgoing_node ); while ( found && ( outgoing_node->linear ) ) // for every node in this line { nodeCounter++; temp_pt = ( KMER_PT * ) stackPush ( nodeStack ); temp_pt->node = outgoing_node; temp_pt->isSmaller = smaller; if ( smaller ) { temp_pt->kmer = word; } else { temp_pt->kmer = bal_word; } prev_pt = temp_pt; if ( smaller ) { for ( ch = 0; ch < 4; ch++ ) { flag = get_kmer_right_cov ( *outgoing_node, ch ); if ( flag ) { break; } } word = nextKmer ( prev_pt->kmer, ch ); bal_word = reverseComplement ( word, overlaplen ); if ( KmerLarger ( word, bal_word ) ) { tempKmer = bal_word; bal_word = word; word = tempKmer; smaller = 0; } else { smaller = 1; } hash_ban = hash_kmer ( word ); setPicker = hash_ban % thrd_num; found = search_kmerset ( KmerSets[setPicker], word, &outgoing_node ); } else { for ( ch = 0; ch < 4; ch++ ) { flag = get_kmer_left_cov ( *outgoing_node, ch ); if ( flag ) { break; } } word = nextKmer ( prev_pt->kmer, int_comp ( ch ) ); bal_word = reverseComplement ( word, overlaplen ); if ( KmerLarger ( word, bal_word ) ) { tempKmer = bal_word; bal_word = word; word = tempKmer; smaller = 0; } else { smaller = 1; } hash_ban = hash_kmer ( word ); setPicker = hash_ban % thrd_num; found = search_kmerset ( KmerSets[setPicker], word, &outgoing_node ); } } if ( outgoing_node ) //this is always true { nodeCounter++; temp_pt = ( KMER_PT * ) stackPush ( nodeStack ); temp_pt->node = outgoing_node; temp_pt->isSmaller = smaller; if ( smaller ) { temp_pt->kmer = word; } else { temp_pt->kmer = bal_word; } } *node_c = nodeCounter; }
static void chopKmer4read(int t, int threadID) { char *src_seq = seqBuffer + seqBreakers[t]; char *bal_seq = rcSeq[threadID]; int len_seq = lenBuffer[t]; int j, bal_j; Kmer hash_ban, bal_hash_ban; Kmer word, bal_word; int index; word = 0; for (index = 0; index < overlaplen; index++) { word <<= 2; word += src_seq[index]; } reverseComplementSeq(src_seq, len_seq, bal_seq); // complementary node bal_word = reverseComplement(word, overlaplen); bal_j = len_seq - 0 - overlaplen; // 0; index = indexArray[t]; if(word < bal_word) { hash_ban = hash_kmer(word); kmerBuffer[index] = word; hashBanBuffer[index] = hash_ban; smallerBuffer[index++] = 1; } else { bal_hash_ban = hash_kmer(bal_word); kmerBuffer[index] = bal_word; hashBanBuffer[index] = bal_hash_ban; smallerBuffer[index++] = 0; } //printf("%dth: %p with %p\n",kmer_c-1,bal_word,bal_hash_ban); for(j = 1; j <= len_seq - overlaplen; j ++) { word = nextKmer(word, src_seq[j - 1 + overlaplen]); bal_j = len_seq - j - overlaplen; // j; bal_word = prevKmer(bal_word, bal_seq[bal_j]); if(word < bal_word) { hash_ban = hash_kmer(word); kmerBuffer[index] = word; hashBanBuffer[index] = hash_ban; smallerBuffer[index++] = 1; //printf("%dth: %p with %p\n",kmer_c-1,word,hashBanBuffer[kmer_c-1]); } else { // complementary node bal_hash_ban = hash_kmer(bal_word); kmerBuffer[index] = bal_word; hashBanBuffer[index] = bal_hash_ban; smallerBuffer[index++] = 0; //printf("%dth: %p with %p\n",kmer_c-1,bal_word,hashBanBuffer[kmer_c-1]); } } }