]> git.donarmstrong.com Git - samtools.git/blobdiff - bcftools/bcf.h
* improved kstring (added kstrtok)
[samtools.git] / bcftools / bcf.h
index 1c0436a78a684cf68f222f3924d8346243c88e83..3c0ab2cf8a71853a51361eca248bd0df342b423e 100644 (file)
@@ -2,10 +2,12 @@
 #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;
@@ -32,8 +34,9 @@ typedef struct {
 } bcf_hdr_t;
 
 typedef struct {
+       int is_vcf;
+       void *v;
        BGZF *fp;
-       bcf_hdr_t h;
 } bcf_t;
 
 struct __bcf_idx_t;
@@ -45,14 +48,17 @@ extern "C" {
 
        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);
@@ -68,4 +74,15 @@ extern "C" {
 }
 #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