Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add faidx_seq_len64(), fai_adjust_region() interfaces and faidx tests #1519

Merged
merged 2 commits into from
Nov 9, 2022

Conversation

daviesrob
Copy link
Member

Add faidx_seq_len64() as a replacement for faidx_seq_len() that can return the correct length of sequences longer than INT_MAX.

Make faidx_seq_len() clamp its output at INT_MAX, which is probably slightly less bad than overflowing.

Adds a fai_adjust_region() function that can be used to ensure that a given range does not go beyond the end of the requested sequence. The interface is designed so that the output of fai_parse_region() can be passed to it. This essentially exposes the internal faidx_adjust_position() function which is currently used to enforce the same limits in the faidx_fetch_seq64() and faidx_fetch_qual64() interfaces. The new function allows callers to get a better idea of what will be retrieved by applying the limits in advance.

While writing this, I discovered that faidx didn't really have any tests of its own, although some were run as side-effects of other tests. The second (rather bigger) commit adds some dedicated faidx tests.

Add faidx_seq_len64() as a replacement for faidx_seq_len() that
can return the correct length of sequences longer than INT_MAX.

Make faidx_seq_len() clamp its output at INT_MAX, which is
probably slightly less bad than overflowing.

Adds a fai_adjust_region() function that can be used to ensure that
a given range does not go beyond the end of the requested sequence.
The interface is designed so that the output of fai_parse_region()
can be passed to it.  This essentially exposes the internal
faidx_adjust_position() function which is currently used to
enforce the same limits in the faidx_fetch_seq64() and
faidx_fetch_qual64() interfaces.  The new function allows
callers to get a better idea of what will be retrieved by
applying the limits in advance.
@@ -0,0 +1,35 @@
#!/bin/sh
#
# Copyright (C) 2017-2018 Genome Research Ltd.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Date?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What? You mean it's not 2018? What happened?

(Now fixed).

The faidx interfaces were only being tested as side-effects of
other tests.  This adds dedicated tests for them.
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