Skip to content

Do not write the coverage sentinel to D4 - #274

Open
kojix2 wants to merge 1 commit into
brentp:masterfrom
kojix2:fix-d4-sentinel
Open

kojix2 wants to merge 1 commit into
brentp:masterfrom
kojix2:fix-d4-sentinel

Conversation

@kojix2

@kojix2 kojix2 commented Nov 9, 2026

Copy link
Copy Markdown

Hi Brent Pedersen,

I'm using the D4 format to inspect BAM coverage. I've also been building my own D4 file browser, d4-plot. It's vibe coding, though.

I initially used mosdepth to generate D4 files, but while porting the related code, I noticed problems with how the data was displayed. The attached image shows an example.

I then asked ChatGPT to audit the code, and it appeared there were several issues. I don't really understand the details myself. I considered opening issues and submitting fixes as pull requests, but the problems spanned multiple repositories, and it looked like a lot of work for someone like me who struggles with Rust and Nim.

In particular, development of d4-format doesn't seem very active at the moment. So I ended up porting several related libraries to Crystal, driven by an irrational desire to reinvent the wheel, my passion for Crystal, and foolish use of LLMs.

This pull request fixes one of the clearest issues found: depth values at the end being lost.

As a regression test, it generates a seven-base BAM with depths 127,128,254,255,256,257,5000 and checks the values read back from D4. The code was written by GPT-6.1 Sol through multiple rounds of revision.

Thanks you.

kojix2

Temporarily remove the final coverage sentinel when writing D4 values, then restore it for subsequent output. Use the existing d4-nim writer without copying the depth array. Add a BAM-to-D4 regression using the existing HTSlib bindings.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant