X-Git-Url: http://woldlab.caltech.edu/gitweb/?p=samtools.git;a=blobdiff_plain;f=bcftools%2Fbcf.h;h=822ae5cf80fd7f9dc375259524935c933f088323;hp=36578956bbae06d4c216c121a2ddb3a94cad94d8;hb=0f906dafb2ad22371a753557562ef95c3034480d;hpb=8d2494d1fb7cd0fa7c63be5ffba8dd1a11457522 diff --git a/bcftools/bcf.h b/bcftools/bcf.h index 3657895..822ae5c 100644 --- a/bcftools/bcf.h +++ b/bcftools/bcf.h @@ -28,9 +28,23 @@ #ifndef BCF_H #define BCF_H +#define BCF_VERSION "0.1.17-dev (r973:277)" + #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 +88,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; @@ -117,6 +131,8 @@ extern "C" { int vcf_close(bcf_t *bp); // read the VCF/BCF header bcf_hdr_t *vcf_hdr_read(bcf_t *bp); + // read the sequence dictionary from a separate file; required for VCF->BCF conversion + int vcf_dictread(bcf_t *bp, bcf_hdr_t *h, const char *fn); // read a VCF/BCF record; return -1 on end-of-file and <-1 for errors int vcf_read(bcf_t *bp, bcf_hdr_t *h, bcf1_t *b); // write the VCF header @@ -128,10 +144,23 @@ extern "C" { int bcf_shrink_alt(bcf1_t *b, int n); // convert GL to PL int bcf_gl2pl(bcf1_t *b); + // if the site is an indel + int bcf_is_indel(const bcf1_t *b); + bcf_hdr_t *bcf_hdr_subsam(const bcf_hdr_t *h0, int n, char *const* samples, int *list); + int bcf_subsam(int n_smpl, int *list, bcf1_t *b); + // move GT to the first FORMAT field + int bcf_fix_gt(bcf1_t *b); + // update PL generated by old samtools + int bcf_fix_pl(bcf1_t *b); + // convert PL to GLF-like 10-likelihood GL + int bcf_gl10(const bcf1_t *b, uint8_t *gl); + // convert up to 4 INDEL alleles to GLF-like 10-likelihood GL + int bcf_gl10_indel(const bcf1_t *b, uint8_t *gl); // string hash table void *bcf_build_refhash(bcf_hdr_t *h); void bcf_str2id_destroy(void *_hash); + void bcf_str2id_thorough_destroy(void *_hash); int bcf_str2id_add(void *_hash, const char *str); int bcf_str2id(void *_hash, const char *str); void *bcf_str2id_init();