Zig drop-in replacement for bcrham and ig-sw (zero C++ deps)#339
Open
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>
Collaborator
Author
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. |
Owner
|
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. |
Collaborator
Author
|
Hey Duncan! Thanks for the comment. I'll work on all these bits. |
Collaborator
Author
|
@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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.