Validate bedMethyl merge inputs and preserve row identities - #664
Open
SuhasSrinivasan wants to merge 2 commits into
Open
Validate bedMethyl merge inputs and preserve row identities#664SuhasSrinivasan wants to merge 2 commits into
SuhasSrinivasan wants to merge 2 commits into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #663.
Summary
--min-samples.Severity
Severity: High — scientific correctness, sample membership, and output integrity
Rationale: The affected command can exit successfully after omitting a requested sample, combining biologically distinct motif rows, or falsely satisfying a sample-support filter. Its output remains syntactically valid, making the scientific error difficult to detect downstream.
Root cause
The merge reader list was built with
filter_map, discarding any data/index open error after--min-samples allhad already been resolved against the requested input count. The output was opened first, so even an eventual failure could overwrite an existing result. Separately,BedMethylLineretains only the modification-code component of column 4; merge keyed and serialized that reduced representation, and incremented sample support once per row.Implementation
HtsTabixHandlerconstruction results with path context before creating the Rayon pool or output writer. This preserves requested cardinality and fails without touching output.BedMethylLinethat also retains the exact column-4 name. The generic parser and public schema remain unchanged.n_samples..csi-before-.tbiindex discovery through the existing Tabix handler and avoid an O(total-input) pre-read.Preserved behavior
.tbiand.csiindexes remain accepted.Non-goals
bedmethyl merge.Behavior before and after
m,CG,0andm,DRACH,2at one position in two inputsmrowh,CG,0rows in only one of two inputs with--min-samples allhrow falsely retainedh,CG,0excluded--min-samples all --forceTesting
Test environment
ac7ae9da532e89a6f453b90bb980efb97955f59973dab255ceb39a7c1ec6b5531c0191ce352c18c6; clean5cecc3fb3a9336068d9e3c68d5c08d678153dd2cCargo.lockSHA-25649c08c4c51b6f4320726551146d971fa9ef2183d40c3f6c631b2005965e242c0; resolvedhts-sys 2.2.0; the lockfile is not in this diffm/h; duplicate-onlyhretained; missing input silently skipped and sentinel overwrittencargo test --offline --locked -p modkit --test test_bedmethyl_util test_bedmethyl_merge_preserves_full_name_and_counts_distinct_inputs -- --exact --test-threads=1cargo test --offline --locked -p modkit --test test_bedmethyl_util test_bedmethyl_merge_rejects_one_bad_input_with_min_samples_all -- --exact --test-threads=1cargo test --offline --locked -p mod_kit bedmethyl -- --test-threads=1cargo test --offline --locked -p modkit --test test_bedmethyl_util -- --test-threads=1cargo test --offline --workspace --all-targets -- --test-threads=1on the frozen exact head--threads 1 --io-threads 1 --min-samples all60ee4d996c0d5cb7d8218f77e383f58213567860268168f1245daf1a2888cb42; fixed exact two-row SHA-256485e6f10ec492710ab2f95d3de9d8a5327bf823c57074fd6df795ea8bd9c3c22--force --min-samples allabsent.input.bed.gz, and preserves 15-byte sentinel with SHA-256db5a4b107e2107da20a4e94e5aaf4f379752c06a1367e00ed279ae5a9c1ab729a,m,CG,0,m,DRACH,2, numeric76792,CG,0; duplicate rows; reversed reader and row orderallrustfmt --edition 2021 --checkon both changed Rust files;git diff --check upstream/master...HEAD; clean-worktree checkTests not performed
cargo clippywas not run.Scientific validation
--min-samplescounts the requested input files that contribute a qualifying matching identity, never the number of rows.Output and compatibility
Reviewer guide
test_bedmethyl_merge_preserves_full_name_and_counts_distinct_inputsfor the exact scientific count and identity oracle.modkit-core/src/bedmethyl_util/subcommands.rs.test_bedmethyl_utiltarget.Checklist