Skip to content

feat: add SAM and CRAM input support#2

Merged
ewels merged 2 commits into
mainfrom
sam-cram
Feb 13, 2026
Merged

feat: add SAM and CRAM input support#2
ewels merged 2 commits into
mainfrom
sam-cram

Conversation

@ewels
Copy link
Copy Markdown
Member

@ewels ewels commented Feb 13, 2026

Summary

  • Add support for SAM and CRAM input files alongside the existing BAM support (rust-htslib auto-detects format)
  • Add --reference / -r CLI option for specifying a CRAM reference FASTA, with early validation when missing
  • Update all CLI help text, error messages, log output, and documentation to be format-agnostic

Changes

CLI (src/cli.rs)

  • Rename bam positional argument to input (accepts SAM/BAM/CRAM)
  • Add --reference / -r option for CRAM reference FASTA

Core (src/counting.rs)

  • Thread reference: Option<&str> through count_reads() and process_chromosome_batch()
  • Call set_reference() on all htslib readers when a reference is provided
  • Update error/log messages and doc comments to say "alignment file" instead of "BAM"

Entry point (src/main.rs)

  • Early validation: bail with a clear message if CRAM input is detected without --reference or REF_PATH env var
  • Rename bam_steminput_stem, update log messages

Config (src/config.rs)

  • Rename bam_to_gtf_mapping()alignment_to_gtf_mapping()

Tests

  • New SAM integration test (test_sam_input_matches_bam) verifying identical output to BAM
  • New tests/data/test.sam test fixture
  • --reference flag coverage in CLI unit test

Documentation

  • README: new "Supported Formats" section, updated usage examples
  • CHANGELOG, CONTRIBUTING, benchmark README updated

- Rename CLI 'bam' argument to 'input', accepting SAM/BAM/CRAM files
- Add --reference/-r option for specifying CRAM reference FASTA
- Call set_reference() on all htslib readers when reference is provided
- Add early validation for CRAM input without reference or REF_PATH
- Update all error messages, log output, and doc comments to be format-agnostic
- Rename bam_to_gtf_mapping() to alignment_to_gtf_mapping()
- Add SAM integration test verifying identical output to BAM
- Add --reference coverage to CLI unit test
- Update README, CHANGELOG, CONTRIBUTING, and benchmark docs
@ewels ewels merged commit 121592d into main Feb 13, 2026
4 checks passed
@ewels ewels deleted the sam-cram branch February 13, 2026 02:33
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