Creating CRC32 hashes in a CRAM file header
1
0
Entering edit mode
4 weeks ago
onter ▴ 170

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

samtools htslib crc32 cram • 319 views
ADD COMMENT
0
Entering edit mode

While samtools devs stop by it is not very often. You may want to create an issue on samtools/htslib GitHub site and then link it here.

ADD REPLY
1
Entering edit mode
27 days ago
jkbonfield ★ 1.3k

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).

ADD COMMENT

Login before adding your answer.

Traffic: 1635 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6