This repository builds a simple workflow for SBML pathway simulation and parameter fitting with libRoadRunner.
- Start from an SBML model in
working_homo-sapiens/. - Generate target values for all model species with
generate_target_file.pyvia local Ollama. - Run optimization with
roadrunner_new.pyto fit selected model parameters against target values. - (Optional) Save optimized parameter values back into the SBML file.
working_examples/: Generic SBML templates for testing and experimentation.working_homo-sapiens/: Pathway SBML models prepared for dynamic simulation.generated_target/: Auto-generated prompts and CSV targets (created bygenerate_target_file.py).generate_target_file.py: Parses SBML, builds a prompt, calls local Ollama, and writes a target CSV.roadrunner_new.py: Runs OpenAI-ES style optimization with RoadRunner against target values.test.csv: Example target file used byroadrunner_new.pyin its current configuration.
- Python 3.10+
- Dependencies from
requirements.txt - Ollama installed locally
- A pulled Ollama model (default in script:
llama3.2:3b)
Install dependencies:
pip install -r requirements.txtPreferred (winget):
winget install --id Ollama.Ollama -e --accept-package-agreements --accept-source-agreementsIf winget is unavailable, install from: https://ollama.com/download/windows
ollama --versionIf you get ollama non riconosciuto, use the full path:
& "$env:LOCALAPPDATA\Programs\Ollama\ollama.exe" --versionollama serveIf ollama is not in PATH, use:
& "$env:LOCALAPPDATA\Programs\Ollama\ollama.exe" serveKeep this terminal open while generating targets.
If you see bind ... 11434, it means the server is already running (this is okay).
In a second terminal:
ollama pull llama3.2:3bPATH fallback:
& "$env:LOCALAPPDATA\Programs\Ollama\ollama.exe" pull llama3.2:3bInvoke-RestMethod http://127.0.0.1:11434/api/tagsYou should see your downloaded model in the JSON response.
Server:
ollama serveModel:
ollama pull llama3.2:3bpython generate_target_file.py --sbml working_homo-sapiens/R-HSA-1855192.sbmlDefault outputs:
generated_target/R-HSA-1855192/prompt_R-HSA-1855192.txtgenerated_target/R-HSA-1855192/target.csv
- Choose a specific Ollama model:
python generate_target_file.py --sbml working_homo-sapiens/R-HSA-1855192.sbml --model llama3.2:3b- Dry run (no API call, prompt only):
python generate_target_file.py --sbml working_homo-sapiens/R-HSA-1855192.sbml --dry-run- Custom output CSV:
python generate_target_file.py --sbml working_homo-sapiens/R-HSA-1855192.sbml --output-csv test.csvroadrunner_new.py currently uses:
- SBML model:
working_homo-sapiens/R-HSA-1855192.sbml - Targets file:
./test.csv - Tuned parameters:
log_K_in,log_K_out,log_lambda_1
Run:
python roadrunner_new.pyWhat it does:
- Loads target values from
test.csv. - Simulates the model with RoadRunner.
- Optimizes parameters with an OpenAI-ES loop.
- Plots optimization loss.
- Writes optimized parameter values back into the SBML file.
- Generate a target file:
python generate_target_file.py --sbml working_homo-sapiens/R-HSA-1855192.sbml --output-csv test.csv- Fit model parameters against that target file:
python roadrunner_new.pyUse merge_sbml.py to merge two SBML pathway files into a single deterministic output model.
python merge_sbml.py working_homo-sapiens/R-HSA-1660537.sbml working_homo-sapiens/R-HSA-1660508.sbml -o working_homo-sapiens/merged_1660537_1660508.sbml- Merged SBML file at the path passed to
-o. - Merge report JSON next to it with suffix
.merge_report.json.
For the example above, outputs are:
working_homo-sapiens/merged_1660537_1660508.sbmlworking_homo-sapiens/merged_1660537_1660508_merge_report.json
- Suppress validation warnings:
python merge_sbml.py working_homo-sapiens/R-HSA-1660537.sbml working_homo-sapiens/R-HSA-1660508.sbml -o working_homo-sapiens/merged_1660537_1660508.sbml --suppress-validation-warnings