Skip to content

Commit 9cf5121

Browse files
ewelscursoragent
andauthored
Migrate BAM I/O from rust-htslib to noodles (#115)
* Migrate BAM I/O from rust-htslib to noodles (#113) Replace rust-htslib with a pure-Rust noodles backend behind a compatibility shim at src/rna/bam/. The shim preserves the existing Reader/IndexedReader/Record API used across dupRadar, RSeQC, preseq, Qualimap, and samtools-compatible outputs. Key changes: - Add noodles-backed BAM/SAM/CRAM readers with indexed fetch support - Preserve samtools-identical CHK checksums via packed sequence bytes - Update build docs: no cmake/htslib system deps required - All integration and unit tests pass in release mode Co-authored-by: Phil Ewels <phil.ewels@seqera.io> * Update docs, Dockerfile, and CI for noodles migration Replace rust-htslib build prerequisites with noodles (pure Rust) across the website docs, Dockerfile, GitHub Actions workflows, and CHANGELOG. Co-authored-by: Phil Ewels <phil.ewels@seqera.io> * Fix CI: rustfmt and bump MSRV to 1.89 for noodles - Remove extra blank line in main.rs (cargo fmt --check) - Bump rust-version to 1.89 (required by noodles 0.111) - Update MSRV CI job to match Co-authored-by: Phil Ewels <phil.ewels@seqera.io> --------- Co-authored-by: Cursor Agent <cursoragent@cursor.com>
1 parent 3f41801 commit 9cf5121

36 files changed

Lines changed: 1624 additions & 734 deletions

.cargo/audit.toml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,4 @@
22
# https://github.com/rustsec/rustsec/tree/main/cargo-audit
33

44
[advisories]
5-
# custom_derive v0.1.7 — unmaintained crate pulled in transitively by
6-
# rust-htslib v1.0.0. There is no newer rust-htslib release that drops it,
7-
# and this is an "unmaintained" notice, not a vulnerability.
8-
# Re-evaluate when rust-htslib releases a version without custom_derive.
9-
ignore = ["RUSTSEC-2025-0058"]
5+
ignore = []

.github/workflows/ci.yml

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ permissions:
1010

1111
env:
1212
CARGO_TERM_COLOR: always
13+
CXX: g++
1314

1415
jobs:
1516
test:
@@ -36,12 +37,11 @@ jobs:
3637
if: runner.os == 'Linux'
3738
run: |
3839
sudo apt-get update
39-
sudo apt-get install -y cmake zlib1g-dev libbz2-dev liblzma-dev \
40-
libcurl4-openssl-dev libssl-dev libfontconfig1-dev pkg-config clang
40+
sudo apt-get install -y g++ libfontconfig1-dev pkg-config
4141
4242
- name: Install macOS build deps
4343
if: runner.os == 'macOS'
44-
run: brew install bzip2 xz
44+
run: brew install fontconfig
4545

4646
- uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # ratchet:Swatinem/rust-cache@v2.9.1
4747

@@ -87,8 +87,7 @@ jobs:
8787
- name: Install Linux build deps
8888
run: |
8989
sudo apt-get update
90-
sudo apt-get install -y cmake zlib1g-dev libbz2-dev liblzma-dev \
91-
libcurl4-openssl-dev libssl-dev libfontconfig1-dev pkg-config clang
90+
sudo apt-get install -y g++ libfontconfig1-dev pkg-config
9291
9392
- uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # ratchet:Swatinem/rust-cache@v2.9.1
9493

@@ -103,13 +102,12 @@ jobs:
103102
- name: Install Rust MSRV toolchain
104103
uses: dtolnay/rust-toolchain@631a55b12751854ce901bb631d5902ceb48146f7 # ratchet:dtolnay/rust-toolchain@master
105104
with:
106-
toolchain: "1.87"
105+
toolchain: "1.89"
107106

108107
- name: Install Linux build deps
109108
run: |
110109
sudo apt-get update
111-
sudo apt-get install -y cmake zlib1g-dev libbz2-dev liblzma-dev \
112-
libcurl4-openssl-dev libssl-dev libfontconfig1-dev pkg-config clang
110+
sudo apt-get install -y g++ libfontconfig1-dev pkg-config
113111
114112
- uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # ratchet:Swatinem/rust-cache@v2.9.1
115113

.github/workflows/release.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ permissions:
1212

1313
env:
1414
CARGO_TERM_COLOR: always
15+
CXX: g++
1516
IMAGE_NAME: ${{ github.repository }}
1617

1718
jobs:
@@ -130,13 +131,12 @@ jobs:
130131
if: runner.os == 'Linux'
131132
run: |
132133
sudo apt-get update
133-
sudo apt-get install -y cmake zlib1g-dev libbz2-dev liblzma-dev \
134-
libcurl4-openssl-dev libssl-dev libfontconfig1-dev pkg-config clang
134+
sudo apt-get install -y g++ libfontconfig1-dev pkg-config
135135
136136
# macOS build dependencies
137137
- name: Install macOS build deps
138138
if: runner.os == 'macOS'
139-
run: brew install bzip2 xz
139+
run: brew install fontconfig
140140

141141
- name: Build
142142
run: >

AGENTS.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ To prepare a release:
244244
| Crate | Purpose |
245245
| ---------------------- | ------------------------------------- |
246246
| `clap` v4 | CLI argument parsing (derive) |
247-
| `rust-htslib` | BAM file I/O (statically linked) |
247+
| `noodles` | BAM/SAM/CRAM file I/O (pure Rust) |
248248
| `plotters` | Chart generation (PNG + SVG) |
249249
| `serde` | YAML config deserialization |
250250
| `anyhow` | Error handling |
@@ -282,7 +282,7 @@ forwarded to `count_reads()` as the `skip_dup_check: bool` parameter).
282282
- Test data is generated by `tests/create_test_data.R` — do not modify `tests/expected/` by hand.
283283
- Float output formatting must match R's behavior (15 significant digits, "NA" for NaN, trailing-zero trimming).
284284
- The pipeline processes BAM files which can be very large — performance matters.
285-
- System dependencies needed for building: cmake, zlib, bz2, lzma, curl, ssl, clang (for `rust-htslib`).
285+
- System dependencies needed for building: a C++ compiler (for the preseq RNG FFI shim), libfontconfig (for plot rendering). noodles handles BAM/SAM/CRAM I/O in pure Rust with no htslib/cmake dependency.
286286
- Benchmark results are produced by the [RustQC-benchmarks](https://github.com/seqeralabs/RustQC-benchmarks)
287287
Nextflow pipeline. When benchmarks are re-run, verify that all results referenced in the docs
288288
and the top-level `README.md` are updated to reflect the new numbers.

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
# RustQC Changelog
22

3+
## [Unreleased]
4+
5+
### Other changes
6+
7+
- Migrate BAM/SAM/CRAM I/O from rust-htslib to pure-Rust [noodles](https://crates.io/crates/noodles) (#113)
8+
- Simplify build requirements: no cmake or htslib system libraries needed
9+
- Bump MSRV to Rust 1.89 (required by noodles 0.111)
10+
311
## [Version 0.2.1](https://github.com/seqeralabs/RustQC/releases/tag/v0.2.1) - 2026-04-09
412

513
### Bug fixes

CONTRIBUTING.md

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,24 +6,18 @@ Thanks for your interest in contributing to RustQC! This document covers how to
66

77
### Prerequisites
88

9-
You need a working Rust toolchain (stable) and the following system libraries for building `rust-htslib`:
10-
11-
- cmake, clang
12-
- zlib, libbz2, liblzma
13-
- libcurl, libssl
14-
- libfontconfig (for plot rendering)
9+
You need a working Rust toolchain (stable), a C++ compiler (for the preseq RNG FFI shim), and libfontconfig (for plot rendering). BAM/SAM/CRAM I/O is handled by the pure-Rust [noodles](https://crates.io/crates/noodles) crate — no htslib or cmake required.
1510

1611
On Ubuntu/Debian:
1712

1813
```bash
19-
sudo apt-get install cmake clang zlib1g-dev libbz2-dev liblzma-dev \
20-
libcurl4-openssl-dev libssl-dev libfontconfig1-dev
14+
sudo apt-get install g++ libfontconfig1-dev
2115
```
2216

2317
On macOS (with Homebrew):
2418

2519
```bash
26-
brew install cmake xz
20+
brew install fontconfig
2721
```
2822

2923
### Building

0 commit comments

Comments
 (0)