Skip to content

hts_idx_t file query API #1902

@d-cameron

Description

@d-cameron

htslib appears to lack a clean index querying API. The internals of hts_idx_t are not publicly visible, and there does not appear to be a function to find the appropriate position to seek to.

Looking at the source code, the following options appear to be available:

  • create a hts_itr_t using hts_itr_query() then peek in hts_itr_t.curr_off. Unfortunately, This structure should be considered opaque by end users.
  • Wrap a call to hts_itr_multi_next() with no-op callbacks except for hts_seek_func that saves the seek position that can then be returned. The mock htsFile cannot be NULL nor a cram file due to the internal cram_set_option calls within hts_itr_multi_next.

Other approaches such as handing over ownership of your FP to BGZF, call hts_itr_next() with a no-op hts_readrec_func, letting the seek happen and querying fp->seeked mihgt work but I want to handle the compression myself.

What is the 'correct' way of querying an index for the file position(s)/internals(s) that a genomic interval/position(s) could be located in?

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions