From 6c4bde51547b600c9afb0157e76b34f811081320 Mon Sep 17 00:00:00 2001 From: Heng Li Date: Wed, 10 Nov 2010 21:54:46 +0000 Subject: [PATCH] use zlib for direct reading when BCF_LITE is in use --- bcftools/bcf.c | 4 +++- bcftools/bcf.h | 14 +++++++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/bcftools/bcf.c b/bcftools/bcf.c index 05eae5b..bdc0a5e 100644 --- a/bcftools/bcf.c +++ b/bcftools/bcf.c @@ -13,7 +13,9 @@ bcf_t *bcf_open(const char *fn, const char *mode) } else { b->fp = strcmp(fn, "-")? bgzf_open(fn, mode) : bgzf_fdopen(fileno(stdin), mode); } - b->fp->owned_file = 1; +#ifndef BCF_LITE + b->fp->ownede_file = 1; +#endif return b; } diff --git a/bcftools/bcf.h b/bcftools/bcf.h index 89feeb8..f87ac1e 100644 --- a/bcftools/bcf.h +++ b/bcftools/bcf.h @@ -30,7 +30,19 @@ #include #include + +#ifndef BCF_LITE #include "bgzf.h" +typedef BGZF *bcfFile; +#else +typedef gzFile bcfFile; +#define bgzf_open(fn, mode) gzopen(fn, mode) +#define bgzf_fdopen(fd, mode) gzdopen(fd, mode) +#define bgzf_close(fp) gzclose(fp) +#define bgzf_read(fp, buf, len) gzread(fp, buf, len) +#define bgzf_write(fp, buf, len) +#define bgzf_flush(fp) +#endif /* A member in the structs below is said to "primary" if its content @@ -74,7 +86,7 @@ typedef struct { typedef struct { int is_vcf; // if the file in operation is a VCF void *v; // auxillary data structure for VCF - BGZF *fp; // file handler for BCF + bcfFile fp; // file handler for BCF } bcf_t; struct __bcf_idx_t; -- 2.39.2