diff --git a/Makefile b/Makefile index b888509a0..5120b2480 100644 --- a/Makefile +++ b/Makefile @@ -101,7 +101,7 @@ lib-shared: libhts.so endif -PACKAGE_VERSION = 1.2 +PACKAGE_VERSION = 1.2.1 LIBHTS_SOVERSION = 1 diff --git a/NEWS b/NEWS index e060a1d33..c135613d7 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,10 @@ +Noteworthy changes in release 1.2.1 (3 February 2015) + +* Reinstated hts_file_type() and FT_* macros, which were available until 1.1 + but briefly removed in 1.2. This function is deprecated and will be removed + in a future release -- you should use hts_detect_format() etc instead + + Noteworthy changes in release 1.2 (2 February 2015) * HTSlib now has a configure script which checks your build environment diff --git a/hts.c b/hts.c index 7c3aeabb5..5f4d677e6 100644 --- a/hts.c +++ b/hts.c @@ -722,6 +722,29 @@ char **hts_readlines(const char *fn, int *_n) return s; } +// DEPRECATED: To be removed in a future HTSlib release +int hts_file_type(const char *fname) +{ + int len = strlen(fname); + if ( !strcasecmp(".vcf.gz",fname+len-7) ) return FT_VCF_GZ; + if ( !strcasecmp(".vcf",fname+len-4) ) return FT_VCF; + if ( !strcasecmp(".bcf",fname+len-4) ) return FT_BCF_GZ; + if ( !strcmp("-",fname) ) return FT_STDIN; + + hFILE *f = hopen(fname, "r"); + if (f == NULL) return 0; + + htsFormat fmt; + if (hts_detect_format(f, &fmt) < 0) { hclose_abruptly(f); return 0; } + if (hclose(f) < 0) return 0; + + switch (fmt.format) { + case vcf: return (fmt.compression == no_compression)? FT_VCF : FT_VCF_GZ; + case bcf: return (fmt.compression == no_compression)? FT_BCF : FT_BCF_GZ; + default: return 0; + } +} + /**************** *** Indexing *** ****************/ diff --git a/htsfile.1 b/htsfile.1 index 501055da4..b55cafa17 100644 --- a/htsfile.1 +++ b/htsfile.1 @@ -1,4 +1,4 @@ -.TH htsfile 1 "2 February 2015" "htslib-1.2" "Bioinformatics tools" +.TH htsfile 1 "3 February 2015" "htslib-1.2.1" "Bioinformatics tools" .SH NAME htsfile \- identify high-throughput sequencing data files .\" diff --git a/htslib/hts.h b/htslib/hts.h index 42e8c5832..084c1626b 100644 --- a/htslib/hts.h +++ b/htslib/hts.h @@ -379,6 +379,21 @@ extern "C" { int hts_itr_next(BGZF *fp, hts_itr_t *iter, void *r, void *data); const char **hts_idx_seqnames(const hts_idx_t *idx, int *n, hts_id2name_f getid, void *hdr); // free only the array, not the values + /** + * hts_file_type() - Convenience function to determine file type + * DEPRECATED: This function has been replaced by hts_detect_format(). + * It and these FT_* macros will be removed in a future HTSlib release. + */ + #define FT_UNKN 0 + #define FT_GZ 1 + #define FT_VCF 2 + #define FT_VCF_GZ (FT_GZ|FT_VCF) + #define FT_BCF (1<<2) + #define FT_BCF_GZ (FT_GZ|FT_BCF) + #define FT_STDIN (1<<3) + int hts_file_type(const char *fname); + + #ifdef __cplusplus } #endif diff --git a/tabix.1 b/tabix.1 index 5902cc922..55c0ebbee 100644 --- a/tabix.1 +++ b/tabix.1 @@ -1,4 +1,4 @@ -.TH tabix 1 "2 February 2015" "htslib-1.2" "Bioinformatics tools" +.TH tabix 1 "3 February 2015" "htslib-1.2.1" "Bioinformatics tools" .SH NAME .PP bgzip \- Block compression/decompression utility