r896: more flexible ALT reading
This commit is contained in:
parent
2a18fa114f
commit
71277f0fea
18
bntseq.c
18
bntseq.c
|
|
@ -179,17 +179,25 @@ bntseq_t *bns_restore(const char *prefix)
|
|||
if ((fp = fopen(strcat(strcpy(alt_filename, prefix), ".alt"), "r")) != 0) { // read .alt file if present
|
||||
char str[1024];
|
||||
khash_t(str) *h;
|
||||
int i, absent;
|
||||
int c, i, absent;
|
||||
khint_t k;
|
||||
h = kh_init(str);
|
||||
for (i = 0; i < bns->n_seqs; ++i) {
|
||||
k = kh_put(str, h, bns->anns[i].name, &absent);
|
||||
kh_val(h, k) = i;
|
||||
}
|
||||
while (fscanf(fp, "%s", str) == 1) {
|
||||
k = kh_get(str, h, str);
|
||||
if (k != kh_end(h))
|
||||
bns->anns[kh_val(h, k)].is_alt = 1;
|
||||
i = 0;
|
||||
while ((c = fgetc(fp)) != EOF) {
|
||||
if (c == '\t' || c == '\n' || c == '\r') {
|
||||
str[i] = 0;
|
||||
if (str[0] != '@') {
|
||||
k = kh_get(str, h, str);
|
||||
if (k != kh_end(h))
|
||||
bns->anns[kh_val(h, k)].is_alt = 1;
|
||||
}
|
||||
while (c != '\n' && c != EOF) c = fgetc(fp);
|
||||
i = 0;
|
||||
} else str[i++] = c; // FIXME: potential segfault here
|
||||
}
|
||||
kh_destroy(str, h);
|
||||
fclose(fp);
|
||||
|
|
|
|||
5
bwa.c
5
bwa.c
|
|
@ -239,7 +239,12 @@ bwaidx_t *bwa_idx_load(const char *hint, int which)
|
|||
idx = calloc(1, sizeof(bwaidx_t));
|
||||
if (which & BWA_IDX_BWT) idx->bwt = bwa_idx_load_bwt(hint);
|
||||
if (which & BWA_IDX_BNS) {
|
||||
int i, c;
|
||||
idx->bns = bns_restore(prefix);
|
||||
for (i = c = 0; i < idx->bns->n_seqs; ++i)
|
||||
if (idx->bns->anns[i].is_alt) ++c;
|
||||
if (bwa_verbose >= 3)
|
||||
fprintf(stderr, "[M::%s] read %d ALT contigs\n", __func__, c);
|
||||
if (which & BWA_IDX_PAC) {
|
||||
idx->pac = calloc(idx->bns->l_pac/4+1, 1);
|
||||
err_fread_noeof(idx->pac, 1, idx->bns->l_pac/4+1, idx->bns->fp_pac); // concatenated 2-bit encoded sequence
|
||||
|
|
|
|||
Loading…
Reference in New Issue