static void gt_seqorder_get_hdrsorted_seqnums(const GtEncseq *encseq, GtUword *seqnums, GtCompareWithData cmpfunc) { GtUword i; gt_assert(encseq != NULL); for (i = 0UL; i < gt_encseq_num_of_sequences(encseq); i++) seqnums[i] = i; (void) gt_qsort_r(seqnums, gt_encseq_num_of_sequences(encseq), sizeof (GtUword), (void*) encseq, cmpfunc); }
GtBucketspec2 *gt_bucketspec2_new(const Bcktab *bcktab, const Encodedsequence *encseq, Readmode readmode, Seqpos partwidth, unsigned int numofchars) { GtBucketspec2 *bucketspec2; unsigned int idx; gt_assert(numofchars > 0); bucketspec2 = gt_malloc(sizeof(*bucketspec2)); bucketspec2->partwidth = partwidth; bucketspec2->prefixlength = bcktab_prefixlength(bcktab); bucketspec2->numofchars = numofchars; bucketspec2->numofcharssquared = numofchars * numofchars; bucketspec2->encseq = encseq; bucketspec2->readmode = readmode; bucketspec2->order = gt_malloc(sizeof(*bucketspec2->order) * numofchars); bucketspec2->superbuckettab = gt_malloc(sizeof(*bucketspec2->superbuckettab) * numofchars); gt_array2dim_malloc(bucketspec2->subbuckettab,(unsigned long) numofchars, (unsigned long) numofchars); if (bucketspec2->prefixlength == 2U) { fill2subbuckets(bucketspec2,bcktab); } else { fillanysubbuckets(bucketspec2,bcktab); } for (idx = 0; idx<numofchars; idx++) { bucketspec2->order[idx] = idx; } gt_qsort_r(bucketspec2->order,(size_t) numofchars, sizeof (*bucketspec2->order),bucketspec2, comparesuperbucketsizes); resetsorted(bucketspec2); #ifdef SHOWBUCKETSPEC2 showbucketspec2(bucketspec2); #endif determinehardwork(bucketspec2); resetsorted(bucketspec2); return bucketspec2; }
unsigned long gt_uint64hashtable_partialsums(GtUint64hashtable *table, GtTimer *timer) { size_t idx, next = 0; unsigned long psum, maxsize = 0; table->sortedhspace = gt_malloc((size_t) table->allentries * sizeof (*table->sortedhspace)); if (timer != NULL) { gt_timer_show_progress(timer, "sorting the hashkeys",stdout); } for (idx = 0; idx < table->alloc; idx++) { if (table->hspace[idx].count > 0) { gt_assert(next < (size_t) table->allentries); table->sortedhspace[next++] = idx; if (maxsize < table->hspace[idx].count) { maxsize = table->hspace[idx].count; } } } gt_qsort_r(table->sortedhspace,next,sizeof(*table->sortedhspace), table->hspace,compareGtUint64hashstoredvalue); gt_assert(next > 0); if (table->zero_occurs) { table->hspace[table->sortedhspace[0]].count += table->zero_count; } if (timer != NULL) { gt_timer_show_progress(timer, "computing partial sums",stdout); } for (idx = (size_t) 1; idx < next; idx++) { table->hspace[table->sortedhspace[idx]].count += table->hspace[table->sortedhspace[idx-1]].count; } psum = table->hspace[table->sortedhspace[next-1]].count; gt_free(table->sortedhspace); return psum; }