Skip to content

Replace bio with an own FASTQ reader; trim minimap2 features - #85

Merged
wdecoster merged 4 commits into
masterfrom
own-fastq-parser
Oct 29, 2026
Merged

wdecoster merged 4 commits into
masterfrom
own-fastq-parser

Conversation

@wdecoster

@wdecoster wdecoster commented Oct 29, 2026 •

Copy link
Copy Markdown
Owner

Follows #84 (merged).

What

Replaces bio with a ~150-line FASTQ reader of our own (src/fastq.rs), and builds minimap2 without its default map-file feature. chopper used bio only for its FASTQ reader and record type. minimap2's map-file feature only provides Aligner::map_file, which chopper doesn't call, and it pulls in a second FASTQ parser (needletail). The unused approx dependency is removed too.

before after
runtime crates 123 55
Cargo.lock packages 166 86
filtering 200 MB, -t 4 78 ms 71 ms

Behaviour

Valid FASTQ: unchanged. The v0.14.1 digest test from #84 passes on the new reader, and in 26 further runs against the v0.14.1 binary (every trim approach, the filters, gzip input, -t 1 and -t 4) stdout and stderr were identical. Like bio, the reader trims trailing whitespace from each line and accepts CRLF.

Malformed FASTQ: deliberately better.

Input v0.14.1 now
sequence and quality of different lengths accepted, then panic in trimming error naming the read and line, exit 1
blank lines between records or at the end parse panic skipped
read without bases (@r\n\n+\n\n) "incomplete record" panic empty read, dropped by the length filter
truncated record, missing @, non-UTF-8 header panic (exit 101) with a debug-formatted error Error: problem parsing FASTQ input at line N: ..., exit 1
wrapped (multi-line) records quality lines matched to sequence lines by count matched by length; a one-line sequence takes exactly one quality line

The header is now kept whole instead of being split into id and description at the first space, so the reassembly that record_to_string needed (see the old CLAUDE.md note) is gone. CLAUDE.md is updated.

Tests

make ci: 72 unit tests (10 new for the reader) and 19 end-to-end tests pass, plus the 4 ignored smoke tests and clippy -D warnings.

🤖 Generated with Claude Code

wdecoster and others added 3 commits October 29, 2026 14:01
bio was used only for its FASTQ reader and record type, yet brought in
about 60 crates (nalgebra, ndarray, statrs, petgraph, regex, ...). The
new reader in src/fastq.rs yields the same records on well-formed input,
so FASTQ output stays byte-identical to v0.14.1 (checked by the digest
test), and handles malformed input better:

- mismatched sequence/quality lengths are an error instead of a panic
  later in trimming
- wrapped records pair qualities by length; a one-line sequence takes
  exactly one quality line
- empty reads and blank lines are accepted
- parse errors name the line and exit 1 instead of panicking

The header is kept whole, so the id/description reassembly goes away.
Also drops the unused approx dependency. Runtime crates 125 -> 61,
lockfile 172 -> 95 packages, clean release build 41 s -> 27 s.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
That feature only provides Aligner::map_file, which chopper does not use,
and pulls in needletail, buffer-redux and bytecount. The contamination
filter builds its index with with_index and aligns with map, both
unaffected.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@wdecoster
wdecoster deleted the branch ubam-io October 29, 2026 19:57
@wdecoster wdecoster closed this Oct 29, 2026
@wdecoster wdecoster reopened this Oct 29, 2026
@wdecoster
wdecoster changed the base branch from ubam-io to master October 29, 2026 19:58
@wdecoster
wdecoster merged commit db59fc4 into master Oct 29, 2026
1 check passed
@wdecoster
wdecoster deleted the own-fastq-parser branch October 29, 2026 20:00
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