Skip to content

Conversation

@jmarshall
Copy link
Member

@jmarshall jmarshall commented Nov 26, 2025

This adds functions to the public API to pack and unpack the SEQ and QUAL fields individually, enabling third-party code to take advantage of the optimised and SIMD-optimized implementations of this functionality that HTSlib provides.

The format ones were the motivation for this; in particular they will be immediately useful for pysam. The parse ones are perhaps of less widespread use (at least in their current form) as usually if writing to a bam1_t there’ll need to be some memory reallocating going on too. But I think pysam would benefit from accessing HTSlib’s implementations of these too.

The optimised COPY_MINUS_N() implementation declares its own locals.
Make the simple COPY_MINUS_N() declare its own local i rather than
shadowing a local of that name from its caller.
@jmarshall jmarshall marked this pull request as ready for review December 11, 2025 08:58
@daviesrob daviesrob self-assigned this Dec 18, 2025
@daviesrob
Copy link
Member

This mostly looks OK to me. It might be good to mention in the documentation exactly how big the destination buffer needs to be, especially for bam_format_seq() and bam_format_qual() where it's a bit less obvious. Also exactly what's going on in sam_format_qual() and sam_parse_qual() - that 33 is added to / subtracted from the values to convert them to / from printable ASCII; and that the sam_parse_qual() error state means that conversion failed because one of the input values was too small.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants