GtUword gt_bwtrangesplitallwithoutspecial(Mbtab *mbtab, GtUword *rangeOccs, const FMindex *fmindex, GtUword lbound, GtUword ubound) { const BWTSeq *bwtseq = (const BWTSeq *) fmindex; AlphabetRangeSize idx, rangesize = MRAEncGetRangeSize(EISGetAlphabet(bwtseq->seqIdx),0); gt_assert(sizeof (AlphabetRangeSize) <= sizeof (GtUword)); BWTSeqPosPairRangeOcc(bwtseq, 0, lbound, ubound,rangeOccs); for (idx = 0; idx < rangesize; idx++) { if (rangeOccs[idx] < rangeOccs[rangesize+idx]) { mbtab[idx].lowerbound = bwtseq->count[idx] + rangeOccs[idx]; mbtab[idx].upperbound = bwtseq->count[idx] + rangeOccs[rangesize+idx]; } else { mbtab[idx].lowerbound = mbtab[idx].upperbound = 0; } } return (GtUword) rangesize; }
GtUword gt_pck_get_nonspecial_count(const FMindex *index) { const BWTSeq *bwtseq = (const BWTSeq *) index; return BWTSeqAggTransformedCount(bwtseq, MRAEncGetRangeSize(BWTSeqGetAlphabet(bwtseq), 0)); }
GtUword gt_pck_special_occ_in_nonspecial_intervals(const FMindex *index) { const BWTSeq *bwtseq = (const BWTSeq *) index; GtUword count = 0, *rangeOccs, first_special_row; unsigned short idx, rangesize; rangesize = (unsigned short) MRAEncGetRangeSize(BWTSeqGetAlphabet(bwtseq), 1); rangeOccs = gt_calloc(rangesize, sizeof (GtUword)); first_special_row = gt_pck_get_nonspecial_count(index); BWTSeqRangeOcc(bwtseq, 1, first_special_row, rangeOccs); for (idx = 0; idx < rangesize; idx++) count += rangeOccs[idx]; gt_free(rangeOccs); return count; }
GtUword gt_bwtrangesplitallwithspecial(Mbtab *mbtab, GtUword *rangeOccs, const FMindex *voidBwtSeq, GtUword lbound, GtUword ubound) { GtUword char_idx, range_idx, rangebase; const BWTSeq *bwtseq = (const BWTSeq *) voidBwtSeq; const MRAEnc *alphabet = BWTSeqGetAlphabet(bwtseq); AlphabetRangeID numofranges = MRAEncGetNumRanges(alphabet); AlphabetRangeSize rangesize = 0, totalrange = 0; for (range_idx = 0; range_idx < (GtUword) numofranges; range_idx++) { GtUword rangeOcc_idx = 0; rangesize = MRAEncGetRangeSize(alphabet, range_idx); totalrange += rangesize; BWTSeqPosPairRangeOcc(bwtseq, range_idx, lbound, ubound,rangeOccs); rangebase = (GtUword) MRAEncGetRangeBase(alphabet, range_idx); for (char_idx = rangebase; char_idx < rangebase + rangesize; char_idx++) { if (rangeOccs[rangeOcc_idx] < rangeOccs[rangesize+rangeOcc_idx]) { mbtab[char_idx].lowerbound = bwtseq->count[char_idx] + rangeOccs[rangeOcc_idx]; mbtab[char_idx].upperbound = bwtseq->count[char_idx] + rangeOccs[rangesize+rangeOcc_idx]; } else { mbtab[char_idx].lowerbound = mbtab[char_idx].upperbound = 0; } rangeOcc_idx++; } } return totalrange; }
extern Seqpos BWTSeqGetRankSort(const BWTSeq *bwtSeq, Seqpos pos, AlphabetRangeID range, struct extBitsRetrieval *extBits) { BitOffset locVarBits; AlphabetRangeSize rSize; gt_assert(bwtSeq->rangeSort[range] == SORTMODE_RANK); EISRetrieveExtraBits(bwtSeq->seqIdx, pos, EBRF_RETRIEVE_CWBITS | EBRF_RETRIEVE_VARBITS, extBits, bwtSeq->hint); locVarBits = locateVarBits(bwtSeq, extBits); rSize = MRAEncGetRangeSize(EISGetAlphabet(bwtSeq->seqIdx), range); { Seqpos ranks[rSize * 2]; Seqpos BWTRankTotal = 0; AlphabetRangeSize i; EISPosPairRangeRank(bwtSeq->seqIdx, range, extBits->start, pos, ranks, bwtSeq->hint); for (i = 0; i < rSize; ++i) BWTRankTotal += ranks[i + rSize] - ranks[i]; return gt_bsGetSeqpos(extBits->varPart, extBits->varOffset + locVarBits + bwtSeq->bitsPerOrigRank * BWTRankTotal, bwtSeq->bitsPerOrigRank); } }
void gt_bwtrangesplitwithoutspecial(GtArrayBoundswithchar *bwci, GtUword *rangeOccs, const FMindex *fmindex, GtUword lbound, GtUword ubound) { const BWTSeq *bwtseq = (const BWTSeq *) fmindex; AlphabetRangeSize idx, rangesize; rangesize = MRAEncGetRangeSize(EISGetAlphabet(bwtseq->seqIdx),0); bwci->nextfreeBoundswithchar = 0; BWTSeqPosPairRangeOcc(bwtseq, 0, lbound, ubound,rangeOccs); for (idx = 0; idx < rangesize; idx++) { if (rangeOccs[idx] < rangeOccs[rangesize+idx]) { bwci->spaceBoundswithchar[bwci->nextfreeBoundswithchar].inchar = idx; bwci->spaceBoundswithchar[bwci->nextfreeBoundswithchar].lbound = bwtseq->count[idx] + rangeOccs[idx]; bwci->spaceBoundswithchar[bwci->nextfreeBoundswithchar++].rbound = bwtseq->count[idx] + rangeOccs[rangesize+idx]; } } }