]> git.donarmstrong.com Git - samtools.git/blobdiff - bcftools/bcf.h
* put n_smpl to "bcf1_t" to simplify API a little
[samtools.git] / bcftools / bcf.h
index 09235740584413e1548e264424137e6784c0555f..92b2c0364e72503f189b0754da160e310cf034e3 100644 (file)
@@ -6,19 +6,20 @@
 #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;
 
 typedef struct {
        int32_t tid, pos;
-       uint32_t qual:8, l_str:24;
-       int m_str;
+       int32_t l_str, m_str;
+       float qual;
        char *str, *ref, *alt, *flt, *info, *fmt; // fmt, ref, alt and info point to str
        int n_gi, m_gi;
        bcf_ginfo_t *gi;
-       int n_alleles;
+       int n_alleles, n_smpl;
        // derived info: ref, alt, flt, info, fmt, n_gi, n_alleles
 } bcf1_t;
 
@@ -48,7 +49,7 @@ extern "C" {
        bcf_t *bcf_open(const char *fn, const char *mode);
        int bcf_close(bcf_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_sync(bcf1_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);
@@ -57,14 +58,24 @@ extern "C" {
        int bcf_destroy(bcf1_t *b);
        char *bcf_fmt(const bcf_hdr_t *h, bcf1_t *b);
 
+       bcf_t *vcf_open(const char *fn, const char *mode);
        int vcf_close(bcf_t *bp);
+       bcf_hdr_t *vcf_hdr_read(bcf_t *bp);
+       int vcf_hdr_write(bcf_t *bp, const bcf_hdr_t *h);
+       int vcf_write(bcf_t *bp, bcf_hdr_t *h, bcf1_t *b);
+       int vcf_read(bcf_t *bp, bcf_hdr_t *h, bcf1_t *b);
+
+       int bcf_shrink_alt(bcf1_t *b, int n);
+       int bcf_gl2pl(bcf1_t *b);
 
        void *bcf_build_refhash(bcf_hdr_t *h);
        void bcf_str2id_destroy(void *_hash);
+       int bcf_str2id_add(void *_hash, const char *str);
        int bcf_str2id(void *_hash, const char *str);
+       void *bcf_str2id_init();
 
        int bcf_idx_build(const char *fn);
-       uint64_t bcf_idx_query(const bcf_idx_t *idx, int tid, int beg, int end);
+       uint64_t bcf_idx_query(const bcf_idx_t *idx, int tid, int beg);
        int bcf_parse_region(void *str2id, const char *str, int *tid, int *begin, int *end);
        bcf_idx_t *bcf_idx_load(const char *fn);
        void bcf_idx_destroy(bcf_idx_t *idx);
@@ -73,4 +84,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