int gt_nextSequentiallcpvalue(GtUword *currentlcp, Sequentialsuffixarrayreader *ssar, GtError *err) { GtUchar tmpsmalllcpvalue; int retval; gt_assert(ssar != NULL); if (ssar->scanfile) { retval = gt_readnextfromstream_GtUchar(&tmpsmalllcpvalue, &ssar->suffixarray->lcptabstream); if (retval > 0) { if (tmpsmalllcpvalue < (GtUchar) LCPOVERFLOW) { *currentlcp = (GtUword) tmpsmalllcpvalue; } else { Largelcpvalue tmpexception; retval = gt_readnextfromstream_Largelcpvalue(&tmpexception, &ssar->suffixarray->llvtabstream); if (retval == 0) { gt_error_set(err,"file %s: line %d: unexpected end of file when " "reading llvtab",__FILE__,__LINE__); return -1; } *currentlcp = tmpexception.value; } } else { return 0; } } else { if (ssar->nextlcptabindex < ssar->numberofsuffixes) { tmpsmalllcpvalue = ssar->suffixarray->lcptab[ssar->nextlcptabindex++]; if (tmpsmalllcpvalue < (GtUchar) LCPOVERFLOW) { *currentlcp = (GtUword) tmpsmalllcpvalue; } else { gt_assert(ssar->suffixarray->llvtab[ssar->largelcpindex].position == ssar->nextlcptabindex-1); *currentlcp = ssar->suffixarray->llvtab[ssar->largelcpindex++].value; } } else { return 0; } } return 1; }
int gt_emissionmergedesa_stepdeleteandinsertothersuffixes( Emissionmergedesa *emmesa, GtError *err) { Mergertrienode *tmpsmallestleaf, *tmplcpnode; Largelcpvalue tmpexception; GtUchar tmpsmalllcpvalue; int retval; unsigned long tmpsuftabvalue, tmplcpvalue, tmplastbranchdepth; unsigned int tmpidx; gt_error_check(err); for (emmesa->buf.nextstoreidx = 0; emmesa->numofentries > 0 && emmesa->buf.nextstoreidx < (unsigned int) SIZEOFMERGERESULTBUFFER; emmesa->buf.nextstoreidx++) { tmpsmallestleaf = gt_mergertrie_findsmallestnode(&emmesa->trierep); tmplastbranchdepth = tmpsmallestleaf->parent->depth; tmpidx = tmpsmallestleaf->suffixinfo.idx; emmesa->buf.suftabstore[emmesa->buf.nextstoreidx].idx = tmpidx; emmesa->buf.suftabstore[emmesa->buf.nextstoreidx].startpos = tmpsmallestleaf->suffixinfo.startpos; if (emmesa->nextpostable[tmpidx] > gt_encseq_total_length(emmesa->suffixarraytable[tmpidx].encseq)) { gt_mergertrie_deletesmallestpath(tmpsmallestleaf,&emmesa->trierep); emmesa->numofentries--; } else { retval = gt_readnextfromstream_GtUchar(&tmpsmalllcpvalue, &emmesa->suffixarraytable[tmpidx]. lcptabstream); if (retval < 0) { return -1; } if (retval == 0) { gt_error_set(err,"file %s: line %d: unexpected end of file when " "reading lcptab",__FILE__,__LINE__); return -2; } if (tmpsmalllcpvalue == LCPOVERFLOW) { retval = gt_readnextfromstream_Largelcpvalue( &tmpexception, &emmesa->suffixarraytable[tmpidx].llvtabstream); if (retval < 0) { return -3; } if (retval == 0) { gt_error_set(err,"file %s: line %d: unexpected end of file when " "reading llvtab",__FILE__,__LINE__); return -4; } tmplcpvalue = tmpexception.value; } else { tmplcpvalue = (unsigned long) tmpsmalllcpvalue; } if (tmplcpvalue > tmplastbranchdepth) { tmplastbranchdepth = tmplcpvalue; } tmplcpnode = findlargestnodeleqlcpvalue(tmpsmallestleaf,tmplcpvalue,err); retval = gt_readnextfromstream_GtUlong(&tmpsuftabvalue, &emmesa->suffixarraytable[tmpidx]. suftabstream_GtUlong); if (retval == 0) { gt_error_set(err,"file %s: line %d: unexpected end of file when " "reading suftab",__FILE__,__LINE__); return -6; } emmesa->nextpostable[tmpidx]++; fillandinsert(&emmesa->trierep, tmpidx, tmpsuftabvalue, tmplcpnode, emmesa->ident++); tmpsmallestleaf = gt_mergertrie_findsmallestnode(&emmesa->trierep); gt_mergertrie_deletesmallestpath(tmpsmallestleaf,&emmesa->trierep); } if (emmesa->numofentries > 0) { emmesa->buf.lcptabstore[emmesa->buf.nextstoreidx] = tmplastbranchdepth; emmesa->buf.lastpage = false; } else { emmesa->buf.lastpage = true; } } return 0; }