X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=bam.h;h=64867f10733f6889c1a0e0fa7a61e8e2802c2407;hb=f8941aebcb194dbe1ff32c161d3cd51d80805d5d;hp=6316c9b438320dc5df8751f5c1a73ed6c185b6e4;hpb=1a23a35867ee992dcffcf3d17df2b7d41732f33b;p=samtools.git diff --git a/bam.h b/bam.h index 6316c9b..64867f1 100644 --- a/bam.h +++ b/bam.h @@ -41,26 +41,11 @@ */ #include -#include #include #include #include -#define _IOLIB 2 - -#if _IOLIB == 1 && !defined(_NO_RAZF) -#define BAM_TRUE_OFFSET -#include "razf.h" -/*! @abstract BAM file handler */ -typedef RAZF *bamFile; -#define bam_open(fn, mode) razf_open(fn, mode) -#define bam_dopen(fd, mode) razf_dopen(fd, mode) -#define bam_close(fp) razf_close(fp) -#define bam_read(fp, buf, size) razf_read(fp, buf, size) -#define bam_write(fp, buf, size) razf_write(fp, buf, size) -#define bam_tell(fp) razf_tell(fp) -#define bam_seek(fp, pos, dir) razf_seek(fp, pos, dir) -#elif _IOLIB == 2 +#ifndef BAM_LITE #define BAM_VIRTUAL_OFFSET16 #include "bgzf.h" /*! @abstract BAM file handler */ @@ -72,18 +57,15 @@ typedef BGZF *bamFile; #define bam_write(fp, buf, size) bgzf_write(fp, buf, size) #define bam_tell(fp) bgzf_tell(fp) #define bam_seek(fp, pos, dir) bgzf_seek(fp, pos, dir) -#elif _IOLIB == 3 -#define BAM_VIRTUAL_OFFSET16 -#include "razf.h" -/*! @abstract BAM file handler */ -typedef RAZF *bamFile; -#define bam_open(fn, mode) razf_open2(fn, mode) -#define bam_dopen(fd, mode) razf_dopen2(fd, mode) -#define bam_close(fp) razf_close(fp) -#define bam_read(fp, buf, size) razf_read(fp, buf, size) -#define bam_write(fp, buf, size) razf_write(fp, buf, size) -#define bam_tell(fp) razf_tell2(fp) -#define bam_seek(fp, pos, dir) razf_seek2(fp, pos, dir) +#else +#define BAM_TRUE_OFFSET +#include +typedef gzFile bamFile; +#define bam_open(fn, mode) gzopen(fn, mode) +#define bam_dopen(fd, mode) gzdopen(fd, mode) +#define bam_close(fp) gzclose(fp) +#define bam_read(fp, buf, size) gzread(fp, buf, size) +/* no bam_write/bam_tell/bam_seek() here */ #endif /*! @typedef @@ -527,6 +509,8 @@ extern "C" { */ 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; @@ -541,9 +525,6 @@ extern "C" { /*! @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; @@ -600,8 +581,9 @@ extern "C" { @param ref_id the returned chromosome ID @param begin the returned start coordinate @param end the returned end coordinate + @return 0 on success; -1 on failure */ - void bam_parse_region(bam_header_t *header, const char *str, int *ref_id, int *begin, int *end); + int bam_parse_region(bam_header_t *header, const char *str, int *ref_id, int *begin, int *end); /*! @abstract Retrieve data of a tag @@ -624,7 +606,7 @@ extern "C" { void bam_aux_append(bam1_t *b, const char tag[2], char type, int len, uint8_t *data); - // uint8_t *bam_aux_get_core(bam1_t *b, const char tag[2]); // an alias of bam_aux_get() + uint8_t *bam_aux_get_core(bam1_t *b, const char tag[2]); // an alias of bam_aux_get() /*! @abstract Calculate the rightmost coordinate of an alignment on the