Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@ cargo clippy # lint
cargo fmt --check # check formatting
```

Shell-based equivalence and integration tests live in `tests/`:
- `tests/equivalence-e2e.sh` — end-to-end comparison against original MaxBin2
- `tests/pipeline-trace.sh` — recursive pipeline equivalence (Rust vs C++)
- `tests/cli-equivalence.sh` / `tests/cli-integration.sh` — CLI behavior
- `tests/bench-genecaller.sh` — FragGeneScan vs FragGeneScanRs benchmark
Shell-based equivalence and integration tests live in `crates/maxbin-rs/tests/`:
- `crates/maxbin-rs/tests/equivalence-e2e.sh` — end-to-end comparison against original MaxBin2
- `crates/maxbin-rs/tests/pipeline-trace.sh` — recursive pipeline equivalence (Rust vs C++)
- `crates/maxbin-rs/tests/cli-equivalence.sh` / `crates/maxbin-rs/tests/cli-integration.sh` — CLI behavior
- `crates/maxbin-rs/tests/bench-genecaller.sh` — FragGeneScan vs FragGeneScanRs benchmark

## Architecture

### CLI (clap derive, `src/cli.rs`)
### CLI (clap derive, `crates/maxbin-rs/src/cli.rs`)

Uses standard double-dash flags (`--contig`, `--abund`, etc.). Single-dash compatibility was dropped in v0.2.0. Subcommands expose individual pipeline stages:

Expand All @@ -45,7 +45,7 @@ Uses standard double-dash flags (`--contig`, `--abund`, etc.). Single-dash compa
- `maxbin-rs cpp-em` — run the original C++ EM via FFI (equivalence testing only)
- `maxbin-rs sam-to-abund` — compute abundance from a SAM file

### Key source files
### Key source files (in `crates/maxbin-rs/src/`)

- `pipeline.rs` — orchestration for each subcommand
- `emanager.rs` — EM algorithm core (E-step, M-step, convergence)
Expand Down
28 changes: 6 additions & 22 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,26 +1,10 @@
[package]
name = "maxbin-rs"
version = "0.4.0"
edition = "2024"
[workspace]
resolver = "3"
members = ["crates/maxbin-rs"]

[dependencies]
clap = { version = "4.6.1", features = ["derive"] }
flate2 = "1.1.9"
frag_gene_scan_rs = "1.1.0"
rayon = "1.10"
serde = { version = "1", features = ["derive"] }
serde_json = "1"
seq_io = "0.3"
tempfile = "3"

[build-dependencies]
cc = "1.2.60"

[dev-dependencies]
proptest = "1.11.0"

# Optimized test profile for benchmarks.
# Profiles are only honored at the workspace root, so the benchmark profile
# that used to live in the crate manifest moves here.
# Usage: cargo nextest run --cargo-profile bench bench_components -- --ignored
[profile.bench]
inherits = "release"
debug = true # keep symbols for profiling
debug = true # keep symbols for profiling
20 changes: 20 additions & 0 deletions crates/maxbin-rs/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
[package]
name = "maxbin-rs"
version = "0.4.0"
edition = "2024"

[dependencies]
clap = { version = "4.6.1", features = ["derive"] }
flate2 = "1.1.9"
frag_gene_scan_rs = "1.1.0"
rayon = "1.10"
serde = { version = "1", features = ["derive"] }
serde_json = "1"
seq_io = "0.3"
tempfile = "3"

[build-dependencies]
cc = "1.2.60"

[dev-dependencies]
proptest = "1.11.0"
4 changes: 2 additions & 2 deletions build.rs → crates/maxbin-rs/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ fn main() {
let manifest_dir = PathBuf::from(env::var("CARGO_MANIFEST_DIR").unwrap());

// Rebuild if patch or FFI wrappers change.
println!("cargo:rerun-if-changed=nix/maxbin2-cpp-ffi.patch");
println!("cargo:rerun-if-changed=vendor/maxbin2-cpp-ffi.patch");
println!("cargo:rerun-if-changed=vendor/ffi");
println!("cargo:rerun-if-env-changed=MAXBIN2_SRC_TARBALL");

Expand Down Expand Up @@ -108,7 +108,7 @@ fn main() {
fs::remove_dir(&src_subdir).unwrap();

// Step 3: Apply the patch.
let patch_path = manifest_dir.join("nix/maxbin2-cpp-ffi.patch");
let patch_path = manifest_dir.join("vendor/maxbin2-cpp-ffi.patch");
// The patch has paths like a/src/EManager.cpp, so we need to adjust.
// We'll apply with -p2 to strip "a/src/" down to the filename.
let patch_output = Command::new("patch")
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,7 @@
''
export MAXBIN_RS_DETERMINISTIC=1
export HOME=$(mktemp -d)
bash ${./tests/pipeline-trace.sh} \
bash ${./crates/maxbin-rs/tests/pipeline-trace.sh} \
"${intermediates.cami-small}/contigs.fa" \
"${intermediates.cami-small}/abund" \
"${intermediates.cami-small}/hmmout"
Expand Down
20 changes: 10 additions & 10 deletions nix/tests.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#
# Each entry here creates a small shell script that:
# 1. Sets environment variables pointing to Nix-cached test data
# 2. Runs the actual test script from tests/
# 2. Runs the actual test script from crates/maxbin-rs/tests/
#
# This indirection exists because the test scripts are plain bash (readable
# without knowing Nix), but they need paths to data in the Nix store —
Expand Down Expand Up @@ -31,7 +31,7 @@

let
# Helper: create a sandboxed CLI integration test for a given dataset.
# Runs tests/cli-integration.sh with the binary on PATH and test data
# Runs crates/maxbin-rs/tests/cli-integration.sh with the binary on PATH and test data
# available. Tests flag parsing, subcommands, error cases, and output
# validation end-to-end.
mkCliTest =
Expand All @@ -55,7 +55,7 @@ let
export MAXBIN_RS_DETERMINISTIC=1
export HOME=$(mktemp -d)

bash ${../tests/cli-integration.sh}
bash ${../crates/maxbin-rs/tests/cli-integration.sh}

touch $out
'';
Expand Down Expand Up @@ -83,7 +83,7 @@ let
export MAXBIN_RS_DETERMINISTIC=1
export HOME=$(mktemp -d)

bash ${../tests/cli-equivalence.sh}
bash ${../crates/maxbin-rs/tests/cli-equivalence.sh}

touch $out
'';
Expand Down Expand Up @@ -114,7 +114,7 @@ let
maxbin-rs
];
text = ''
bash ${../tests/pipeline-trace.sh} \
bash ${../crates/maxbin-rs/tests/pipeline-trace.sh} \
"${contigs}" \
"${intermediates'}/abund" \
"${intermediates'}/hmmout"
Expand Down Expand Up @@ -443,7 +443,7 @@ in
export CONTIGS="${datasets.bfragilis.contigs}"
export TRAIN_DIR="${fraggenescan-rs}/share/FragGeneScanRs/train"
export PATH="${fraggenescan}/libexec/FragGeneScan:$PATH"
bash ${../tests/bench-genecaller.sh}
bash ${../crates/maxbin-rs/tests/bench-genecaller.sh}
'';
};

Expand All @@ -456,7 +456,7 @@ in
export CONTIGS="${datasets.capes-s7.contigs}"
export TRAIN_DIR="${fraggenescan-rs}/share/FragGeneScanRs/train"
export PATH="${fraggenescan}/libexec/FragGeneScan:$PATH"
bash ${../tests/bench-genecaller.sh}
bash ${../crates/maxbin-rs/tests/bench-genecaller.sh}
'';
};

Expand All @@ -469,7 +469,7 @@ in
text = ''
export CONTIGS="${datasets.bfragilis.contigs}"
export ABUND="${intermediates.bfragilis}/abund"
bash ${../tests/bench-pipeline.sh}
bash ${../crates/maxbin-rs/tests/bench-pipeline.sh}
'';
};

Expand All @@ -479,7 +479,7 @@ in
text = ''
export CONTIGS="${datasets.capes-s7.contigs}"
export ABUND="${intermediates.capes}/abund"
bash ${../tests/bench-pipeline.sh}
bash ${../crates/maxbin-rs/tests/bench-pipeline.sh}
'';
};

Expand All @@ -490,7 +490,7 @@ in
text = ''
export CONTIGS="${datasets.capes-s7.contigs}"
export READS="${datasets.capes-s7.reads1} ${datasets.capes-s7.reads2}"
bash ${../tests/bench-pipeline.sh}
bash ${../crates/maxbin-rs/tests/bench-pipeline.sh}
'';
};

Expand Down
Loading