Zig drop-in replacement for bcrham and ig-sw (zero C++ deps)#339
Zig drop-in replacement for bcrham and ig-sw (zero C++ deps)#339
Conversation
When PARTIS_ZIG_CORE_EXE is set, partitiondriver uses that executable instead of packages/ham/bcrham. This enables end-to-end testing of the Zig port (partis-zig-core) against the partis Python test suite without modifying any existing behavior. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
The Zig binary doesn't emit bcrham's timing and debug strings to stdout, so print_partition_dbgfo() and check_wait_times() crash when trying to summarize None values. Skip both when PARTIS_ZIG_CORE_EXE is set. Also use top-level `os` import instead of local `import os as _os`. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
All three zig-core-integration hunks now have inline comments explaining the change (the other two guards already had comments). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Downloads Zig 0.15.2 if not present, clones matsengrp/partis-zig-core, builds a static binary with no GSL/OpenBLAS deps, and prints the PARTIS_ZIG_CORE_EXE export line to use it. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- waterer.py: skip ig-sw existence check when PARTIS_ZIG_IGSW_EXE is set - waterer.py: use PARTIS_ZIG_IGSW_EXE binary in get_ig_sw_cmd_str when set - bin/install-zig-backend.sh: print PARTIS_ZIG_IGSW_EXE export alongside existing PARTIS_ZIG_CORE_EXE export With both env vars set, partis runs end-to-end with no C binaries. validate-partis-suite.sh --quick PASS with full Zig pipeline. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Verified on Linux x86_64bin/install-zig-backend.sh
export PARTIS_ZIG_CORE_EXE=.../zig-out/bin/partis-zig-core
export PARTIS_ZIG_IGSW_EXE=.../zig-out/bin/partis-zig-igsw
partis annotate --infname test/ref-results/test/simu.yaml \
--parameter-dir test/ref-results/test/parameters/simu \
--outfname /tmp/zig-test-out.yamlBuild succeeded, annotate ran to completion: 36/36 sequences annotated. |
|
This looks great! Thanks for working on this. A few quick thoughts
|
|
@psathyrella I've opened a new pull request, #340, to work on those changes. Once the pull request is ready, I'll request review from you. |
|
Hey Duncan! Thanks for the comment. I'll work on all these bits. |
|
@psathyrella if it seems like this has legs, I wonder what you would think about bringing the Zig code to be part of the partis repo. It would simplify install and future development. |
… CLI args Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- test/test.py: add --bcrham-binary and --ig-sw-binary passthrough args - partitiondriver.py: remove path-comparison guards in print_partition_dbgfo() and check_wait_times() now that Zig binary emits bcrham-compatible debug strings to stdout Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
partitiondriver.py / utils.py: - check_wait_times: skip timing check if any bcrham time is None - print_partition_dbgfo: show 'n/a' when timing is None - summarize_bcrham_dbgstrs: filter None before min/max zig-backend/partis-zig-core: bump to commit with use-after-free, double-free, missing cache writes, and ksw zero-length panic fixes Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
Here's a progress update after running the full test suite ( Bugs found and fixed
The test data (
The Zig bcrham doesn't emit the same timing line as C++ bcrham, so Test run commandAll 9 runnable steps pass. The submodule has been pushed to |
… fixes Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
Two more bugs fixed while getting
|
Summary
Wires in
matsengrp/partis-zig-coreas a zero-dependency drop-in replacement for both the C++bcrhambinary and the Cig-swbinary. Both Zig binaries are selected at runtime via environment variables, so the default C++ path is fully preserved.Changes
Three hunks in
partitiondriver.py(~6 lines total):get_hmm_cmd_str:PARTIS_ZIG_CORE_EXEenv var overrides the bcrham path when setprint_partition_dbgfo: guard — Zig binary doesn't emit bcrham timing/debug stringscheck_wait_times: guard — same reasonTwo hunks in
waterer.py:__init__: skip ig-sw binary existence check whenPARTIS_ZIG_IGSW_EXEis setget_ig_sw_cmd_str:PARTIS_ZIG_IGSW_EXEenv var overrides the ig-sw path when setOne new script:
bin/install-zig-backend.sh: downloads Zig if needed, clonespartis-zig-core, builds both static binaries, prints the export linesInstall
No GSL, OpenBLAS, yaml-cpp, or other C++ library dependencies. Works on Linux x86_64 and macOS ARM64 out of the box.
Validation
Correctness: Ran
partis cache-parameterson 36 BCR sequences fromtest/ref-results/test/simu.yamlwith both backends:ig-sw (ksw.zig): Verified on macOS ARM64 — 36/36 sequences pass smith-waterman with the Zig ig-sw, matching the C binary. Note:
ksw.zigreplaces the SSE2-dependentksw.cwith cross-platform@VectorSIMD, enabling builds on ARM without x86 intrinsics.Test suite:
test/test.py --quickpasses with both Zig binaries substituted.Equivalence: 18 checkpoint-level JSON comparisons between C++ and Zig all pass.
Backward compatibility
Unset both
PARTIS_ZIG_CORE_EXEandPARTIS_ZIG_IGSW_EXE→ original C++ bcrham and C ig-sw used, no behaviour change.