Repository navigation
Bundle BioNetGen 2.9.3 to generate rule-based reaction networks (0.0.22) - #29
Merged
Merged
Conversation
…ion 0.0.22 VCell expands a rule-based application's reaction rules into a reaction network with BioNetGen (perl <vcell.installDir>/bionetgen/BNG2.pl), which libvcell lacked: such math could not be generated (vcml_to_ode_input fell back to the stored math; vcml_to_vcml and the others failed). - libvcell/vcell_install/bionetgen/: the Perl part of BioNetGen 2.9.3 (MIT): BNG2.pl and Perl2/, copied unchanged from the official release (README records the source and sha256); network generation does not use its compiled simulators, so bin/ is left out. Pre-commit excludes it. - The Python package sets LIBVCELL_VCELL_INSTALL_DIR to it, and BioNetGenSupport.configure(), first in every model-building method, makes it vcell.installDir (each call runs in a fresh isolate). - vcml_to_ode_input regenerates a rule-based application with it and falls back to the stored math only if that fails (no perl on the PATH, a BioNetGen timeout), naming the reason in its message. - build.py and the local build script record with the variable set, so native-image covers the BioNetGen path. Checked against VCell's own BioNetGen 2.3.0 (vcell_submodule/bionetgen) on the 109 rule-based models with ODE simulations in a 2,730-model VCell corpus: 103 give byte-identical solver input with either version; the other 6 fail identically with both (model errors, two BioNetGen timeouts). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
VCell's Windows code launches bionetgen/win64Standalone/BNG2.exe, never perl BNG2.pl, so the bundled BNG2.pl was unused on Windows (CI: "CreateProcess error=2", the regeneration test failed). The old 2.3.0 BNG2.exe in VCell's repository is GPLv3; this builds a new one from the bundled MIT 2.9.3. - scripts/pack_bionetgen.sh packs BNG2.pl and Perl2/ with PAR::Packer (-I Perl2 and every module named, since BNG2.pl looks for Perl2/ beside itself) into a standalone executable with its own Perl, then smoke-tests it by generating a network with nothing from outside it. Prototyped on macOS: the packed binary generates the same network as perl BNG2.pl (egfr_net, 4,177 lines). - The Windows jobs of main.yml and on-release-main.yml install PAR::Packer and run it before the build, cached on a hash of the BioNetGen files and the script. - The exe is git-ignored and included in the wheel; build.py warns on Windows when it is missing (rule-based models then use their stored math). - The Python regeneration test needs the exe on Windows and perl elsewhere. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…n.yml Git Bash puts the Perl that ships with Git for Windows first on the PATH, so cpanm ran under it and failed (no ExtUtils::Manifest); the Windows pack step now puts Strawberry Perl first and runs cpanm and pp through it. main.yml opened a tmate debug session on every failure and waited for a connection, holding the job (and the runner) until it timed out. The release workflow's tmate step stays: it is opt-in (debug_tmate) and limited to 30 minutes. Co-Authored-By: Claude Opus 5.5 <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.
libvcell can now generate the math of rule-based applications. VCell expands an application's reaction rules into a reaction network with BioNetGen (
perl <vcell.installDir>/bionetgen/BNG2.pl), which libvcell didn't have.Until now:
vcml_to_ode_inputfell back to the stored math (0.0.21);vcml_to_vcmland the other model-building calls failed. pyvcell writes every model throughvcml_to_vcml, so rule-based models couldn't be built or edited there.What's bundled
libvcell/vcell_install/bionetgen/: the Perl part of BioNetGen 2.9.3 (MIT, the current upstream release), 1.6 MB.BNG2.plandPerl2/, copied unchanged from the officialBioNetGen-2.9.3-linux.tar.gz. ItsREADME.mdrecords the source and sha256; the mac release is identical, and the win release differs only in line endings.bin/is left out.perlon thePATH. macOS and most Linux distributions have it.BNG2.exe, so no Perl is needed. VCell's Windows code always launchesbionetgen/win64Standalone/BNG2.exe, neverperl BNG2.pl; this PR's first CI run failed on exactly that (CreateProcess error=2).scripts/pack_bionetgen.sh, with PAR::Packer, the tool VCell's own 2.3.0 exe was built with. It embeds a Perl interpreter. VCell's old 2.3.0 exe is GPLv3 and isn't used.pp -I Perl2with every module named, becauseBNG2.pllooks forPerl2/next to itself.perl BNG2.pl(BioNetGen'segfr_net, 4,177 lines).main.ymlandon-release-main.ymlinstall PAR::Packer and pack the exe before the build. The step is cached on a hash of the BioNetGen files and the script, so the slow install only runs when they change.build.pywarns on Windows if it's missing; rule-based models then use their stored math.How it's wired
LIBVCELL_VCELL_INSTALL_DIRtolibvcell/vcell_install(_internal/native_utils.py). A value already in the environment wins.BioNetGenSupport.configure(), called first in every model-building method, turns that variable intovcell.installDir. Each native call runs in a fresh isolate, so the setting is made per call.vcml_to_ode_inputregenerates a rule-based application with the bundled BioNetGen. It falls back to the stored math only if that fails, for example with noperlor a BioNetGen timeout, and names the reason:"<input file>; stored math (rule-based application: BioNetGen could not regenerate its reaction network: <why>)".build.pyandscripts/local_build_native.shrecord with the variable set, so native-image covers the BioNetGen path. The recording log showsexecuteBNG() as perl script.Does 2.9.3 behave like VCell's 2.3.0?
VCell's own copy (
vcell_submodule/bionetgen) is 2.3.0, under GPLv3. 2.9.3 is MIT. To check they agree, I regenerated every rule-based model with an ODE simulation in a 2,730-model VCell corpus (109 models) with both versions and compared the solver input:The README asks for this check to be repeated before moving to a newer release.
Tests
SolverEntrypointsTestgives 24/24.perl, or the packed exe on Windows. A second test forces the fallback by pointing the variable at a directory with no BioNetGen, and checks the message. 29/29 pass on a fresh native build.make checkis clean.pyproject.tomlis at 0.0.22. The wheel listslibvcell/vcell_install/**explicitly.🤖 Generated with Claude Code