In my program I am trying to follow the CRAM specs for updating the CRAM header container and then updating the CRC32 hash to match it.
I can't seem to create a valid CRC32 hash (not recognized by samtools). I have tried to feed the exact same header bytes into my program to create this hash and it comes out different than the valid CRAM file's CRC32.
Has anyone had this issue? Maybe i'm not understanding how the header data is serialized for the CRC32 hash
1 answer
There are multiple CRCs. Every block has a CRC, but the structures do too. The cram container structure (section 7 of the spec) is written here in htslib. It's a little messy due to different CRAM versions being supported, but essentially it just encodes all the data into a buffer, checksums that buffer, and then appends the checksum to the end of it.
https://github.com/samtools/htslib/blob/develop/cram/cram_io.c#L4026-L4095
If you're doing this and it fails, then possibly it's a different CRC hash. There are multiple CRCs available, but the one we use is the one used in the Deflate specification (so crc32 from zlib or libdeflate_crc32).
Log in to answer this question.
While
samtoolsdevs stop by it is not very often. You may want to create an issue onsamtools/htslibGitHub site and then link it here.