Debian Codegraph @

NEWS

raw
1 Noteworthy changes in release 1.22.1 (14th July 2025)
2 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3
4 Bug Fixes
5 ---------
6
7 * SECURITY fix: Prevent CRAM byte_array decoder from overflowing its output
8 buffer. This could be triggered by certain malformed CRAM inputs.
9 (PR #1934)
10
11 * Two fixes for crashes reported when trying to save data with very long
12 alignment records with sequence '*' as CRAM 3.1:
13
14 - The htscodecs submodule is updated to v1.6.4.
15 This includes a fix to the rANS encoder to prevent it from failing on
16 these inputs.
17 (PR #1935. Reported by Martin Pollard)
18
19 - Improved error handling in cram_compress_block2(). If the previously-chosen
20 CRAM compression method starts to fail, it will now try other methods
21 instead of giving up immediately.
22 (PR #1931. Reported by Martin Pollard)
23
24
25 * Fix warnings due to the wrong datatype being passed to curl_easy_setopt()
26 (PR #1925. Thanks to John Marshall)
27
28 * Prevent instances of `memcpy(out, NULL, 0)`, which is strictly undefined
29 behaviour.
30 (PR #1930. Thanks to Ben Lawrence).
31
32 Build Changes
33 -------------
34
35 * Fixed compilation against older glibc / macOS SDKs that incorrectly
36 suppressed some symbols if _XOPEN_SOURCE was defined.
37 (PR #1928. Reported by John Marshall)
38
39 * Fixed ref-cache configure check for libcurl, so that if libcurl is
40 not available, or turned off by `./configure --disable-libcurl`,
41 the `ref-cache` build will be automatically disabled as well.
42 (PR #1929, fixes #1926. Reported by biounix)
43
44 Noteworthy changes in release 1.22 (30th May 2025)
45 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
46
47 Note this release changes the default output CRAM version from 3.0 to 3.1.
48 HTSlib and SAMtools have been able to read CRAM 3.1 since version 1.12,
49 however other tools may not yet be able to cope. We know Noodles reads CRAM
50 3.1 and htsjdk has a draft implementation that has not yet been released.
51
52 HTSlib has options for modifying the output formats, which are exposed in
53 SAMtools. When specifying an output format you can explicitly change the
54 version via e.g. `samtools view -O cram,version=3.0 ...`.
55
56 Further documentation on this change can be found at
57 https://www.htslib.org/benchmarks/CRAM.html
58
59
60 HTSlib no longer fetches CRAM reference data from EBI's server by default. Your
61 organisation may wish to set up local infrastructure to supply reference
62 sequences, e.g., using the new ref-cache tool included in this HTSlib release.
63 See the REF_CACHE and REF_PATH environment variables documented in
64 https://www.htslib.org/doc/reference_seqs.html and the SAMtools man
65 page for details.
66
67
68 Updates
69 -------
70
71 * NEW. Add ref-cache, a caching proxy for reference sequences. This is a local
72 server of reference sequences, for use when encoding or decoding CRAM files
73 that use reference-based compression.
74 (PR #1911, PR #1921, PR #1922)
75
76 * Add support for matching VCF lines by ID.
77 (PR #1844, addresses issue bcftools#1739 reported by Han Cao)
78
79 * Make it possible to test for VCF_REF as declared in the documentation.
80 (PR #1879)
81
82 * Updated VCF code to work with VCF 4.4 prefixed phasing info.
83 (PR#1861, fixes #1847. Reported by John Marshall)
84
85 * Use the highest VCF version when merging headers.
86 (PR#1912, see bcftools#2395 and bcftools#2404)
87
88 * Update RLEN calculation for VCF 4.4 and 4.5.
89 (PR#1897, fixes #1820. Reported by Dave Lawrence)
90
91 * Convert U to T instead of U to N when sam_parsing. Though SAM format itself
92 can contain U the BAM format cannot.
93 (PR #1854, fixes samtools#2131 reported by James Ferguson)
94
95 * Add an hts_crc32 function to use zlib or libdeflate. The libdeflate crc32
96 function is faster than native zlib and should be used when available.
97 (PR #1850)
98
99 * Increase the input block size for bgzip. This deals with a slow down
100 introduced in PR #1493 when reading from a pipe.
101 (PR #1768, fixes #1767. Reported by Konstantin Riege)
102
103 * Allow BYTE_ARRAY_STOP to work on non-zero STOP code with TOK3. Although the
104 htscodecs name tokeniser uses a NUL between names there is no reason why
105 another value could not be used. This change lets CRAM recognise other
106 separator values.
107 (PR #1871)
108
109 * Remove cram seek ability to do range queries via SEEK_CUR. A probable
110 misfeature from the original implementation.
111 (PR #1878, fixes #1877. Reported by Rick Wertenbroek)
112
113 * Add hts_tpool_worker_id() API. This may be used to associate data with a
114 thread rather than to a job.
115 (PR #1875)
116
117 * Update bcf_synced_reader to use htsFile.
118 (PR #1868, implements #1862. Requested by Brent Pedersen)
119
120 * Exit with return value 1 on tabix parse error. This previously returned 0.
121 (PR #1887, fixes #1885. Reported by Fan-iX)
122
123 * Automatically recognise BED vs TSV files and add the option -C, --coords to
124 set index positions (1 or 0 based coordinates) in annot-tsv.
125 (PR #1894)
126
127 * Reading SQ lines with multiple differing LN will now fail. Such lines are
128 invalid (by the spec) and previous handling was inconsistent.
129 (PR #1882, fixes #1866)
130
131 * Return errors instead of EOF after all I/O errors etc in
132 hts_itr_multi_next/sam_itr_next/sam_read1/vcf_parse/bcf_read.
133 (PR#1899. Thanks to John Marshall)
134
135 * Remove UR:file:// and UR:ftp:// from ref search path, plus REF_PATH to EBI.
136 Removing EBI as the default fallback when REF_PATH not set prevents the
137 unintended DDOS on EBI's servers.
138 (PR#1881. PR#1915, fixes oss-fuzz issue 418125747)
139
140 Build Changes
141 -------------
142
143 * Detect the presence of getauxval() and elf_aux_info() for *BSD variants.
144 (PR #1835, thanks to Brad Smith)
145
146 * Make HAVE_ATTRIBUTE_TARGET check also check that SSSE3 intrinsics work.
147 Mainly for use with old compilers.
148 (PR #1886, fixes #1838 and pysam-developers/pysam#1327. Thanks to
149 John Marshall)
150
151 * Fix broken tests due to MSYS2 changes. Due to changes in how MSYS2 perl
152 reported the identity of the OS it was built for, our tests were failing to
153 adapt to the Windows style file locations.
154 (PR #1892)
155
156 * Updated htscodecs submodule to version 1.6.3
157 (PR #1917)
158
159 * Fix the script used to build the symbol version file.
160 (PR #1918)
161
162 Bug fixes
163 ---------
164
165 * Fix possible 1 byte underflow in find_file_extension().
166 Fixes an issue reported by OSS-Fuzz.
167 (PR #1840, fixes oss-fuzz id 71740)
168
169 * Replace home-brew string end searching with memchr() to speed up looking at
170 long aux tags.
171 (PR #1842)
172
173 * Prevent segfault on empty tbi index. This could happen when a VCF file has a
174 header but no data lines.
175 (PR #1845, fixes bcftools#2286. Reported by Devon Ryan)
176
177 * Fix CRAM embed_ref=2 with seqs overlapping ref end.
178 (PR #1848 and PR #1849 which fixed oss-fuzz issue 372547397)
179
180 * Fix sam_hdr_remove_line_pos() not dealing with the 0 index position properly.
181 (PR #1853. Thanks to Julian Regalado Perez)
182
183 * Fix threaded sam_read1() after EOF. Prevents sam_read1() getting stuck when
184 trying to read after EOF and waiting forever for data that is never going to
185 arrive.
186 (PR #1856, fixes #1855. Reported by Yan Gao)
187
188 * Fix a bug in breakend detection. It was incorrectly assuming that the ALT
189 allele is of equal length to REF allele, but the VCF specification allows
190 breakend insertions.
191 (PR #1858, fixes bcftools#2317. Reported by Nicolai von Kügelgen).
192
193 * Fix cram_encode fuzzer issue caused by negative reference lengths. Reported
194 by OSS-Fuzz.
195 (PR #1863 fixes oss-fuzz issue 382922241)
196
197 * Fixed a typo in vcf.h.
198 (PR #1870, thanks to Yu Wang)
199
200 * Reset variant types after updating alleles with bcf_update_alleles() or
201 bcf_update_alleles_str(). Prevents an out-of-bounds access by
202 bcftools consensus.
203 (PR #1883)
204
205 * Recognize T > A[chr15:12345[ breakend type in VCF.
206 (PR#1903, fixes bcftools#2389. Reported by Dennis Hendriksen)
207
208 * Fix possible buffer overruns in expand_path().
209 (PR#1907)
210
211 Documentation updates
212 ---------------------
213
214 * Add instructions to INSTALL for FreeBSD, NetBSD and OpenBSD.
215 (PR #1843)
216
217 * Clarify bam_set1() parameter documentation to note that quality values do not
218 have the ASCII 33 offset.
219 (PR #1891. Thanks to Chris Wright)
220
221 * Fixed incorrectly named table in bam1_t structure documentation.
222 (PR #1923. Thanks to Julian Hess)
223
224 Noteworthy changes in release 1.21 (12th September 2024)
225 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
226
227 The primary user-visible changes in this release are updates to the
228 annot-tsv tool and some speed improvements. Full details of other
229 changes and bugs fixed are below.
230
231 Notice: this is the last SAMtools / HTSlib release where CRAM 3.0 will be
232 the default CRAM version. From the next we will change to CRAM 3.1
233 unless the version is explicitly specified, for example using
234 "samtools view -O cram,version=3.0".
235
236
237 Updates
238 -------
239
240 * Extend annot-tsv with several new command line options.
241 --delim permits use of other delimiters.
242 --headers for selection of other header formats.
243 --no-header-idx to suppress column index numbers in header.
244 Also removed -h as it is now short for --headers. Note --help
245 still works. (PR #1779)
246
247 * Allow annot-tsv -a to rename annotations. (PR #1709)
248
249 * Extend annot-tsv --overlap to be able to specify the overlap
250 fraction separately for source and target. (PR #1811)
251
252 * Added new APIs to facilitate low-level CRAM container manipulations,
253 used by the new "samtools cat" region filtering code. Functions are:
254 cram_container_get_coords()
255 cram_filter_container()
256 cram_index_extents()
257 cram_container_num2offset()
258 cram_container_offset2num()
259 cram_num_containers()
260 cram_num_containers_between()
261 Also improved cram_index_query() to cope with HTS_IDX_NOCOOR regions.
262 (PR #1771)
263
264 * Bgzip now retains file modification and access times when
265 compressing and decompressing. (PR #1727, fixes #1718. Requested by
266 Gert Hulselmans.)
267
268 * Use FNV1a for string hashing in khash. The old algorithm was
269 particularly weak with base-64 style strings and lead to a large
270 number of collisions. (PR #1806. Fixes samtools/samtools#2066,
271 reported by Hans-Joachim Ruscheweyh)
272
273 * Improve the speed of the nibble2base() function on Intel (PR
274 #1667, PR #1764, PR #1786, PR #1802, thanks to Ruben Vorderman) and
275 ARM (PR #1795, thanks to John Marshall).
276
277 * bgzf_getline() will now warn if it encounters UTF-16 data.
278 (PR #1487, thanks to John Marshall)
279
280 * Speed up bgzf_read(). While this does not reduce CPU significantly,
281 it does increase the maximum parallelism available permitting 10-15%
282 faster decoding. (PR #1772, PR #1800, Issue #1798)
283
284 * Speed up faidx by use of better isgraph methods (PR #1797) and
285 whole-line reading (PR #1799, thanks to John Marshall).
286
287 * Speed up kputll() function, speeding up BAM -> SAM conversion by
288 about 5% and also samtools depth. (PR #1805)
289
290 * Added more example code, covering fasta/fastq indexing, tabix
291 indexing and use of the thread pool. (PR #1666)
292
293 Build Changes
294 -------------
295
296 * Code warning fixes for pedantic compilers (PR #1777) and avoid
297 some undefined behaviour (PR #1810, PR #1816, PR #1828).
298
299 * Windows based CI has been migrated from AppVeyor to GitHub Actions.
300 (PR #1796, PR #1803, PR #1808)
301
302 * Miscellaneous minor build infrastructure and code fixes.
303 (PR #1807, PR #1829, both thanks to John Marshall)
304
305 * Updated htscodecs submodule to version 1.6.1 (PR #1828)
306
307 * Fixed an awk script in the Makefile that only worked with gawk. (PR #1831)
308
309 Bug fixes
310 ---------
311
312 * Fix small OSS-Fuzz reported issues with CRAM encoding and long
313 CIGARS and/or illegal positions. (PR #1775, PR #1801, PR #1817)
314
315 * Fix issues with on-the-fly indexing of VCF/BCF (bcftools --write-index)
316 when not using multiple threads. (PR #1837. Fixes samtools/bcftools#2267,
317 reported by Giulio Genovese)
318
319 * Stricter limits on POS / MPOS / TLEN in sam_parse1(). This fixes
320 a signed overflow reported by OSS-Fuzz and should help prevent other
321 as-yet undetected bugs. (PR #1812)
322
323 * Check that the underlying file open worked for preload: URLs. Fixes
324 a NULL pointer dereference reported by OSS-Fuzz. (PR #1821)
325
326 * Fix an infinite loop in hts_itr_query() when given extremely large
327 positions which cause integer overflow. Also adds hts_bin_maxpos()
328 and hts_idx_maxpos() functions.
329 (PR #1774, thanks to John Marshall and reported by Jesus Alberto
330 Munoz Mesa)
331
332 * Fix an out of bounds read in hts_itr_multi_next() when switching
333 chromosomes. This bug is present in releases 1.11 to 1.20.
334 (PR #1788. Fixes samtools/samtools#2063, reported by acorvelo)
335
336 * Work around parsing problems with colons in CHROM names.
337 Fixes samtools/bcftools#2139. (PR #1781, John Marshall / James Bonfield)
338
339 * Correct the CPU detection for Mac OS X 10.7. cpuid is used by
340 htscodecs (see samtools/htscodecs#116), and the corresponding
341 changes in htslib are PR #1785. Reported by Ryan Carsten Schmidt.
342
343 * Make BAM zero-length intervals work the same as CRAM; permitted and
344 returning overlapping records. (PR #1787. Fixes
345 samtools/samtools#2060, reported by acorvelo)
346
347 * Replace assert() with abort() in BCF synced reader. This is not an
348 ideal solution, but it gives consistent behaviour when compiling
349 with or without NDEBUG. (PR #1791, thanks to Martin Pollard)
350
351 * Fixed failure to change the write block size on compressed SAM or VCF
352 files due to an internal type confusion. (PR #1826)
353
354 * Fixed an out-of-bounds read in cram_codec_iter_next() (PR #1832)
355
356 Noteworthy changes in release 1.20 (15th April 2024)
357 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
358
359 Updates
360 -------
361
362 * When working on named files, bgzip now sets the modified and access times
363 of the output files it makes to match those of the corresponding input.
364 (PR #1727, feature request #1718. Requested by Gert Hulselmans)
365
366 * It's now possible to use a -o option to specify the output file name in
367 bgzip.
368 (PR #1747, feature request #1726. Requested by Gert Hulselmans)
369
370 * Improved error faidx error messages.
371 (PR #1743, thanks to Nick Moore)
372
373 * Faster reading of SAM array (type "B") tags. These often turn up
374 in ONT and PacBio data.
375 (PR #1741)
376
377 * Improved validity checking of base modification tags.
378 (PR #1749)
379
380 * mpileup overlap removal now works where one read has a deletion.
381 (PR #1751, fixes samtools/samtools#1992. Reported by Long Tian)
382
383 * The S3 plugin can now find buckets via S3 access point aliases.
384 (PR #1756, thanks to Matt Pawelczyk;
385 fixes samtools/samtools#1984. Reported by Albert Li)
386
387 * Added a --threads option (and -@ short option) to tabix.
388 (PR #1755, feature request #1735. Requested by Dan Bolser)
389
390 * tabix can now index Graph Alignment Format (GAF) files.
391 (See https://github.com/lh3/gfatools/blob/master/doc/rGFA.md)
392 (PR #1763, thanks to Adam Novak)
393
394 Bug fixes
395 ---------
396
397 * Security fix: Prevent possible heap overflow in cram_encode_aux() on
398 bad RG:Z tags.
399 (PR #1737)
400
401 * Security fix: Prevent attempts to call a NULL pointer if certain URL
402 schemes are used in CRAM @SQ UR: tags.
403 (PR #1757)
404
405 * Security fix: Fixed a bug where following certain AWS S3 redirects could
406 downgrade the connection from TLS (i.e. https://) to unencrypted http://.
407 This could happen when using path-based URLs and AWS_DEFAULT_REGION
408 was set to a region other that the one where the data was stored.
409 (PR #1762, fixes #1760. Reported by andaca)
410
411 * Fixed arithmetic overflow when loading very long references for CRAM.
412 (PR #1738, fixes #1738. Reported by Shane McCarthy)
413
414 * Fixed faidx and CRAM reference look-ups on compressed fasta where the .fai
415 index file was present, but the .gzi index of compressed offsets was not.
416 (PR #1745, fixes #1744. Reported by Theodore Li)
417
418 * Fixed BCF indexing on-the-fly bug which produced invalid indexes when
419 using multiple compression threads.
420 (PR #1742, fixes #1740. Reported by graphenn)
421
422 * Ensure that pileup destructors are called by bam_plp_destroy(), to
423 prevent memory leaks.
424 (PR #1749, PR #1754)
425
426 * Ensure on-the-fly index timestamps are always older than the data file.
427 Previously the files could be closed out of order, leading to warnings
428 being printed when using the index.
429 (PR #1753, fixes #1732. Reported by Gert Hulselmans)
430
431 * To prevent data corruption when reading (strictly invalid) VCF files
432 with duplicated FORMAT tags, all but the first copy of the data
433 associated with the tag are now dropped with a warning.
434 (PR #1752, PR #1761, fixes #1733. Reported by anthakki)
435
436 * Fixed a bug introduced in release 1.19 (PR #1689) which broke variant
437 record data if it tried to remove an over-long tag.
438 (PR #1752, PR #1761)
439
440 * Changed error to warning when complaining about use of the CG tag
441 in SAM or CRAM files.
442 (PR #1758, fixes samtools/samtools#2002)
443
444 Noteworthy changes in release 1.19.1 (22nd January 2024)
445 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
446
447 * Fixed a regression in release 1.19 that caused all aux records to
448 be stored uncompressed in CRAM files. The resulting files were
449 correctly formatted, but bigger than they needed to be.
450 (PR#1729, fixes samtools#1968. Reported by Clockris)
451
452 * Fixed possible out-of-bounds reads due to an incorrect check on
453 B tag lengths in cram_encode_aux(). (PR#1725)
454
455 * Fixed an incorrect check on tag length which could fail to catch a
456 two byte out-of-bounds read in bam_get_aux(). (PR#1728)
457
458 * Made errors reported by hts_open_format() less confusing when it can't
459 open the reference file. (PR#1724, fixes #1723. Reported by
460 Alex Leonard)
461
462 * Made hts_close() fail more gracefully if it's passed a NULL pointer
463 (PR#1724)
464
465 Noteworthy changes in release 1.19 (12th December 2023)
466 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
467
468 Updates
469 -------
470
471 * A temporary work-around has been put in the VCF parser so that it is
472 less likely to fail on rows with a large number of ALT alleles,
473 where Number=G tags like PL can expand beyond the 2Gb limit enforced
474 by HTSlib. For now, where this happens the offending tag will be dropped
475 so the data can be processed, albeit without the likelihood data.
476
477 In future work, the library will instead convert such tags into their
478 local alternatives (see https://github.com/samtools/hts-specs/pull/434).
479 (PR #1689)
480
481 * New program. Adds annot-tsv which annotates regions in a destination file with
482 texts from overlapping regions in a source file.
483 (PR#1619)
484
485 * Change bam_parse_cigar() so that it can modify existing BAM records. This
486 makes more useful as public API. Previously it could only handle partially
487 formed BAM records.
488 (PR#1651, fixes #1650. Reported by Oleksii Nikolaienko)
489
490 * Add "uncompressed" to hts_format_description() where appropriate. This adds
491 an "uncompressed" description to uncompressed files that would normally be
492 compressed, such as BAM and BCF.
493 (PR#1656, in relation to samtools#1884. Thanks to John Marshall)
494
495 * Speed up to the VCF parser and writer.
496 (PR#1644 and PR#1663)
497
498 * Add an hclen (hard clip length) SAM filter function.
499 (PR#1660, with reference to samtools#813)
500
501 * Avoid really closing stdin/stdout in hclose()/hts_close()/et al.
502 See discussion in PR for details.
503 (PR#1665. Thanks to John Marshall)
504
505 * Add support to handle multiple files in bgzip.
506 (PR#1658, fixes #1642. Requested by bw2)
507
508 * Enable auto-vectorisation in CRAM 3.1 codecs. Speeds decoding on some
509 sequencing platform data.
510 (PR#1669)
511
512 * Speed up removal of lines in large headers.
513 (PR#1662, fixes #1460. Reported by Anže Starič)
514
515 * Apply seqtk PR to improve kseq.h parsing performance. Port of
516 Fabian Klötzl's (kloetzl) lh3/seqtk#123 and attractivechaos/klib#173 to
517 HTSlib.
518 (PR#1674. Thanks to John Marshall)
519
520 Build changes
521 -------------
522
523 * Updated htscodecs submodule to 1.6.0.
524 (PR#1685, PR#1717, PR#1719)
525
526 * Apply the packed attribute to uint*_u types for Clang to prevent
527 -fsanitize=alignment failures.
528 (PR#1667. Thanks to Fangrui Song)
529
530 * Fuzz testing improvements.
531 (PR#1664)
532
533 * Add C++ casts for external headers in klist.h and kseq.h.
534 (PR#1683. See also PR#1674 and PR#1682)
535
536 * Add test case compiling the public headers as C++.
537 (PR#1682. Thanks to John Marshall)
538
539 * Enable optimisation level -O3 for SAM QUAL+33 formatting.
540 (PR#1679)
541
542 * Make compiler flag detection work with zig cc.
543 (PR#1687)
544
545 * Fix unused value warnings when built with NDEBUG.
546 (PR#1688)
547
548 * Remove some disused Makefile variables, fix typos and a warning. Improve
549 bam_parse_basemod() documentation.
550 (PR#1705, Thanks to John Marshall)
551
552 Bug fixes
553 ---------
554
555 * Fail bgzf_useek() when offset is above block limits.
556 (PR#1668)
557
558 * Fix multi-threaded on-the-fly indexing problems.
559 (PR#1672, fixes samtools#1861 and bcftools#1985. Reported by Mark Ebbert and
560 lacek)
561
562 * Fix hfile_libcurl small seek bug.
563 (PR#1676, fixes samtools#1918. Also may fix #1037, #1625 and samtools#1622.
564 Reported by Alex Reynolds, Mark Walker, Arthur Gilly and skatragadda-nygc.
565 Thanks to John Marshall)
566
567 * Fix a minor memory leak in malformed CRAM EXTERNAL blocks. [fuzz]
568 (PR#1671)
569
570 * Fix a cram decode hang from block_resize().
571 (PR#1680. Reported by Sebastian Deorowicz)
572
573 * Cram fuzzing improvements. Fixes a number of cram errors.
574 (PR#1701, fixes #1691, #1692, #1693, #1696, #1697, #1698, #1699 and #1700.
575 Thanks to Octavio Galland for finding and reporting all these)
576
577 * Fix crypt4gh redirection.
578 (PR#1675, fixes grbot/crypt4gh-tutorial#2. Reported by hth4)
579
580 * Fix PG header linking when records make a loop.
581 (PR#1702, fixes #1694. Reported by Octavio Galland)
582
583 * Prevent issues with no-stored-sequence records in CRAM files, by ensuring
584 they are accounted for properly in block size calculations, and by limiting
585 the maximum query length in the CIGAR data. Originally seen as an overflow
586 by OSS-Fuzz / UBSAN, it turned out this could lead to excessive time and
587 memory use by HTSlib, and could result in it writing out unreadable CRAM
588 files.
589 (PR#1710)
590
591 * Fix some illegal shifts and integer overflows found by OSS-Fuzz / UBSAN.
592 (PR#1707, PR#1712, PR#1713)
593
594 Noteworthy changes in release 1.18 (25th July 2023)
595 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
596
597 Updates
598 -------
599
600 * Using CRAM 3.1 no longer gives a warning about the specification
601 being draft. Note CRAM 3.0 is still the default output format.
602 (PR#1583)
603
604 * Replaced use of sprintf with snprintf, to silence potential warnings
605 from Apple's compilers and those who implement similar checks.
606 (PR#1594, fixes #1586. Reported by Oleksii Nikolaienko)
607
608 * Fastq output will now generate empty records for reads with no
609 sequence data (i.e. sequence is "*" in SAM format). (PR#1576,
610 fixes samtools/samtools#1576. Reported by Nils Homer)
611
612 * CRAM decoding speed-ups. (PR#1580)
613
614 * A new MN aux tag can now be used to verify that MM/ML base modification
615 data has not been broken by hard clipping. (PR#1590, PR#1612. See also
616 PR samtools/hts-specs#714 and issue samtools/hts-specs#646.
617 Reported by Jared Simpson)
618
619 * The base modification API has been improved to make it easier for callers
620 to tell unchecked bases from unmodified ones. (PR#1636, fixes #1550.
621 Requested by Chris Wright)
622
623 * A new bam_mods_queryi() API has been added to return additional
624 data about the i-th base modification returned by bam_mods_recorded().
625 (PR#1636, fixes #1550 and #1635. Requested by Jared Simpson)
626
627 * Speed up index look-ups for whole-chromosome queries. (PR#1596)
628
629 * Mpileup now merges adjacent (mis)match CIGAR operations, so CIGARs
630 using the X/= operators give the same results as if the M operator
631 was used. (PR#1607, fixes #1597. Reported by Marcel Martin)
632
633 * It's now possible to call bcf_sr_set_regions() after adding readers
634 using bcf_sr_add_reader() (previously this returned an error). Doing so
635 will discard any unread data, and reset the readers so they iterate over
636 the new regions. (PR#1624, fixes samtools/bcftools#1918. Reported by
637 Gregg Thomas)
638
639 * The synced BCF reader can now accept regions with reference names including
640 colons and hyphens, by enclosing them in curly braces. For example,
641 {chr_part:1-1001}:10-20 will return bases 10 to 20 from reference
642 "chr_part:1-1001". (PR#1630, fixes #1620. Reported by Bren)
643
644 * Add a "samples" directory with code demonstrating usage of HTSlib plus
645 a tutorial document. (PR#1589)
646
647 Build changes
648 -------------
649
650 * Htscodecs has been updated to 1.5.1 (PR#1654)
651
652 * Htscodecs SIMD code now works with Apple multiarch binaries.
653 (PR#1587, HTSlib fix for samtools/htscodecs#76. Reported by John Marshall)
654
655 * Improve portability of "expr" usage in version.sh.
656 (PR#1593, fixes #1592. Reported by John Marshall)
657
658 * Improve portability to *BSD targets by ensuring _XOPEN_SOURCE is defined
659 correctly and that source files properly include "config.h". Perl
660 scripts also now all use #!/usr/bin/env instead of assuming that
661 it's in /usr/bin/perl. (PR#1628, fixes #1606.
662 Reported by Robert Clausecker)
663
664 * Fixed NAME entry in htslib-s3-plugin man page so the whatis and apropos
665 commands find it. (PR#1634, thanks to Étienne Mollier)
666
667 * Assorted dependency tracking fixes. (PR#1653, thanks to John Marshall)
668
669 Documentation updates
670 ---------------------
671
672 * Changed Alpine build instructions as they've switched back to using openssl.
673 (PR#1609)
674
675 * Recommend using -rdynamic when statically linking a libhts.a with
676 plugins enabled. (PR#1611, thanks to John Marshall. Fixes #1600,
677 reported by Jack Wimberley)
678
679 * Fixed example in docs for sam_hdr_add_line(). (PR#1618, thanks to kojix2)
680
681 * Improved test harness for base modifications API. (PR#1648)
682
683 Bug fixes
684 ---------
685
686 * Fix a major bug when searching against a CRAM index where one container
687 has start and end coordinates entirely contained within the previous
688 container. This would occasionally miss data, and sometimes return much
689 more than required. The bug affected versions 1.11 to 1.17, although the
690 change in 1.11 was bug-fixing multi-threaded index queries. This bug did
691 not affect index building. There is no need to reindex your CRAM files.
692 (PR#1574, PR#1640. Fixes #1569, #1639, samtools/samtools#1808,
693 samtools/samtools#1819. Reported by xuxif, Jens Reeder and Jared Simpson)
694
695 * Prevent CRAM blocks from becoming too big in files with short
696 sequences but very long aux tags. (PR #1613)
697
698 * Fix bug where the CRAM decoder for CONST_INT and CONST_BYTE
699 codecs may incorrectly look for extra data in the CORE block.
700 Note that this bug only affected the experimental CRAM v4.0 decoder.
701 (PR#1614)
702
703 * Fix crypt4gh redirection so it works in conjunction with non-file
704 IO, such as using htsget. (PR#1577)
705
706 * Improve error checking for the VCF POS column, when facing invalid
707 data. (PR#1575, replaces #1570 originally reported and fixed
708 by Colin Nolan.)
709
710 * Improved error checking on VCF indexing to validate the data is BGZF
711 compressed. (PR#1581)
712
713 * Fix bug where bin number calculation could overflow when making iterators
714 over regions that go to the end of a chromosome. (PR#1595)
715
716 * Backport attractivechaos/klib#78 (by Pall Melsted) to HTSlib.
717 Prevents infinite loops in kseq_read() when reading broken gzip files.
718 (PR#1582, fixes #1579. Reported by Goran Vinterhalter)
719
720 * Backport attractivechaos/klib@384277a (by innoink) to HTSlib.
721 Fixes the kh_int_hash_func2() macro definition.
722 (PR#1599, fixes #1598. Reported by fanxinping)
723
724 * Remove a compilation warning on systems with newer libcurl releases.
725 (PR#1572)
726
727 * Windows: Fixed BGZF EOF check for recent MinGW releases. (PR#1601,
728 fixes samtools/bcftools#1901)
729
730 * Fixed bug where tabix would not return the correct regions for files
731 where the column ordering is end, ..., begin instead of begin, ..., end.
732 (PR#1626, fixes #1622. Reported by Hiruna Samarakoon)
733
734 * sam_format_aux1() now always NUL-terminates Z/H tags. (PR#1631)
735
736 * Ensure base modification iterator is reset when no MM tag is present.
737 (PR#1631, PR#1647)
738
739 * Fix segfault when attempting to write an uncompressed BAM file opened using
740 hts_open(name, "wbu"). This was attempting to write BAM data without
741 wrapping it in BGZF blocks, which is invalid according to the BAM
742 specification. "wbu" is now internally converted to "wb0" to output
743 uncompressed data wrapped in BGZF blocks. (PR#1632, fixes #1617.
744 Reported by Joyjit Daw)
745
746 * Fixed over-strict bounds check in probaln_glocal() which caused it to make
747 sub-optimal alignments when the requested band width was greater than the
748 query length. (PR#1616, fixes #1605. Reported by Jared Simpson)
749
750 * Fixed possible double frees when handling errors in bcf_hdr_add_hrec(),
751 if particular memory allocations fail. (PR#1637)
752
753 * Ensure that bcf_hdr_remove() clears up all pointers to the items removed
754 from dictionaries. Failing to do this could have resulted in a call
755 requesting a deleted item via bcf_hdr_get_hrec() returning a stale pointer.
756 (PR#1637)
757
758 * Stop the gzip decompresser from finishing prematurely when an empty
759 gzip block is followed by more data. (PR#1643, PR#1646)
760
761 Noteworthy changes in release 1.17 (21st February 2023)
762 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
763
764 * A new API for iterating through a BAM record's aux field.
765 (PR#1354, addresses #1319. Thanks to John Marshall)
766
767 * Text mode for bgzip. Allows bgzip to compress lines of text with block breaks
768 at newlines.
769 (PR#1493, thanks to Mike Lin for the initial version PR#1369)
770
771 * Make tabix support CSI indices with large positions. Unlike SAM and VCF
772 files, BED files do not set a maximum reference length which hindered CSI
773 support. This change sets an arbitrary large size of 100G to enable it to
774 work.
775 (PR#1506)
776
777 * Add a fai_line_length function. Exposes the internal line-wrap length.
778 (PR#1516)
779
780 * Check for invalid barcode tags in fastq output.
781 (PR#1518, fixes samtools#1728. Reported by Poshi)
782
783 * Warn if reference found in a CRAM file is not contained in the specified
784 reference file.
785 (PR#1517 and PR#1521, adds diagnostics for #1515. Reported by Wei WeiDeng)
786
787 * Add a faidx_seq_len64 function that can return sequence lengths longer than
788 INT_MAX. At the same time limit faidx_seq_len to INT_MAX output. Also add a
789 fai_adjust_region to ensure given ranges do not go beyond the end of the
790 requested sequence.
791 (PR#1519)
792
793 * Add a bcf_strerror function to give text descriptions of BCF errors.
794 (PR#1510)
795
796 * Add CRAM SQ/M5 header checking when specifying a fasta file. This is to
797 prevent creating a CRAM that cannot be decoded again.
798 (PR#1522. In response to samtools#1748 though not a direct fix)
799
800 * Improve support for very long input lines (> 2Gbyte). This is mostly useful
801 for tabix which does not do much interpretation of its input.
802 (PR#1542, a partial fix for #1539)
803
804 * Speed up load_ref_portion. This function has been sped up by about 7x, which
805 speeds up low-depth CRAM decoding by about 10%.
806 (PR#1551)
807
808 * Expand CRAM API to cope with new samtools cram_size command.
809 (PR#1546)
810
811 * Merges neighbouring I and D ops into one op within pileup. This means
812 4M1D1D1D3M is reported as 4M3D3M. Fixing this in sam.c means not only is
813 samtools mpileup now looking better, but any tool using the mpileup API will
814 be getting consistent results.
815 (PR#1552, fixes the last remaining part of samtools#139)
816
817 * Update the API documentation for bgzf_mt as it refered to a previous
818 iteration.
819 (PR#1556, fixes #1553. Reported by Raghavendra Padmanabhan)
820
821
822 Build changes
823 -------------
824
825 * Use POSIX grep in testing as egrep and fgrep are considered obsolete.
826 (PR#1509, thanks to David Seifert)
827
828 * Switch to building libdefalte with cmake for Cirris CI.
829 (PR#1511)
830
831 * Ensure strings in config_vars.h are escaped correctly.
832 (PR#1530, fixes #1527. Reported by Lucas Czech)
833
834 * Easier modification of shared library permissions during install.
835 (PR#1532, fixes #1525. Reported by StephDC)
836
837 * Fix build on ancient compilers. Added -std=gnu90 to build tests so older
838 C compilers will still be happy.
839 (PR#1524, fixes #1523. Reported by Martin Jakt)
840
841 * Switch MacOS CI tests to an ARM-based image.
842 (PR#1536)
843
844 * Cut down the number of embed_ref=2 tests that get run.
845 (PR#1537)
846
847 * Add symbol versions to libhts.so. This is to aid package developers.
848 (PR#1560 addresses #1505, thanks to John Marshall. Reported by Stefan Bruens)
849
850 * htscodecs now updated to v1.4.0.
851 (PR#1563)
852
853 * Cleaned up misleading system error reports in test_bgzf.
854 (PR#1565)
855
856 Bug fixes
857 ---------
858
859 * VCF. Fix n-squared complexity in sample line with many adjacent tabs [fuzz].
860 (PR#1503)
861
862 * Improved bcftools detection and reporting of bgzf decode errors.
863 (PR#1504, thanks to Lilian Janin. PR#1529 thanks to Bergur Ragnarsson, fixes
864 #1528. PR#1554)
865
866 * Prevent crash when the only FASTA entry has no sequence [fuzz].
867 (PR#1507)
868
869 * Fixed typo in sam.h documentation.
870 (PR#1512, thanks to kojix2)
871
872 * Fix buffer read-overrun in bam_plp_insertion_mod.
873 (PR#1520)
874
875 * Fix hash keys being left behind by bcf_hdr_remove.
876 (PR#1535, fixes #1533. Reported by Giulio Genovese in #842)
877
878 * Make bcf_hdr_idinfo_exists more robust by checking id value exists.
879 (PR#1544, fixes #1538. Reported by Giulio Genovese)
880
881 * CRAM improvements. Fixed crash with multi-threaded CRAM. Fixed a bug in the
882 codec parameter learning for CRAM 3.1 name tokeniser. Fixed Cram compression
883 container substitution matrix generation,
884 (PR#1558, PR#1559 and PR#1562)
885
886 Noteworthy changes in release 1.16 (18th August 2022)
887 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
888
889 * Make hfile_s3 refresh AWS credentials on expiry in order to make HTSlib work
890 better with AWS IAM credentials, which have a limited lifespan.
891 (PR#1462 and PR#1474, addresses #344)
892
893 * Allow BAM headers between 2GB and 4GB in size once more. This is not
894 permitted in the BAM specification but was allowed in an earlier version of
895 HTSlib. There is now a warning at 2GB and a hard failure at 4GB.
896 (PR#1421, fixes #1420 and samtools#1613. Reported by John Marshall and
897 R C Mueller)
898
899 * Improve error message when failing to load an index.
900 (PR#1468, example of the problem samtools#1637)
901
902 * Permit MM (base modification) tags containing "." and "?" suffixes. These
903 define implicit vs explicit coordinates. See the SAM tags specification for
904 details.
905 (PR#1423 and PR#1426, fixes #1418. PR#1469, fixes #1466. Reported
906 by cjw85)
907
908 * Warn if spaces instead of tabs are detected in a VCF file to prevent
909 confusion.
910 (PR#1328, fixes bcftools#1575. Reported by ketkijoshi278)
911
912 * Add an "sclen" filter expression keyword. This is the length of a soft-clip,
913 both left and right end. It may be combined with qlen (qlen-sclen) to obtain
914 the number of bases in the query sequence that have been aligned to the genome
915 ie it provides a way to compare local-alignment vs global-alignment length.
916 (PR#1441 and PR/samtools#1661, fixes #1436. Requested by Chang Y)
917
918 * Improve error messages for CRAM reference mismatches. If the user specifies
919 the wrong reference, the CRAM slice header MD5sum checks fail. We now report
920 the SQ line M5 string too so it is possible to validate against the whole
921 chr in the ref.fa file. The error message has also been improved to report
922 the reference name instead of #num. Finally, we now hint at the likely cause,
923 which counters the misleading samtools supplied error of "truncated or
924 corrupt" file.
925 (PR#1427, fixes samtools#1640. Reported by Jian-Guo Zhou)
926
927 * Expose more of the CRAM API and add new functionality to extract the reference
928 from a CRAM file.
929 (PR#1429 and PR#1442)
930
931 * Improvements to the implementation of embedded references in CRAM where no
932 external reference is specified.
933 (PR#1449, addresses some of the issues in #1445)
934
935 * The CRAM writer now allows alignment records with RG:Z: aux tags that
936 don't have a corresponding @RG ID in the file header. Previously these
937 tags would have been silently dropped. HTSlib will complain whenever it
938 has to add one though, as such tags do not conform to recommended practice
939 for the SAM, BAM and CRAM formats.
940 (PR#1480, fixes #1479. Reported by Alex Leonard)
941
942 * Set tab delimiter in man page for tabix GFF3 sort.
943 (PR#1457. Thanks to Colin Diesh)
944
945 * When using libdeflate, the 1...9 scale of BGZF compression levels is
946 now remapped to the 1...12 range used by libdeflate instead of being
947 passed directly. In particular, HTSlib levels 8 and 9 now map to
948 libdeflate levels 10 and 12, so it is possible to select the highest (but
949 slowest) compression offered by libdeflate.
950 (PR#1488, fixes #1477. Reported by Gert Hulselmans)
951
952 * The VCF variant API has been extended so that it can return separate flags
953 for INS and DEL variants as well as the existing INDEL one. These flags
954 have not been added to the old bcf_get_variant_types() interface as
955 it could break existing users. To access them, it is necessary to use new
956 functions bcf_has_variant_type() and bcf_has_variant_types().
957 (PR#1467)
958
959 * The missing, but trivial, `le_to_u8()` function has been added to hts_endian.
960 (PR#1494, Thanks to John Marshall)
961
962 * bcf_format_gt() now works properly on big-endian platforms.
963 (PR#1495, Thanks to John Marshall)
964
965 Build changes
966 -------------
967
968 These are compiler, configuration and makefile based changes.
969
970 * Update htscodecs to version 1.3.0 for new SIMD code + various fixes.
971 Updates the htscodecs submodule and adds changes necessary to make HTSlib
972 build the new SIMD codec implementations.
973 (PR#1438, PR#1489, PR#1500)
974
975 * Fix clang builds under mingw. Under mingw, clang requires dllexport to be
976 applied to both function declarations and function definitions.
977 (PR#1435, PR#1497, PR#1498 fixes #1433. Reported by teepean)
978
979 * Fix curl type warning with gcc 12.1 on Windows.
980 (PR#1443)
981
982 * Detect ARM Neon support and only build appropriate SIMD object files.
983 (PR#1451, fixes #1450. Thanks to John Marshall)
984
985 * `make print-config` now reports extra CFLAGS that are needed to build the
986 SIMD parts of htscodecs. These may be of use to third-party build
987 systems that don't use HTSlib's or htscodecs' build infrastructure. (PR#1485.
988 Thanks to John Marshall)
989
990 * Fixed some Makefile dependency issues for the "check"/"test" targets
991 and plugins. In particular, "make check" will now build the "all" target,
992 if not done already, before running the tests.
993 (PR#1496)
994
995 Bug fixes
996 ---------
997
998 * Fix bug when reading position -1 in BCF (0 in VCF), which is used to indicate
999 telomeric regions. The BCF reader was incorrectly assuming the value stored
1000 in the file was unsigned, so a VCF->BCF->VCF round-trip would change it
1001 from 0 to 4294967296.
1002 (PR#1476, fixes #1475 and bcftools#1753. Reported by Rodrigo Martin)
1003
1004 * Various bugs and quirks have been fixed in the filter expression engine,
1005 mostly related to the handling of absent tags, and the is_true flag.
1006 Note that as a result of these fixes, some filter expressions may give
1007 different results:
1008 - Fixed and-expressions including aux tag values which could give an invalid
1009 true result depending on the order of terms.
1010 - The expression `![NM]` is now true if only `NM` does not exist. In
1011 earlier versions it would also report true for tags like `NM:i:0` which
1012 exist but have a value of zero.
1013 - The expression `[X1] != 0` is now false when `X1` does not exist. Earlier
1014 versions would return true for this comparison when the tag was missing.
1015 - NULL values due to missing tags now propagate through string, bitwise
1016 and mathematical operations. Logical operations always treat them as
1017 false.
1018 (PR#1463, fixes samtools#1670. Reported by Gert Hulselmans;
1019 PR#1478, fixes samtools#1677. Reported by johnsonzcode)
1020
1021 * Fix buffer overrun in bam_plp_insertion_mod. Memory now grows to the proper
1022 size needed for base modification data.
1023 (PR#1430, fixes samtools#1652. Reported by hd2326)
1024
1025 * Remove limit of returned size from fai_retrieve().
1026 (PR#1446, fixes samtools#1660. Reported by Shane McCarthy)
1027
1028 * Cap hts_getline() return value at INT_MAX. Prevents hts_getline() from
1029 returning a negative number (a fail) for very long string length values.
1030 (PR#1448. Thanks to John Marshall)
1031
1032 * Fix breakend detection and test bcf_set_variant_type().
1033 (PR#1456, fixes #1455. Thanks to Martin Pollard)
1034
1035 * Prevent arrays of BCF_BT_NULL values found in BCF files from causing
1036 bcf_fmt_array() to call exit() as the type is unsupported. These are
1037 now tested for and caught by bcf_record_check(), which returns an
1038 error code instead. (PR#1486)
1039
1040 * Improved detection of fasta and fastq files that have very long comments
1041 following identifiers. (PR#1491, thanks to John Marshall.
1042 Fixes samtools/samtools#1689, reported by cjw85)
1043
1044 * Fixed a SEGV triggered by giving a SAM file to `samtools import`.
1045 (PR#1492)
1046
1047 Noteworthy changes in release 1.15.1 (7th April 2022)
1048 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1049
1050 * Security fix: Fixed broken error reporting in the sam_prob_realn()
1051 function, due to a missing hts_log() parameter. Prior to this fix
1052 (i.e., in HTSlib versions 1.8 to 1.15) it was possible to abuse
1053 the log message format string by passing a specially crafted
1054 alignment record to this function. (PR#1406)
1055
1056 * HTSlib now uses libhtscodecs release 1.2.2. This fixes a number
1057 of bugs where invalid compressed data could trigger usage of
1058 uninitialised values. (PR#1416)
1059
1060 * Fixed excessive memory used by multi-threaded SAM output on
1061 long reads. (Part of PR#1384)
1062
1063 * Fixed a bug where tabix would misinterpret region specifiers
1064 starting at position 0. It will also now warn if the file
1065 being indexed is supposed to be 1-based but has positions
1066 less than or equal to 0. (PR#1411)
1067
1068 * The VCF header parser will now issue a warning if it finds an
1069 INFO header with Type=Flag but Number not equal to 0. It will
1070 also ignore the incorrect Number so the flag can be used. (PR#1415)
1071
1072 Noteworthy changes in release 1.15 (21st February 2022)
1073 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1074
1075 Features and Updates
1076 --------------------
1077
1078 * Bgzip now has a --keep option to not remove the input file after
1079 compressing. (PR#1331)
1080
1081 * Improved file format detection so some BED files are no longer
1082 detected as FASTQ or FASTA. (PR#1350, thanks to John Marshall)
1083
1084 * Added xz (lzma), zstd and D4 formats to the file type detection
1085 functions. We don't actively support reading these data types, but
1086 function calls and htsfile can detect them. (PR#1340, thanks to
1087 John Marshall)
1088
1089 * CRAM now also uses libdeflate for read-names if the libdeflate
1090 version is new enough (1.9 onwards). Previously we used zlib for
1091 this due to poor performance of libdeflate. This gives a slight
1092 speed up and reduction in file size. (PR#1383)
1093
1094 * The VCF and BCF readers will now issue a warning if contig, INFO
1095 or FORMAT IDs do not match the formats described in the VCFv4.3
1096 specification. Note that while the invalid names will mostly still
1097 be accepted, future updates will convert the warnings to errors
1098 causing files including invalid names to be rejected. (PR#1389)
1099
1100 Build changes
1101 -------------
1102
1103 These are compiler, configuration and makefile based changes.
1104
1105 * HTSlib now uses libhtscodecs release 1.2.1.
1106
1107 * Improved support for compiling and linking against HTSlib with
1108 Microsoft Visual Studio. (PR#1380, #1377, #1375. Thanks to
1109 Aidan Bickford and John Marshall)
1110
1111 * Various internal CI improvements.
1112
1113 Bug fixes
1114 ---------
1115
1116 * Fixed CRAM index queries for HTSJDK output (PR#1388, reported by
1117 Chris Norman). Note this also fixes writing CRAM writing, to match
1118 the specification (and HTSJDK), from version 3.1 onwards.
1119
1120 * Fixed CRAM index queries when required-fields settings are selected
1121 to ignore CIGARs (PR#1372, reported by Giulio Genovese).
1122
1123 * Unmapped but placed (having chr/pos) are now included in the BAM
1124 indices. (PR#1352, thanks to John Marshall)
1125
1126 * CRAM now honours the filename##idx##index nomenclature for
1127 specifying non-standard index locations. (PR#1360, reported by
1128 Michael Cariaso)
1129
1130 * Minor CRAM v1.0 read-group fix (PR#1349, thanks to John Marshall)
1131
1132 * Permit .fa and .fq file type detection as synonyms for FASTA and
1133 FASTQ. (PR#1386).
1134
1135 * Empty VCF format fields are now output ":.:" as instead of "::".
1136 (PR#1370)
1137
1138 * Repeated bcf_sr_seek calls now work. (PR#1363, reported by
1139 Giulio Genovese)
1140
1141 * Bcf_remove_allele_set now works on unpacked BCF records. (PR#1358,
1142 reported by Brent Pedersen).
1143
1144 * The hts_parse_decimal() function used to read numbers in region lists
1145 is now better at rejecting non-numeric values. In particular it
1146 now rejects a lone 'G' instead of interpreting it as '0G', i.e. zero.
1147 (PR#1396, PR#1400, reported by SSSimon Yang; thanks to John Marshall).
1148
1149 * Improve support for GPU issues listed by -Wdouble-promotion.
1150 (PR#1365, reported by David Seisert)
1151
1152 * Fix example code in header file documentation. (PR#1381, Thanks to
1153 Aidan Bickford)
1154
1155 Noteworthy changes in release 1.14 (22nd October 2021)
1156 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1157
1158 Features and Updates
1159 --------------------
1160
1161 * Added a keep option to bgzip to leave the original file untouched. This
1162 brings bgzip into line with gzip. (PR #1331, thanks to Alex Petty)
1163
1164 * "endpos" has been added to the filter language, giving the position
1165 of the rightmost mapped base as measured by the CIGAR string. For
1166 unmapped reads it is the same as "pos". (PR #1307, thanks to John Marshall)
1167
1168 * Interfaces have been added to interpret the new base modification tags
1169 added to the SAMtags document in samtools/hts-specs#418. (PR #1132)
1170
1171 * New API functions hts_flush()/sam_flush()/bcf_flush() for flushing output
1172 htsFile/samFile/vcfFile streams. (PR #1326, thanks to John Marshall)
1173
1174 * The synced_bcf_reader now sorts lines with symbolic alleles by END tag as
1175 well as POS. (PR #1321)
1176
1177 * Added synced_bcf_reader options BCF_SR_REGIONS_OVERLAP and
1178 BCF_SR_TARGETS_OVERLAP for better control of records that start outside
1179 the desired region but overlap it are handled. Fixes samtools/bcftools#1420
1180 and samtools/bcftools#1421 raised by John Marshall. (PR #1327)
1181
1182 * HTSlib will now accept long-cigar CG:B: tags made by htsjdk which don't
1183 quite follow the specification properly (using signed values instead of
1184 unsigned). Thanks to Colin Diesh for reporting an example file. (PR #1317)
1185
1186 * The warning printed when the BGZF reader finds a file with no EOF block
1187 has been changed to be less alarming. Unfortunately some third-party
1188 BGZF encoders don't write EOF blocks at the end of files. Thanks to
1189 Keiran Raine for reporting an example file. (PR #1323)
1190
1191 * The FASTA and FASTQ readers get an option to skip over the first item on
1192 the header line, and use the second as the read name. It allows the original
1193 name to be restored on some of the fastq files served from the European
1194 Nucleotide Archive (ENA). (PR #1325)
1195
1196 * HTSlib is now more strict when parsing the VCF samples line (beginning
1197 #CHROM). It will only accept tabs between the mandatory field names and
1198 sample names must be separated with tabs. (PR #1328)
1199
1200 * HTSlib will now warn if it looks like the header has been corrupted
1201 by diagnostic messages from the program that made it. This can happen when
1202 using `nohup`, which by default mixes stdout and stderr into the same
1203 stream. (PR#1339, thanks to John Marshall)
1204
1205 * File format detection will now recognise signatures for XZ, Zstd and D4
1206 files (note that HTSlib will not read them yet). (PR #1340, thanks to
1207 John Marshall)
1208
1209 Build changes
1210 -------------
1211
1212 These are compiler, configuration and makefile based changes.
1213
1214 * Some redundant tests have been removed from the test harness, speeding it up.
1215 (PR #1308)
1216
1217 * The version.sh script now works better on shallow checkouts. (PR #1324)
1218
1219 * A check-untracked Makefile target has been added to catch untracked files
1220 (mostly) left by the test harness. (PR #1324)
1221
1222 Bug fixes
1223 ---------
1224
1225 * Fixed a case where flushing the thread pool could very occasionally cause
1226 a deadlock. (PR #1309)
1227
1228 * Fixed a bug where some CRAM files could fail to decode if the required_fields
1229 option was in use. Thanks to Matt Sexton for reporting the issue.
1230 (PR #1314, fixes samtools/samtools#1475)
1231
1232 * Fixed a regression where the S3 plugin could not read public files unless
1233 you supplied some Amazon credentials. Thanks to Chris Saunders for reporting.
1234 (PR #1332, fixes samtools/samtools#1491)
1235
1236 * Fixed a possible CRAM thread deadlock discovered by @ryancaicse.
1237 (PR #1330, fixes #1329)
1238
1239 * Some set-but-unused variables have been removed. (PR #1334)
1240
1241 * Fixed a bug which prevented "flag.read2" from working in the filter
1242 language unless it was at the end of the expression. Thanks to Vamsi Kodali
1243 for reporting the issue. (PR #1342)
1244
1245 * Fixed a memory leak that could happen if CRAM fails to inflate a LZMA
1246 block. (PR #1340, thanks to John Marshall)
1247
1248 Noteworthy changes in release 1.13 (7th July 2021)
1249 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1250
1251 Features and Updates
1252 --------------------
1253
1254 * In case a PG header line has multiple ID tags supplied by other applications,
1255 the header API now selects the first one encountered as the identifying tag
1256 and issues a warning when detecting subsequent ID tags.
1257 (#1256; fixed samtools/samtools#1393)
1258
1259 * VCF header reading function (vcf_hdr_read) no longer tries to download a
1260 remote index file by default.
1261 (#1266; fixes #380)
1262
1263 * Support reading and writing FASTQ format in the same way as SAM, BAM or CRAM.
1264 Records read from a FASTQ file will be treated as unmapped data.
1265 (#1156)
1266
1267 * Added GCP requester pays bucket access. Thanks to @indraniel.
1268 (#1255)
1269
1270 * Made mpileup's overlap removal choose which copy to remove at random instead
1271 of always removing the second one. This avoids strand bias in experiments
1272 where the +ve and -ve strand reads always appear in the same order.
1273 (#1273; fixes samtools/bcftools#1459)
1274
1275 * It is now possible to use platform specific BAQ parameters. This also
1276 selects long-read parameters for read lengths bigger than 1kb, which helps
1277 bcftools mpileup call SNPs on PacBio CCS reads.
1278 (#1275)
1279
1280 * Improved bcf_remove_allele_set. This fixes a bug that stopped iteration over
1281 alleles prematurely, marks removed alleles as 'missing' and does automatic
1282 lazy unpacking.
1283 (#1288; fixes #1259)
1284
1285 * Improved compression metrics for unsorted CRAM files. This improves the
1286 choice of codecs when handling unsorted data.
1287 (#1291)
1288
1289 * Linear index entries for empty intervals are now initialised with the file
1290 offset in the next non-empty interval instead of the previous one. This
1291 may reduce the amount of data iterators have to discard before reaching
1292 the desired region, when the starting location is in a sequence gap.
1293 Thanks to @carsonh for reporting the issue.
1294 (#1286; fixes #486)
1295
1296 * A new hts_bin_level API function has been added, to compute the level of a
1297 given bin in the binning index.
1298 (#1286)
1299
1300 * Related to the above, a new API method, hts_idx_nseq, now returns the total
1301 number of contigs from an index.
1302 (#1295 and #1299)
1303
1304 * Added bracket handling to bcf_hdr_parse_line, for use with ##META lines.
1305 Thanks to Alberto Casas Ortiz.
1306 (#1240)
1307
1308 Build changes
1309 -------------
1310
1311 These are compiler, configuration and makefile based changes.
1312
1313 * HTSlib now uses libhtscodecs release 1.1.1.
1314
1315 * Added a curl/curl.h check to configure and improved INSTALL documentation on
1316 build options. Thanks to Melanie Kirsche and John Marshall.
1317 (#1265; fixes #1261)
1318
1319 * Some fixes to address GCC 11.1 warnings.
1320 (#1280, #1284, #1285; fixes #1283)
1321
1322 * Supports building HTSlib in a separate directory. Thanks to John Marshall.
1323 (#1277; fixes #231)
1324
1325 * Supports building HTSlib on MinGW 32-bit environments. Thanks to
1326 John Marshall.
1327 (#1301)
1328
1329 Bug fixes
1330 ---------
1331
1332 * Fixed hts_itr_query() et al region queries: fixed bug introduced in
1333 HTSlib 1.12, which led to iterators producing very few reads for some
1334 queries (especially for larger target regions) when unmapped reads were
1335 present. HTSlib 1.11 had a related problem in which iterators would omit
1336 a few unmapped reads that should have been produced; cf #1142.
1337 Thanks to Daniel Cooke for reporting the issue.
1338 (#1281; fixes #1279)
1339
1340 * Removed compressBound assertions on opening bgzf files. Thanks to
1341 Gurt Hulselmans for reporting the issue.
1342 (#1258; fixed #1257)
1343
1344 * Duplicate sample name error message for a VCF file now only displays the
1345 duplicated name rather the entire same name list.
1346 (#1262; fixes samtools/bcftools#1451)
1347
1348 * Fix to make samtools cat work on CRAMs again.
1349 (#1276; fixes samtools/samtools#1420)
1350
1351 * Fix for a double memory free in SAM header creation. Thanks to @ihsineme.
1352 (#1274)
1353
1354 * Prevent assert in bcf_sr_set_regions. Thanks to Dr K D Murray.
1355 (#1270)
1356
1357 * Fixed crash in knet_open() etc stubs. Thanks to John Marshall.
1358 (#1289)
1359
1360 * Fixed filter expression "cigar" on unmapped reads. Stop treating an empty
1361 CIGAR string as an error. Thanks to Chang Y for reporting the issue.
1362 (#1298, fixes samtools/samtools#1445)
1363
1364 * Bug fixes in the bundled copy of htscodecs:
1365
1366 - Fixed an uninitialized access in the name tokeniser decoder.
1367 (samtools/htscodecs#23)
1368
1369 - Fixed a bug with name tokeniser and variable number of names per slice,
1370 causing it to incorrectly report an error on certain valid inputs.
1371 (samtools/htscodecs#24)
1372
1373
1374 Noteworthy changes in release 1.12 (17th March 2021)
1375 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1376
1377 Features and Updates
1378 --------------------
1379
1380 * Added experimental CRAM 3.1 and 4.0 support. (#929)
1381
1382 These should not be used for long term data storage as the
1383 specification still needs to be ratified by GA4GH and may be subject
1384 to changes in format. (This is highly likely for 4.0). However it
1385 may be tested using:
1386
1387 test/test_view -t ref.fa -C -o version=3.1 in.bam -p out31.cram
1388
1389 For smaller but slower files, try varying the compression profile
1390 with an additional "-o small". Profile choices are fast, normal,
1391 small and archive, and can be applied to all CRAM versions.
1392
1393 * Added a general filtering syntax for alignment records in SAM/BAM/CRAM
1394 readers. (#1181, #1203)
1395
1396 An example to find chromosome spanning read-pairs with high mapping
1397 quality: 'mqual >= 30 && mrname != rname'
1398
1399 To find significant sized deletions:
1400 'cigar =~ "[0-9]{2}D"' or 'rlen - qlen > 10'.
1401
1402 To report duplicates that aren't part of a "proper pair":
1403 'flag.dup && !flag.proper_pair'
1404
1405 More details are in the samtools.1 man page under "FILTER EXPRESSIONS".
1406
1407 * The knet networking code has been removed. It only supported the http
1408 and ftp protocols, and a better and safer alternative using libcurl
1409 has been available since release 1.3. If you need access to ftp:// and
1410 http:// URLs, HTSlib should be built with libcurl support. (#1200)
1411
1412 * The old htslib/knetfile.h interfaces have been marked as deprecated. Any
1413 code still using them should be updated to use hFILE instead. (#1200)
1414
1415 * Added an introspection API for checking some of the capabilities provided
1416 by HTSlib. (#1170) Thanks also to John Marshall for contributions. (#1222)
1417 - `hfile_list_schemes`: returns the number of schemes found
1418 - `hfile_list_plugins`: returns the number of plugins found
1419 - `hfile_has_plugin`: checks if a specific plugin is available
1420 - `hts_features`: returns a bit mask with all available features
1421 - `hts_test_feature`: test if a feature is available
1422 - `hts_feature_string`: return a string summary of enabled features
1423
1424 * Made performance improvements to `probaln_glocal` method, which
1425 speeds up mpileup BAQ calculations. (#1188)
1426 - Caching of reused loop variables and removal of loop invariants
1427 - Code reordering to remove instruction latency.
1428 - Other refactoring and tidyups.
1429
1430 * Added a public method for constructing a BAM record from the
1431 component pieces. Thanks to Anders Kaplan. (#1159, #1164)
1432
1433 * Added two public methods, `sam_parse_cigar` and `bam_parse_cigar`, as part of
1434 a small CIGAR API (#1169, #1182). Thanks to Daniel Cameron for input. (#1147)
1435
1436 * HTSlib, and the included htsfile program, will now recognise the old
1437 RAZF compressed file format. Note that while the format is detected,
1438 HTSlib is unable to read it. It is recommended that RAZF files are
1439 uncompressed with `gunzip` before using them with HTSlib. Thanks to
1440 John Marshall (#1244); and Matthew J. Oldach who reported problems
1441 with uncompressing some RAZF files (samtools/samtools#1387).
1442
1443 * The S3 plugin now has options to force the address style. It will recognise
1444 the addressing_style and host_bucket entries in the respective aws
1445 .credentials and s3cmd .s3cfg files. There is also a new HTS_S3_ADDRESS_STYLE
1446 environment variable. Details are in the htslib-s3-plugin.7 man file (#1249).
1447
1448 Build changes
1449 -------------
1450
1451 These are compiler, configuration and makefile based changes.
1452
1453 * Added new Makefile targets for the applications that embed HTSlib and
1454 want to run its test suite or clean its generated artefacts. (#1230, #1238)
1455
1456 * The CRAM codecs are now obtained via the htscodecs submodule, hence
1457 when cloning it is now best to use "git clone --recursive". In an
1458 existing clone, you may use "git submodule update --init" to obtain
1459 the htscodecs submodule checkout.
1460
1461 * Updated CI test configuration to recurse HTSlib submodules. (#1359)
1462
1463 * Added Cirrus-CI integration as a replacement for Travis, which was
1464 phased out. (#1175; #1212)
1465
1466 * Updated the Windows image used by Appveyor to 'Visual Studio 2019'. (#1172;
1467 fixed #1166)
1468
1469 * Fixed a buglet in configure.ac, exposed by the release 2.70 of autoconf.
1470 Thanks to John Marshall. (#1198)
1471
1472 * Fixed plugin linking on macOS, to prevent symbol conflict when linking
1473 with a static HTSlib. Thanks to John Marshall. (#1184)
1474
1475 * Fixed a clang++9 error in `cram_io.h`. Thanks to Pjotr Prins. (#1190)
1476
1477 * Introduced $(ALL_CPPFLAGS) to allow for more flexibility in setting the
1478 compiler flags. Thanks to John Marshall. (#1187)
1479
1480 * Added 'fall through' comments to prevent warnings issued by Clang on
1481 intentional fall through case statements, when building with
1482 `-Wextra flag`. Thanks to John Marshall. (#1163)
1483
1484 * Non-configure builds now define _XOPEN_SOURCE=600 to allow them to work
1485 when the `gcc -std=c99` option is used. Thanks to John Marshall. (#1246)
1486
1487 Bug fixes
1488 ---------
1489
1490 * Fixed VCF `#CHROM` header parsing to only separate columns at tab characters.
1491 Thanks to Sam Morris for reporting the issue.
1492 (#1237; fixed samtools/bcftools#1408)
1493
1494 * Fixed a crash reported in `bcf_sr_sort_set`, which expects REF to be present.
1495 (#1204; fixed samtools/bcftools#1361)
1496
1497 * Fixed a bcf synced reader bug when filtering with a region list, and
1498 the first record for a chromosome had the same position as the last
1499 record for the previous chromosome. (#1254; fixed samtools/bcftools#1441)
1500
1501 * Fixed a bug in the overlapping logic of mpileup, dealing with iterating over
1502 CIGAR segments. Thanks to `@wulj2` for the analysis. (#1202; fixed #1196)
1503
1504 * Fixed a tabix bug that prevented setting the correct number of lines to be
1505 skipped in a region file. Thanks to Jim Robinson for reporting it. (#1189;
1506 fixed #1186)
1507
1508 * Made `bam_itr_next` an alias for `sam_itr_next`, to prevent it from crashing
1509 when working with htsFile pointers. Thanks to Torbjörn Klatt for
1510 reporting it. (#1180; fixed #1179)
1511
1512 * Fixed once per outgoing multi-threaded block `bgzf_idx_flush` assertion, to
1513 accommodate situations when a single record could span multiple blocks.
1514 Thanks to `@lacek`. (#1168; fixed samtools/samtools#1328)
1515
1516 * Fixed assumption of pthread_t being a non-structure, as permitted by POSIX.
1517 Thanks also to John Marshall and Anders Kaplan. (#1167, #1153, #1153)
1518
1519 * Fixed the minimum offset of a BAI index bin, to account for unmapped reads.
1520 Thanks to John Marshall for spotting the issue. (#1158; fixed #1142)
1521
1522 * Fixed the CRLF handling in `sam_parse_worker` method. Thanks to
1523 Anders Kaplan. (#1149; fixed #1148)
1524
1525 * Included unistd.h and errno.h directly in HTSlib files, as opposed to
1526 including them indirectly, via third party code. Thanks to
1527 Andrew Patterson (#1143) and John Marshall (#1145).
1528
1529
1530 Noteworthy changes in release 1.11 (22nd September 2020)
1531 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1532
1533 Features and Updates
1534 --------------------
1535
1536 * Support added for remote reference files. fai_path() can take a remote
1537 reference file and will return the corresponding index file. Remote indexes
1538 can be handled by refs_load_fai(). UR tags in @SQ lines can now be set to
1539 remote URIs. (#1017)
1540
1541 * Added tabix --separate-regions option, which adds header comment lines
1542 separating different regions' output records when multiple target regions
1543 are supplied on the command line. (#1108)
1544
1545 * Added tabix --cache option to set a BGZF block cache size. Most beneficial
1546 when the -R option is used and the same blocks need to be re-read multiple
1547 times. (#1053)
1548
1549 * Improved error checking in tabix and added a --verbosity option so
1550 it is possible to change the amount of logging when it runs. (#1040)
1551
1552 * A note about the maximum chromosome length usable with TBI indexes has been
1553 added to the tabix manual page. Thanks to John Marshall. (#1070)
1554
1555 * New method vcf_open_mode() changes the opening mode of a variant file
1556 based on its file extension. Similar to sam_open_mode(). (#1096)
1557
1558 * The VCF parser has been made faster and easier to maintain. (#1057)
1559
1560 * bcf_record_check() has been made faster, giving a 15% speed increase when
1561 reading an uncompressed BCF file. (#1130)
1562
1563 * The VCF parser now recognises the "<NON_REF>" symbolic allele produced
1564 by GATK. (#1045)
1565
1566 * Support has been added for simultaneous reading of unindexed VCF/BCF files
1567 when using the synced_bcf_reader interface. Input files must have the
1568 chromosomes in the same order as each other and be consistent with the order
1569 of sequences in the header. (#1089)
1570
1571 * The VCF and BCF readers will now attempt to fix up invalid INFO/END tags
1572 where the stored END value is less than POS, resulting in an apparently
1573 negative record length. Such files have been generated by programs which
1574 used END incorrectly, and by broken lift-over processes that failed to
1575 update any END tags present. (#1021; fixed samtools/bcftools#1154)
1576
1577 * The htsFile interface can now detect the crypt4gh encrypted format (see
1578 https://samtools.github.io/hts-specs/crypt4gh.pdf). If HTSlib is
1579 built with external plug-in support, and the hfile_crypt4gh plug-in is
1580 present, the file will be passed to it for decryption. The plug-in
1581 can be obtained from https://github.com/samtools/htslib-crypt4gh. (#1046)
1582
1583 * hts_srand48() now seeds the same POSIX-standard sequences of pseudo-random
1584 numbers regardless of platform, including on OpenBSD where plain srand48()
1585 produces a different cryptographically-strong non-deterministic sequence.
1586 Thanks to John Marshall. (#1002)
1587
1588 * Iterators now work with 64 bit positions. (#1018)
1589
1590 * Improved the speed of range queries when using BAI indexes by
1591 making better use of the linear index data included in the file.
1592 The best improvement is on low-coverage data. (#1031)
1593
1594 * Alignments which consume no reference bases are now considered to have
1595 length 1. This would make such alignments cover 1 reference position in
1596 the same manner as alignments that are unmapped or have no CIGAR strings.
1597 These alignments can now be returned by iterator-based queries. Thanks
1598 to John Marshall. (#1063; fixed samtools/samtools#1240, see also
1599 samtools/hts-specs#521).
1600
1601 * A bam_set_seqi() function to modify a single base in the BAM structure
1602 has been added. This is a companion function to bam_seqi(). (#1022)
1603
1604 * Writing SAM format is around 30% faster. (#1035)
1605
1606 * Added sam_format_aux1() which converts a BAM aux tag to a SAM format string.
1607 (#1134)
1608
1609 * bam_aux_update_str() no longer requires NUL-terminated strings. It
1610 is also now possible to create tags containing part of a longer string.
1611 (#1088)
1612
1613 * It is now possible to use external plug-ins in language bindings that
1614 dynamically load HTSlib. Note that a side-effect of this change is that
1615 some plug-ins now link against libhts.so, which means that they have to be
1616 able to find the shared library when they are started up. Thanks to
1617 John Marshall. (#1072)
1618
1619 * bgzf_close(), and therefore hts_close(), will now return non-zero when
1620 closing a BGZF handle on which errors have been detected. (Part of #1117)
1621
1622 * Added a special case to the kt_fisher_exact() test for when the table
1623 probability is too small to be represented in a double. This fixes a
1624 bug where it would, for some inputs, fail to correctly determine which
1625 side of the distribution the table was on resulting in swapped p-values
1626 being returned for the left- and right-tailed tests. The two-tailed
1627 test value was not affected by this problem. (#1126)
1628
1629 * Improved error diagnostics in the CRAM decoder (#1042), BGZF (#1049),
1630 the VCF and BCF readers (#1059), and the SAM parser (#1073).
1631
1632 * ks_resize() now allocates 1.5 times the requested size when it needs
1633 to expand a kstring instead of rounding up to the next power of two.
1634 This has been done mainly to make the inlined function smaller, but it
1635 also reduces the overhead of storing data in kstrings at the expense of
1636 possibly needing a few more reallocations. (#1129)
1637
1638 CRAM improvements
1639 -----------------
1640
1641 * Delay CRAM crc32 checks until the data actually needs to be used. With
1642 other changes this leads to a 20x speed up in indexing and other sub-query
1643 based actions. (#988)
1644
1645 * CRAM now handles the transition from mapped to unmapped data in a better
1646 way, improving compression of the unmapped data. (#961)
1647
1648 * CRAM can now use libdeflate. (#961)
1649
1650 * Fixed bug in MD tag generation with "b" read feature codes, causing the
1651 numbers in the tag to be too large. Note that HTSlib never uses this
1652 feature code so it is unlikely that this bug would be seen on real data.
1653 The problem was found when testing against hand-crafted CRAM files. (#1086)
1654
1655 * Fixed a regression where the CRAM multi-region iterator became much less
1656 efficient when using threads. It now works more like the single iterator
1657 and does not preemptively decode the next container unless it will be used.
1658 (#1061)
1659
1660 * Set CRAM default quality in lossy quality modes. If lossy quality is enabled
1661 and 'B', 'q' or 'Q' features are used, CRAM starts off with QUAL being all 255
1662 (as per BAM spec and "*" quality) and then modifies individual qualities as
1663 dictated by the specific features.
1664
1665 However that then produces ASCII quality " " (space, q=-1) for the unmodified
1666 bases. Instead ASCII quality "?" (q=30) is used, as per HTSJDK. Quality 255
1667 is still used for sequences with no modifications at all. (#1094)
1668
1669
1670 Build changes
1671 -------------
1672
1673 These are compiler, configuration and makefile based changes.
1674
1675 * `make all` now also builds htslib_static.mk and htslib-uninstalled.pc.
1676 Thanks to John Marshall. (#1011)
1677
1678 * Various cppcheck-1.90 warnings have been fixed. (#995, #1011)
1679
1680 * HTSlib now prefers its own headers when being compiled, fixing build
1681 failures on machines that already had a system-installed HTSlib. Thanks to
1682 John Marshall. (#1078; fixed #347)
1683
1684 * Define HTSLIB_EXPORT without using a helper macro to reduce the length of
1685 compiler diagnostics that mention exported functions. Thanks to
1686 John Marshall. (#1029)
1687
1688 * Fix dirty default build by including latest pkg.m4 instead of using
1689 aclocal.m4. Thanks to Damien Zammit. (#1091)
1690
1691 * Struct tags have been added to htslib/*.h public typedefs. This makes it
1692 possible to forward declare htsFile without including htslib/hts.h. Thanks
1693 to Lucas Czech and John Marshall. (#1115; fixed #1106)
1694
1695 * Fixed compiler warnings emitted by the latest gcc and clang releases
1696 when compiling HTSlib, along with some -Wextra warnings in the public
1697 include files. Thanks to John Marshall. (#1066, #1063, #1083)
1698
1699 Bug fixes
1700 ---------
1701
1702 * Fixed hfile_libcurl breakage when using libcurl 7.69.1 or later. Thanks to
1703 John Marshall for tracking down the exact libcurl change that caused the
1704 incompatibility. (#1105; fixed samtools/samtools#1254 and
1705 samtools/samtools#1284)
1706
1707 * Fixed overflows kroundup32() and kroundup_size_t() which caused them to
1708 return zero when rounding up values where the most significant bit was
1709 set. When this happens they now return the highest value that can
1710 be stored (#1044). All of the kroundup macro definitions have also been
1711 gathered together into a unified implementation (#1051).
1712
1713 * Fixed missing return parameter value in idx_test_and_fetch(). Thanks to
1714 Lilian Janin. (#1014)
1715
1716 * Fixed crashes due to inconsistent selection between BGZF and plain (hFILE)
1717 interfaces when reading files. [fuzz] (#1019)
1718
1719 * Added and/or fixed byte swapping code for big-endian platforms. Thanks
1720 to Jun Aruga, John Marshall, Michael R Crusoe and Gianfranco Costamagna
1721 for their help. (#1023; fixed #119 and #355)
1722
1723 * Fixed a problem with multi-threaded on-the-fly indexes which would
1724 occasionally write virtual offsets pointing at the end of a BGZF block.
1725 Attempting to read from such an offset caused EOF to be incorrectly
1726 reported. These offsets are now handled correctly, and the indexer
1727 has been updated to avoid generating them. (#1028; fixed
1728 samtools/samtools#1197)
1729
1730 * In sam_hdr_create(), free newly allocated SN strings when encountering an
1731 error. [fuzz] (#1034)
1732
1733 * Prevent double free in case of idx_test_and_fetch() failure. Thanks to
1734 @fanwayne for the bug report. (#1047; fixed #1033)
1735
1736 * In the header, link a new PG line only to valid chains. Prevents an
1737 explosive growth of PG lines on headers where PG lines are already present
1738 but not linked together correctly. (#1062; fixed samtools/samtools#1235)
1739
1740 * Also in the header, when calling sam_hdr_update_line(), update target arrays
1741 only when the name or length is changed. (#1007)
1742
1743 * Fixed buffer overflows in CRAM MD5 calculation triggered by
1744 files with invalid compression headers, or files with embedded
1745 references that were one byte too short. [fuzz] (#1024, #1068)
1746
1747 * Fix mpileup regression between 1.9 and 1.10 where overlap detection
1748 was incorrectly skipped on reads where RNEXT, PNEXT and TLEN were
1749 set to the "unavailable" values ("*", 0, 0 in SAM). (#1097)
1750
1751 * kputs() now checks for null pointer in source string. [fuzz] (#1087)
1752
1753 * Fix potential bcf_update_alleles() crash on 0 alleles. Thanks to
1754 John Marshall. (#994)
1755
1756 * Added bcf_unpack() calls to some bcf_update functions to fix a bug
1757 where updates made after a call to bcf_dup() could be lost. (#1032;
1758 fixed #1030)
1759
1760 * Error message typo "Number=R" instead of "Number=G" fixed in
1761 bcf_remove_allele_set(). Thanks to Ilya Vorontsov. (#1100)
1762
1763 * Fixed crashes that could occur in BCF files that use IDX= header annotations
1764 to create a sparse set of CHROM, FILTER or FORMAT indexes, and
1765 include records that use one of the missing index values. [fuzz] (#1092)
1766
1767 * Fixed potential integer overflows in the VCF parser and ensured that
1768 the total length of FORMAT fields cannot go over 2Gbytes. [fuzz] (#1044,
1769 #1104; latter is CVE-2020-36403 affecting all HTSlib versions up to 1.10.2)
1770
1771 * Download index files atomically in idx_test_and_fetch(). This prevents
1772 corruption when running parallel jobs on S3 files. Thanks to John Marshall.
1773 (#1112; samtools/samtools#1242).
1774
1775 * The pileup constructor callback is now given the copy of the bam1_t struct
1776 made by pileup instead of the original one passed to bam_plp_push(). This
1777 makes it the same as the one passed to the destructor and ensures that
1778 cached data, for example the location of an aux tag, will remain valid.
1779 (#1127)
1780
1781 * Fixed possible error in code_sort() on negative CRAM Huffman code
1782 length. (#1008)
1783
1784 * Fixed possible undefined shift in cram_byte_array_stop_decode_init(). (#1009)
1785
1786 * Fixed a bug where range queries to the end of a given reference
1787 would return incorrect results on CRAM files. (#1016;
1788 fixed samtools/samtools#1173)
1789
1790 * Fixed an integer overflow in cram_read_slice(). [fuzz] (#1026)
1791
1792 * Fixed a memory leak on failure in cram_decode_slice(). [fuzz] (#1054)
1793
1794 * Fixed a regression which caused cram_transcode_rg() to fail, resulting
1795 in a crash in "samtools cat" on CRAM files. (#1093;
1796 fixed samtools/samtools#1276)
1797
1798 * Fixed an undersized string reallocation in the threaded SAM reader which
1799 caused it to crash when reading SAM files with very long lines. Numerous
1800 memory allocation checks have also been added. (#1117)
1801
1802
1803 Noteworthy changes in release 1.10.2 (19th December 2019)
1804 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1805
1806 This is a release fix that corrects minor inconsistencies discovered in
1807 previous deliverables.
1808
1809
1810 Noteworthy changes in release 1.10.1 (17th December 2019)
1811 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1812
1813 The support for 64-bit coordinates in VCF brought problems for files
1814 not conforming to VCF/BCF specification. While previous versions would
1815 make out-of-range values silently overflow creating nonsense values
1816 but parseable file, the version 1.10 would silently create an invalid BCF.
1817
1818
1819 Noteworthy changes in release 1.10 (6th December 2019)
1820 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1821
1822 Brief summary
1823 -------------
1824
1825 There are many changes in this release, so the executive summary is:
1826
1827 * Addition of support for references longer than 2Gb (NB: SAM and VCF
1828 formats only, not their binary counterparts). This may need changes
1829 in code using HTSlib. See README.large_positions.md for more information.
1830
1831 * Added a SAM header API.
1832
1833 * Major speed up to SAM reading and writing. This also now supports
1834 multi-threading.
1835
1836 * We can now auto-index on-the-fly while writing a file. This also
1837 includes to bgzipped SAM.gz.
1838
1839 * Overhaul of the S3 interface, which now supports version 4
1840 signatures. This also makes writing to S3 work.
1841
1842 These also required some ABI changes. See below for full details.
1843
1844
1845 Features / updates
1846 ------------------
1847
1848 * A new SAM/BAM/CRAM header API has been added to HTSlib, allowing header
1849 data to be updated without having to parse or rewrite large parts of the
1850 header text. See htslib/sam.h for function definitions and
1851 documentation. (#812)
1852
1853 The header typedef and several pre-existing functions have been renamed
1854 to have a sam_hdr_ prefix: sam_hdr_t, sam_hdr_init(), sam_hdr_destroy(),
1855 and sam_hdr_dup(). (The existing bam_hdr_-prefixed names are still
1856 provided for compatibility with existing code.) (#887, thanks to
1857 John Marshall)
1858
1859 * Changes to hfile_s3, which provides support for the AWS S3 API. (#839)
1860
1861 - hfile_s3 now uses version 4 signatures by default. Attempting to write to
1862 an S3 bucket will also now work correctly. It is possible to force
1863 version 2 signatures by creating environment variable HTS_S3_V2 (the exact
1864 value does not matter, it just has to exist). Note that writing depends
1865 on features that need version 4 signatures, so forcing version 2 will
1866 disable writes.
1867
1868 - hfile_s3 will automatically retry requests where the region endpoint
1869 was not specified correctly, either by following the 301 redirect (when
1870 using path-style requests) or reading the 400 response (when using
1871 virtual-hosted style requests and version 4 signatures). The first
1872 region to try can be set by using the AWS_DEFAULT_REGION environment
1873 variable, by setting "region" in ".aws/credentials" or by setting
1874 "bucket_location" in ".s3cfg".
1875
1876 - hfile_s3 now percent-escapes the path component of s3:// URLs. For
1877 backwards-compatibility it will ignore any paths that have already
1878 been escaped (detected by looking for '%' followed by two hexadecimal
1879 digits.)
1880
1881 - New environment variables HTS_S3_V2, HTS_S3_HOST, HTS_S3_S3CFG
1882 and HTS_S3_PART_SIZE to force version-2 signatures, control the
1883 S3 server hostname, the configuration file and upload chunk
1884 sizes respectively.
1885
1886 * Numerous SAM format improvements.
1887
1888 - Bgzipped SAM files can now be indexed and queried. The library now
1889 recognises sam.gz as a format name to ease this usage. (#718, #916)
1890
1891 - The SAM reader and writer now supports multi-threading via the
1892 thread-pool. (#916)
1893
1894 Note that the multi-threaded SAM reader does not currently support seek
1895 operations. Trying to do this (for example with an iterator range request)
1896 will result in the SAM readers dropping back to single-threaded mode.
1897
1898 - Major speed up of SAM decoding and encoding, by around 2x. (#722)
1899
1900 - SAM format can now handle 64-bit coordinates and references. This
1901 has implications for the ABI too (see below). Note BAM and CRAM
1902 currently cannot handle references longer than 2Gb, however given
1903 the speed and threading improvements SAM.gz is a viable workaround. (#709)
1904
1905 * We can now automatically build indices on-the-fly while writing
1906 SAM, BAM, CRAM, VCF and BCF files. (Note for SAM and VCF this only
1907 works when bgzipped.) (#718)
1908
1909 * HTSlib now supports the @SQ-AN header field, which lists alternative names
1910 for reference sequences. This means given "@SQ SN:1 AN:chr1", tools like
1911 samtools can accept requests for "1" or "chr1" equivalently. (#931)
1912
1913 * Zero-length files are no longer considered to be valid SAM files
1914 (with no header and no alignments). This has been changed so that pipelines
1915 such as `somecmd | samtools ...` with `somecmd` aborting before outputting
1916 anything will now propagate the error to the second command. (#721, thanks
1917 to John Marshall; #261 reported by Adrian Tan)
1918
1919 * Added support for use of non-standard index names by pasting the
1920 data filename and index filename with ##idx##. For example
1921 "/path1/my_data.bam##idx##/path2/my_index.csi" will open bam file
1922 "/path1/my_data.bam" and index file "/path2/my_index.csi". (#884)
1923
1924 This affects hts_idx_load() and hts_open() functions.
1925
1926 * Improved the region parsing code to handle colons in reference
1927 names. Strings can be disambiguated by the use of braces, so for
1928 example when reference sequences called "chr1" and "chr1:100-200"
1929 are both present, the regions "{chr1}:100-200" and "{chr1:100-200}"
1930 unambiguously indicate which reference is being used. (#708)
1931
1932 A new function hts_parse_region() has been added along with
1933 specialisations for sam_parse_region() and fai_parse_region().
1934
1935 * CRAM encoding now has additional checks for MD/NM validity. If
1936 they are incorrect, it stores the (incorrect copy) verbatim so
1937 round-trips "work". (#792)
1938
1939 * Sped up decoding of CRAM by around 10% when the MD tag is being
1940 generated. (#874)
1941
1942 * CRAM REF_PATH now supports %Ns (where N is a single digit)
1943 expansion in http URLs, similar to how it already supported this
1944 for directories. (#791)
1945
1946 * BGZF now permits indexing and seeking using virtual offsets in
1947 completely uncompressed streams. (#904, thanks to Adam Novak)
1948
1949 * bgzip now asks for extra confirmation before decompressing files
1950 that don't have a known compression extension (e.g. .gz). This avoids
1951 `bgzip -d foo.bam.bai` producing a foo.bam file that is very much not
1952 a BAM-formatted file. (#927, thanks to John Marshall)
1953
1954 * The htsfile utility can now copy files (including to/from URLs using
1955 HTSlib's remote access facilities) with the --copy option, in
1956 addition to its existing uses of identifying file formats and
1957 displaying sequence or variant data. (#756, thanks to John Marshall)
1958
1959 * Added tabix --min-shift option. (#752, thanks to Garrett Stevens)
1960
1961 * Tabix now has an -D option to disable storing a local copy of a
1962 remote index. (#870)
1963
1964 * Improved support for MSYS Windows compiler environment. (#966)
1965
1966 * External htslib plugins are now supported on Windows. (#966)
1967
1968
1969 API additions and improvements
1970 ------------------------------
1971
1972 * New API functions bam_set_mempolicy() and bam_get_mempolicy() have
1973 been added. These allow more control over the ownership of bam1_t
1974 alignment record data; see documentation in htslib/sam.h for more
1975 information. (#922)
1976
1977 * Added more HTS_RESULT_USED checks, this time for VCF I/O. (#805)
1978
1979 * khash can now hash kstrings. This makes it easier to hash
1980 non-NUL-terminated strings. (#713)
1981
1982 * New haddextension() filename extension API function. (#788, thanks to
1983 John Marshall)
1984
1985 * New hts_resize() macro, designed to replace uses of hts_expand()
1986 and hts_expand0(). (#805)
1987
1988 * Added way of cleaning up unused jobs in the thread pool via the new
1989 hts_tpool_dispatch3() function. (#830)
1990
1991 * New API functions hts_reglist_create() and sam_itr_regarray() are added
1992 to create hts_reglist_t region lists from `chr:<from>-<to>` type region
1993 specifiers. (#836)
1994
1995 * Ksort has been improved to facilitate library use. See KSORT_INIT2
1996 (adds scope / namespace capabilities) and KSORT_INIT_STATIC interfaces.
1997 (#851, thanks to John Marshall)
1998
1999 * New kstring functions (#879):
2000 KS_INITIALIZE - Initializer for structure assignment
2001 ks_initialize() - Initializer for pointed-to kstrings
2002 ks_expand() - Increase kstring capacity by a given amount
2003 ks_clear() - Set kstring length to zero
2004 ks_free() - Free the underlying buffer
2005 ks_c_str() - Returns the kstring buffer as a const char *,
2006 or an empty string if the length is zero.
2007
2008 * New API functions hts_idx_load3(), sam_index_load3(), tbx_index_load3()
2009 and bcf_index_load3() have been added. These allow control of whether
2010 remote indexes should be cached locally, and allow the error message
2011 printed when the index does not exist to be suppressed. (#870)
2012
2013 * Improved hts_detect_format() so it no longer assumes all text is
2014 SAM unless positively identified otherwise. It also makes a stab
2015 at detecting bzip2 format and identifying BED, FASTA and FASTQ
2016 files. (#721, thanks to John Marshall; #200, #719 both reported by
2017 Torsten Seemann)
2018
2019 * File format errors now set errno to EFTYPE (BSD, MacOS) when
2020 available instead of ENOEXEC. (#721)
2021
2022 * New API function bam_set_qname (#942)
2023
2024 * In addition to the existing hts_version() function, which reflects the
2025 HTSlib version being used at runtime, <htslib/hts.h> now also provides
2026 HTS_VERSION, a preprocessor macro reflecting the HTSlib version that
2027 a program is being compiled against. (#951, thanks to John Marshall; #794)
2028
2029
2030 ABI changes
2031 -----------
2032
2033 This release contains a number of things which change the Application
2034 Binary Interface (ABI). This means code compiled against an earlier
2035 library will require recompiling. The shared library soversion has
2036 been bumped.
2037
2038 * On systems that support it, the default symbol visibility has been
2039 changed to hidden and the only exported symbols are ones that form part
2040 of the officially supported ABI. This is to make clear exactly which
2041 symbols are considered parts of the library interface. It also
2042 helps packagers who want to check compatibility between HTSlib versions.
2043 (#946; see for example issues #311, #616, and #695)
2044
2045 * HTSlib now supports 64 bit reference positions. This means several
2046 structures, function parameters, and return values have been made bigger
2047 to allow larger values to be stored. While most code that uses
2048 HTSlib interfaces should still build after this change, some alterations
2049 may be needed - notably to printf() formats where the values of structure
2050 members are being printed. (#709)
2051
2052 Due to file format limitations, large positions are only supported
2053 when reading and writing SAM and VCF files.
2054
2055 See README.large_positions.md for more information.
2056
2057 * An extra field has been added to the kbitset_t struct so bitsets can
2058 be made smaller (and later enlarged) without involving memory allocation.
2059 (#710, thanks to John Marshall)
2060
2061 * A new field has been added to the bam_pileup1_t structure to keep track
2062 of which CIGAR operator is being processed. This is used by a new
2063 bam_plp_insertion() function which can be used to return the sequence of
2064 any inserted bases at a given pileup location. If the alignment includes
2065 CIGAR P operators, the returned sequence will include pads. (#699)
2066
2067 * The hts_itr_t and hts_itr_multi_t structures have been merged and can be
2068 used interchangeably. Extra fields have been added to hts_itr_t to support
2069 this. hts_itr_multi_t is now a typedef for hts_itr_t; sam_itr_multi_next()
2070 is now an alias for sam_itr_next() and hts_itr_multi_destroy() is an alias
2071 for hts_itr_destroy(). (#836)
2072
2073 * An improved regidx interface has been added. To allow this, struct
2074 reg_t has been removed, regitr_t has been modified and various new
2075 API functions have been added to htslib/regidx.h. While parts of
2076 the old regidx API have been retained for backwards compatibility,
2077 it is recommended that all code using regidx should be changed to use
2078 the new interface. (#761)
2079
2080 * Elements in the hts_reglist_t structure have been reordered slightly
2081 so that they pack together better. (#761)
2082
2083 * bgzf_utell() and bgzf_useek() now use type off_t instead of long for
2084 the offset. This allows them to work correctly on files longer than
2085 2G bytes on Windows and 32-bit Linux. (#868)
2086
2087 * A number of functions that used to return void now return int so that
2088 they can report problems like memory allocation failures. Callers
2089 should take care to check the return values from these functions. (#834)
2090
2091 The affected functions are:
2092 ksort.h: ks_introsort(), ks_mergesort()
2093 sam.h: bam_mplp_init_overlaps()
2094 synced_bcf_reader.h: bcf_sr_regions_flush()
2095 vcf.h: bcf_format_gt(), bcf_fmt_array(),
2096 bcf_enc_int1(), bcf_enc_size(),
2097 bcf_enc_vchar(), bcf_enc_vfloat(), bcf_enc_vint(),
2098 bcf_hdr_set_version(), bcf_hrec_format()
2099 vcfutils.h: bcf_remove_alleles()
2100
2101 * bcf_set_variant_type() now outputs VCF_OVERLAP for spanning
2102 deletions (ALT=*). (#726)
2103
2104 * A new field (hrecs) has been added to the bam_hdr_t structure for
2105 use by the new header API. The old sdict field is now not used and
2106 marked as deprecated. The l_text field has been changed from uint32_t
2107 to size_t, to allow for very large headers in SAM files. The text
2108 and l_text fields have been left for backwards compatibility, but
2109 should not be accessed directly in code that uses the new header API.
2110 To access the header text, the new functions sam_hdr_length() and
2111 sam_hdr_str() should be used instead. (#812)
2112
2113 * The old cigar_tab field is now marked as deprecated; use the new
2114 bam_cigar_table[] instead. (#891, thanks to John Marshall)
2115
2116 * The bam1_core_t structure's l_qname and l_extranul fields have been
2117 rearranged and enlarged; l_qname still includes the extra NULs.
2118 (Almost all code should use bam_get_qname(), bam_get_cigar(), etc,
2119 and has no need to use these fields directly.) HTSlib now supports
2120 the SAM specification's full 254 QNAME length again. (#900, thanks
2121 to John Marshall; #520)
2122
2123 * bcf_index_load() no longer tries the '.tbi' suffix when looking for
2124 BCF index files (.tbi indexes are for text files, not binary BCF). (#870)
2125
2126 * htsFile has a new 'state' member to support SAM multi-threading. (#916)
2127
2128 * A new field has been added to the bam1_t structure, and others
2129 have been rearranged to remove structure holes. (#709; #922)
2130
2131
2132 Bug fixes
2133 ---------
2134
2135 * Several BGZF format fixes:
2136
2137 - Support for multi-member gzip files. (#744, thanks to Adam Novak; #742)
2138
2139 - Fixed error handling code for native gzip formatted files. (64c4927)
2140
2141 - CRCs checked when threading too (previously only when non-threaded). (#745)
2142
2143 - Made bgzf_useek function work with threads. (#818)
2144
2145 - Fixed rare threading deadlocks. (#831)
2146
2147 - Reading of very short files (<28 bytes) that do not contain an EOF block.
2148 (#910)
2149
2150 * Fixed some thread pool deadlocks caused by race conditions. (#746, #906)
2151
2152 * Many additional memory allocation checks in VCF, BCF, SAM and CRAM
2153 code. This also changes the return type of some functions. See ABI
2154 changes above. (#920 amongst others)
2155
2156 * Replace some sam parsing abort() calls with proper errors.
2157 (#721, thanks to John Marshall; #576)
2158
2159 * Fixed to permit SAM read names of length 252 to 254 (the maximum
2160 specified by the SAM specification). (#900, thanks to John Marshall)
2161
2162 * Fixed mpileup overlap detection heuristic to work with BAMs having
2163 long CIGARs (more than 65536 operations). (#802)
2164
2165 * Security fix: CIGAR strings starting with the "N" operation can no
2166 longer cause underflow on the bam CIGAR structure. Similarly CIGAR
2167 strings that are entirely "D" ops could leak the contents of
2168 uninitialised variables. (#699)
2169
2170 * Fixed bug where alignments starting 0M could cause an invalid
2171 memory access in sam_prob_realn(). (#699)
2172
2173 * Fixed out of bounds memory access in mpileup when given a reference
2174 with binary characters (top-bit set). (#808, thanks to John Marshall)
2175
2176 * Fixed crash in mpileup overlap_push() function. (#882; #852 reported
2177 by Pierre Lindenbaum)
2178
2179 * Fixed various potential CRAM memory leaks when recovering from
2180 error cases.
2181
2182 * Fixed CRAM index queries for unmapped reads (#911; samtools/samtools#958
2183 reported by @acorvelo)
2184
2185 * Fixed the combination of CRAM embedded references and multiple
2186 slices per container. This was incorrectly setting the header
2187 MD5sum. (No impact on default CRAM behaviour.) (b2552fd)
2188
2189 * Removed unwanted explicit data flushing in CRAM writing, which on
2190 some OSes caused major slowdowns. (#883)
2191
2192 * Fixed inefficiencies in CRAM encoding when many small references
2193 occur within the middle of large chromosomes. Previously it
2194 switched into multi-ref mode, but not back out of it which caused
2195 the read POS field to be stored poorly. (#896)
2196
2197 * Fixed CRAM handling of references when the order of sequences in a
2198 supplied fasta file differs to the order of the @SQ headers. (#935)
2199
2200 * Fixed BAM and CRAM multi-threaded decoding when used in conjunction
2201 with the multi-region iterator. (#830; #577, #822, #926 all reported by
2202 Brent Pedersen)
2203
2204 * Removed some unaligned memory accesses in CRAM encoder and
2205 undefined behaviour in BCF reading (#867, thanks to David Seifert)
2206
2207 * Repeated calling of bcf_empty() no longer crashes. (#741)
2208
2209 * Fixed bug where some 8 or 16-bit negative integers were stored using values
2210 reserved by the BCF specification. These numbers are now promoted to the
2211 next size up, so -121 to -128 are stored using at least 16 bits, and -32761
2212 to -32768 are stored using 32 bits.
2213
2214 Note that while BCF files affected by this bug are technically incorrect,
2215 it is still possible to read them. When converting to VCF format,
2216 HTSlib (and therefore bcftools) will interpret the values as intended
2217 and write out the correct negative numbers. (#766, thanks to John Marshall;
2218 samtools/bcftools#874)
2219
2220 * Allow repeated invocations of bcf_update_info() and bcf_update_format_*()
2221 functions. (#856, thanks to John Marshall; #813 reported by Steffen Möller)
2222
2223 * Memory leak removed in knetfile's kftp_parse_url() function. (#759, thanks
2224 to David Alexander)
2225
2226 * Fixed various crashes found by libfuzzer (invalid data leading to
2227 errors), mostly but not exclusively in CRAM, VCF and BCF decoding. (#805)
2228
2229 * Improved robustness of BAI and CSI index creation and loading. (#870; #967)
2230
2231 * Prevent (invalid) creation of TBI indices for BCF files.
2232 (#837; samtools/bcftools#707)
2233
2234 * Better parsing of handling of remote URLs with ?param=val
2235 components and their interaction with remote index URLs. (#790; #784
2236 reported by Mark Ebbert)
2237
2238 * hts_idx_load() now checks locally for all possible index names before
2239 attempting to download a remote index. It also checks that the remote
2240 file it downloads is actually an index before trying to save and use
2241 it. (#870; samtools/samtools#1045 reported by Albert Vilella)
2242
2243 * hts_open_format() now honours the compression field, no longer also
2244 requiring an explicit "z" in the mode string. Also fixed a 1 byte
2245 buffer overrun. (#880)
2246
2247 * Removed duplicate hts_tpool_process_flush prototype. (#816, reported by
2248 James S Blachly)
2249
2250 * Deleted defunct cram_tell declaration. (66c41e2; #915 reported by
2251 Martin Morgan)
2252
2253 * Fixed overly aggressive filename suffix checking in bgzip. (#927, thanks to
2254 John Marshall; #129, reported by @hguturu)
2255
2256 * Tabix and bgzip --help output now goes to standard output. (#754, thanks to
2257 John Marshall)
2258
2259 * Fixed bgzip index creation when using multiple threads. (#817)
2260
2261 * Made bgzip -b option honour -I (index filename). (#817)
2262
2263 * Bgzip -d no longer attempts to unlink(NULL) when decompressing stdin. (#718)
2264
2265
2266 Miscellaneous other changes
2267 ---------------------------
2268
2269 * Integration with Google OSS fuzzing for automatic detection of
2270 more bugs. (Thanks to Google for their assistance and the bugs it
2271 has found.) (#796, thanks to Markus Kusano)
2272
2273 * aclocal.m4 now has the pkg-config macros. (6ec3b94d; #733 reported by
2274 Thomas Hickman)
2275
2276 * Improved C++ compatibility of some header files. (#772; #771 reported
2277 by @cwrussell)
2278
2279 * Improved strict C99 compatibility. (#860, thanks to John Marshall)
2280
2281 * Travis and AppVeyor improvements to aid testing. (#747; #773 thanks to
2282 Lennard Berger; #781; #809; #804; #860; #909)
2283
2284 * Various minor compiler warnings fixed. (#708; #765; #846, #860, thanks to
2285 John Marshall; #865; #966; #973)
2286
2287 * Various new and improved error messages.
2288
2289 * Documentation updates (mostly in the header files).
2290
2291 * Even more testing with "make check".
2292
2293 * Corrected many copyright dates. (#979)
2294
2295 * The default non-configure Makefile now uses libcurl instead of
2296 knet, so it can support https. (#895)
2297
2298
2299
2300
2301
2302
2303 Noteworthy changes in release 1.9 (18th July 2018)
2304 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2305
2306 * If `./configure` fails, `make` will stop working until either configure
2307 is re-run successfully, or `make distclean` is used. This makes
2308 configuration failures more obvious. (#711, thanks to John Marshall)
2309
2310 * The default SAM version has been changed to 1.6. This is in line with the
2311 latest version specification and indicates that HTSlib supports the
2312 CG tag used to store long CIGAR data in BAM format.
2313
2314 * bgzip integrity check option '--test' (#682, thanks to @sd4B75bJ, @jrayner)
2315
2316 * Faidx can now index fastq files as well as fasta. The fastq index adds
2317 an extra column to the `.fai` index which gives the offset to the quality
2318 values. New interfaces have been added to `htslib/faidx.h` to read the
2319 fastq index and retrieve the quality values. It is possible to open
2320 a fastq index as if fasta (only sequences will be returned), but not
2321 the other way round. (#701)
2322
2323 * New API interfaces to add or update integer, float and array aux tags. (#694)
2324
2325 * Add `level=<number>` option to `hts_set_opt()` to allow the compression
2326 level to be set. Setting `level=0` enables uncompressed output. (#715)
2327
2328 * Improved bgzip error reporting.
2329
2330 * Better error reporting when CRAM reference files can't be opened. (#706)
2331
2332 * Fixes to make tests work properly on Windows/MinGW - mainly to handle
2333 line ending differences. (#716)
2334
2335 * Efficiency improvements:
2336
2337 - Small speed-up for CRAM indexing.
2338
2339 - Reduce the number of unnecessary wake-ups in the thread pool. (#703)
2340
2341 - Avoid some memory copies when writing data, notably for uncompressed
2342 BGZF output. (#703)
2343
2344 * Bug fixes:
2345
2346 - Fix multi-region iterator bugs on CRAM files. (#684)
2347
2348 - Fixed multi-region iterator bug that caused some reads to be skipped
2349 incorrectly when reading BAM files. (#687)
2350
2351 - Fixed synced_bcf_reader() bug when reading contigs multiple times. (#691,
2352 reported by @freeseek)
2353
2354 - Fixed bug where bcf_hdr_set_samples() did not update the sample dictionary
2355 when removing samples. (#692, reported by @freeseek)
2356
2357 - Fixed bug where the VCF record ref length was calculated incorrectly
2358 if an INFO END tag was present. (71b00a)
2359
2360 - Fixed warnings found when compiling with gcc 8.1.0. (#700)
2361
2362 - sam_hdr_read() and sam_hdr_write() will now return an error code
2363 if passed a NULL file pointer, instead of crashing.
2364
2365 - Fixed possible negative array look-up in sam_parse1() that somehow escaped
2366 previous fuzz testing. (CVE-2018-13845, #731, reported by @fCorleone)
2367
2368 - Fixed bug where cram range queries could incorrectly report an error
2369 when using multiple threads. (#734, reported by Brent Pedersen)
2370
2371 - Fixed very rare rANS normalisation bug that could cause an assertion
2372 failure when writing CRAM files. (#739, reported by @carsonhh)
2373
2374 Noteworthy changes in release 1.8 (3rd April 2018)
2375 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2376
2377 * The URL to get sequences from the EBI reference server has been changed
2378 to https://. This is because the EBI no longer serve sequences via
2379 plain HTTP - requests to the http:// endpoint just get redirected.
2380 HTSlib needs to be linked against libcurl to download https:// URLs,
2381 so CRAM users who want to get references from the EBI will need to
2382 run configure and ensure libcurl support is enabled using the
2383 --enable-libcurl option.
2384
2385 * Added libdeflate as a build option for alternative faster compression and
2386 decompression. Results vary by CPU but compression should be twice as fast
2387 and decompression faster.
2388
2389 * It is now possible to set the compression level in bgzip. (#675; thanks
2390 to Nathan Weeks).
2391
2392 * bgzip now gets its own manual page.
2393
2394 * CRAM encoding now stored MD and NM tags verbatim where the reference
2395 contains 'N' characters, to work around ambiguities in the SAM
2396 specification (samtools #717/762).
2397 Also added "store_md" and "store_nm" cram-options for forcing these
2398 tags to be stored at all locations. This is best when combined with
2399 a subsequent decode_md=0 option while reading CRAM.
2400
2401 * Multiple CRAM bug fixes, including a fix to free and the subsequent reuse of
2402 references with `-T ref.fa`. (#654; reported by Chris Saunders)
2403
2404 * CRAM multi-threading bugs fixed: don't try to call flush on reading;
2405 processing of multiple range queries; problems with multi-slice containers.
2406
2407 * Fixed crashes caused when decoding some cramtools produced CRAM files.
2408
2409 * Fixed a couple of minor rANS issues with handling invalid data.
2410
2411 * Fixed bug where probaln_glocal() tried to allocate far more memory than
2412 needed when the query sequence was much longer than the reference. This
2413 caused crashes in samtools and bcftools mpileup when used on data with very
2414 long reads. (#572, problem reported by Felix Bemm via minimap2).
2415
2416 * sam_prop_realn() now returns -1 (the same value as for unmapped reads)
2417 on reads that do not include at least one 'M', 'X' or '=' CIGAR operator,
2418 and no longer adds BQ or ZQ tags. BAQ adjustments are only made to bases
2419 covered by these operators so there is no point in trying to align
2420 reads that do not have them. (#572)
2421
2422 Noteworthy changes in release 1.7 (26th January 2018)
2423 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2424
2425 * BAM: HTSlib now supports BAMs which include CIGARs with more than
2426 65535 operations as per HTS-Specs 18th November (dab57f4 and 2f915a8).
2427
2428 * BCF/VCF:
2429 - Removed the need for long double in pileup calculations.
2430 - Sped up the synced reader in some situations.
2431 - Bug fixing: removed memory leak in bcf_copy.
2432
2433 * CRAM:
2434 - Added support for HTS_IDX_START in cram iterators.
2435 - Easier to build when lzma header files are absent.
2436 - Bug fixing: a region query with REQUIRED_FIELDS option to
2437 disable sequence retrieval now gives correct results.
2438 - Bug fixing: stop queries to regions starting after the last
2439 read on a chromosome from incorrectly reporting errors
2440 (#651, #653; reported by Imran Haque and @egafni via pysam).
2441
2442 * Multi-region iterator: The new structure takes a list of regions and
2443 iterates over all, deduplicating reads in the process, and producing a
2444 full list of file offset intervals. This is usually much faster than
2445 repeatedly using the old single-region iterator on a series of regions.
2446
2447 * Curl improvements:
2448 - Add Bearer token support via HTS_AUTH_LOCATION env (#600).
2449 - Use CURL_CA_BUNDLE environment variable to override the CA (#622;
2450 thanks to Garret Kelly & David Alexander).
2451 - Speed up (removal of excessive waiting) for both http(s) and ftp.
2452 - Avoid repeatedly reconnecting by removal of unnecessary seeks.
2453 - Bug fixing: double free when libcurl_open fails.
2454
2455 * BGZF block caching, if enabled, now performs far better (#629; reported
2456 by Ram Yalamanchili).
2457
2458 * Added an hFILE layer for in-memory I/O buffers (#590; thanks to Thomas
2459 Hickman).
2460
2461 * Tidied up the drand48 support (intended for systems that do not
2462 provide this function).
2463
2464 Noteworthy changes in release 1.6 (28th September 2017)
2465 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2466
2467 * Fixed bug where iterators on CRAM files did not propagate error return
2468 values to the caller correctly. Thanks go to Chris Saunders.
2469
2470 * Overhauled Windows builds. Building with msys2/mingw64 now works
2471 correctly and passes all tests.
2472
2473 * More improvements to logging output (thanks again to Anders Kaplan).
2474
2475 * Return codes from sam_read1() when reading cram have been made
2476 consistent with those returned when reading sam/bam. Thanks to
2477 Chris Saunders (#575).
2478
2479 * BGZF CRC32 checksums are now always verified.
2480
2481 * It's now possible to set nthreads = 1 for cram files.
2482
2483 * hfile_libcurl has been modified to make it thread-safe. It's also
2484 better at handling web servers that do not honour byte range requests
2485 when attempting to seek - it now sets errno to ESPIPE and keeps
2486 the existing connection open so callers can revert to streaming mode
2487 it they want to.
2488
2489 * hfile_s3 now recalculates access tokens if they have become stale. This
2490 fixes a reported problem where authentication failed after a file
2491 had been in use for more than 15 minutes.
2492
2493 * Fixed bug where remote index fetches would fail to notice errors when
2494 writing files.
2495
2496 * bam_read1() now checks that the query sequence length derived from the
2497 CIGAR alignment matches the sequence length in the BAM record.
2498
2499 Noteworthy changes in release 1.5 (21st June 2017)
2500 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2501
2502 * Added a new logging API: hts_log(), along with hts_log_error(),
2503 hts_log_warn() etc. convenience macros. Thanks go to Anders Kaplan
2504 for the implementation. (#499, #543, #551)
2505
2506 * Added a new file I/O option "block_size" (HTS_OPT_BLOCK_SIZE) to
2507 alter the hFILE buffer size.
2508
2509 * Fixed various bugs, including compilation issues samtools/bcftools#610,
2510 samtools/bcftools#611 and robustness to corrupted data #537, #538,
2511 #541, #546, #548, #549, #554.
2512
2513
2514 Noteworthy changes in release 1.4.1 (8th May 2017)
2515 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2516
2517 This is primarily a security bug fix update.
2518
2519 * Fixed SECURITY (CVE-2017-1000206) issue with buffer overruns with
2520 malicious data. (#514)
2521
2522 * S3 support for non Amazon AWS endpoints. (#506)
2523
2524 * Support for variant breakpoints in bcftools. (#516)
2525
2526 * Improved handling of BCF NaNs. (#485)
2527
2528 * Compilation / portability improvements. (#255, #423, #498, #488)
2529
2530 * Miscellaneous bug fixes (#482, #521, #522, #523, #524).
2531
2532 * Sanitise headers (#509)
2533
2534
2535 Release 1.4 (13 March 2017)
2536
2537 * Incompatible changes: several functions and data types have been changed
2538 in this release, and the shared library soversion has been bumped to 2.
2539
2540 - bam_pileup1_t has an additional field (which holds user data)
2541 - bam1_core_t has been modified to allow for >64K CIGAR operations
2542 and (along with bam1_t) so that CIGAR entries are aligned in memory
2543 - hopen() has vararg arguments for setting URL scheme-dependent options
2544 - the various tbx_conf_* presets are now const
2545 - auxiliary fields in bam1_t are now always stored in little-endian byte
2546 order (previously this depended on if you read a bam, sam or cram file)
2547 - index metadata (accessible via hts_idx_get_meta()) is now always
2548 stored in little-endian byte order (previously this depended on if
2549 the index was in tbi or csi format)
2550 - bam_aux2i() now returns an int64_t value
2551 - fai_load() will no longer save local copies of remote fasta indexes
2552 - hts_idx_get_meta() now takes a uint32_t * for l_meta (was int32_t *)
2553
2554 * HTSlib now links against libbz2 and liblzma by default. To remove these
2555 dependencies, run configure with options --disable-bz2 and --disable-lzma,
2556 but note that this may make some CRAM files produced elsewhere unreadable.
2557
2558 * Added a thread pool interface and replaced the bgzf multi-threading
2559 code to use this pool. BAM and CRAM decoding is now multi-threaded
2560 too, using the pool to automatically balance the number of threads
2561 between decode, encode and any data processing jobs.
2562
2563 * New errmod_cal(), probaln_glocal(), sam_cap_mapq(), and sam_prob_realn()
2564 functions, previously internal to SAMtools, have been added to HTSlib.
2565
2566 * Files can now be accessed via Google Cloud Storage using gs: URLs, when
2567 HTSlib is configured to use libcurl for network file access rather than
2568 the included basic knetfile networking.
2569
2570 * S3 file access now also supports the "host_base" setting in the
2571 $HOME/.s3cfg configuration file.
2572
2573 * Data URLs ("data:,text") now follow the standard RFC 2397 format and may
2574 be base64-encoded (when written as "data:;base64,text") or may include
2575 percent-encoded characters. HTSlib's previous over-simplified "data:text"
2576 format is no longer supported -- you will need to add an initial comma.
2577
2578 * When plugins are enabled, S3 support is now provided by a separate
2579 hfile_s3 plugin rather than by hfile_libcurl itself as previously.
2580 When --enable-libcurl is used, by default both GCS and S3 support
2581 and plugins will also be built; they can be individually disabled
2582 via --disable-gcs and --disable-s3.
2583
2584 * The iRODS file access plugin has been moved to a separate repository.
2585 Configure no longer has a --with-irods option; instead build the plugin
2586 found at <https://github.com/samtools/htslib-plugins>.
2587
2588 * APIs to portably read and write (possibly unaligned) data in little-endian
2589 byte order have been added.
2590
2591 * New functions bam_auxB_len(), bam_auxB2i() and bam_auxB2f() have been
2592 added to make accessing array-type auxiliary data easier. bam_aux2i()
2593 can now return the full range of values that can be stored in an integer
2594 tag (including unsigned 32 bit tags). bam_aux2f() will return the value
2595 of integer tags (as a double) as well as floating-point ones. All of
2596 the bam_aux2 and bam_auxB2 functions will set errno if the requested
2597 conversion is not valid.
2598
2599 * New functions fai_load3() and fai_build3() allow fasta indexes to be
2600 stored in a different location to the indexed fasta file.
2601
2602 * New functions bgzf_index_dump_hfile() and bgzf_index_load_hfile()
2603 allow bgzf index files (.gzi) to be written to / read from an existing
2604 hFILE handle.
2605
2606 * hts_idx_push() will report when trying to add a range to an index that
2607 is beyond the limits that the given index can handle. This means trying
2608 to index chromosomes longer than 2^29 bases with a .bai or .tbi index
2609 will report an error instead of apparently working but creating an invalid
2610 index entry.
2611
2612 * VCF formatting is now approximately 4x faster. (Whether this is
2613 noticeable depends on what was creating the VCF.)
2614
2615 * CRAM lossy_names mode now works with TLEN of 0 or TLEN within +/- 1
2616 of the computed value. Note in these situations TLEN will be
2617 generated / fixed during CRAM decode.
2618
2619 * CRAM now supports bzip2 and lzma codecs. Within htslib these are
2620 disabled by default, but can be enabled by specifying "use_bzip2" or
2621 "use_lzma" in an hts_opt_add() call or via the mode string of the
2622 hts_open_format() function.
2623
2624 Noteworthy changes in release 1.3.2 (13 September 2016)
2625
2626 * Corrected bin calculation when converting directly from CRAM to BAM.
2627 Previously a small fraction of converted reads would fail Picard's
2628 validation with "bin field of BAM record does not equal value computed"
2629 (SAMtools issue #574).
2630
2631 * Plugins can now signal to HTSlib which of RTLD_LOCAL and RTLD_GLOBAL
2632 they wish to be opened with -- previously they were always RTLD_LOCAL.
2633
2634
2635 Noteworthy changes in release 1.3.1 (22 April 2016)
2636
2637 * Improved error checking and reporting, especially of I/O errors when
2638 writing output files (#17, #315, PR #271, PR #317).
2639
2640 * Build fixes for 32-bit systems; be sure to run configure to enable
2641 large file support and access to 2GiB+ files.
2642
2643 * Numerous VCF parsing fixes (#321, #322, #323, #324, #325; PR #370).
2644 Particular thanks to Kostya Kortchinsky of the Google Security Team
2645 for testing and numerous input parsing bug reports.
2646
2647 * HTSlib now prints an informational message when initially creating a
2648 CRAM reference cache in the default location under your $HOME directory.
2649 (No message is printed if you are using $REF_CACHE to specify a location.)
2650
2651 * Avoided rare race condition when caching downloaded CRAM reference sequence
2652 files, by using distinctive names for temporary files (in addition to O_EXCL,
2653 which has always been used). Occasional corruption would previously occur
2654 when multiple tools were simultaneously caching the same reference sequences
2655 on an NFS filesystem that did not support O_EXCL (PR #320).
2656
2657 * Prevented race condition in file access plugin loading (PR #341).
2658
2659 * Fixed mpileup memory leak, so no more "[bam_plp_destroy] memory leak [...]
2660 Continue anyway" warning messages (#299).
2661
2662 * Various minor CRAM fixes.
2663
2664 * Fixed documentation problems #348 and #358.
2665
2666
2667 Noteworthy changes in release 1.3 (15 December 2015)
2668
2669 * Files can now be accessed via HTTPS and Amazon S3 in addition to HTTP
2670 and FTP, when HTSlib is configured to use libcurl for network file access
2671 rather than the included basic knetfile networking.
2672
2673 * HTSlib can be built to use remote access hFILE backends (such as iRODS
2674 and libcurl) via a plugin mechanism. This allows other backends to be
2675 easily added and facilitates building tools that use HTSlib, as they
2676 don't need to be linked with the backends' various required libraries.
2677
2678 * When writing CRAM output, sam_open() etc now default to writing CRAM v3.0
2679 rather than v2.1.
2680
2681 * fai_build() and samtools faidx now accept initial whitespace in ">"
2682 headers (e.g., "> chr1 description" is taken to refer to "chr1").
2683
2684 * tabix --only-header works again (was broken in 1.2.x; #249).
2685
2686 * HTSlib's configure script and Makefile now fully support the standard
2687 convention of allowing CC/CPPFLAGS/CFLAGS/LDFLAGS/LIBS to be overridden
2688 as needed. Previously the Makefile listened to $(LDLIBS) instead; if you
2689 were overriding that, you should now override LIBS rather than LDLIBS.
2690
2691 * Fixed bugs #168, #172, #176, #197, #206, #225, #245, #265, #295, and #296.
2692
2693
2694 Noteworthy changes in release 1.2.1 (3 February 2015)
2695
2696 * Reinstated hts_file_type() and FT_* macros, which were available until 1.1
2697 but briefly removed in 1.2. This function is deprecated and will be removed
2698 in a future release -- you should use hts_detect_format() etc instead
2699
2700
2701 Noteworthy changes in release 1.2 (2 February 2015)
2702
2703 * HTSlib now has a configure script which checks your build environment
2704 and allows for selection of optional extras. See INSTALL for details
2705
2706 * By default, reference sequences are fetched from the EBI CRAM Reference
2707 Registry and cached in your $HOME cache directory. This behaviour can
2708 be controlled by setting REF_PATH and REF_CACHE environment variables
2709 (see the samtools(1) man page for details)
2710
2711 * Numerous CRAM improvements:
2712 - Support for CRAM v3.0, an upcoming revision to CRAM supporting
2713 better compression and per-container checksums
2714 - EOF checking for v2.1 and v3.0 (similar to checking BAM EOF blocks)
2715 - Non-standard values for PNEXT and TLEN fields are now preserved
2716 - hts_set_fai_filename() now provides a reference file when encoding
2717 - Generated read names are now numbered from 1, rather than being
2718 labelled 'slice:record-in-slice'
2719 - Multi-threading and speed improvements
2720
2721 * New htsfile command for identifying file formats, and corresponding
2722 file format detection APIs
2723
2724 * New tabix --regions FILE, --targets FILE options for filtering via BED files
2725
2726 * Optional iRODS file access, disabled by default. Configure with --with-irods
2727 to enable accessing iRODS data objects directly via 'irods:DATAOBJ'
2728
2729 * All occurrences of 2^29 in the source have been eliminated, so indexing
2730 and querying against reference sequences larger than 512Mbp works (when
2731 using CSI indices)
2732
2733 * Support for plain GZIP compression in various places
2734
2735 * VCF header editing speed improvements
2736
2737 * Added seq_nt16_int[] (equivalent to the samtools API's bam_nt16_nt4_table)
2738
2739 * Reinstated faidx_fetch_nseq(), which was accidentally removed from 1.1.
2740 Now faidx_fetch_nseq() and faidx_nseq() are equivalent; eventually
2741 faidx_fetch_nseq() will be deprecated and removed [#156]
2742
2743 * Fixed bugs #141, #152, #155, #158, #159, and various memory leaks