Conversation
|
why read record returns a pointer? |
Removed and made it void. |
|
i think i already wrote sam hdr there |
| htsFile *fp = hts_open("-", "w"); // "-" means stdout | ||
| sam_hdr_write(fp, reader->header); | ||
| hts_close(fp); |
There was a problem hiding this comment.
@NickRoz1 Yes, you do include the sam hdr in the gbam. But I didn't see this when tryiing to read the gbam so that the output txt file also has the sam header. @AndreaGuarracino said that we need to have it in the output txt.
| // reader->header = sam_hdr_parse(strlen(file+seekpos+meta_size), file+seekpos+meta_size); <- this doesn't work | ||
| // because strlen(...) calculates length until the first \0 byte, which is not guaranteed in binary data. | ||
| int32_t *header_len_ptr = (int32_t *)(file + seekpos + meta_size); | ||
| char *header_start = (char *)(header_len_ptr + 1); | ||
| assert(*header_len_ptr == header_len); // Sanity check to confirm the calculated header length is matched with the header length stored in the metadata. | ||
| reader->header = sam_hdr_parse(*header_len_ptr, header_start); |
There was a problem hiding this comment.
@NickRoz1 I think strlen(file+seekpos+meta_size) doesn't give the correct header length. I had to use (int32_t *)(file + seekpos + meta_size) get the correct header length.
I have also included header_len in the meta header so that we can do a sanity check when reading the gbam to check calculated header length is matched with the header length stored in the metadata.
There was a problem hiding this comment.
if you jump to the meta offset + metasize and then read till the end of the file you get the header
eventually we must also write crc32 in the end of the file so the header length info is not necessary
if crc32 of meta plus header wont match when reading then we have damage in the file
|
Needs rebase plus why logs in PR? |
No description provided.