Add bowtie2 as a mapper#291
Conversation
Support bowtie2 alongside bwa, minimap2 and strobealign, both for read mapping (coverm contig/genome/make) and for pre-generating databases (coverm makedb). - Add a BOWTIE2 variant to MappingProgram and thread it through all the exhaustive matches (parameter selection, dependency checking, index generation, command building). - Build bowtie2 mapping commands separately, since bowtie2 takes the index via -x, reads via -1/-2/-U/--interleaved and threads via -p. Unlike the other mappers, bowtie2 does not auto-detect FASTA vs FASTQ input, so peek at the first read record (via needletail, which also handles gzip/bzip2/xz) and pass -f for FASTA reads. - Generate bowtie2 indexes with bowtie2-build, both as temporary indexes during mapping and as persistent databases via makedb (written as a prefix, like BWA). Detect a pre-built index beside the reference prefix so it can be reused. - Add --bowtie2-params to contig/genome/make/makedb, a check_for_bowtie2 dependency check, CLI help/table entries, README docs and the bowtie2 conda dependency. - Add tests for direct bowtie2 mapping and makedb round-trips. https://claude.ai/code/session_0197qbhqSpTk8JEAPcRDHcvV
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 04b583e9ff
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| .expect("Failed to glean file name from reference path"); | ||
| let copied_reference = std::path::Path::new(output_directory).join(reference_file_name); | ||
|
|
||
| if copied_reference == std::path::Path::new(reference_path) { |
There was a problem hiding this comment.
Avoid copying strobealign references onto themselves
When coverm makedb -p strobealign is run with an output directory that resolves to the reference's own directory but is spelled differently (for example -r ref.fna -o ., -r ./ref.fna -o $(pwd), or symlinked paths), this lexical Path comparison does not catch that source and destination are the same file. std::fs::copy then opens the destination with truncation, so the input FASTA can be silently emptied before indexing; canonicalize both paths or otherwise detect same-file before copying.
Useful? React with 👍 / 👎.
Summary
Adds bowtie2 as a supported mapper alongside bwa, minimap2 and strobealign — for both read mapping (
coverm contig/genome/make) and pre-generating databases (coverm makedb).This builds on #290 (the
makedbcommand), so its commits appear here too; it is intended to merge after / on top of #290.Changes
Core mapping (
bam_generator.rs)BOWTIE2variant toMappingProgram, threaded through all exhaustive matches.-x, reads via-1/-2/-U/--interleaved, threads via-p..fq.gzfiles, so the first read record is peeked vianeedletail(which also handles gzip/bzip2/xz) and-fis passed for FASTA reads.Index / database generation (
mapping_index_maintenance.rs)bowtie2-build, both as temporary indexes during mapping and as persistent databases viamakedb(written as a prefix, like BWA).coverm contig -r <prefix> -p bowtie2reuses it.CLI / wiring (
cli.rs,bin/coverm.rs,mapping_parameters.rs,external_command_checker.rs)bowtie2in the mapper list,--bowtie2-paramson contig/genome/make/makedb, acheck_for_bowtie2dependency check, CLI help/table entries and makedb usage hints.Deps, docs, tests
bowtie2conda dependency topixi.tomland updatedpixi.lock(kept at lockfile format v6 to avoid a noisy re-solve).makedbexamples).makedbround-trips.Testing
Ran the full integration suite in the pixi environment: 113 passed, 0 failed, 4 ignored, including the 3 new bowtie2 tests.
cargo clippy -- -D warningsandcargo fmt --checkare clean.https://claude.ai/code/session_0197qbhqSpTk8JEAPcRDHcvV
Generated by Claude Code