* allow to get mpileup at required sites
***********/
typedef struct {
***********/
typedef struct {
} mplp_conf_t;
typedef struct {
} mplp_conf_t;
typedef struct {
bam_mplp_t iter;
bam_header_t *h = 0;
char *ref;
bam_mplp_t iter;
bam_header_t *h = 0;
char *ref;
// allocate
data = calloc(n, sizeof(void*));
plp = calloc(n, sizeof(void*));
// allocate
data = calloc(n, sizeof(void*));
plp = calloc(n, sizeof(void*));
bam_header_destroy(h_tmp);
}
}
bam_header_destroy(h_tmp);
}
}
+ if (conf->fn_pos) hash = load_pos(conf->fn_pos, h);
// mpileup
ref_tid = -1; ref = 0;
iter = bam_mplp_init(n, mplp_func, (void**)data);
while (bam_mplp_auto(iter, &tid, &pos, n_plp, plp) > 0) {
if (conf->reg && (pos < beg0 || pos >= end0)) continue; // out of the region requested
// mpileup
ref_tid = -1; ref = 0;
iter = bam_mplp_init(n, mplp_func, (void**)data);
while (bam_mplp_auto(iter, &tid, &pos, n_plp, plp) > 0) {
if (conf->reg && (pos < beg0 || pos >= end0)) continue; // out of the region requested
+ if (hash) {
+ khint_t k;
+ k = kh_get(64, hash, (uint64_t)tid<<32 | pos);
+ if (k == kh_end(hash)) continue;
+ }
if (tid != ref_tid) {
free(ref);
if (conf->fai) ref = fai_fetch(conf->fai, h->target_name[tid], &ref_len);
if (tid != ref_tid) {
free(ref);
if (conf->fai) ref = fai_fetch(conf->fai, h->target_name[tid], &ref_len);
+ if (hash) { // free the hash table
+ khint_t k;
+ for (k = kh_begin(hash); k < kh_end(hash); ++k)
+ if (kh_exist(hash, k)) free(kh_val(hash, k));
+ kh_destroy(64, hash);
+ }
bam_mplp_destroy(iter);
bam_header_destroy(h);
for (i = 0; i < n; ++i) {
bam_mplp_destroy(iter);
bam_header_destroy(h);
for (i = 0; i < n; ++i) {
int c;
mplp_conf_t mplp;
memset(&mplp, 0, sizeof(mplp_conf_t));
int c;
mplp_conf_t mplp;
memset(&mplp, 0, sizeof(mplp_conf_t));
- while ((c = getopt(argc, argv, "f:r:")) >= 0) {
+ while ((c = getopt(argc, argv, "f:r:l:")) >= 0) {
switch (c) {
case 'f':
mplp.fai = fai_load(optarg);
if (mplp.fai == 0) return 1;
break;
switch (c) {
case 'f':
mplp.fai = fai_load(optarg);
if (mplp.fai == 0) return 1;
break;
- case 'r': mplp.reg = strdup(optarg);
+ case 'r': mplp.reg = strdup(optarg); break;
+ case 'l': mplp.fn_pos = strdup(optarg); break;
- fprintf(stderr, "Usage: samtools mpileup [-r reg] [-f in.fa] in1.bam [in2.bam [...]]\n");
+ fprintf(stderr, "Usage: samtools mpileup [-r reg] [-f in.fa] [-l pos] in1.bam [in2.bam [...]]\n");
return 1;
}
mpileup(&mplp, argc - optind, argv + optind);
return 1;
}
mpileup(&mplp, argc - optind, argv + optind);
#endif
#ifndef PACKAGE_VERSION
#endif
#ifndef PACKAGE_VERSION
-#define PACKAGE_VERSION "0.1.8 (r613)"
+#define PACKAGE_VERSION "0.1.8-1 (r615)"
#endif
int bam_taf2baf(int argc, char *argv[]);
#endif
int bam_taf2baf(int argc, char *argv[]);
-CFLAGS= -g -Wall #-O2 #-m64 #-arch ppc
+CFLAGS= -g -Wall -O2 #-m64 #-arch ppc
CXXFLAGS= $(CFLAGS)
DFLAGS= -D_FILE_OFFSET_BITS=64
OBJS=
CXXFLAGS= $(CFLAGS)
DFLAGS= -D_FILE_OFFSET_BITS=64
OBJS=