static void supernode_cleaner_alloc(SupernodeCleaner *cl, size_t nthreads, size_t covg_threshold, size_t min_keep_tip, uint8_t *keep_flags, const dBGraph *db_graph) { size_t i; CovgBuffer *cbufs = ctx_calloc(nthreads, sizeof(CovgBuffer)); for(i = 0; i < nthreads; i++) covg_buf_alloc(&cbufs[i], 1024); uint64_t *covg_hist_init, *covg_hist_cleaned; uint64_t *mean_covg_hist_init, *mean_covg_hist_cleaned; uint64_t *len_hist_init, *len_hist_cleaned; covg_hist_init = ctx_calloc(DUMP_COVG_ARRSIZE, sizeof(uint64_t)); covg_hist_cleaned = ctx_calloc(DUMP_COVG_ARRSIZE, sizeof(uint64_t)); mean_covg_hist_init = ctx_calloc(DUMP_MEAN_COVG_ARRSIZE, sizeof(uint64_t)); mean_covg_hist_cleaned = ctx_calloc(DUMP_MEAN_COVG_ARRSIZE, sizeof(uint64_t)); len_hist_init = ctx_calloc(DUMP_LEN_ARRSIZE, sizeof(uint64_t)); len_hist_cleaned = ctx_calloc(DUMP_LEN_ARRSIZE, sizeof(uint64_t)); SupernodeCleaner tmp = {.nthreads = nthreads, .covg_threshold = covg_threshold, .min_keep_tip = min_keep_tip, .cbufs = cbufs, .covg_hist_init = covg_hist_init, .covg_hist_cleaned = covg_hist_cleaned, .covg_arrsize = DUMP_COVG_ARRSIZE, .mean_covg_hist_init = mean_covg_hist_init, .mean_covg_hist_cleaned = mean_covg_hist_cleaned, .mean_covg_arrsize = DUMP_MEAN_COVG_ARRSIZE, .len_hist_init = len_hist_init, .len_hist_cleaned = len_hist_cleaned, .len_arrsize = DUMP_LEN_ARRSIZE, .keep_flags = keep_flags, .num_tips = 0, .num_low_covg_snodes = 0, .num_tip_and_low_snodes = 0, .num_tip_kmers = 0, .num_low_covg_snode_kmers = 0, .num_tip_and_low_snode_kmers = 0, .db_graph = db_graph}; memcpy(cl, &tmp, sizeof(SupernodeCleaner)); } static void supernode_cleaner_dealloc(SupernodeCleaner *cl) { size_t i; for(i = 0; i < cl->nthreads; i++) covg_buf_dealloc(&cl->cbufs[i]); ctx_free(cl->cbufs); ctx_free(cl->covg_hist_init); ctx_free(cl->covg_hist_cleaned); ctx_free(cl->mean_covg_hist_init); ctx_free(cl->mean_covg_hist_cleaned); ctx_free(cl->len_hist_init); ctx_free(cl->len_hist_cleaned); memset(cl, 0, sizeof(SupernodeCleaner)); }
static void unitig_cleaner_alloc(UnitigCleaner *cl, size_t nthreads, size_t covg_threshold, size_t min_keep_tip, uint8_t *keep_flags, const dBGraph *db_graph) { size_t i; CovgBuffer *cbufs = ctx_calloc(nthreads, sizeof(CovgBuffer)); for(i = 0; i < nthreads; i++) covg_buf_alloc(&cbufs[i], 1024); uint64_t *kmer_covgs_init, *kmer_covgs_clean; uint64_t *unitig_covgs_init, *unitig_covg_clean; uint64_t *len_hist_init, *len_hist_clean; kmer_covgs_init = ctx_calloc(DUMP_COVG_ARRSIZE, sizeof(uint64_t)); kmer_covgs_clean = ctx_calloc(DUMP_COVG_ARRSIZE, sizeof(uint64_t)); unitig_covgs_init = ctx_calloc(DUMP_COVG_ARRSIZE, sizeof(uint64_t)); unitig_covg_clean = ctx_calloc(DUMP_COVG_ARRSIZE, sizeof(uint64_t)); len_hist_init = ctx_calloc(DUMP_LEN_ARRSIZE, sizeof(uint64_t)); len_hist_clean = ctx_calloc(DUMP_LEN_ARRSIZE, sizeof(uint64_t)); UnitigCleaner tmp = {.nthreads = nthreads, .covg_threshold = covg_threshold, .min_keep_tip = min_keep_tip, .cbufs = cbufs, .kmer_covgs_init = kmer_covgs_init, .kmer_covgs_clean = kmer_covgs_clean, .unitig_covgs_init = unitig_covgs_init, .unitig_covg_clean = unitig_covg_clean, .covg_arrsize = DUMP_COVG_ARRSIZE, .len_hist_init = len_hist_init, .len_hist_clean = len_hist_clean, .len_arrsize = DUMP_LEN_ARRSIZE, .keep_flags = keep_flags, .num_tips = 0, .num_low_covg_snodes = 0, .num_tip_and_low_snodes = 0, .num_tip_kmers = 0, .num_low_covg_snode_kmers = 0, .num_tip_and_low_snode_kmers = 0, .db_graph = db_graph}; memcpy(cl, &tmp, sizeof(UnitigCleaner)); } static void unitig_cleaner_dealloc(UnitigCleaner *cl) { size_t i; for(i = 0; i < cl->nthreads; i++) covg_buf_dealloc(&cl->cbufs[i]); ctx_free(cl->cbufs); ctx_free(cl->kmer_covgs_init); ctx_free(cl->kmer_covgs_clean); ctx_free(cl->unitig_covgs_init); ctx_free(cl->unitig_covg_clean); ctx_free(cl->len_hist_init); ctx_free(cl->len_hist_clean); memset(cl, 0, sizeof(UnitigCleaner)); }