--- htslib-0.2.0~rc3.orig/bgzf.c +++ htslib-0.2.0~rc3/bgzf.c @@ -143,14 +143,6 @@ return compress_level; } -// Close abortively-opened file, ignoring any errors that occur (unlikely) -static void close_noerr(hFILE *fp) -{ - int save = errno; - if (hclose(fp) != 0) { /* Ignore errors as we're already unwinding one */ } - errno = save; -} - BGZF *bgzf_open(const char *path, const char *mode) { BGZF *fp = 0; @@ -159,7 +151,7 @@ hFILE *fpr; if ((fpr = hopen(path, "r")) == 0) return 0; fp = bgzf_read_init(fpr); - if (fp == 0) { close_noerr(fpr); return NULL; } + if (fp == 0) { hclose_abruptly(fpr); return NULL; } fp->fp = fpr; } else if (strchr(mode, 'w')) { hFILE *fpw; @@ -181,7 +173,7 @@ hFILE *fpr; if ((fpr = hdopen(fd, "r")) == 0) return 0; fp = bgzf_read_init(fpr); - if (fp == 0) { close_noerr(fpr); return NULL; } // FIXME this closes fd + if (fp == 0) { hclose_abruptly(fpr); return NULL; } // FIXME this closes fd fp->fp = fpr; } else if (strchr(mode, 'w')) { hFILE *fpw; @@ -582,19 +574,6 @@ return -1; } -static ssize_t mt_write(BGZF *fp, const void *data, size_t length) -{ - const uint8_t *input = (const uint8_t*)data; - ssize_t rest = length; - while (rest) { - int copy_length = BGZF_BLOCK_SIZE - fp->block_offset < rest? BGZF_BLOCK_SIZE - fp->block_offset : rest; - memcpy((uint8_t*)fp->uncompressed_block + fp->block_offset, input, copy_length); - fp->block_offset += copy_length; input += copy_length; rest -= copy_length; - if (fp->block_offset == BGZF_BLOCK_SIZE) mt_lazy_flush(fp); - } - return length - rest; -} - #else // ~ #ifdef BGZF_MT int bgzf_mt(BGZF *fp, int n_threads, int n_sub_blks) @@ -646,21 +625,25 @@ return hwrite(fp->fp, data, length); const uint8_t *input = (const uint8_t*)data; - int block_length = BGZF_BLOCK_SIZE, bytes_written = 0; + ssize_t remaining = length; assert(fp->is_write); -#ifdef BGZF_MT - if (fp->mt) return mt_write(fp, data, length); -#endif - while (bytes_written < length) { + while (remaining > 0) { uint8_t* buffer = (uint8_t*)fp->uncompressed_block; - int copy_length = block_length - fp->block_offset < length - bytes_written? block_length - fp->block_offset : length - bytes_written; + int copy_length = BGZF_BLOCK_SIZE - fp->block_offset; + if (copy_length > remaining) copy_length = remaining; memcpy(buffer + fp->block_offset, input, copy_length); fp->block_offset += copy_length; input += copy_length; - bytes_written += copy_length; - if (fp->block_offset == block_length && bgzf_flush(fp)) break; + remaining -= copy_length; + if (fp->block_offset == BGZF_BLOCK_SIZE) { +#ifdef BGZF_MT + if (fp->mt) mt_lazy_flush(fp); + else +#endif + if (bgzf_flush(fp) != 0) break; + } } - return bytes_written; + return length - remaining; } ssize_t bgzf_raw_write(BGZF *fp, const void *data, size_t length) @@ -703,10 +686,12 @@ int bgzf_check_EOF(BGZF *fp) { uint8_t buf[28]; - off_t offset; - offset = htell(fp->fp); - if (hseek(fp->fp, -28, SEEK_END) < 0) { hclearerr(fp->fp); return 0; } - if ( hread(fp->fp, buf, 28) < 0 ) return -1; + off_t offset = htell(fp->fp); + if (hseek(fp->fp, -28, SEEK_END) < 0) { + if (errno == ESPIPE) { hclearerr(fp->fp); return 2; } + else return -1; + } + if ( hread(fp->fp, buf, 28) != 28 ) return -1; if ( hseek(fp->fp, offset, SEEK_SET) < 0 ) return -1; return (memcmp("\037\213\010\4\0\0\0\0\0\377\6\0\102\103\2\0\033\0\3\0\0\0\0\0\0\0\0\0", buf, 28) == 0)? 1 : 0; } --- htslib-0.2.0~rc3.orig/cram/cram_io.c +++ htslib-0.2.0~rc3/cram/cram_io.c @@ -82,7 +82,7 @@ #include "hfile.h" #define paranoid_hclose(fp) (hclose(fp)) #else -#define hclose(fp) (fclose(fp)) +#define hclose_abruptly(fp) (fclose(fp)) #define hflush(fp) (fflush(fp)) #define hgetc(fp) (getc(fp)) #define hputc(c, fp) (putc((c), (fp))) @@ -3211,7 +3211,7 @@ fd = cram_dopen(fp, filename, mode); if (!fd) - (void)hclose(fp); + hclose_abruptly(fp); return fd; } --- htslib-0.2.0~rc3.orig/debian/changelog +++ htslib-0.2.0~rc3/debian/changelog @@ -0,0 +1,5 @@ +htslib (0.2.0~rc3-1) unstable; urgency=low + + * Initial release. (Closes: #729282) + + -- Charles Plessy Sat, 16 Nov 2013 15:35:03 +0900 --- htslib-0.2.0~rc3.orig/debian/compat +++ htslib-0.2.0~rc3/debian/compat @@ -0,0 +1 @@ +9 --- htslib-0.2.0~rc3.orig/debian/control +++ htslib-0.2.0~rc3/debian/control @@ -0,0 +1,54 @@ +Source: htslib +Maintainer: Debian Med Packaging Team +Uploaders: Charles Plessy +Section: libs +Priority: optional +Build-Depends: debhelper (>= 9), + dh-exec, + zlib1g-dev +Standards-Version: 3.9.5 +Vcs-Browser: http://anonscm.debian.org/gitweb/?p=debian-med/htslib.git +Vcs-Git: git://anonscm.debian.org/debian-med/htslib.git -b debian/unstable +Homepage: https://github.com/samtools/htslib + +Package: libhts0 +Architecture: any +Multi-Arch: same +Depends: ${shlibs:Depends}, + ${misc:Depends} +Description: C library for high-throughput sequencing data formats + HTSlib is a unified C library for accessing common file formats, such as SAM + (Sequence Alignment/Map) and VCF (Variant Call Format), used for nucleic acid + sequence data obtained by high-throughput sequencing. + . + HTSlib implements a generalized BAM (binary SAM) index. The HTSlib file + reader first looks for the new index and then for the old if the new index is + absent. + . + HTSlib is still experimental. It has not been tested on large-scale real + data. Some useful APIs are missing. + +Package: libhts-dev +Architecture: any +Multi-Arch: same +Section: libdevel +Depends: libhts0 (= ${binary:Version}), + ${shlibs:Depends}, + ${misc:Depends} +Description: Development files for the HTSlib + HTSlib is a unified C library for accessing common file formats, such as SAM + (Sequence Alignment/Map) and VCF (Variant Call Format), used for nucleic acid + sequence data obtained by high-throughput sequencing. + . + This package contains development files: headers, static library, manual pages, + etc. + +Package: htslib-test +Architecture: all +Depends: ${misc:Depends} +Description: Test data for HTSlib + HTSlib is a unified C library for accessing common file formats, such as SAM + (Sequence Alignment/Map) and VCF (Variant Call Format), used for nucleic acid + sequence data obtained by high-throughput sequencing. + . + This package contains test files and scripts for the HTSlib. --- htslib-0.2.0~rc3.orig/debian/copyright +++ htslib-0.2.0~rc3/debian/copyright @@ -0,0 +1,143 @@ +Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ +Source: https://github.com/samtools/htslib + +Files: * +Copyright: (C) 2012-2013 Genome Research Ltd. + (c) 2008 Broad Institute / Massachusetts Institute of Technology + The Wellcome Trust Sanger Institute + (c) 2008, 2009, 2011 by Attractive Chaos +License: MIT + +Files: cram/* +Copyright: (c) 2012-2013 Genome Research Ltd. + (c) 1995-1996 MEDICAL RESEARCH COUNCIL +License: Various_BSD-3-Clause + The files in the 'cram' directory are under one or both of the following + licenses. + . + --------------------------------------------------------------------------- + . + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + . + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + . + 2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + . + 3. Neither the names Genome Research Ltd and Wellcome Trust Sanger + Institute nor the names of its contributors may be used to endorse or promote + products derived from this software without specific prior written permission. + . + THIS SOFTWARE IS PROVIDED BY GENOME RESEARCH LTD AND CONTRIBUTORS "AS IS" AND + ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL GENOME RESEARCH LTD OR CONTRIBUTORS BE LIABLE + FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + . + --------------------------------------------------------------------------- + . + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + . + 1 Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + . + 2 Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + . + 3 Neither the name of the MEDICAL RESEARCH COUNCIL, THE LABORATORY OF + MOLECULAR BIOLOGY nor the names of its contributors may be used to endorse or + promote products derived from this software without specific prior written + permission. + . + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Files: cram/md5.? +Copyright: No copyright is claimed +License: solar-MD5 + This is an OpenSSL-compatible implementation of the RSA Data Security, Inc. + MD5 Message-Digest Algorithm (RFC 1321). + . + Homepage: + http://openwall.info/wiki/people/solar/software/public-domain-source-code/md5 + . + Author: + Alexander Peslyak, better known as Solar Designer + . + This software was written by Alexander Peslyak in 2001. No copyright is + claimed, and the software is hereby placed in the public domain. + In case this attempt to disclaim copyright and place the software in the + public domain is deemed null and void, then the software is + Copyright (c) 2001 Alexander Peslyak and it is hereby released to the + general public under the following terms: + . + Redistribution and use in source and binary forms, with or without + modification, are permitted. + . + There's ABSOLUTELY NO WARRANTY, express or implied. + +Files: htslib/razf.? +Copyright: 2008, Jue Ruan , Heng Li +License: BSD-2-clause~with-minor-differences-in-the-disclaimer + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + . + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + . + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + . + THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + SUCH DAMAGE. + +License: MIT + Permission is hereby granted, free of charge, to any person obtaining + a copy of this software and associated documentation files (the + "Software"), to deal in the Software without restriction, including + without limitation the rights to use, copy, modify, merge, publish, + distribute, sublicense, and/or sell copies of the Software, and to + permit persons to whom the Software is furnished to do so, subject to + the following conditions: + . + The above copyright notice and this permission notice shall be + included in all copies or substantial portions of the Software. + . + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS + BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. + --- htslib-0.2.0~rc3.orig/debian/gbp.conf +++ htslib-0.2.0~rc3/debian/gbp.conf @@ -0,0 +1,15 @@ +# This package uses pristine-tar, and does not follow the canonical layout of git-buildpackage. + +[DEFAULT] +# the default branch for upstream sources: +upstream-branch = develop +# the default branch for the debian patch: +debian-branch = debian/unstable +# the default tag formats used: +upstream-tag = %(version)s +# use pristine-tar: +pristine-tar = True + +[dch] +# include 7 digits of the commit id in the changelog enty: +id-length = 7 --- htslib-0.2.0~rc3.orig/debian/htslib-test.install +++ htslib-0.2.0~rc3/debian/htslib-test.install @@ -0,0 +1 @@ +test/* /usr/share/htslib-test --- htslib-0.2.0~rc3.orig/debian/libhts-dev.install +++ htslib-0.2.0~rc3/debian/libhts-dev.install @@ -0,0 +1,5 @@ +#! /usr/bin/dh-exec +usr/include/* usr/include/ +usr/lib/*.a usr/lib/${DEB_HOST_MULTIARCH}/ +usr/lib/*.so usr/lib/${DEB_HOST_MULTIARCH}/ +usr/share/man/man5/* usr/share/man/man5/ --- htslib-0.2.0~rc3.orig/debian/libhts0.install +++ htslib-0.2.0~rc3/debian/libhts0.install @@ -0,0 +1,2 @@ +#! /usr/bin/dh-exec +usr/lib/libhts.so.* usr/lib/${DEB_HOST_MULTIARCH}/ --- htslib-0.2.0~rc3.orig/debian/libhts0.symbols +++ htslib-0.2.0~rc3/debian/libhts0.symbols @@ -0,0 +1,507 @@ +libhts.so.0 libhts0 #MINVER# + MD5_Final@Base 0.2.0~rc3 + MD5_Init@Base 0.2.0~rc3 + MD5_Update@Base 0.2.0~rc3 + _reader_next_line@Base 0.2.0~rc3 + bam_aux2A@Base 0.2.0~rc3 + bam_aux2Z@Base 0.2.0~rc3 + bam_aux2f@Base 0.2.0~rc3 + bam_aux2i@Base 0.2.0~rc3 + bam_aux_append@Base 0.2.0~rc3 + bam_aux_del@Base 0.2.0~rc3 + bam_aux_get@Base 0.2.0~rc3 + bam_aux_type2size@Base 0.2.0~rc3 + bam_cigar2qlen@Base 0.2.0~rc3 + bam_cigar2rlen@Base 0.2.0~rc3 + bam_construct_seq@Base 0.2.0~rc3 + bam_copy1@Base 0.2.0~rc3 + bam_destroy1@Base 0.2.0~rc3 + bam_endpos@Base 0.2.0~rc3 + bam_hdr_destroy@Base 0.2.0~rc3 + bam_hdr_init@Base 0.2.0~rc3 + bam_hdr_read@Base 0.2.0~rc3 + bam_hdr_write@Base 0.2.0~rc3 + bam_header_to_cram@Base 0.2.0~rc3 + bam_index_build@Base 0.2.0~rc3 + bam_init1@Base 0.2.0~rc3 + bam_mplp_auto@Base 0.2.0~rc3 + bam_mplp_destroy@Base 0.2.0~rc3 + bam_mplp_init@Base 0.2.0~rc3 + bam_mplp_set_maxcnt@Base 0.2.0~rc3 + bam_name2id@Base 0.2.0~rc3 + bam_plp_auto@Base 0.2.0~rc3 + bam_plp_destroy@Base 0.2.0~rc3 + bam_plp_init@Base 0.2.0~rc3 + bam_plp_next@Base 0.2.0~rc3 + bam_plp_push@Base 0.2.0~rc3 + bam_plp_reset@Base 0.2.0~rc3 + bam_plp_set_mask@Base 0.2.0~rc3 + bam_plp_set_maxcnt@Base 0.2.0~rc3 + bam_read1@Base 0.2.0~rc3 + bam_readrec@Base 0.2.0~rc3 + bam_write1@Base 0.2.0~rc3 + bcf_add_filter@Base 0.2.0~rc3 + bcf_calc_ac@Base 0.2.0~rc3 + bcf_clear@Base 0.2.0~rc3 + bcf_destroy@Base 0.2.0~rc3 + bcf_empty1@Base 0.2.0~rc3 + bcf_enc_vchar@Base 0.2.0~rc3 + bcf_enc_vfloat@Base 0.2.0~rc3 + bcf_enc_vint@Base 0.2.0~rc3 + bcf_float_missing@Base 0.2.0~rc3 + bcf_float_vector_end@Base 0.2.0~rc3 + bcf_fmt_array@Base 0.2.0~rc3 + bcf_fmt_sized_array@Base 0.2.0~rc3 + bcf_get_fmt@Base 0.2.0~rc3 + bcf_get_format_values@Base 0.2.0~rc3 + bcf_get_info@Base 0.2.0~rc3 + bcf_get_info_values@Base 0.2.0~rc3 + bcf_get_variant_type@Base 0.2.0~rc3 + bcf_get_variant_types@Base 0.2.0~rc3 + bcf_gt_type@Base 0.2.0~rc3 + bcf_hdr_add_hrec@Base 0.2.0~rc3 + bcf_hdr_add_sample@Base 0.2.0~rc3 + bcf_hdr_append@Base 0.2.0~rc3 + bcf_hdr_check_sanity@Base 0.2.0~rc3 + bcf_hdr_destroy@Base 0.2.0~rc3 + bcf_hdr_dup@Base 0.2.0~rc3 + bcf_hdr_fmt_text@Base 0.2.0~rc3 + bcf_hdr_get_hrec@Base 0.2.0~rc3 + bcf_hdr_id2int@Base 0.2.0~rc3 + bcf_hdr_init@Base 0.2.0~rc3 + bcf_hdr_parse@Base 0.2.0~rc3 + bcf_hdr_parse_line@Base 0.2.0~rc3 + bcf_hdr_parse_sample_line@Base 0.2.0~rc3 + bcf_hdr_printf@Base 0.2.0~rc3 + bcf_hdr_read@Base 0.2.0~rc3 + bcf_hdr_register_hrec@Base 0.2.0~rc3 + bcf_hdr_seqnames@Base 0.2.0~rc3 + bcf_hdr_set@Base 0.2.0~rc3 + bcf_hdr_subset@Base 0.2.0~rc3 + bcf_hdr_sync@Base 0.2.0~rc3 + bcf_hdr_write@Base 0.2.0~rc3 + bcf_header_debug@Base 0.2.0~rc3 + bcf_hrec_add_key@Base 0.2.0~rc3 + bcf_hrec_debug@Base 0.2.0~rc3 + bcf_hrec_destroy@Base 0.2.0~rc3 + bcf_hrec_dup@Base 0.2.0~rc3 + bcf_hrec_find_key@Base 0.2.0~rc3 + bcf_hrec_set_val@Base 0.2.0~rc3 + bcf_index@Base 0.2.0~rc3 + bcf_index_build@Base 0.2.0~rc3 + bcf_init@Base 0.2.0~rc3 + bcf_is_snp@Base 0.2.0~rc3 + bcf_read@Base 0.2.0~rc3 + bcf_readrec@Base 0.2.0~rc3 + bcf_remove_alleles@Base 0.2.0~rc3 + bcf_sr_add_reader@Base 0.2.0~rc3 + bcf_sr_destroy@Base 0.2.0~rc3 + bcf_sr_init@Base 0.2.0~rc3 + bcf_sr_next_line@Base 0.2.0~rc3 + bcf_sr_regions_destroy@Base 0.2.0~rc3 + bcf_sr_regions_init@Base 0.2.0~rc3 + bcf_sr_regions_next@Base 0.2.0~rc3 + bcf_sr_regions_query@Base 0.2.0~rc3 + bcf_sr_regions_seek@Base 0.2.0~rc3 + bcf_sr_set_regions@Base 0.2.0~rc3 + bcf_sr_set_samples@Base 0.2.0~rc3 + bcf_sr_set_targets@Base 0.2.0~rc3 + bcf_subset@Base 0.2.0~rc3 + bcf_sweep_bwd@Base 0.2.0~rc3 + bcf_sweep_destroy@Base 0.2.0~rc3 + bcf_sweep_fwd@Base 0.2.0~rc3 + bcf_sweep_hdr@Base 0.2.0~rc3 + bcf_sweep_init@Base 0.2.0~rc3 + bcf_trim_alleles@Base 0.2.0~rc3 + bcf_type_shift@Base 0.2.0~rc3 + bcf_unpack@Base 0.2.0~rc3 + bcf_update_alleles@Base 0.2.0~rc3 + bcf_update_alleles_str@Base 0.2.0~rc3 + bcf_update_filter@Base 0.2.0~rc3 + bcf_update_format@Base 0.2.0~rc3 + bcf_update_id@Base 0.2.0~rc3 + bcf_update_info@Base 0.2.0~rc3 + bcf_write@Base 0.2.0~rc3 + bgzf_check_EOF@Base 0.2.0~rc3 + bgzf_close@Base 0.2.0~rc3 + bgzf_dopen@Base 0.2.0~rc3 + bgzf_flush@Base 0.2.0~rc3 + bgzf_flush_try@Base 0.2.0~rc3 + bgzf_getc@Base 0.2.0~rc3 + bgzf_getline@Base 0.2.0~rc3 + bgzf_hopen@Base 0.2.0~rc3 + bgzf_index_add_block@Base 0.2.0~rc3 + bgzf_index_build_init@Base 0.2.0~rc3 + bgzf_index_destroy@Base 0.2.0~rc3 + bgzf_index_dump@Base 0.2.0~rc3 + bgzf_index_load@Base 0.2.0~rc3 + bgzf_is_bgzf@Base 0.2.0~rc3 + bgzf_mt@Base 0.2.0~rc3 + bgzf_open@Base 0.2.0~rc3 + bgzf_raw_read@Base 0.2.0~rc3 + bgzf_raw_write@Base 0.2.0~rc3 + bgzf_read@Base 0.2.0~rc3 + bgzf_read_block@Base 0.2.0~rc3 + bgzf_seek@Base 0.2.0~rc3 + bgzf_set_cache_size@Base 0.2.0~rc3 + bgzf_useek@Base 0.2.0~rc3 + bgzf_utell@Base 0.2.0~rc3 + bgzf_write@Base 0.2.0~rc3 + cram_beta_decode_char@Base 0.2.0~rc3 + cram_beta_decode_free@Base 0.2.0~rc3 + cram_beta_decode_init@Base 0.2.0~rc3 + cram_beta_decode_int@Base 0.2.0~rc3 + cram_beta_encode_char@Base 0.2.0~rc3 + cram_beta_encode_free@Base 0.2.0~rc3 + cram_beta_encode_init@Base 0.2.0~rc3 + cram_beta_encode_int@Base 0.2.0~rc3 + cram_beta_encode_store@Base 0.2.0~rc3 + cram_block_method2str@Base 0.2.0~rc3 + cram_byte_array_len_decode@Base 0.2.0~rc3 + cram_byte_array_len_decode_free@Base 0.2.0~rc3 + cram_byte_array_len_decode_init@Base 0.2.0~rc3 + cram_byte_array_len_encode@Base 0.2.0~rc3 + cram_byte_array_len_encode_free@Base 0.2.0~rc3 + cram_byte_array_len_encode_init@Base 0.2.0~rc3 + cram_byte_array_len_encode_store@Base 0.2.0~rc3 + cram_byte_array_stop_decode_block@Base 0.2.0~rc3 + cram_byte_array_stop_decode_char@Base 0.2.0~rc3 + cram_byte_array_stop_decode_free@Base 0.2.0~rc3 + cram_byte_array_stop_decode_init@Base 0.2.0~rc3 + cram_byte_array_stop_encode@Base 0.2.0~rc3 + cram_byte_array_stop_encode_free@Base 0.2.0~rc3 + cram_byte_array_stop_encode_init@Base 0.2.0~rc3 + cram_byte_array_stop_encode_store@Base 0.2.0~rc3 + cram_close@Base 0.2.0~rc3 + cram_compress_block@Base 0.2.0~rc3 + cram_content_type2str@Base 0.2.0~rc3 + cram_decode_TD@Base 0.2.0~rc3 + cram_decode_compression_header@Base 0.2.0~rc3 + cram_decode_slice@Base 0.2.0~rc3 + cram_decode_slice_header@Base 0.2.0~rc3 + cram_decode_slice_mt@Base 0.2.0~rc3 + cram_decode_slice_thread@Base 0.2.0~rc3 + cram_decoder_init@Base 0.2.0~rc3 + cram_dopen@Base 0.2.0~rc3 + cram_encode_compression_header@Base 0.2.0~rc3 + cram_encode_container@Base 0.2.0~rc3 + cram_encode_slice_header@Base 0.2.0~rc3 + cram_encoder_init@Base 0.2.0~rc3 + cram_encoding2str@Base 0.2.0~rc3 + cram_eof@Base 0.2.0~rc3 + cram_external_decode_block@Base 0.2.0~rc3 + cram_external_decode_char@Base 0.2.0~rc3 + cram_external_decode_free@Base 0.2.0~rc3 + cram_external_decode_init@Base 0.2.0~rc3 + cram_external_decode_int@Base 0.2.0~rc3 + cram_external_encode@Base 0.2.0~rc3 + cram_external_encode_free@Base 0.2.0~rc3 + cram_external_encode_init@Base 0.2.0~rc3 + cram_external_encode_store@Base 0.2.0~rc3 + cram_flush@Base 0.2.0~rc3 + cram_flush_container@Base 0.2.0~rc3 + cram_flush_container_mt@Base 0.2.0~rc3 + cram_flush_thread@Base 0.2.0~rc3 + cram_free_block@Base 0.2.0~rc3 + cram_free_compression_header@Base 0.2.0~rc3 + cram_free_container@Base 0.2.0~rc3 + cram_free_file_def@Base 0.2.0~rc3 + cram_free_slice@Base 0.2.0~rc3 + cram_free_slice_header@Base 0.2.0~rc3 + cram_gamma_decode@Base 0.2.0~rc3 + cram_gamma_decode_free@Base 0.2.0~rc3 + cram_gamma_decode_init@Base 0.2.0~rc3 + cram_get_bam_seq@Base 0.2.0~rc3 + cram_get_ref@Base 0.2.0~rc3 + cram_get_seq@Base 0.2.0~rc3 + cram_header_to_bam@Base 0.2.0~rc3 + cram_huffman_decode_char0@Base 0.2.0~rc3 + cram_huffman_decode_char@Base 0.2.0~rc3 + cram_huffman_decode_free@Base 0.2.0~rc3 + cram_huffman_decode_init@Base 0.2.0~rc3 + cram_huffman_decode_int0@Base 0.2.0~rc3 + cram_huffman_decode_int@Base 0.2.0~rc3 + cram_huffman_encode_char0@Base 0.2.0~rc3 + cram_huffman_encode_char@Base 0.2.0~rc3 + cram_huffman_encode_free@Base 0.2.0~rc3 + cram_huffman_encode_init@Base 0.2.0~rc3 + cram_huffman_encode_int0@Base 0.2.0~rc3 + cram_huffman_encode_int@Base 0.2.0~rc3 + cram_huffman_encode_store@Base 0.2.0~rc3 + cram_index_free@Base 0.2.0~rc3 + cram_index_load@Base 0.2.0~rc3 + cram_index_query@Base 0.2.0~rc3 + cram_load_reference@Base 0.2.0~rc3 + cram_new_block@Base 0.2.0~rc3 + cram_new_compression_header@Base 0.2.0~rc3 + cram_new_container@Base 0.2.0~rc3 + cram_new_metrics@Base 0.2.0~rc3 + cram_new_slice@Base 0.2.0~rc3 + cram_open@Base 0.2.0~rc3 + cram_put_bam_seq@Base 0.2.0~rc3 + cram_read_SAM_hdr@Base 0.2.0~rc3 + cram_read_block@Base 0.2.0~rc3 + cram_read_container@Base 0.2.0~rc3 + cram_read_file_def@Base 0.2.0~rc3 + cram_read_slice@Base 0.2.0~rc3 + cram_ref_decr@Base 0.2.0~rc3 + cram_ref_incr@Base 0.2.0~rc3 + cram_ref_load@Base 0.2.0~rc3 + cram_seek@Base 0.2.0~rc3 + cram_seek_to_refpos@Base 0.2.0~rc3 + cram_set_header@Base 0.2.0~rc3 + cram_set_option@Base 0.2.0~rc3 + cram_set_voption@Base 0.2.0~rc3 + cram_stats_add@Base 0.2.0~rc3 + cram_stats_create@Base 0.2.0~rc3 + cram_stats_del@Base 0.2.0~rc3 + cram_stats_dump@Base 0.2.0~rc3 + cram_stats_encoding@Base 0.2.0~rc3 + cram_stats_free@Base 0.2.0~rc3 + cram_subexp_decode@Base 0.2.0~rc3 + cram_subexp_decode_free@Base 0.2.0~rc3 + cram_subexp_decode_init@Base 0.2.0~rc3 + cram_uncompress_block@Base 0.2.0~rc3 + cram_write_SAM_hdr@Base 0.2.0~rc3 + cram_write_block@Base 0.2.0~rc3 + cram_write_container@Base 0.2.0~rc3 + cram_write_file_def@Base 0.2.0~rc3 + debug_buffer@Base 0.2.0~rc3 + debug_buffers@Base 0.2.0~rc3 + download_and_open@Base 0.2.0~rc3 + expand_cache_path@Base 0.2.0~rc3 + fai_build@Base 0.2.0~rc3 + fai_build_core@Base 0.2.0~rc3 + fai_destroy@Base 0.2.0~rc3 + fai_fetch@Base 0.2.0~rc3 + fai_load@Base 0.2.0~rc3 + fai_read@Base 0.2.0~rc3 + fai_save@Base 0.2.0~rc3 + faidx_fetch_nseq@Base 0.2.0~rc3 + faidx_fetch_seq@Base 0.2.0~rc3 + file_exists@Base 0.2.0~rc3 + file_size@Base 0.2.0~rc3 + flen@Base 0.2.0~rc3 + hclose@Base 0.2.0~rc3 + hclose_abruptly@Base 0.2.0~rc3 + hdopen@Base 0.2.0~rc3 + hfile_destroy@Base 0.2.0~rc3 + hfile_init@Base 0.2.0~rc3 + hfile_oflags@Base 0.2.0~rc3 + hflush@Base 0.2.0~rc3 + hgetc2@Base 0.2.0~rc3 + hopen@Base 0.2.0~rc3 + hopen_net@Base 0.2.0~rc3 + hpeek@Base 0.2.0~rc3 + hputc2@Base 0.2.0~rc3 + hputs2@Base 0.2.0~rc3 + hread2@Base 0.2.0~rc3 + hseek@Base 0.2.0~rc3 + hts_close@Base 0.2.0~rc3 + hts_file_type@Base 0.2.0~rc3 + hts_get_bgzfp@Base 0.2.0~rc3 + hts_getline@Base 0.2.0~rc3 + hts_idx_destroy@Base 0.2.0~rc3 + hts_idx_finish@Base 0.2.0~rc3 + hts_idx_get_meta@Base 0.2.0~rc3 + hts_idx_getfn@Base 0.2.0~rc3 + hts_idx_init@Base 0.2.0~rc3 + hts_idx_load@Base 0.2.0~rc3 + hts_idx_load_local@Base 0.2.0~rc3 + hts_idx_push@Base 0.2.0~rc3 + hts_idx_save@Base 0.2.0~rc3 + hts_idx_set_meta@Base 0.2.0~rc3 + hts_itr_destroy@Base 0.2.0~rc3 + hts_itr_next@Base 0.2.0~rc3 + hts_itr_query@Base 0.2.0~rc3 + hts_itr_querys@Base 0.2.0~rc3 + hts_open@Base 0.2.0~rc3 + hts_parse_reg@Base 0.2.0~rc3 + hts_readlines@Base 0.2.0~rc3 + hts_set_fai_filename@Base 0.2.0~rc3 + hts_useek@Base 0.2.0~rc3 + hts_utell@Base 0.2.0~rc3 + hts_verbose@Base 0.2.0~rc3 + hts_version@Base 0.2.0~rc3 + hwrite2@Base 0.2.0~rc3 + int32_decode@Base 0.2.0~rc3 + int32_encode@Base 0.2.0~rc3 + int32_get@Base 0.2.0~rc3 + int32_put@Base 0.2.0~rc3 + is_directory@Base 0.2.0~rc3 + is_file@Base 0.2.0~rc3 + itf8_decode@Base 0.2.0~rc3 + itf8_encode@Base 0.2.0~rc3 + itf8_put_blk@Base 0.2.0~rc3 + kf_betai@Base 0.2.0~rc3 + kf_erfc@Base 0.2.0~rc3 + kf_gammap@Base 0.2.0~rc3 + kf_gammaq@Base 0.2.0~rc3 + kf_lgamma@Base 0.2.0~rc3 + kftp_connect@Base 0.2.0~rc3 + kftp_connect_file@Base 0.2.0~rc3 + kftp_parse_url@Base 0.2.0~rc3 + kftp_reconnect@Base 0.2.0~rc3 + kh_clear_s2i@Base 0.2.0~rc3 + kh_del_s2i@Base 0.2.0~rc3 + kh_destroy_s2i@Base 0.2.0~rc3 + kh_get_s2i@Base 0.2.0~rc3 + kh_init_s2i@Base 0.2.0~rc3 + kh_put_s2i@Base 0.2.0~rc3 + kh_resize_s2i@Base 0.2.0~rc3 + khttp_connect_file@Base 0.2.0~rc3 + khttp_parse_url@Base 0.2.0~rc3 + kmemmem@Base 0.2.0~rc3 + knet_close@Base 0.2.0~rc3 + knet_dopen@Base 0.2.0~rc3 + knet_open@Base 0.2.0~rc3 + knet_read@Base 0.2.0~rc3 + knet_seek@Base 0.2.0~rc3 + ks_combsort__off@Base 0.2.0~rc3 + ks_destroy@Base 0.2.0~rc3 + ks_getuntil2@Base 0.2.0~rc3 + ks_heapadjust__off@Base 0.2.0~rc3 + ks_heapmake__off@Base 0.2.0~rc3 + ks_heapsort__off@Base 0.2.0~rc3 + ks_init@Base 0.2.0~rc3 + ks_introsort__off@Base 0.2.0~rc3 + ks_ksmall__off@Base 0.2.0~rc3 + ks_mergesort__off@Base 0.2.0~rc3 + ks_shuffle__off@Base 0.2.0~rc3 + ksplit_core@Base 0.2.0~rc3 + ksprintf@Base 0.2.0~rc3 + kstrnstr@Base 0.2.0~rc3 + kstrstr@Base 0.2.0~rc3 + kstrtok@Base 0.2.0~rc3 + kt_fisher_exact@Base 0.2.0~rc3 + kvsprintf@Base 0.2.0~rc3 + ltf8_decode@Base 0.2.0~rc3 + ltf8_get@Base 0.2.0~rc3 + ltf8_put@Base 0.2.0~rc3 + mfascii@Base 0.2.0~rc3 + mfclose@Base 0.2.0~rc3 + mfcreate@Base 0.2.0~rc3 + mfcreate_from@Base 0.2.0~rc3 + mfdestroy@Base 0.2.0~rc3 + mfdetach@Base 0.2.0~rc3 + mfeof@Base 0.2.0~rc3 + mfflush@Base 0.2.0~rc3 + mfgetc@Base 0.2.0~rc3 + mfgets@Base 0.2.0~rc3 + mfopen@Base 0.2.0~rc3 + mfprintf@Base 0.2.0~rc3 + mfread@Base 0.2.0~rc3 + mfrecreate@Base 0.2.0~rc3 + mfreopen@Base 0.2.0~rc3 + mfseek@Base 0.2.0~rc3 + mftell@Base 0.2.0~rc3 + mftruncate@Base 0.2.0~rc3 + mfwrite@Base 0.2.0~rc3 + mkdir_prefix@Base 0.2.0~rc3 + mrewind@Base 0.2.0~rc3 + mstderr@Base 0.2.0~rc3 + mstdin@Base 0.2.0~rc3 + mstdout@Base 0.2.0~rc3 + mungetc@Base 0.2.0~rc3 + mygetline@Base 0.2.0~rc3 + open_path_mfile@Base 0.2.0~rc3 + paranoid_fclose@Base 0.2.0~rc3 + pool_alloc@Base 0.2.0~rc3 + pool_create@Base 0.2.0~rc3 + pool_destroy@Base 0.2.0~rc3 + pool_free@Base 0.2.0~rc3 + razf_close@Base 0.2.0~rc3 + razf_dopen2@Base 0.2.0~rc3 + razf_dopen@Base 0.2.0~rc3 + razf_get_data_size@Base 0.2.0~rc3 + razf_jump@Base 0.2.0~rc3 + razf_open2@Base 0.2.0~rc3 + razf_open@Base 0.2.0~rc3 + razf_read@Base 0.2.0~rc3 + razf_seek2@Base 0.2.0~rc3 + razf_seek@Base 0.2.0~rc3 + razf_skip@Base 0.2.0~rc3 + razf_tell2@Base 0.2.0~rc3 + razf_write@Base 0.2.0~rc3 + refs2id@Base 0.2.0~rc3 + refs_free@Base 0.2.0~rc3 + sam_format1@Base 0.2.0~rc3 + sam_hdr_PG_ID@Base 0.2.0~rc3 + sam_hdr_add@Base 0.2.0~rc3 + sam_hdr_add_PG@Base 0.2.0~rc3 + sam_hdr_add_lines@Base 0.2.0~rc3 + sam_hdr_decr_ref@Base 0.2.0~rc3 + sam_hdr_dump@Base 0.2.0~rc3 + sam_hdr_dup@Base 0.2.0~rc3 + sam_hdr_find@Base 0.2.0~rc3 + sam_hdr_find_key@Base 0.2.0~rc3 + sam_hdr_find_line@Base 0.2.0~rc3 + sam_hdr_find_rg@Base 0.2.0~rc3 + sam_hdr_free@Base 0.2.0~rc3 + sam_hdr_incr_ref@Base 0.2.0~rc3 + sam_hdr_length@Base 0.2.0~rc3 + sam_hdr_link_pg@Base 0.2.0~rc3 + sam_hdr_name2ref@Base 0.2.0~rc3 + sam_hdr_new@Base 0.2.0~rc3 + sam_hdr_parse@Base 0.2.0~rc3 + sam_hdr_parse_@Base 0.2.0~rc3 + sam_hdr_read@Base 0.2.0~rc3 + sam_hdr_rebuild@Base 0.2.0~rc3 + sam_hdr_str@Base 0.2.0~rc3 + sam_hdr_update@Base 0.2.0~rc3 + sam_hdr_vadd@Base 0.2.0~rc3 + sam_hdr_write@Base 0.2.0~rc3 + sam_parse1@Base 0.2.0~rc3 + sam_read1@Base 0.2.0~rc3 + sam_write1@Base 0.2.0~rc3 + seq_nt16_str@Base 0.2.0~rc3 + seq_nt16_table@Base 0.2.0~rc3 + string_alloc@Base 0.2.0~rc3 + string_dup@Base 0.2.0~rc3 + string_ndup@Base 0.2.0~rc3 + string_pool_create@Base 0.2.0~rc3 + string_pool_destroy@Base 0.2.0~rc3 + stringify_argv@Base 0.2.0~rc3 + t_pool_delete_result@Base 0.2.0~rc3 + t_pool_destroy@Base 0.2.0~rc3 + t_pool_dispatch2@Base 0.2.0~rc3 + t_pool_dispatch@Base 0.2.0~rc3 + t_pool_flush@Base 0.2.0~rc3 + t_pool_init@Base 0.2.0~rc3 + t_pool_next_result@Base 0.2.0~rc3 + t_pool_next_result_wait@Base 0.2.0~rc3 + t_pool_results_queue_empty@Base 0.2.0~rc3 + t_pool_results_queue_len@Base 0.2.0~rc3 + t_pool_results_queue_sz@Base 0.2.0~rc3 + t_results_queue_destroy@Base 0.2.0~rc3 + t_results_queue_init@Base 0.2.0~rc3 + tbx_conf_bed@Base 0.2.0~rc3 + tbx_conf_gff@Base 0.2.0~rc3 + tbx_conf_psltbl@Base 0.2.0~rc3 + tbx_conf_sam@Base 0.2.0~rc3 + tbx_conf_vcf@Base 0.2.0~rc3 + tbx_destroy@Base 0.2.0~rc3 + tbx_index@Base 0.2.0~rc3 + tbx_index_build@Base 0.2.0~rc3 + tbx_index_load@Base 0.2.0~rc3 + tbx_name2id@Base 0.2.0~rc3 + tbx_parse1@Base 0.2.0~rc3 + tbx_readrec@Base 0.2.0~rc3 + tbx_seqnames@Base 0.2.0~rc3 + tbx_set_meta@Base 0.2.0~rc3 + tokenise_search_path@Base 0.2.0~rc3 + vcf_format@Base 0.2.0~rc3 + vcf_hdr_read@Base 0.2.0~rc3 + vcf_hdr_write@Base 0.2.0~rc3 + vcf_parse@Base 0.2.0~rc3 + vcf_read@Base 0.2.0~rc3 + vcf_write@Base 0.2.0~rc3 + vflen@Base 0.2.0~rc3 + zfclose@Base 0.2.0~rc3 + zfeof@Base 0.2.0~rc3 + zfgets@Base 0.2.0~rc3 + zfopen@Base 0.2.0~rc3 + zfpeek@Base 0.2.0~rc3 + zfputs@Base 0.2.0~rc3 + zfseeko@Base 0.2.0~rc3 + zftello@Base 0.2.0~rc3 --- htslib-0.2.0~rc3.orig/debian/rules +++ htslib-0.2.0~rc3/debian/rules @@ -0,0 +1,24 @@ +#!/usr/bin/make -f + +export DH_VERBOSE=1 + +%: + dh $@ + +override_dh_auto_test: + dh_auto_test + $(RM) test/*.tmp test/*.tmp.* test/*.o test/*.dSYM \ + test/fieldarith test/hfile test/test_view test/test-vcf-api test/test-vcf-sweep + +override_dh_auto_build: + dh_auto_build -- \ + CFLAGS="$$(dpkg-buildflags --get CFLAGS)" \ + CPPFLAGS="-I. -DSAMTOOLS=1 $$(dpkg-buildflags --get CPPFLAGS)" \ + LDFLAGS="$$(dpkg-buildflags --get LDFLAGS)" + +override_dh_auto_install: + dh_auto_install -- prefix=/usr + +override_dh_clean: + chmod ugo+x debian/libhts0.install debian/libhts-dev.install + dh_clean --- htslib-0.2.0~rc3.orig/debian/watch +++ htslib-0.2.0~rc3/debian/watch @@ -0,0 +1,3 @@ +version=3 +opts=filenamemangle=s/.+\/v?(\d\S*)\.tar\.gz/htslib-$1.tar.gz/,uversionmangle=s/-rc/~rc/ \ + https://github.com/samtools/htslib/tags .*/v?(\d\S*)\.tar\.gz --- htslib-0.2.0~rc3.orig/hfile.c +++ htslib-0.2.0~rc3/hfile.c @@ -264,6 +264,14 @@ else return 0; } +void hclose_abruptly(hFILE *fp) +{ + int save = errno; + if (fp->backend->close(fp) < 0) { /* Ignore subsequent errors */ } + hfile_destroy(fp); + errno = save; +} + /*************************** * File descriptor backend * --- htslib-0.2.0~rc3.orig/hfile.h +++ htslib-0.2.0~rc3/hfile.h @@ -57,6 +57,12 @@ int hclose(hFILE *fp) HTS_RESULT_USED; /*! + @abstract Close the stream, without flushing or propagating errors + @notes For use while cleaning up after an error only. Preserves errno. +*/ +void hclose_abruptly(hFILE *fp); + +/*! @abstract Return the stream's error indicator @return Non-zero (in fact, an errno value) if an error has occurred. @notes This would be called herror() and return true/false to parallel --- htslib-0.2.0~rc3.orig/hts.c +++ htslib-0.2.0~rc3/hts.c @@ -4,6 +4,7 @@ #include #include #include +#include #include "htslib/bgzf.h" #include "htslib/hts.h" #include "cram/cram.h" @@ -175,9 +176,8 @@ if (hts_verbose >= 2) fprintf(stderr, "[E::%s] fail to open file '%s'\n", __func__, fn); - if (hfile) { - if (hclose(hfile) != 0) { /* Ignore errors */ } - } + if (hfile) + hclose_abruptly(hfile); if (fp) { free(fp->fn); @@ -187,29 +187,34 @@ return NULL; } -void hts_close(htsFile *fp) +int hts_close(htsFile *fp) { + int ret, save; + if (fp->is_bin || (fp->is_write && fp->is_compressed==1)) { - bgzf_close(fp->fp.bgzf); + ret = bgzf_close(fp->fp.bgzf); } else if (fp->is_cram) { - cram_close(fp->fp.cram); + ret = cram_close(fp->fp.cram); } else if (fp->is_kstream) { #if KS_BGZF BGZF *gzfp = ((kstream_t*)fp->fp.voidp)->f; - bgzf_close(gzfp); + ret = bgzf_close(gzfp); #else gzFile gzfp = ((kstream_t*)fp->fp.voidp)->f; - gzclose(gzfp); + ret = gzclose(gzfp); #endif ks_destroy((kstream_t*)fp->fp.voidp); } else { - hclose(fp->fp.hfile); + ret = hclose(fp->fp.hfile); } + save = errno; free(fp->fn); free(fp->fn_aux); free(fp->line.s); free(fp); + errno = save; + return ret; } int hts_set_fai_filename(htsFile *fp, const char *fn_aux) --- htslib-0.2.0~rc3.orig/htslib/bgzf.h +++ htslib-0.2.0~rc3/htslib/bgzf.h @@ -182,7 +182,10 @@ * Check if the BGZF end-of-file (EOF) marker is present * * @param fp BGZF file handler opened for reading - * @return 1 if EOF is present; 0 if not or on I/O error + * @return 1 if the EOF marker is present and correct; + * 2 if it can't be checked, e.g., because fp isn't seekable; + * 0 if the EOF marker is absent; + * -1 (with errno set) on error */ int bgzf_check_EOF(BGZF *fp); --- htslib-0.2.0~rc3.orig/htslib/hts.h +++ htslib-0.2.0~rc3/htslib/hts.h @@ -80,25 +80,39 @@ */ const char *hts_version(); - /*! - @param fn The file name or "-" for stdin/stdout - @param mode Mode matching /[rwbuz0-9]+/: 'r' for reading, 'w' for writing and - a digit specifies the zlib compression level. Note that there - is a distinction between 'u' and '0': the first yields plain - uncompressed output whereas the latter outputs uncompressed - data wrapped in the zlib format. - @example - [rw]b .. compressed BCF, BAM, FAI; with "r" detects uncompressed - files when not reading from stdin - [rw]u .. uncompressed BCF - [rw]z .. compressed VCF - [rw] .. uncompressed VCF - */ - htsFile *hts_open(const char *fn, const char *mode); - void hts_close(htsFile *fp); - int hts_getline(htsFile *fp, int delimiter, kstring_t *str); - char **hts_readlines(const char *fn, int *_n); +/*! + @abstract Open a SAM/BAM/CRAM/VCF/BCF/etc file + @param fn The file name or "-" for stdin/stdout + @param mode Mode matching /[rw][bcuz0-9]+/ + @discussion + With 'r' opens for reading; any further format mode letters are ignored + as the format is detected by checking the first few bytes or BGZF blocks + of the file. With 'w' opens for writing, with format specifier letters: + b binary format (BAM, BCF, etc) rather than text (SAM, VCF, etc) + c CRAM format + u uncompressed + z compressed + [0-9] zlib compression level + Note that there is a distinction between 'u' and '0': the first yields + plain uncompressed output whereas the latter outputs uncompressed data + wrapped in the zlib format. + @example + [rw]b .. compressed BCF, BAM, FAI + [rw]u .. uncompressed BCF + [rw]z .. compressed VCF + [rw] .. uncompressed VCF +*/ +htsFile *hts_open(const char *fn, const char *mode); + +/*! + @abstract Close a file handle, flushing buffered data for output streams + @param fp The file handle to be closed + @return 0 for success, or negative if an error occurred. +*/ +int hts_close(htsFile *fp); +int hts_getline(htsFile *fp, int delimiter, kstring_t *str); +char **hts_readlines(const char *fn, int *_n); /*! @abstract Set .fai filename for a file opened for reading --- htslib-0.2.0~rc3.orig/htslib/vcfutils.h +++ htslib-0.2.0~rc3/htslib/vcfutils.h @@ -52,13 +52,16 @@ * bcf_gt_type() - determines type of the genotype * @fmt_ptr: the GT format field as set for example by set_fmt_ptr * @isample: sample index (starting from 0) - * @ial: index of the non-reference allele (starting from 1) + * @ial: index of the 1st non-reference allele (starting from 1) + * @jal: index of the 2nd non-reference allele (starting from 1) * * Returns the type of the genotype (one of GT_HOM_RR, GT_HET_RA, - * GT_HOM_AA, GT_HET_AA, or GT_UNKN). If $ial is not NULL and the - * genotype has one or more non-reference alleles, $ial will be set. - * In case of GT_HET_AA, the allele which appeared first in ALT is - * used. + * GT_HOM_AA, GT_HET_AA, GT_HAPL_R, GT_HAPL_A or GT_UNKN). If $ial + * is not NULL and the genotype has one or more non-reference + * alleles, $ial will be set. In case of GT_HET_AA, $ial is the + * position of the allele which appeared first in ALT. If $jal is + * not null and the genotype is GT_HET_AA, $jal will be set and is + * the position of the second allele in ALT. */ #define GT_HOM_RR 0 // note: the actual value of GT_* matters, used in dosage r2 calculation #define GT_HOM_AA 1 @@ -67,7 +70,7 @@ #define GT_HAPL_R 4 #define GT_HAPL_A 5 #define GT_UNKN 6 -int bcf_gt_type(bcf_fmt_t *fmt_ptr, int isample, int *ial); +int bcf_gt_type(bcf_fmt_t *fmt_ptr, int isample, int *ial, int *jal); static inline int bcf_acgt2int(char c) { --- htslib-0.2.0~rc3.orig/sam.c +++ htslib-0.2.0~rc3/sam.c @@ -65,7 +65,7 @@ // check EOF has_EOF = bgzf_check_EOF(fp); if (has_EOF < 0) { - if (errno != ESPIPE && hts_verbose >= 2) perror("[W::sam_hdr_read] bgzf_check_EOF"); + perror("[W::sam_hdr_read] bgzf_check_EOF"); } else if (has_EOF == 0 && hts_verbose >= 2) fprintf(stderr, "[W::%s] EOF marker is absent. The input is probably truncated.\n", __func__); // read "BAM1" --- htslib-0.2.0~rc3.orig/vcfutils.c +++ htslib-0.2.0~rc3/vcfutils.c @@ -81,9 +81,9 @@ return 0; } -int bcf_gt_type(bcf_fmt_t *fmt_ptr, int isample, int *_ial) +int bcf_gt_type(bcf_fmt_t *fmt_ptr, int isample, int *_ial, int *_jal) { - int i, nals = 0, has_ref = 0, has_alt = 0, ial = 0; + int i, nals = 0, has_ref = 0, has_alt = 0, ial = 0, jal = 0; #define BRANCH_INT(type_t,missing,vector_end) { \ type_t *p = (type_t*) (fmt_ptr->p + isample*fmt_ptr->size); \ for (i=0; in; i++) \ @@ -96,7 +96,15 @@ if ( !ial ) { ial = tmp; has_alt = 1; } \ else if ( tmp!=ial ) \ { \ - if ( tmp0 ? ial-1 : ial; + if ( _jal ) *_jal = jal>0 ? jal-1 : jal; if ( !nals ) return GT_UNKN; if ( nals==1 ) return has_ref ? GT_HAPL_R : GT_HAPL_A;