static int gt_cntlist_parse_ascii(FILE *infp, bool alloc_cntlist, GtBitsequence **cntlist, GtUword *nofreads, GtError *err) { int n; GtUword seqnum; gt_assert(infp != NULL && nofreads != NULL && cntlist != NULL); /*@i1@*/ gt_error_check(err); n = fscanf(infp, "[n: "GT_WU"]\n", nofreads); if (n!=1 || *nofreads == 0) { gt_error_set(err, "contained reads file: unrecognized format"); return -1; } if (alloc_cntlist) GT_INITBITTAB(*cntlist, *nofreads); while (true) { n = fscanf(infp, ""GT_WU"\n", &seqnum); if (n == EOF) break; else if (n != 1) { gt_error_set(err, "contained reads file: unrecognized format"); return -1; } GT_SETIBIT(*cntlist, seqnum); } return 0; }
static int gt_cntlist_parse_bin(FILE *infp, bool alloc_cntlist, GtBitsequence **cntlist, GtUword *nofreads, GtError *err) { int had_err = gt_cntlist_parse_bin_or_bit_header(infp, nofreads, err); if (had_err == 0) { size_t n; GtUword seqnum; gt_assert(cntlist != NULL); if (alloc_cntlist) GT_INITBITTAB(*cntlist, *nofreads); while (true) { n = fread(&seqnum, sizeof (GtUword), (size_t)1, infp); if (n != (size_t)1) { if (!feof(infp)) { gt_error_set(err, "contained reads file: unrecognized format"); had_err = -1; } break; } GT_SETIBIT(*cntlist, seqnum); } } return had_err; }
/* prepare sspbittab and determine length of shortest sequence */ static void prepare_sspbittab_and_shortest(unsigned long totallength, ContfindBUstate *state) { unsigned long length, lastseqstart, i, ssp; GT_INITBITTAB(state->sspbittab, totallength + 1); lastseqstart = 0; state->shortest = totallength; for (i = 1UL; i <= state->nofsequences - 1; i++) { ssp = gt_encseq_seqstartpos(state->encseq, i) - 1; GT_SETIBIT(state->sspbittab, ssp); length = ssp - lastseqstart; lastseqstart = ssp + 1; if (length < state->shortest) state->shortest = length; } GT_SETIBIT(state->sspbittab, totallength); length = totallength - lastseqstart; if (length < state->shortest) state->shortest = length; }
static inline void mark_contained(GtContfind c, GtUword u_seqnum, GtUword v_seqnum, GtBitsequence *cntreads) { gt_assert(cntreads != NULL); switch (c) { case GT_CONTFIND_U: GT_SETIBIT(cntreads, u_seqnum); break; case GT_CONTFIND_EQ: /* convention: skip one with higher seqnum (which is v) */ if (v_seqnum != u_seqnum) GT_SETIBIT(cntreads, v_seqnum); break; case GT_CONTFIND_V: GT_SETIBIT(cntreads, v_seqnum); break; default: /* nothing to do */ break; } }
static inline void processcontained(unsigned long seqnum, ContfindBUstate *state) { if (state->firstrevcompl > 0) seqnum = GT_READJOINER_READNUM(seqnum, state->firstrevcompl, state->nofsequences); if (!GT_ISIBITSET(state->contained, seqnum)) { GT_SETIBIT(state->contained, seqnum); state->counter++; } if (state->csize == 0 || seqnum < state->cmin) state->cmin = seqnum; state->csize++; }
static void storematch(void *info,const GtIdxMatch *match) { Storematchinfo *storematch = (Storematchinfo *) info; unsigned long seqnum; if (match->dbabsolute) { seqnum = gt_encseq_seqnum(storematch->encseq, match->dbstartpos); } else { seqnum = match->dbseqnum; } if (!GT_ISIBITSET(storematch->hasmatch,seqnum)) { GT_SETIBIT(storematch->hasmatch,seqnum); } }
static void gt_wtree_encseq_fill_bits(GtWtreeEncseq *we) { unsigned int level_idx; GtUword sym_idx; GtEncseqReader *er = gt_encseq_create_reader_with_readmode(we->encseq, GT_READMODE_FORWARD, 0); gt_assert(we != NULL); for (level_idx = 0; level_idx < we->levels; level_idx++) { for (sym_idx = 0; sym_idx < we->parent_instance.members->length; sym_idx++) { GtWtreeSymbol c_sym = gt_wtree_encseq_map(we, gt_encseq_reader_next_encoded_char(er)); if (gt_wtree_encseq_set_nodestart_and_current_fo(we, level_idx, c_sym)) { /*0*/ if (we->current_fo != NULL) { gt_assert(we->node_start + we->current_fo->offset < we->num_of_bits); we->current_fo->offset++; we->current_fo->left_size++; } } else { if (we->current_fo != NULL) { gt_assert(we->node_start + we->current_fo->offset < we->num_of_bits); GT_SETIBIT(we->bits, we->node_start + we->current_fo->offset); we->current_fo->offset++; } } } gt_encseq_reader_reinit_with_readmode(er, we->encseq, GT_READMODE_FORWARD, 0); } gt_encseq_reader_delete(er); gt_wtree_encseq_fill_offset_delete(we->root_fo); we->root_fo = we->current_fo = NULL; gt_encseq_delete(we->encseq); we->encseq = NULL; }
static unsigned int lcp_bucketends(Lcpsubtab *lcpsubtab, Suffixwithcode *previoussuffix, GT_UNUSED GtUword firstspecialsuffix, unsigned int minchanged, GtUword nonspecialsinbucket, GtUword specialsinbucket, GtCodetype code, const GtBcktab *bcktab) { GtUword lcpvalue; unsigned int maxprefixindex, minprefixindex; Suffixwithcode firstspecialsuffixwithcode; /* there is at least one element in the bucket. if there is more than one element in the bucket, then we insert them using the information from the bcktab */ if (specialsinbucket > 1UL) { if (lcpsubtab->lcp2file != NULL) { maxprefixindex = gt_bcktab_pfxidx2lcpvalues_uint8( &minprefixindex, lcpsubtab->lcp2file->smalllcpvalues, specialsinbucket, bcktab, code); if (lcpsubtab->lcp2file->maxbranchdepth < (GtUword) maxprefixindex) { lcpsubtab->lcp2file->maxbranchdepth = (GtUword) maxprefixindex; } } else { GtUword start = lcpsubtab->tableoflcpvalues.lcptaboffset + nonspecialsinbucket; maxprefixindex = gt_bcktab_pfxidx2lcpvalues_Lcpvaluetype( &minprefixindex, lcpsubtab->tableoflcpvalues.bucketoflcpvalues + start, specialsinbucket, bcktab, code); #ifndef NDEBUG { GtUword idx; for (idx=start; idx<start + specialsinbucket; idx++) { GT_SETIBIT(lcpsubtab->tableoflcpvalues.isset,idx); } } #endif } } else { minprefixindex = maxprefixindex = gt_bcktab_singletonmaxprefixindex(bcktab, code); } firstspecialsuffixwithcode.code = code; firstspecialsuffixwithcode.prefixindex = maxprefixindex; #ifdef SKDEBUG firstspecialsuffixwithcode.startpos = firstspecialsuffix; /* gt_bcktab_consistencyofsuffix(__LINE__, encseq,readmode,bcktab,numofchars, &firstspecialsuffixwithcode); */ #endif lcpvalue = computelocallcpvalue(previoussuffix, &firstspecialsuffixwithcode, minchanged); if (lcpsubtab->lcp2file != NULL) { if (lcpsubtab->lcp2file->maxbranchdepth < lcpvalue) { lcpsubtab->lcp2file->maxbranchdepth = lcpvalue; } lcpsubtab->lcp2file->smalllcpvalues[0] = (uint8_t) lcpvalue; } else { gt_assert(lcpvalue <= GT_LCPVALUE_MAX); lcpsubtab->tableoflcpvalues.bucketoflcpvalues [lcpsubtab->tableoflcpvalues.lcptaboffset + nonspecialsinbucket] = (GtLcpvaluetype) lcpvalue; #ifndef NDEBUG GT_SETIBIT(lcpsubtab->tableoflcpvalues.isset, lcpsubtab->tableoflcpvalues.lcptaboffset + nonspecialsinbucket); #endif } return minprefixindex; }