1 #ifndef SAM_RSEM_AUX_H_
2 #define SAM_RSEM_AUX_H_
10 // dwt: duplicate without text
11 bam_header_t *bam_header_dwt(const bam_header_t *ori_h)
15 h = bam_header_init();
16 h->n_targets = ori_h->n_targets;
17 h->target_len = (uint32_t*)calloc(h->n_targets, 4);
18 h->target_name = (char**)calloc(h->n_targets, sizeof(char*));
19 for (int i = 0; i < h->n_targets; i++) {
20 h->target_len[i] = ori_h->target_len[i];
21 h->target_name[i] = strdup(ori_h->target_name[i]);
27 void append_header_text(bam_header_t *header, const char* text, int len)
29 int x = header->l_text + 1;
30 int y = header->l_text + len + 1; // 1 byte null
31 if (text == 0) return;
34 if (x < y) header->text = (char*)realloc(header->text, y);
35 strncpy(header->text + header->l_text, text, len); // we cannot use strcpy() here.
36 header->l_text += len;
37 header->text[header->l_text] = 0;
40 void expand_data_size(bam1_t *b) {
41 if (b->m_data < b->data_len) {
42 b->m_data = b->data_len;
43 kroundup32(b->m_data);
44 b->data = (uint8_t*)realloc(b->data, b->m_data);
48 #endif /* SAM_RSEM_AUX_H_ */