Debian Codegraph @

debian/patches/faidx-pysam-0.24.patch

raw
1 Description: Fix write_fa_subset with pysam >= 0.24
2 pysam 0.24.x rewrote the samtools stdout redirection. As a result
3 pysam.faidx(infile, region) no longer returns the fetched sequence as
4 a string (it returns an empty string while the sequence is written to
5 the process' real stdout), which made write_fa_subset write empty
6 output files and broke ariba/tests/faidx_test.py::test_write_fa_subset.
7 Fetch sequences via pysam.FastaFile instead, which works with all
8 supported pysam versions.
9 Forwarded: no
10 Last-Update: 2026-09-21
11
12 --- a/ariba/faidx.py
13 +++ b/ariba/faidx.py
14 @@ -8,7 +8,10 @@
15 pysam.faidx(infile)
16
17 f = pyfastaq.utils.open_file_write(outfile)
18 - for name in seq_names:
19 - print(pysam.faidx(infile, name), end='', file=f)
20 + with pysam.FastaFile(infile) as fasta:
21 + for name in seq_names:
22 + seq = fasta.fetch(name)
23 + print('>' + name, file=f)
24 + print(seq, file=f)
25 pyfastaq.utils.close(f)
26