Skip to content

__hts_idx_t uncompressed and compressed offset getters #845

@brainstorm

Description

@brainstorm

Hello htslib devs,

I'm starting to work on a htsget-server implementation that relies on htslib, based on preliminary work on samtools/hts-specs#385. The first issue I've found is finding public getters for indexes, namely the (64 bit) compressed and uncompressed offsets. As @delagoya points out in his binary formats blogpost from 2016:

There are no tools that independently inspect this binary format and spit out the information into text, only tools (e.g. PICARD, samtools) that use the index for random access into BAM files. If I wanted that information I would either need to calculate the file offsets myself (as is done in the excellent htsnexus) or implement my own binary file parser for BAI files.

I have been writing some small C snippets to see if that's still the case today. Thanks @jmarshall for the handy htslib C scaffold, very useful to get started quickly. I'm not sure I can externally access hts_idx_t attributes I need via any of methods/getters currently available?

In other words, I just need an exported method to access the tuple of 64bit pointers pointing to the compressed and uncompressed block offsets. The only (not publicly) available ones seem to be:

    // $ nm ../htslib/hts.o | grep load
    // 000000000000aae0 T _hts_idx_load
    // 000000000000ab60 T _hts_idx_load2
    // 000000000000b550 t _hts_idx_load_core

But the compiler yells: hts_idx_t struct is: "pointer to incomplete class is not allowed" for the aforementioned struct, as expected.

Since I'm a newcomer to the codebase I'm probably missing some way to do it right, so I just wanted to ask first before adding my own functions to retrieve the block offsets and file a pullrequest that might not get merged.

Happy to hear about pointers (no pun intended) and advice, perhaps this is being discussed offline ATM since crypt4gh is ongoing and there seems to be some probably related ABI-breaking changes queued as well in this issue tracker?

Thanks in advance!

/cc @ohofmann @reisingerf

Metadata

Metadata

Assignees

No one assigned

    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