#define BCF_H
#include <stdint.h>
+#include <zlib.h>
#include "bgzf.h"
typedef struct {
- int fmt, len; // len is the unit length
+ uint32_t fmt;
+ int len; // len is the unit length
void *data;
// derived info: fmt, len
} bcf_ginfo_t;
} bcf_hdr_t;
typedef struct {
+ int is_vcf;
+ void *v;
BGZF *fp;
- bcf_hdr_t h;
} bcf_t;
struct __bcf_idx_t;
bcf_t *bcf_open(const char *fn, const char *mode);
int bcf_close(bcf_t *b);
- int bcf_read(bcf_t *bp, bcf1_t *b);
+ int bcf_read(bcf_t *bp, const bcf_hdr_t *h, bcf1_t *b);
int bcf_sync(int n_smpl, bcf1_t *b);
- int bcf_write(bcf_t *bp, const bcf1_t *b);
- int bcf_hdr_write(bcf_t *b);
+ int bcf_write(bcf_t *bp, const bcf_hdr_t *h, const bcf1_t *b);
+ bcf_hdr_t *bcf_hdr_read(bcf_t *b);
+ int bcf_hdr_write(bcf_t *b, const bcf_hdr_t *h);
int bcf_hdr_sync(bcf_hdr_t *b);
- int bcf_hdr_cpy(bcf_hdr_t *h, const bcf_hdr_t *h0);
+ void bcf_hdr_destroy(bcf_hdr_t *h);
int bcf_destroy(bcf1_t *b);
- char *bcf_fmt(bcf_t *bp, bcf1_t *b);
+ char *bcf_fmt(const bcf_hdr_t *h, bcf1_t *b);
+
+ int vcf_close(bcf_t *bp);
void *bcf_build_refhash(bcf_hdr_t *h);
void bcf_str2id_destroy(void *_hash);
}
#endif
+static inline uint32_t bcf_str2int(const char *str, int l)
+{
+ int i;
+ uint32_t x = 0;
+ for (i = 0; i < l && i < 4; ++i) {
+ if (str[i] == 0) return x;
+ x = x<<8 | str[i];
+ }
+ return x;
+}
+
#endif