*/
int bam_plbuf_push(const bam1_t *b, bam_plbuf_t *buf);
+ int bam_pileup_file(bamFile fp, int mask, bam_pileup_f func, void *func_data);
+
struct __bam_lplbuf_t;
typedef struct __bam_lplbuf_t bam_lplbuf_t;
/*! @abstract bam_plbuf_push() equivalent with level calculated. */
int bam_lplbuf_push(const bam1_t *b, bam_lplbuf_t *buf);
- /*! @abstract bam_plbuf_file() equivalent with level calculated. */
- int bam_lpileup_file(bamFile fp, int mask, bam_pileup_f func, void *func_data);
-
struct __bam_index_t;
typedef struct __bam_index_t bam_index_t;
return 0;
}
+int bam_pileup_file(bamFile fp, int mask, bam_pileup_f func, void *func_data)
+{
+ bam_plbuf_t *buf;
+ int ret;
+ bam1_t *b;
+ b = bam_init1();
+ buf = bam_plbuf_init(func, func_data);
+ bam_plbuf_set_mask(buf, mask);
+ while ((ret = bam_read1(fp, b)) >= 0)
+ bam_plbuf_push(b, buf);
+ bam_plbuf_push(0, buf);
+ bam_plbuf_destroy(buf);
+ bam_destroy1(b);
+ return 0;
+}
+
/**********************
*** from bam_aux.c ***
**********************/
{
return bam_plbuf_push(b, tv->plbuf);
}
-
-int bam_lpileup_file(bamFile fp, int mask, bam_pileup_f func, void *func_data)
-{
- bam_lplbuf_t *buf;
- int ret;
- bam1_t *b;
- b = (bam1_t*)calloc(1, sizeof(bam1_t));
- buf = bam_lplbuf_init(func, func_data);
- bam_plbuf_set_mask(buf->plbuf, mask);
- while ((ret = bam_read1(fp, b)) >= 0)
- bam_lplbuf_push(b, buf);
- bam_lplbuf_push(0, buf);
- bam_lplbuf_destroy(buf);
- free(b->data); free(b);
- return 0;
-}
}
return 0;
}
+
+int bam_pileup_file(bamFile fp, int mask, bam_pileup_f func, void *func_data)
+{
+ bam_plbuf_t *buf;
+ int ret;
+ bam1_t *b;
+ b = bam_init1();
+ buf = bam_plbuf_init(func, func_data);
+ bam_plbuf_set_mask(buf, mask);
+ while ((ret = bam_read1(fp, b)) >= 0)
+ bam_plbuf_push(b, buf);
+ bam_plbuf_push(0, buf);
+ bam_plbuf_destroy(buf);
+ bam_destroy1(b);
+ return 0;
+}
#include "bam.h"
#ifndef PACKAGE_VERSION
-#define PACKAGE_VERSION "0.1.5-4 (r394)"
+#define PACKAGE_VERSION "0.1.5-5 (r395)"
#endif
int bam_taf2baf(int argc, char *argv[]);