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
|
if ((fp = fopen(strcat(strcpy(alt_filename, prefix), ".alt"), "r")) != 0) { // read .alt file if present
|
||||||
char str[1024];
|
char str[1024];
|
||||||
khash_t(str) *h;
|
khash_t(str) *h;
|
||||||
int i, absent;
|
int c, i, absent;
|
||||||
khint_t k;
|
khint_t k;
|
||||||
h = kh_init(str);
|
h = kh_init(str);
|
||||||
for (i = 0; i < bns->n_seqs; ++i) {
|
for (i = 0; i < bns->n_seqs; ++i) {
|
||||||
k = kh_put(str, h, bns->anns[i].name, &absent);
|
k = kh_put(str, h, bns->anns[i].name, &absent);
|
||||||
kh_val(h, k) = i;
|
kh_val(h, k) = i;
|
||||||
}
|
}
|
||||||
while (fscanf(fp, "%s", str) == 1) {
|
i = 0;
|
||||||
k = kh_get(str, h, str);
|
while ((c = fgetc(fp)) != EOF) {
|
||||||
if (k != kh_end(h))
|
if (c == '\t' || c == '\n' || c == '\r') {
|
||||||
bns->anns[kh_val(h, k)].is_alt = 1;
|
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);
|
kh_destroy(str, h);
|
||||||
fclose(fp);
|
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));
|
idx = calloc(1, sizeof(bwaidx_t));
|
||||||
if (which & BWA_IDX_BWT) idx->bwt = bwa_idx_load_bwt(hint);
|
if (which & BWA_IDX_BWT) idx->bwt = bwa_idx_load_bwt(hint);
|
||||||
if (which & BWA_IDX_BNS) {
|
if (which & BWA_IDX_BNS) {
|
||||||
|
int i, c;
|
||||||
idx->bns = bns_restore(prefix);
|
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) {
|
if (which & BWA_IDX_PAC) {
|
||||||
idx->pac = calloc(idx->bns->l_pac/4+1, 1);
|
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
|
err_fread_noeof(idx->pac, 1, idx->bns->l_pac/4+1, idx->bns->fp_pac); // concatenated 2-bit encoded sequence
|
||||||
|
|
|
||||||
2
main.c
2
main.c
|
|
@ -4,7 +4,7 @@
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
|
|
||||||
#ifndef PACKAGE_VERSION
|
#ifndef PACKAGE_VERSION
|
||||||
#define PACKAGE_VERSION "0.7.10-r895-dirty"
|
#define PACKAGE_VERSION "0.7.10-r896-dirty"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int bwa_fa2pac(int argc, char *argv[]);
|
int bwa_fa2pac(int argc, char *argv[]);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue