int main() { int i, digit; pnode phead = NULL; init_node(&phead, sizeof(snode)); create_chain(phead); pnode arr[N]; for (i = 0; i < N; i++) { init_node(&arr[i], sizeof(snode)); } digit = max_digit(phead); for (i = 0; i < digit; i++) { phead_to_arr(phead, arr); arr_to_phead(phead, arr); } show_chain(phead); for (i = 0; i < N; i++) { destroy_chain(&arr[i]); } destroy_chain(&phead); return 0; }
int main() { pnode phead = NULL; init_node(&phead, sizeof(snode)); create_chain(phead); show_chain(phead); destroy_chain(&phead); return 0; }
void cleanup(void) { PUTS("cleanup"); hotkey_t *hk = hotkeys_head; while (hk != NULL) { hotkey_t *next = hk->next; destroy_chain(hk->chain); free(hk->cycle); free(hk); hk = next; } hotkeys_head = hotkeys_tail = NULL; }
static void consensus(args_t *args) { htsFile *fasta = hts_open(args->ref_fname, "rb"); if ( !fasta ) error("Error reading %s\n", args->ref_fname); kstring_t str = {0,0,0}; while ( hts_getline(fasta, KS_SEP_LINE, &str) > 0 ) { if ( str.s[0]=='>' ) { // new sequence encountered, apply all chached variants while ( args->vcf_rbuf.n ) { if (args->chain) { print_chain(args); destroy_chain(args); } bcf1_t *rec = args->vcf_buf[args->vcf_rbuf.f]; if ( rec->rid!=args->rid || ( args->fa_end_pos && rec->pos > args->fa_end_pos ) ) break; int i = rbuf_shift(&args->vcf_rbuf); apply_variant(args, args->vcf_buf[i]); } flush_fa_buffer(args, 0); init_region(args, str.s+1); continue; } args->fa_length += str.l; args->fa_src_pos += str.l; // determine if uppercase or lowercase is used in this fasta file if ( args->fa_case==-1 ) args->fa_case = toupper(str.s[0])==str.s[0] ? 1 : 0; if ( args->mask && args->rid>=0) mask_region(args, str.s, str.l); kputs(str.s, &args->fa_buf); bcf1_t **rec_ptr = NULL; while ( args->rid>=0 && (rec_ptr = next_vcf_line(args)) ) { bcf1_t *rec = *rec_ptr; // still the same chr and the same region? if not, fasta buf can be flushed if ( rec->rid!=args->rid || ( args->fa_end_pos && rec->pos > args->fa_end_pos ) ) { // save the vcf record until next time and flush unread_vcf_line(args, rec_ptr); rec_ptr = NULL; break; } // is the vcf record well beyond cached fasta buffer? if yes, the buf can be flushed if ( args->fa_ori_pos + args->fa_buf.l - args->fa_mod_off <= rec->pos ) { unread_vcf_line(args, rec_ptr); rec_ptr = NULL; break; } // is the cached fasta buffer full enough? if not, read more fasta, no flushing if ( args->fa_ori_pos + args->fa_buf.l - args->fa_mod_off < rec->pos + rec->rlen ) { unread_vcf_line(args, rec_ptr); break; } apply_variant(args, rec); } if ( !rec_ptr ) flush_fa_buffer(args, 60); } if (args->chain) { print_chain(args); destroy_chain(args); } flush_fa_buffer(args, 0); hts_close(fasta); free(str.s); }
/** * Destroy the RNA */ RNA::~RNA() { destroy_chain(); if (m_destroy_trna == 1) delete[] m_trna; }
/** * Set a new RNA chain */ void RNA::set_chain(CodonNode *chain) { destroy_chain(); m_chain = chain; }