Explain why whole-contig CRAM reference lookup failed - #1793
Conversation
The whole-contig lookup reported
A reference must be supplied (reference sequence SAMSequenceRecord(name=1,
length=200,dict_index=0,assembly=null,alternate_names=[]) not found).
which is misleading in the common case: a reference *was* supplied, it just
had not been indexed. It also dumped the entire SAMSequenceRecord at the user.
This is the sibling of the by-region lookup fixed in #1790 for #1732. Both fail
for the same reason, so factor the diagnostic into one helper and use it from
both, rather than letting the two messages drift apart. The message names the
sequence and points at the companion .fai/.gzi/.dict files a CRAM needs.
Message text only; no change to which inputs are accepted.
📝 WalkthroughWalkthrough
ChangesCRAM reference error diagnostics
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/test/java/htsjdk/samtools/cram/build/CRAMReferenceRegionErrorMessageTest.java (1)
91-99: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAssert the
.gziguidance too.The production message includes a
.gzirequirement for bgzipped FASTA files, and the PR objective explicitly includes it, but this test only checks.faiand.dict. Add a.gziassertion to prevent that guidance from regressing.Proposed test addition
Assert.assertTrue( message.contains(".dict"), "the error should mention the required sequence dictionary, but was: " + message); + Assert.assertTrue( + message.contains(".gzi"), + "the error should mention the bgzipped FASTA index, but was: " + message);🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/test/java/htsjdk/samtools/cram/build/CRAMReferenceRegionErrorMessageTest.java` around lines 91 - 99, Update testWholeContigFetchExplainsLikelyCause to also assert that the failed whole-contig fetch message contains ".gzi", alongside the existing sequence, ".fai", and ".dict" guidance checks.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In
`@src/test/java/htsjdk/samtools/cram/build/CRAMReferenceRegionErrorMessageTest.java`:
- Around line 91-99: Update testWholeContigFetchExplainsLikelyCause to also
assert that the failed whole-contig fetch message contains ".gzi", alongside the
existing sequence, ".fai", and ".dict" guidance checks.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 7c6333bb-7c66-4589-afd5-60a1935fc012
📒 Files selected for processing (2)
src/main/java/htsjdk/samtools/cram/build/CRAMReferenceRegion.javasrc/test/java/htsjdk/samtools/cram/build/CRAMReferenceRegionErrorMessageTest.java
Closes #998.
The whole-contig reference lookup reported:
which is misleading in the common case — a reference was supplied, it just had not been indexed — and it dumped the entire
SAMSequenceRecordat the user.This is the sibling of the by-region lookup fixed in #1790 (for #1732). Both fail for the same reason, so I factored the diagnostic into one private helper used by both, rather than letting two copies of the same message drift apart. It names the sequence and points at the companion
.fai/.gzi/.dictfiles a CRAM needs.Message text only — no change to which inputs are accepted.
Tests cover the whole-contig path, assert the two paths report an identical diagnostic, and assert the message no longer contains a raw
SAMSequenceRecord(dump.Test methods follow the house
testXxxcamelCase convention.Summary by CodeRabbit
Bug Fixes
Tests