void gt_condenseq_delete(GtCondenseq *condenseq) { if (condenseq != NULL) { GtUword i; for (i = 0; i < condenseq->ldb_nelems; i++) { gt_editscript_delete(condenseq->links[i].editscript); } for (i = 0; i < condenseq->udb_nelems; i++) { GT_FREEARRAY(&(condenseq->uniques[i].links), uint32_t); } gt_alphabet_delete(condenseq->alphabet); gt_encseq_delete(condenseq->unique_es); gt_free(condenseq->buffer); gt_free(condenseq->filename); gt_free(condenseq->links); gt_free(condenseq->orig_ids); gt_free(condenseq->ubuffer); gt_free(condenseq->uniques); gt_intset_delete(condenseq->sdstab); gt_intset_delete(condenseq->ssptab); gt_free(condenseq); } }
void gth_stat_show(GthStat *stat, bool show_full_stats, bool xmlout, GtFile *outfp) { char *timestring; gt_assert(stat); /* begin XML comment */ if (xmlout) gt_file_xprintf(outfp, "<!--\n"); /* output exon length distribution */ if (stat->exondistri) { gt_file_xprintf(outfp, "%c length distribution of all exons:\n", COMMENTCHAR); gt_disc_distri_show(stat->exondistribution, outfp); } /* output intron length distribution */ if (stat->introndistri) { if (stat->exondistri) gt_file_xprintf(outfp, "%c\n", COMMENTCHAR); gt_file_xprintf(outfp, "%c length distribution of all introns:\n", COMMENTCHAR); gt_disc_distri_show(stat->introndistribution, outfp); } /* output match number distribution */ if (stat->matchnumdistri) { if (stat->exondistri || stat->introndistri) gt_file_xprintf(outfp, "%c\n", COMMENTCHAR); gt_file_xprintf(outfp, "%c distribution of match numbers (per genomic " "file, per reference sequence:\n", COMMENTCHAR); gt_disc_distri_show(stat->matchnumdistribution, outfp); } /* output reference sequence coverage distribution */ if (stat->refseqcovdistri) { if (stat->exondistri || stat->introndistri || stat->matchnumdistri) gt_file_xprintf(outfp, "%c\n", COMMENTCHAR); gt_file_xprintf(outfp, "%c reference sequence coverage distribution (of " "global chains):\n", COMMENTCHAR); gt_disc_distri_show(stat->refseqcoveragedistribution, outfp); } /* output spliced alignment statistics */ if (stat->sa_stats) { if (stat->exondistri || stat->introndistri || stat->matchnumdistri || stat->refseqcovdistri) { gt_file_xprintf(outfp, "%c\n", COMMENTCHAR); } INFOCHAR; gt_file_xprintf(outfp, "spliced alignment alignment score distribution:\n"); gt_disc_distri_show(stat->sa_alignment_score_distribution, outfp); INFOCHAR; gt_file_xfputc('\n', outfp); INFOCHAR; gt_file_xprintf(outfp, "spliced alignment coverage distribution:\n"); gt_disc_distri_show(stat->sa_coverage_distribution, outfp); } /* output general statistics */ outputgeneralstatistics(stat, show_full_stats, outfp); INFOCHAR; gt_file_xfputc('\n', outfp); /* output the memory statistics */ outputmemorystatistics(stat, show_full_stats, outfp); /* output time */ INFOCHAR; gt_file_xfputc('\n', outfp); INFOCHAR; timestring = gth_get_time(); gt_file_xprintf(outfp, "date finished: %s\n", timestring); gt_free(timestring); /* output important messages */ if (stat->numofremovedzerobaseexons || stat->numofautointroncutoutcalls || stat->numofunsuccessfulintroncutoutDPs || stat->numoffailedDPparameterallocations || stat->numoffailedmatrixallocations || stat->numofundeterminedSAs || stat->numoffilteredpolyAtailmatches) { gt_file_xprintf(outfp, "%c\n", COMMENTCHAR); gt_file_xprintf(outfp, "%c important messages:\n", COMMENTCHAR); if (stat->numofremovedzerobaseexons > 0) { gt_file_xprintf(outfp, "%c %lu removed zero base exons\n", COMMENTCHAR, stat->numofremovedzerobaseexons); } if (stat->numofautointroncutoutcalls > 0) { gt_file_xprintf(outfp, "%c %lu times the intron cutout technique was " "used automatically\n", COMMENTCHAR, stat->numofautointroncutoutcalls); } if (stat->numofunsuccessfulintroncutoutDPs > 0) { gt_file_xprintf(outfp, "%c %lu unsuccessful DP calls using intron " "cutout technique\n", COMMENTCHAR, stat->numofunsuccessfulintroncutoutDPs); } if (stat->numoffailedDPparameterallocations > 0) { gt_file_xprintf(outfp, "%c %lu DP parameter allocations failed\n", COMMENTCHAR, stat->numoffailedDPparameterallocations); } if (stat->numoffailedmatrixallocations > 0) { gt_file_xprintf(outfp, "%c %lu matrix allocations failed\n", COMMENTCHAR, stat->numoffailedmatrixallocations); } if (stat->numofundeterminedSAs > 0) { gt_file_xprintf(outfp, "%c %lu undetermined spliced alignments\n", COMMENTCHAR, stat->numofundeterminedSAs); } if (stat->numoffilteredpolyAtailmatches > 0) { gt_file_xprintf(outfp, "%c %lu matches containing a poly(A) tail filtered\n", COMMENTCHAR, stat->numoffilteredpolyAtailmatches); } } /* end XML comment */ if (xmlout) gt_file_xprintf(outfp, "-->\n"); }
static void inter_feature_visitor_free(GtNodeVisitor *nv) { GtInterFeatureVisitor *aiv = gt_inter_feature_visitor_cast(nv); gt_free(aiv->inter_type); gt_free(aiv->outside_type); }
static void condenseq_process_descriptions(GtCondenseq *condenseq, const GtEncseq *orig_es, GtLogger *logger) { GtUword *dist; const char *desc; char *cur_id_startptr; GtUword desclen, dist_idx, distsize = (GtUword) 128, idlen, idx, maxendidx = 0, maxlen = 0, minlen = GT_UWORD_MAX, wastedmem = 0, sdssize, cur_total_id_len = 0; bool use_const_len; condenseq->ids_total_len = 0; dist = gt_calloc((size_t) distsize, sizeof (*dist)); for (idx = 0; idx < condenseq->orig_num_seq; ++idx) { desc = gt_encseq_description(orig_es, &desclen, idx); idlen = condenseq_idlen(desc, desclen); if (distsize <= idlen) { dist = gt_realloc(dist, (size_t) (idlen + 1) * sizeof (*dist)); for (dist_idx = distsize; dist_idx <= idlen; dist_idx++) dist[dist_idx] = 0; distsize = idlen + 1; } dist[idlen]++; if (idlen > maxlen) maxlen = idlen; if (idlen < minlen) minlen = idlen; maxendidx += idlen; } /* calculate memory we would waste if we assume equal length, and size if we store actual descriptions */ for (dist_idx = minlen; dist_idx < maxlen; dist_idx++) { wastedmem += dist[dist_idx] * (maxlen - dist_idx); condenseq->ids_total_len += dist[dist_idx] * dist_idx; } condenseq->ids_total_len += dist_idx * dist[dist_idx]; sdssize = (GtUword) gt_intset_best_memory_size(maxendidx, condenseq->orig_num_seq); use_const_len = wastedmem < sdssize; if (use_const_len) { gt_logger_log(logger, "Condenseq descriptions will use const len, " GT_WU ", \"wasting\" " GT_WU " bytes. SDS would use " GT_WU " bytes", maxlen, wastedmem, sdssize); condenseq->id_len = maxlen; condenseq->ids_total_len = maxlen * condenseq->orig_num_seq; } else { gt_logger_log(logger, "Condenseq descriptions will use sdstab with size " GT_WU ". Const length would have wasted " GT_WU " bytes.", sdssize, wastedmem); condenseq->sdstab = gt_intset_best_new(maxendidx, condenseq->orig_num_seq); } condenseq->orig_ids = gt_calloc((size_t) condenseq->ids_total_len, sizeof (*condenseq->orig_ids)); cur_id_startptr = condenseq->orig_ids; for (idx = 0; idx < condenseq->orig_num_seq; ++idx) { desc = gt_encseq_description(orig_es, &desclen, idx); idlen = condenseq_idlen(desc, desclen); gt_assert(idlen <= maxlen); (void) memcpy(cur_id_startptr, desc, (size_t) idlen); if (use_const_len) { cur_id_startptr += maxlen; cur_total_id_len += maxlen; } else { cur_id_startptr += idlen; cur_total_id_len += idlen; gt_intset_add(condenseq->sdstab, cur_total_id_len); } } gt_assert(cur_total_id_len == condenseq->ids_total_len); gt_free(dist); }
static int gt_seed_extend_runner(GT_UNUSED int argc, GT_UNUSED const char **argv, GT_UNUSED int parsed_args, void *tool_arguments, GtError *err) { GtSeedExtendArguments *arguments = tool_arguments; GtEncseqLoader *encseq_loader = NULL; GtEncseq *aencseq = NULL, *bencseq = NULL; GtGreedyextendmatchinfo *grextinfo = NULL; GtXdropmatchinfo *xdropinfo = NULL; GtQuerymatchoutoptions *querymatchoutopt = NULL; GtTimer *seedextendtimer = NULL; GtExtendCharAccess cam = GT_EXTEND_CHAR_ACCESS_ANY; GtUword errorpercentage = 0UL; int had_err = 0; gt_error_check(err); gt_assert(arguments != NULL); gt_assert(arguments->se_minidentity >= GT_EXTEND_MIN_IDENTITY_PERCENTAGE && arguments->se_minidentity <= 100UL); /* Calculate error percentage from minidentity */ errorpercentage = 100UL - arguments->se_minidentity; /* Measure whole running time */ if (arguments->benchmark || arguments->verbose) { gt_showtime_enable(); } if (gt_showtime_enabled()) { seedextendtimer = gt_timer_new(); gt_timer_start(seedextendtimer); } /* Load encseq A */ encseq_loader = gt_encseq_loader_new(); gt_encseq_loader_enable_autosupport(encseq_loader); aencseq = gt_encseq_loader_load(encseq_loader, gt_str_get(arguments->dbs_indexname), err); if (aencseq == NULL) had_err = -1; /* If there is a 2nd read set: Load encseq B */ if (!had_err) { if (strcmp(gt_str_get(arguments->dbs_queryname), "") != 0) { bencseq = gt_encseq_loader_load(encseq_loader, gt_str_get(arguments->dbs_queryname), err); } else { bencseq = gt_encseq_ref(aencseq); } if (bencseq == NULL) { had_err = -1; gt_encseq_delete(aencseq); } } gt_encseq_loader_delete(encseq_loader); /* set character access method */ if (!had_err && (gt_option_is_set(arguments->se_option_greedy) || gt_option_is_set(arguments->se_option_xdrop) || arguments->se_alignmentwidth > 0)) { cam = gt_greedy_extend_char_access(gt_str_get (arguments->se_char_access_mode), err); if ((int) cam == -1) { had_err = -1; gt_encseq_delete(aencseq); gt_encseq_delete(bencseq); } } /* Use bias dependent parameters, adapted from E. Myers' DALIGNER */ if (!had_err && arguments->bias_parameters) { const GtAlphabet *alpha = gt_encseq_alphabet(aencseq); const double bias_factor[10] = {.690, .690, .690, .690, .780, .850, .900, .933, .966, 1.000}; if (gt_alphabet_is_dna(alpha)) { GtUword at, cg; at = gt_encseq_charcount(aencseq, gt_alphabet_encode(alpha, 'a')); at += gt_encseq_charcount(aencseq, gt_alphabet_encode(alpha, 't')); cg = gt_encseq_charcount(aencseq, gt_alphabet_encode(alpha, 'c')); cg += gt_encseq_charcount(aencseq, gt_alphabet_encode(alpha, 'g')); if (at + cg > 0) { const double ratio = (double)MIN(at, cg) / (at + cg); int bias_index = (int)MAX(0.0, (ratio + 0.025) * 20.0 - 1.0); gt_assert(bias_index < 10); arguments->se_maxalilendiff = 30; arguments->se_perc_match_hist = (GtUword)(100.0 - errorpercentage * bias_factor[bias_index]); if (arguments->verbose) { printf("# Base ratio = %4.2lf -> percmathistory = "GT_WU"\n", ratio, arguments->se_perc_match_hist); } } else { had_err = -1; } } else { had_err = -1; } if (had_err) { gt_error_set(err, "option \"-bias-parameters\" can only be applied to " "the DNA alphabet"); gt_encseq_delete(aencseq); gt_encseq_delete(bencseq); } } /* Prepare options for greedy extension */ if (!had_err && gt_option_is_set(arguments->se_option_greedy)) { grextinfo = gt_greedy_extend_matchinfo_new(errorpercentage, arguments->se_maxalilendiff, arguments->se_historysize, arguments->se_perc_match_hist, arguments->se_alignlength, cam, arguments->se_extendgreedy); if (arguments->benchmark) { gt_greedy_extend_matchinfo_silent_set(grextinfo); } } /* Prepare options for xdrop extension */ if (!had_err && gt_option_is_set(arguments->se_option_xdrop)) { xdropinfo = gt_xdrop_matchinfo_new(arguments->se_alignlength, errorpercentage, arguments->se_xdropbelowscore, arguments->se_extendxdrop); if (arguments->benchmark) { gt_xdrop_matchinfo_silent_set(xdropinfo); } } /* Prepare output options */ if (!had_err && (arguments->se_alignmentwidth > 0 || gt_option_is_set(arguments->se_option_xdrop))) { querymatchoutopt = gt_querymatchoutoptions_new(arguments->se_alignmentwidth); if (gt_option_is_set(arguments->se_option_xdrop) || gt_option_is_set(arguments->se_option_greedy)) { const GtUword sensitivity = gt_option_is_set(arguments->se_option_greedy) ? arguments->se_extendgreedy : 100; gt_querymatchoutoptions_extend(querymatchoutopt, errorpercentage, arguments->se_maxalilendiff, arguments->se_historysize, arguments->se_perc_match_hist, cam, sensitivity); } } /* Start algorithm */ if (!had_err) { GtDiagbandseed dbsarguments; dbsarguments.errorpercentage = errorpercentage; dbsarguments.userdefinedleastlength = arguments->se_alignlength; dbsarguments.seedlength = arguments->dbs_seedlength; dbsarguments.logdiagbandwidth = arguments->dbs_logdiagbandwidth; dbsarguments.mincoverage = arguments->dbs_mincoverage; dbsarguments.maxfreq = arguments->dbs_maxfreq; dbsarguments.memlimit = arguments->dbs_memlimit; dbsarguments.mirror = arguments->mirror; dbsarguments.overlappingseeds = arguments->overlappingseeds; dbsarguments.verify = arguments->dbs_verify; dbsarguments.verbose = arguments->verbose; dbsarguments.debug_kmer = arguments->dbs_debug_kmer; dbsarguments.debug_seedpair = arguments->dbs_debug_seedpair; dbsarguments.seed_display = arguments->seed_display; dbsarguments.extendgreedyinfo = grextinfo; dbsarguments.extendxdropinfo = xdropinfo; dbsarguments.querymatchoutopt = querymatchoutopt; had_err = gt_diagbandseed_run(aencseq, bencseq, &dbsarguments, err); /* clean up */ gt_encseq_delete(aencseq); gt_encseq_delete(bencseq); if (gt_option_is_set(arguments->se_option_greedy)) { gt_greedy_extend_matchinfo_delete(grextinfo); } if (gt_option_is_set(arguments->se_option_xdrop)) { gt_xdrop_matchinfo_delete(xdropinfo); } if (arguments->se_alignmentwidth > 0 || gt_option_is_set(arguments->se_option_xdrop)) { gt_querymatchoutoptions_delete(querymatchoutopt); } } if (gt_showtime_enabled()) { if (!had_err) { char *keystring = gt_seed_extend_params_keystring(gt_option_is_set(arguments-> se_option_greedy), gt_option_is_set(arguments-> se_option_xdrop), arguments->dbs_seedlength, arguments->se_alignlength, arguments->se_minidentity, arguments->se_maxalilendiff, arguments->se_perc_match_hist, arguments->se_extendgreedy, arguments->se_extendxdrop, arguments->se_xdropbelowscore); printf("# TIME seedextend-%s", keystring); gt_free(keystring); gt_timer_show_formatted(seedextendtimer, " overall " GT_WD ".%06ld\n", stdout); } gt_timer_delete(seedextendtimer); } return had_err; }
Tyrindex *gt_tyrindex_new(const char *tyrindexname,GtError *err) { bool haserr = false; size_t numofbytes, rest; Tyrindex *tyrindex; gt_error_check(err); tyrindex = gt_malloc(sizeof *tyrindex); tyrindex->indexfilename = tyrindexname; tyrindex->mappedfileptr = gt_fa_mmap_read_with_suffix(tyrindexname,MERSUFFIX, &numofbytes,err); if (tyrindex->mappedfileptr == NULL) { haserr = true; } if (!haserr) { tyrindex->mertable = (GtUchar *) tyrindex->mappedfileptr; rest = sizeof (GtUword) * EXTRAINTEGERS; if (rest > numofbytes) { gt_error_set(err,"index must contain at least "GT_WU" bytes", (GtUword) rest); haserr = true; } } if (!haserr) { gt_assert(tyrindex->mertable != NULL); tyrindex->mersize = gt_decodesingleinteger(tyrindex->mertable + numofbytes - rest); tyrindex->alphasize = (unsigned int) gt_decodesingleinteger(tyrindex->mertable + numofbytes - rest + sizeof (GtUword)); tyrindex->merbytes = MERBYTES(tyrindex->mersize); if ((numofbytes - rest) % tyrindex->merbytes != 0) { gt_error_set(err,"size of index is "GT_WU " which is not a multiple of "GT_WU, (GtUword) (numofbytes - rest), tyrindex->merbytes); haserr = true; } } if (!haserr) { tyrindex->numofmers = (numofbytes - rest) / tyrindex->merbytes; gt_assert(tyrindex->mertable != NULL); if (tyrindex->numofmers == 0) { tyrindex->lastmer = tyrindex->mertable - 1; } else { tyrindex->lastmer = tyrindex->mertable + numofbytes - rest - tyrindex->merbytes; } } if (haserr) { if (tyrindex->mappedfileptr != NULL) { gt_fa_xmunmap(tyrindex->mappedfileptr); tyrindex->mappedfileptr = NULL; } gt_free(tyrindex); } return haserr ? NULL : tyrindex; }
int gt_bitpackarray_unit_test(GtError *err) { struct BitPackArray *bitStore = NULL; int had_err = 0; { uint32_t *randSrc = NULL; /*< create random ints here for input as bit * store */ uint32_t *randCmp = NULL, /*< used for random ints read back */ mask; size_t i, numRnd; unsigned bits; numRnd = random() % MAX_RND_NUMS + 1; bits = random() % (sizeof (randSrc[0]) * CHAR_BIT + 1); if (bits == 32) mask = ~(uint32_t)0; else mask = ~((~(uint32_t)0)<<bits); gt_log_log("numRnd="GT_WU"\n", (GtUword)numRnd); randSrc = gt_malloc(sizeof (uint32_t)*numRnd); bitStore = bitpackarray_new(bits, numRnd,true); randCmp = gt_malloc(sizeof (uint32_t)*numRnd); for (i = 0; i < numRnd; ++i) { uint32_t v = randSrc[i] = random(); bitpackarray_store_uint32(bitStore, i, v); } for (i = 0; i < numRnd; ++i) { uint32_t v = randSrc[i]; uint32_t r = bitpackarray_get_uint32(bitStore, i); gt_ensure((v & mask) == r); if (had_err) { gt_log_log("gt_bsStoreUInt32/bitpackarray_get_uint32: " "Expected %"PRIu32", got %"PRIu32", i = "GT_WU", bits=%u\n", v & mask, r, (GtUword)i, bits); gt_free(randSrc); gt_free(randCmp); bitpackarray_delete(bitStore); return had_err; } } gt_free(randSrc); gt_free(randCmp); bitpackarray_delete(bitStore); } gt_log_log("bitpackarray_store_uint32/bitpackarray_get_uint32: passed\n"); { uint64_t *randSrc = NULL; /*< create random ints here for input as bit * store */ uint64_t *randCmp = NULL, /*< used for random ints read back */ mask; size_t i, numRnd; unsigned bits; numRnd = random() % MAX_RND_NUMS + 1; bits = random() % (sizeof (randSrc[0]) * CHAR_BIT + 1); if (bits == (sizeof (randSrc[0]) * CHAR_BIT)) mask = ~(uint64_t)0; else mask = ~((~(uint64_t)0)<<bits); gt_ensure((randSrc = gt_malloc(sizeof (uint64_t)*numRnd)) && (bitStore = bitpackarray_new(bits, numRnd,true)) && (randCmp = gt_malloc(sizeof (uint64_t)*numRnd))); if (had_err) { perror("Storage allocations failed"); if (randSrc) gt_free(randSrc); if (randCmp) gt_free(randCmp); if (bitStore) bitpackarray_delete(bitStore); return had_err; } for (i = 0; i < numRnd; ++i) { uint64_t v = randSrc[i] = ((uint64_t)random() << 32 | random()); bitpackarray_store_uint64(bitStore, i, v); } for (i = 0; i < numRnd; ++i) { uint64_t v = randSrc[i]; uint64_t r = bitpackarray_get_uint64(bitStore, i); gt_ensure((v & mask) == r); if (had_err) { gt_log_log("gt_bsStoreUInt64/bitpackarray_get_uint64: " "Expected "GT_LLU", got "GT_LLU", i = "GT_WU", bits=%u\n", (GtUint64)(v & mask), (GtUint64)r, (GtUword)i, bits); gt_free(randSrc); gt_free(randCmp); bitpackarray_delete(bitStore); return had_err; } } gt_free(randSrc); gt_free(randCmp); bitpackarray_delete(bitStore); } gt_log_log("bitpackarray_store_uint64/bitpackarray_get_uint64: passed\n"); return had_err; }
void gt_rbtree_iter_delete (GtRBTreeIter *trav) { gt_free(trav); }
void gt_alignment_delete(GtAlignment *alignment) { if (!alignment) return; gt_multieoplist_delete(alignment->eops); gt_free(alignment); }
void gt_copysortsuffixes(const GtBucketspec2 *bucketspec2, Seqpos *suftab, Verboseinfo *verboseinfo) { Seqpos hardwork = 0, **targetptr; unsigned int idx, idxsource, source, second; #ifdef WITHSUFFIXES { const Seqpos *ptr; for (ptr = suftab; ptr < suftab + bucketspec2->partwidth; ptr++) { showsequenceatstartpos(stdout, ISDIRREVERSE(readmode) ? false : true, ISDIRCOMPLEMENT(readmode) ? true : false, encseq, *ptr); } } #endif targetptr = gt_malloc(sizeof(*targetptr) * bucketspec2->numofchars); for (idxsource = 0; idxsource<bucketspec2->numofchars; idxsource++) { source = bucketspec2->order[idxsource]; for (second = 0; second < bucketspec2->numofchars; second++) { if (!bucketspec2->subbuckettab[source][second].sorted && source != second) { gt_assert(bucketspec2->subbuckettab[source][second].hardworktodo); showverbose(verboseinfo,"hard work for %u %u",source,second); hardwork += getendidx(bucketspec2,source,second) - getstartidx(bucketspec2,source,second); bucketspec2->subbuckettab[source][second].sorted = true; } else { gt_assert(!bucketspec2->subbuckettab[source][second].hardworktodo); } } if (getstartidx(bucketspec2,source,0) < getstartidx(bucketspec2,source,source)) { for (idx = 0; idx < bucketspec2->numofchars; idx++) { targetptr[idx] = suftab + getstartidx(bucketspec2,idx,source); } forwardderive(bucketspec2, targetptr, source, suftab + getstartidx(bucketspec2,source,0)); } if (getendidx(bucketspec2,source,source) < getendidx(bucketspec2,source,bucketspec2->numofchars)) { for (idx = 0; idx < bucketspec2->numofchars; idx++) { targetptr[idx] = suftab + getendidx(bucketspec2,idx,source) - 1; } backwardderive(bucketspec2, targetptr, source, suftab + getendidx(bucketspec2,source,bucketspec2->numofchars) - 1); } for (idx = 0; idx < bucketspec2->numofchars; idx++) { bucketspec2->subbuckettab[idx][source].sorted = true; } bucketspec2->superbuckettab[source].sorted = true; } gt_free(targetptr); showverbose(verboseinfo,"hardwork = " FormatSeqpos " (%.2f)", PRINTSeqposcast(hardwork), (double) hardwork/getencseqtotallength(bucketspec2->encseq)); }
static void destructAddLocateInfoState(struct addLocateInfoState *state) { gt_free(state->revMapQueue); gt_free(state->origRanksQueue); }
void gt_freeBwtSeqpositionextractor(BwtSeqpositionextractor *bspex) { destructExtBitsRetrieval(&(bspex->extBits)); gt_free(bspex); }
void gt_Bwtseqpositioniterator_delete(Bwtseqpositioniterator *bspi) { destructExtBitsRetrieval(&bspi->extBits); gt_free(bspi); }
static void gt_seqorder_arguments_delete(void *tool_arguments) { GtSeqorderArguments *arguments = tool_arguments; if (!arguments) return; gt_free(arguments); }
static int gt_seqorder_runner(GT_UNUSED int argc, const char **argv, int parsed_args, void *tool_arguments, GtError *err) { GtSeqorderArguments *arguments = tool_arguments; int had_err = 0; GtEncseq *encseq; GtEncseqLoader *loader; unsigned long i, nofseqs; gt_error_check(err); gt_assert(arguments != NULL); /* load encseq */ loader = gt_encseq_loader_new(); encseq = gt_encseq_loader_load(loader, argv[parsed_args], err); if (encseq == NULL) had_err = -1; if (had_err == 0 && !gt_encseq_has_description_support(encseq)) gt_warning("%s has no description support", argv[parsed_args]); if (!had_err) { nofseqs = gt_encseq_num_of_sequences(encseq); if (arguments->invert) { for (i = nofseqs; i > 0; i--) gt_seqorder_output(i - 1, encseq); } else if (arguments->shuffle) { unsigned long *seqnums; seqnums = gt_malloc(sizeof (unsigned long) * nofseqs); gt_seqorder_get_shuffled_seqnums(nofseqs, seqnums); for (i = 0; i < nofseqs; i++) gt_seqorder_output(seqnums[i], encseq); gt_free(seqnums); } else { GtSuffixsortspace *suffixsortspace; gt_assert(arguments->sort || arguments->revsort); suffixsortspace = gt_suffixsortspace_new(nofseqs, /* Use iterator over sequence separators: saves a lot of binary searches */ gt_encseq_seqstartpos(encseq, nofseqs-1), false,NULL); gt_seqorder_sort(suffixsortspace, encseq); if (arguments->sort) for (i = 0; i < nofseqs; i++) gt_seqorder_output(gt_encseq_seqnum(encseq, gt_suffixsortspace_getdirect(suffixsortspace, i)), encseq); else for (i = nofseqs; i > 0; i--) gt_seqorder_output(gt_encseq_seqnum(encseq, gt_suffixsortspace_getdirect(suffixsortspace, i - 1)), encseq); gt_suffixsortspace_delete(suffixsortspace, false); } } gt_encseq_loader_delete(loader); gt_encseq_delete(encseq); return had_err; }
void gt_rbtree_delete(GtRBTree *tree) { gt_rbtree_clear(tree); gt_free(tree); }
int gt_rbtree_erase(GtRBTree *tree, void *key) { int rv = -1; gt_assert(tree); gt_assert(key); if (tree->root != NULL) { GtRBTreeNode head = {0,0,{NULL, NULL}}; /* False tree root */ GtRBTreeNode *q, *p, *g; /* Helpers */ GtRBTreeNode *f = NULL; /* Found item */ int dir = 1; /* Set up our helpers */ q = &head; p = NULL; q->link[1] = tree->root; /* Search and push a red node down to fix red violations as we go */ while (q->link[dir] != NULL) { int last = dir; /* Move the helpers down */ g = p, p = q; q = q->link[dir]; dir = (int) (tree->cmp(q->key, key, tree->info) < 0); /* Save the node with matching key and keep going; we'll do removal tasks at the end */ if (tree->cmp(q->key, key, tree->info) == 0) f = q; /* Push the red node down with rotations and color flips */ if (!GT_RBTREE_NODE_IS_RED(q) && !GT_RBTREE_NODE_IS_RED(q->link[dir])) { if (GT_RBTREE_NODE_IS_RED(q->link[(int) !dir])) { p = p->link[last] = gt_rbtree_single(q, dir); } else if (!GT_RBTREE_NODE_IS_RED(q->link[(int) !dir])) { GtRBTreeNode *s = p->link[(int) !last]; if (s != NULL) { if (!GT_RBTREE_NODE_IS_RED(s->link[(int) !last]) && !GT_RBTREE_NODE_IS_RED(s->link[last])) { /* Color flip */ p->red = 0; s->red = 1; q->red = 1; } else { int dir2; gt_assert(g != NULL); dir2 = (int) (g->link[1] == p); if (GT_RBTREE_NODE_IS_RED(s->link[last])) g->link[dir2] = gt_rbtree_double(p, last); else if (GT_RBTREE_NODE_IS_RED(s->link[(int) !last])) g->link[dir2] = gt_rbtree_single(p, last); /* Ensure correct coloring */ q->red = g->link[dir2]->red = 1; g->link[dir2]->link[0]->red = 0; g->link[dir2]->link[1]->red = 0; } } } } } /* Replace and remove the saved node */ if (f != NULL) { if (tree->free != NULL) tree->free(f->key); f->key = q->key; gt_assert(p); p->link[(int) (p->link[1] == q)] = q->link[(int) (q->link[0] == NULL)]; gt_free(q); rv = 0; --tree->size; } /* Update the root (it may be different) */ tree->root = head.link[1]; /* Make the root black for simplified logic */ if (tree->root != NULL) tree->root->red = 0; } return rv; }
void vang_relation_set_key(VangRelation *rel, const char *key) { gt_free(rel->key); rel->key = gt_cstr_dup(key); }
void gth_dp_options_core_delete(GthDPOptionsCore *dp_options_core) { if (!dp_options_core) return; gt_free(dp_options_core); }
void vang_relation_set_note(VangRelation *rel, const char *note) { if(rel->note != NULL) gt_free(rel->note); rel->note = gt_cstr_dup(note); }
Qualifiedinteger *gt_parsequalifiedinteger(const char *option, const char *lparam, GtError *err) { GtWord readint = 0; size_t i; char *lparamcopy; bool haserr = false; Qualifiedinteger *qualint; lparamcopy = gt_malloc(sizeof (char) * (strlen(lparam)+1)); qualint = gt_malloc(sizeof (*qualint)); strcpy(lparamcopy,lparam); for (i=0; lparamcopy[i] != '\0'; i++) { if (!isdigit((int) lparamcopy[i]) && lparamcopy[i] != BESTCHARACTER && lparamcopy[i] != PERCENTAWAYCHARACTER) { ERRORLPARAM; haserr = true; break; } } if (!haserr && i == 0) { ERRORLPARAM; haserr = true; } if (!haserr) { if (lparamcopy[i-1] == BESTCHARACTER) { lparamcopy[i-1] = '\0'; qualint->qualtag = Qualbestof; } else { if (lparamcopy[i-1] == PERCENTAWAYCHARACTER) { lparamcopy[i-1] = '\0'; qualint->qualtag = Qualpercentaway; } else { qualint->qualtag = Qualabsolute; } } if (sscanf(lparamcopy,""GT_WD"",&readint) != 1 || readint <= 0) { ERRORLPARAM; haserr = true; } } if (!haserr && (qualint->qualtag == Qualpercentaway || qualint->qualtag == Qualbestof)) { if (readint > 100L) { ERRORLPARAM; haserr = true; } } qualint->integervalue = (GtUword) readint; gt_free(lparamcopy); if (haserr) { gt_free (qualint); return NULL; } return qualint; }
static inline void rdj_pairwise_generic(bool use_dp, GtOvlfindMode m, GtEncseq *encseq, bool revcompl, bool show_progressbar, bool use_kmp, double max_error, GtUword min_length, bool find_nonmaximal, GtSpmproc proc, GtSpmprocA proc_a, void* procdata, bool cntfilter, GtBitsequence *cntreads_in, GtBitsequence **cntreads_out, GtUword *nofreads) { GtContfind containment_status; GtBitsequence *cntreads = NULL; GtUint64 progress = 0; GtUword i, j, startpos, v_seqnum, nofsequences, n; struct Read u, v; struct Data d; gt_kmp_t** kmp_values = NULL; GT_RDJ_PAIRWISE_INIT_STRUCT_DATA(d, proc, proc_a, procdata, &u, &v, 0); gt_assert(encseq != NULL); d.mode = m; if ((m == GT_OVLFIND_ALL) && cntfilter) d.mode = GT_OVLFIND_PROPER_SPM; n = gt_encseq_num_of_sequences(encseq); if (use_kmp) kmp_values = prepare_kmp_values(encseq, n); nofsequences = n; if (revcompl) n = n >> 1; if (cntreads_in != NULL) cntreads = cntreads_in; else if (m != GT_OVLFIND_SPM) GT_INITBITTAB(cntreads, n); if (show_progressbar) gt_progressbar_start(&progress, (GtUint64)n * ((GtUint64)n - 1ULL) / 2ULL); for (i = 0; i < n; i++) { u.seqnum = i; u.direct = true; u.len = gt_encseq_seqlength(encseq, i); u.seq = gt_malloc(sizeof (char) * (u.len + 1)); startpos = gt_encseq_seqstartpos(encseq, i); gt_encseq_extract_decoded(encseq, u.seq, startpos, startpos + u.len - 1); u.seq[u.len] = '\0'; if (use_kmp) { gt_assert(kmp_values != NULL); u.pi = kmp_values[i]; } for (j = i; j < n; j++) { if (cntfilter) { gt_assert(cntreads != NULL); if ((bool)GT_ISIBITSET(cntreads, i)) break; if ((bool)GT_ISIBITSET(cntreads, j)) continue; } v.seqnum = j; /* find overlaps using direct v */ v.direct = true; v.len = gt_encseq_seqlength(encseq, j); v.seq = gt_malloc(sizeof (char) * (v.len + 1)); startpos = gt_encseq_seqstartpos(encseq, j); gt_encseq_extract_decoded(encseq, v.seq, startpos, startpos + v.len - 1); v.seq[v.len] = '\0'; if (use_kmp) { gt_assert(kmp_values != NULL); v.pi = kmp_values[j]; } containment_status = use_dp ? find_approx_overlaps(&d, max_error, min_length, find_nonmaximal) : find_exact_overlaps(&d, use_kmp, min_length, find_nonmaximal); if (m != GT_OVLFIND_SPM) mark_contained(containment_status, u.seqnum, v.seqnum, cntreads); /* find overlaps using reverse complement of v */ if (revcompl) { v_seqnum = nofsequences - j - 1; v.direct = false; gt_assert(gt_encseq_seqlength(encseq, j) == gt_encseq_seqlength(encseq, v_seqnum)); startpos = gt_encseq_seqstartpos(encseq, v_seqnum); gt_encseq_extract_decoded(encseq, v.seq, startpos, startpos + v.len - 1); if (use_kmp) { gt_assert(kmp_values != NULL); v.pi = kmp_values[v_seqnum]; } containment_status = use_dp ? find_approx_overlaps(&d, max_error, min_length, find_nonmaximal) : find_exact_overlaps(&d, use_kmp, min_length, find_nonmaximal); if (m != GT_OVLFIND_SPM) mark_contained(containment_status, u.seqnum, v.seqnum, cntreads); } gt_free(v.seq); progress++; } gt_free(u.seq); } if (cntreads_out != NULL) *cntreads_out = cntreads; else if (cntreads_in == NULL) gt_free(cntreads); if (nofreads != NULL) *nofreads = n; if (use_kmp) free_kmp_values(kmp_values, revcompl ? n << 1 : n); if (show_progressbar) gt_progressbar_stop(); }
static void specialwrapqueue(Specialpositions *spos) { gt_free(spos->queuespace); }
void gt_maxcoordvalue_delete(GtMaxcoordvalue *max) { if (max != NULL) gt_free(max); }
GtOutlcpinfo *gt_Outlcpinfo_new(const char *indexname, unsigned int numofchars, unsigned int prefixlength, bool withdistribution, bool swallow_tail_lcpvalues, GtFinalProcessBucket final_process_bucket, void *final_process_bucket_info, GtError *err) { bool haserr = false; GtOutlcpinfo *outlcpinfo; outlcpinfo = gt_malloc(sizeof (*outlcpinfo)); outlcpinfo->sizeofinfo = sizeof (*outlcpinfo); outlcpinfo->lcpsubtab.lcptabsum = 0.0; outlcpinfo->swallow_tail_lcpvalues = swallow_tail_lcpvalues; if (withdistribution) { outlcpinfo->lcpsubtab.distlcpvalues = gt_disc_distri_new(); } else { outlcpinfo->lcpsubtab.distlcpvalues = NULL; } if (indexname == NULL) { outlcpinfo->lcpsubtab.lcp2file = NULL; if (final_process_bucket != NULL) { outlcpinfo->lcpsubtab.lcpprocess = gt_malloc(sizeof (*outlcpinfo->lcpsubtab.lcpprocess)); outlcpinfo->lcpsubtab.lcpprocess->final_process_bucket = final_process_bucket; outlcpinfo->lcpsubtab.lcpprocess->final_process_bucket_info = final_process_bucket_info; } else { outlcpinfo->lcpsubtab.lcpprocess = NULL; } } else { outlcpinfo->lcpsubtab.lcpprocess = NULL; outlcpinfo->lcpsubtab.lcp2file = gt_malloc(sizeof (*outlcpinfo->lcpsubtab.lcp2file)); outlcpinfo->sizeofinfo += sizeof (*outlcpinfo->lcpsubtab.lcp2file); outlcpinfo->lcpsubtab.lcp2file->countoutputlcpvalues = 0; outlcpinfo->lcpsubtab.lcp2file->maxbranchdepth = 0; outlcpinfo->lcpsubtab.lcp2file->totalnumoflargelcpvalues = 0; outlcpinfo->lcpsubtab.lcp2file->reservoir = NULL; outlcpinfo->lcpsubtab.lcp2file->sizereservoir = 0; outlcpinfo->lcpsubtab.lcp2file->smalllcpvalues = NULL; GT_INITARRAY(&outlcpinfo->lcpsubtab.lcp2file->largelcpvalues, Largelcpvalue); outlcpinfo->lcpsubtab.lcp2file->outfplcptab = gt_fa_fopen_with_suffix(indexname,GT_LCPTABSUFFIX,"wb",err); if (outlcpinfo->lcpsubtab.lcp2file->outfplcptab == NULL) { haserr = true; } if (!haserr) { outlcpinfo->lcpsubtab.lcp2file->outfpllvtab = gt_fa_fopen_with_suffix(indexname,GT_LARGELCPTABSUFFIX,"wb",err); if (outlcpinfo->lcpsubtab.lcp2file->outfpllvtab == NULL) { haserr = true; } } } outlcpinfo->numsuffixes2output = 0; outlcpinfo->minchanged = 0; if (!haserr && prefixlength > 0) { outlcpinfo->turnwheel = gt_turningwheel_new(prefixlength,numofchars); outlcpinfo->sizeofinfo += gt_turningwheel_size(); } else { outlcpinfo->turnwheel = NULL; } #ifdef SKDEBUG outlcpinfo->previoussuffix.startpos = 0; #endif outlcpinfo->previoussuffix.code = 0; outlcpinfo->previoussuffix.prefixindex = 0; outlcpinfo->previoussuffix.defined = false; outlcpinfo->previousbucketwasempty = false; outlcpinfo->lcpsubtab.tableoflcpvalues.bucketoflcpvalues = NULL; outlcpinfo->lcpsubtab.tableoflcpvalues.numofentries = 0; #ifndef NDEBUG outlcpinfo->lcpsubtab.tableoflcpvalues.isset = NULL; #endif if (haserr) { gt_free(outlcpinfo); return NULL; } return outlcpinfo; }
int gt_intset_16_unit_test(GtError *err) { int had_err = 0; GtIntset *is; GtUword num_of_elems = gt_rand_max(((GtUword) 1) << 10) + 1, *arr = gt_malloc(sizeof (*arr) * num_of_elems), stepsize = GT_DIV2(num_of_elems <<4 / num_of_elems), idx; size_t is_size; gt_error_check(err); arr[0] = gt_rand_max(stepsize) + 1; for (idx = (GtUword) 1; idx < num_of_elems; ++idx) { arr[idx] = arr[idx - 1] + gt_rand_max(stepsize) + 1; } is_size = gt_intset_16_size_of_rep(arr[num_of_elems - 1], num_of_elems); if (!had_err) { if (is_size < (size_t) UINT_MAX) { is = gt_intset_16_new(arr[num_of_elems - 1], num_of_elems); for (idx = 0; idx < num_of_elems; idx++) { gt_intset_16_add(is, arr[idx]); gt_ensure(idx + 1 == gt_intset_16_size(is)); if (idx < num_of_elems - 1) gt_ensure(gt_intset_16_get_idx_smallest_geq(is, arr[idx] + 1) == num_of_elems); } gt_ensure(gt_intset_16_elems_is_valid(is)); gt_ensure(gt_intset_16_secstart_is_valid(is)); for (idx = 0; !had_err && idx < num_of_elems; idx++) { if (arr[idx] != 0 && arr[idx - 1] != (arr[idx] - 1)) { gt_ensure( gt_intset_16_get_idx_smallest_geq_test(is, arr[idx] - 1) == idx); gt_ensure( gt_intset_16_get_idx_smallest_geq(is, arr[idx] - 1) == idx); } gt_ensure(gt_intset_16_get_test(is, idx) == arr[idx]); gt_ensure(gt_intset_16_get(is, idx) == arr[idx]); gt_ensure( gt_intset_16_get_idx_smallest_geq_test(is, arr[idx] + 1) == idx + 1); gt_ensure( gt_intset_16_get_idx_smallest_geq(is, arr[idx] + 1) == idx + 1); } if (!had_err) had_err = gt_intset_unit_test_notinset(is, 0, arr[0] - 1, err); if (!had_err) had_err = gt_intset_unit_test_check_seqnum(is, 0, arr[0] - 1, 0, err); for (idx = (GtUword) 1; !had_err && idx < num_of_elems; idx++) { had_err = gt_intset_unit_test_notinset(is, arr[idx - 1] + 1, arr[idx] - 1, err); if (!had_err) had_err = gt_intset_unit_test_check_seqnum(is, arr[idx - 1] + 1, arr[idx] - 1, idx, err); } gt_intset_delete(is); } } gt_free(arr); return had_err; }
void gt_splitter_delete(GtSplitter *s) { if (!s) return; gt_free(s->tokens); gt_free(s); }
int gt_rbtree_unit_test(GtError *err) { int had_err = 0; GtRBTree *tree = NULL; GtUword i, j, k, *v; gt_error_check (err); gt_rbtree_xtab = gt_malloc(GT_RBTREE_SIZE * sizeof (*gt_rbtree_xtab)); gt_rbtree_ytab = gt_malloc(2*GT_RBTREE_SIZE * sizeof (*gt_rbtree_ytab)); gt_rbtree_ztab = gt_malloc(GT_RBTREE_SIZE * sizeof (*gt_rbtree_ztab)); gt_rbtree_depths = gt_malloc(GT_RBTREE_SIZE * sizeof (*gt_rbtree_depths)); tree = gt_rbtree_new(nrbt_cmp_fn, NULL, NULL); gt_ensure(tree != NULL); for (i = 0; i < (GtUword) GT_RBTREE_SIZE; ++i) { gt_rbtree_xtab[i] = i; } /* Do this loop several times to get different permutations for the random case. */ for (i = 0; i < (GtUword) GT_RBTREE_PASSES; ++i) { NRBT_MANGLECHECK(GT_RBTREE_ASCENDING, GtRBTreeBuild, 0); NRBT_MANGLECHECK(GT_RBTREE_ASCENDING, GtRBTreeFind, 0); NRBT_MANGLECHECK(GT_RBTREE_DESCENDING, GtRBTreeFind, 0); NRBT_MANGLECHECK(GT_RBTREE_RANDOMORDER, GtRBTreeFind, 0); NRBT_WALKCHECK; NRBT_MANGLECHECK (GT_RBTREE_ASCENDING, GtRBTreeDelete, 0); NRBT_MANGLECHECK (GT_RBTREE_ASCENDING, GtRBTreeBuild, 0); NRBT_WALKCHECK; NRBT_MANGLECHECK (GT_RBTREE_DESCENDING, GtRBTreeDelete, 0); NRBT_MANGLECHECK (GT_RBTREE_ASCENDING, GtRBTreeBuild, 0); NRBT_WALKCHECK; NRBT_MANGLECHECK (GT_RBTREE_RANDOMORDER, GtRBTreeDelete, 0); NRBT_MANGLECHECK (GT_RBTREE_DESCENDING, GtRBTreeBuild, 0); NRBT_MANGLECHECK (GT_RBTREE_ASCENDING, GtRBTreeFind, 0); NRBT_MANGLECHECK (GT_RBTREE_DESCENDING, GtRBTreeFind, 0); NRBT_MANGLECHECK (GT_RBTREE_RANDOMORDER, GtRBTreeFind, 0); NRBT_WALKCHECK; NRBT_MANGLECHECK (GT_RBTREE_DESCENDING, GtRBTreeDelete, 0); NRBT_MANGLECHECK (GT_RBTREE_DESCENDING,GtRBTreeBuild, 0); NRBT_WALKCHECK; NRBT_MANGLECHECK (GT_RBTREE_DESCENDING, GtRBTreeDelete, 0); NRBT_MANGLECHECK (GT_RBTREE_DESCENDING, GtRBTreeBuild, 0); NRBT_WALKCHECK; NRBT_MANGLECHECK (GT_RBTREE_RANDOMORDER, GtRBTreeDelete, 0); NRBT_MANGLECHECK (GT_RBTREE_RANDOMORDER, GtRBTreeBuild, 0); NRBT_MANGLECHECK (GT_RBTREE_ASCENDING, GtRBTreeFind, 0); NRBT_MANGLECHECK (GT_RBTREE_DESCENDING, GtRBTreeFind, 0); NRBT_MANGLECHECK (GT_RBTREE_RANDOMORDER, GtRBTreeFind, 0); NRBT_WALKCHECK; NRBT_MANGLECHECK (GT_RBTREE_RANDOMORDER, GtRBTreeDelete, 0); for (j = 1UL; j < (GtUword) GT_RBTREE_SIZE; j *= 2) { NRBT_MANGLECHECK (GT_RBTREE_RANDOMORDER, GtRBTreeBuildDelete, j); } } for (i = 1UL; i < (GtUword) GT_RBTREE_SIZE; i *= 2) { NRBT_MANGLECHECK (GT_RBTREE_ASCENDING, GtRBTreeBuildDelete, i); NRBT_MANGLECHECK (GT_RBTREE_DESCENDING, GtRBTreeBuildDelete, i); NRBT_MANGLECHECK (GT_RBTREE_ASCENDING, GtRBTreeBuildDelete, i); NRBT_MANGLECHECK (GT_RBTREE_DESCENDING, GtRBTreeBuildDelete, i); NRBT_MANGLECHECK (GT_RBTREE_ASCENDING, GtRBTreeBuildDelete, i); NRBT_MANGLECHECK (GT_RBTREE_DESCENDING, GtRBTreeBuildDelete, i); NRBT_MANGLECHECK (GT_RBTREE_ASCENDING, GtRBTreeBuildDelete, i); NRBT_MANGLECHECK (GT_RBTREE_DESCENDING, GtRBTreeBuildDelete, i); } gt_rbtree_delete(tree); gt_free(gt_rbtree_xtab); gt_free(gt_rbtree_ytab); gt_free(gt_rbtree_ztab); gt_free(gt_rbtree_depths); i = 0; j = 1UL, k = 2UL; tree = gt_rbtree_new(nrbt_cmp_fn, NULL, NULL); v = gt_rbtree_root_key(tree); gt_ensure(!v); (void) gt_rbtree_insert(tree, &i); v = gt_rbtree_root_key(tree); gt_ensure(v == &i); gt_ensure(*v == i); (void) gt_rbtree_insert(tree, &j); (void) gt_rbtree_insert(tree, &k); v = gt_rbtree_root_key(tree); gt_ensure(v == &j); gt_ensure(*v == j); gt_rbtree_delete(tree); return had_err; }
void gth_path_walker_delete(GthPathWalker *pw) { if (!pw) return; gt_free(pw); }
void gt_checklinearspace_local(GT_UNUSED bool forward, const GtUchar *useq, GtUword ulen, const GtUchar *vseq, GtUword vlen) { GtAlignment *align; GtWord score1, score2, score3, score4, matchscore = 2, mismatchscore = -2, gapscore = -1; GtUchar *low_useq, *low_vseq; LinspaceManagement *spacemanager; GtScoreHandler *scorehandler; GtAlphabet *alphabet; if (memchr(useq, LINEAR_EDIST_GAP,ulen) != NULL) { fprintf(stderr,"%s: sequence u contains gap symbol\n",__func__); exit(GT_EXIT_PROGRAMMING_ERROR); } if (memchr(vseq, LINEAR_EDIST_GAP,vlen) != NULL) { fprintf(stderr,"%s: sequence v contains gap symbol\n",__func__); exit(GT_EXIT_PROGRAMMING_ERROR); } scorehandler = gt_scorehandler_new_DNA(matchscore, mismatchscore, 0, gapscore); alphabet = gt_scorehandler_get_alphabet(scorehandler); low_useq = check_dna_sequence(useq, ulen, alphabet); low_vseq = check_dna_sequence(vseq, vlen, alphabet); if (low_useq == NULL || low_vseq == NULL) { low_useq? gt_free(low_useq):0; low_vseq? gt_free(low_vseq):0; gt_scorehandler_delete(scorehandler); return; } spacemanager = gt_linspaceManagement_new(); align = gt_alignment_new(); score1 = gt_computelinearspace_local_generic(spacemanager, scorehandler, align, useq, 0, ulen, vseq, 0, vlen); score2 = gt_alignment_eval_with_score(align, matchscore, mismatchscore, gapscore); gt_linspaceManagement_delete(spacemanager); gt_scorehandler_delete(scorehandler); if (score1 != score2) { fprintf(stderr,"gt_computelinearspace_local = "GT_WD" != "GT_WD " = gt_alignment_eval_generic_with_score\n", score1, score2); exit(GT_EXIT_PROGRAMMING_ERROR); } gt_alignment_reset(align); score3 = alignment_in_square_space_local(NULL, align, useq, 0, ulen, vseq, 0, vlen, matchscore, mismatchscore, gapscore); if (score1 != score3) { fprintf(stderr,"gt_computelinearspace_local = "GT_WD" != "GT_WD " = alignment_in_square_space_local\n", score1, score3); exit(GT_EXIT_PROGRAMMING_ERROR); } score4 = gt_alignment_eval_with_score(align, matchscore, mismatchscore, gapscore); if (score3 != score4) { fprintf(stderr,"alignment_in_square_space_local = "GT_WD" != "GT_WD " = gt_alignment_eval_generic_with_score\n", score3, score4); exit(GT_EXIT_PROGRAMMING_ERROR); } gt_alignment_delete(align); gt_free(low_useq); gt_free(low_vseq); }