static void checkmergertrie2(Mergertrierep *trierep, Mergertrienode *node, Mergertrienode *father, Bitsequence *leafused, unsigned int *numberofbitsset) { Mergertrienode *current, *previous; if (MTRIE_ISLEAF(node)) { GtUword start = node->suffixinfo.startpos; #ifndef NDEBUG if (ISIBITSET(leafused,start)) { fprintf(stderr,"leaf "GT_WU" already found\n",start); exit(GT_EXIT_PROGRAMMING_ERROR); } #endif SETIBIT(leafused,start); (*numberofbitsset)++; } else { gt_assert(node->depth == 0 || node->firstchild->rightsibling != NULL); if (father != NULL) { gt_assert(!MTRIE_ISLEAF(father)); #ifndef NDEBUG if (father->depth >= node->depth) { fprintf(stderr,"father.depth = "GT_WU" >= "GT_WU" = node.depth\n", father->depth, node->depth); exit(GT_EXIT_PROGRAMMING_ERROR); } #endif } previous = NULL; for (current = node->firstchild; current != NULL; current = current->rightsibling) { #ifndef NDEBUG if (previous != NULL) { if (mtrie_comparecharacters( getfirstedgechar(trierep,previous,node->depth), previous->suffixinfo.idx, getfirstedgechar(trierep,current,node->depth), current->suffixinfo.idx) >= 0) { fprintf(stderr,"nodes not correctly ordered\n"); exit(GT_EXIT_PROGRAMMING_ERROR); } } #endif checkmergertrie2(trierep,current,node,leafused,numberofbitsset); previous = current; } } }
static void storematch(void *info,const GtMatch *match) { Storematchinfo *storematch = (Storematchinfo *) info; unsigned long seqnum; if (match->dbabsolute) { seqnum = getencseqfrompos2seqnum(storematch->encseq,match->dbstartpos); } else { seqnum = match->dbseqnum; } if (!ISIBITSET(storematch->hasmatch,seqnum)) { SETIBIT(storematch->hasmatch,seqnum); } }
static int gt_tyr_occratio_arguments_check(int rest_argc, void *tool_arguments, GtError *err) { Tyr_occratio_options *arguments = tool_arguments; bool haserr = false; Optionargmodedesc outputmodedesctable[] = { {"unique","number of unique mers",TYROCC_OUTPUTUNIQUE}, {"nonunique","number of nonunique mers (single count)", TYROCC_OUTPUTNONUNIQUE}, {"nonuniquemulti","number of nonunique mers (multi count)", TYROCC_OUTPUTNONUNIQUEMULTI}, {"relative","fraction of unique/non-unique mers relative to all mers", TYROCC_OUTPUTRELATIVE}, {"total","number of all mers",TYROCC_OUTPUTTOTAL} }; if (rest_argc != 0) { gt_error_set(err,"superfluous arguments"); return -1; } if (gt_option_is_set(arguments->refoptionmersizes)) { unsigned long *mersizes = NULL; unsigned long idx, numofmersizes = gt_str_array_size(arguments->mersizesstrings); if (numofmersizes == 0) { gt_error_set(err,"missing argument to option -mersizes:"); haserr = true; } else { mersizes = gt_malloc(sizeof(*mersizes) * numofmersizes); for (idx=0; idx<numofmersizes; idx++) { long readnum; if (sscanf(gt_str_array_get(arguments->mersizesstrings,idx), "%ld",&readnum) != 1 || readnum <= 0) { gt_error_set(err,"invalid argument \"%s\" of option -mersizes: " "must be a positive integer", gt_str_array_get(arguments->mersizesstrings,idx)); haserr = true; break; } mersizes[idx] = (unsigned long) readnum; if (idx > 0 && mersizes[idx-1] >= mersizes[idx]) { gt_error_set(err,"invalid argumnt %s to option -mersizes: " "positive numbers must be strictly increasing", gt_str_array_get(arguments->mersizesstrings,idx)); haserr = true; break; } } } if (!haserr) { gt_assert(mersizes != NULL); arguments->minmersize = mersizes[0]; arguments->maxmersize = mersizes[numofmersizes-1]; INITBITTAB(arguments->outputvector,arguments->maxmersize+1); for (idx=0; idx<numofmersizes; idx++) { SETIBIT(arguments->outputvector,mersizes[idx]); } } gt_free(mersizes); } else { if (arguments->minmersize == 0) { gt_error_set(err,"if option -mersizes is not used, then option " "-minmersize is mandatory"); haserr = true; } if (!haserr) { if (arguments->maxmersize == 0) { gt_error_set(err,"if option -mersizes is not used, then option " "-maxmersize is mandatory"); haserr = true; } } if (!haserr) { if (arguments->minmersize > arguments->maxmersize) { gt_error_set(err,"minimum mer size must not be larger than " "maximum mer size"); haserr = true; } } if (!haserr) { if (arguments->minmersize+arguments->stepmersize > arguments->maxmersize) { gt_error_set(err,"minimum mer size + step value must be smaller or " "equal to maximum mersize"); haserr = true; } } if (!haserr) { unsigned long outputval; INITBITTAB(arguments->outputvector,arguments->maxmersize+1); for (outputval = arguments->minmersize; outputval <= arguments->maxmersize; outputval += arguments->stepmersize) { SETIBIT(arguments->outputvector,outputval); } } } if (!haserr) { unsigned long idx; for (idx=0; idx<gt_str_array_size(arguments->outputspec); idx++) { if (optionargaddbitmask(outputmodedesctable, sizeof (outputmodedesctable)/ sizeof (outputmodedesctable[0]), &arguments->outputmode, "-output", gt_str_array_get(arguments->outputspec,idx), err) != 0) { haserr = true; break; } } } if (!haserr) { if ((arguments->outputmode & TYROCC_OUTPUTRELATIVE) && !(arguments->outputmode & (TYROCC_OUTPUTUNIQUE | TYROCC_OUTPUTNONUNIQUE | TYROCC_OUTPUTNONUNIQUEMULTI))) { gt_error_set(err,"argument relative to option -output requires that one " "of the arguments unique, nonunique, or nonuniquemulti " "is used"); haserr = true; } } return haserr ? - 1: 0; }