Reject invalid and conflicting validate truth rows - #660
Open
SuhasSrinivasan wants to merge 2 commits into
Open
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 #658.
Summary
(contig, strand, position)while preserving idempotent overlaps and strand independence.+/-truth-strand contract and add sentinel-preservation regressions for invalid inputs.Severity
Severity: High — scientific correctness and output integrity
Rationale: Malformed truth rows can be silently discarded and conflicting annotations can change full contingency counts by row order while validate exits successfully. Existing output can also be truncated before a later truth-input failure.
Root cause
The truth parser used
filter_map(... .ok()), converting every line read or parse error into an omitted row. The line parser did not enforce nonnegative nonempty intervals, consumed only the first strand character, and accepted an overly broad modification-token set. Parsed positions were inserted with unconditional last-write-wins semantics, and the report file was created before truth parsing completed.Implementation
0 <= start < end, exact+/-strands, and a documented truth-label grammar: canonical-, numeric ChEBI, one lowercase ASCII short code, or supported one-character uppercase base code.BTreeMap::entryplus interval-level provenance to reject conflicting assignments with both old/new provenance; identical duplicates remain idempotent and different strands independent.Range<i64>rather than allocating a temporary vector.The two commits separate strict input/error handling from conflict detection.
Preserved behavior
-, numeric ChEBI codes, and extra BED columns remain accepted.+and-remains independent.Non-goals
.) truth mode and no special UCSCtrack/browserdirective support are introduced.Behavior before and after
not-a-bed-row0 <= start < end+junkor malformed modification labelmthenhversushthenmTesting
Test environment
585a9791b711e2bd2fb18cd9ed08bdad131b3f1401fd7f3086e390f61e056a67eb172e2986bffdbd; clean5cecc3fb3a9336068d9e3c68d5c08d678153dd2ctests/resources/input_5mC.bamCargo.lockSHA-25649c08c4c51b6f4320726551146d971fa9ef2183d40c3f6c631b2005965e242c0; resolvedhts-sys 2.2.0; the lockfile is not in this diffcargo test -p mod_kit validate::subcommand::tests -- --test-threads=1cargo test -p modkit --test test_validate -- --test-threads=1cargo test --workspace --all-targets -- --test-threads=1on the frozen exact headmalformed-truth.bed,conflict-mh.bed, andconflict-hm.bedfrom the linked issue1and21839; canonical-; extra columnssentinel\nreportb5f7e7d285029324d9b3acae19cc05099271454ac98bfc059a92b0581625cd51rustfmt --edition 2021 --checkon both changed Rust files;git diff --check upstream/master...HEAD; clean-worktree checkTests not performed
cargo clippywas not run.Scientific validation
(contig, strand, position)has at most one truth label; conflicts fail instead of changing category totals.+and-are exact and independent.Output and compatibility
Reviewer guide
ground_truth_bed_reports_mixed_row_error_with_physical_lineandground_truth_bed_rejects_conflicting_overlap_in_both_ordersfor the primary parent-red contracts.parse_ground_truth_bed_linefor coordinates, strand, and label grammar.parse_ground_truth_bed_filefor explicit error propagation and interval-level conflict provenance.ValidateFromModBam::runand the small documentation change.cargo test -p mod_kit validate::subcommand::tests -- --test-threads=1andcargo test -p modkit --test test_validate test_validate_bed_errors_preserve_output_and_report_line -- --exact.Checklist