shapcrn 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. shapcrn-0.1.0/LICENSE +21 -0
  2. shapcrn-0.1.0/MANIFEST.in +4 -0
  3. shapcrn-0.1.0/PKG-INFO +537 -0
  4. shapcrn-0.1.0/README.md +496 -0
  5. shapcrn-0.1.0/pyproject.toml +81 -0
  6. shapcrn-0.1.0/setup.cfg +4 -0
  7. shapcrn-0.1.0/src/shapcrn/__init__.py +65 -0
  8. shapcrn-0.1.0/src/shapcrn/api.py +750 -0
  9. shapcrn-0.1.0/src/shapcrn/cli.py +127 -0
  10. shapcrn-0.1.0/src/shapcrn/examples/__init__.py +1 -0
  11. shapcrn-0.1.0/src/shapcrn/examples/usage_example.py +9 -0
  12. shapcrn-0.1.0/src/shapcrn/exceptions.py +402 -0
  13. shapcrn-0.1.0/src/shapcrn/pipelines/__init__.py +0 -0
  14. shapcrn-0.1.0/src/shapcrn/pipelines/importance.py +1073 -0
  15. shapcrn-0.1.0/src/shapcrn/pipelines/knockin/__init__.py +1 -0
  16. shapcrn-0.1.0/src/shapcrn/pipelines/knockin/knockin_reaction.py +68 -0
  17. shapcrn-0.1.0/src/shapcrn/pipelines/knockin/knockin_species.py +60 -0
  18. shapcrn-0.1.0/src/shapcrn/pipelines/knockout/__init__.py +1 -0
  19. shapcrn-0.1.0/src/shapcrn/pipelines/knockout/knockout_reaction.py +55 -0
  20. shapcrn-0.1.0/src/shapcrn/pipelines/knockout/knockout_species.py +56 -0
  21. shapcrn-0.1.0/src/shapcrn/pipelines/network.py +75 -0
  22. shapcrn-0.1.0/src/shapcrn/pipelines/sensitivity_analysis.py +28 -0
  23. shapcrn-0.1.0/src/shapcrn/utils/__init__.py +0 -0
  24. shapcrn-0.1.0/src/shapcrn/utils/graph.py +336 -0
  25. shapcrn-0.1.0/src/shapcrn/utils/plot.py +587 -0
  26. shapcrn-0.1.0/src/shapcrn/utils/sbml/__init__.py +0 -0
  27. shapcrn-0.1.0/src/shapcrn/utils/sbml/helpers.py +141 -0
  28. shapcrn-0.1.0/src/shapcrn/utils/sbml/io.py +193 -0
  29. shapcrn-0.1.0/src/shapcrn/utils/sbml/knock.py +534 -0
  30. shapcrn-0.1.0/src/shapcrn/utils/sbml/reactions.py +1442 -0
  31. shapcrn-0.1.0/src/shapcrn/utils/sbml/species.py +85 -0
  32. shapcrn-0.1.0/src/shapcrn/utils/sbml/utils.py +551 -0
  33. shapcrn-0.1.0/src/shapcrn/utils/sensitivity.py +1158 -0
  34. shapcrn-0.1.0/src/shapcrn/utils/simulation.py +2643 -0
  35. shapcrn-0.1.0/src/shapcrn/utils/utils.py +584 -0
  36. shapcrn-0.1.0/src/shapcrn.egg-info/PKG-INFO +537 -0
  37. shapcrn-0.1.0/src/shapcrn.egg-info/SOURCES.txt +44 -0
  38. shapcrn-0.1.0/src/shapcrn.egg-info/dependency_links.txt +1 -0
  39. shapcrn-0.1.0/src/shapcrn.egg-info/entry_points.txt +2 -0
  40. shapcrn-0.1.0/src/shapcrn.egg-info/requires.txt +21 -0
  41. shapcrn-0.1.0/src/shapcrn.egg-info/top_level.txt +1 -0
  42. shapcrn-0.1.0/tests/test_api.py +109 -0
  43. shapcrn-0.1.0/tests/test_cli.py +33 -0
  44. shapcrn-0.1.0/tests/test_sbml_io.py +16 -0
  45. shapcrn-0.1.0/tests/test_sensitivity.py +91 -0
  46. shapcrn-0.1.0/tests/test_utils.py +41 -0
shapcrn-0.1.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Tommaso Tocchini
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,4 @@
1
+ include LICENSE
2
+ include README.md
3
+ prune models
4
+ prune results
shapcrn-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,537 @@
1
+ Metadata-Version: 2.4
2
+ Name: shapcrn
3
+ Version: 0.1.0
4
+ Summary: SBML reaction-network analysis with simulation, perturbation, and Shapley-style workflows.
5
+ Author: Tommaso Tocchini
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/TommyTokk/KOShapleyValueForCRNs
8
+ Project-URL: Repository, https://github.com/TommyTokk/KOShapleyValueForCRNs
9
+ Project-URL: Issues, https://github.com/TommyTokk/KOShapleyValueForCRNs/issues
10
+ Keywords: SBML,chemical reaction networks,Shapley values,sensitivity analysis,systems biology
11
+ Classifier: Development Status :: 3 - Alpha
12
+ Classifier: Intended Audience :: Science/Research
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Programming Language :: Python :: 3.10
15
+ Classifier: Programming Language :: Python :: 3.11
16
+ Classifier: Programming Language :: Python :: 3.12
17
+ Classifier: Topic :: Scientific/Engineering :: Bio-Informatics
18
+ Requires-Python: <3.13,>=3.10
19
+ Description-Content-Type: text/markdown
20
+ License-File: LICENSE
21
+ Requires-Dist: numpy
22
+ Requires-Dist: pandas
23
+ Requires-Dist: scipy
24
+ Requires-Dist: scikit-learn
25
+ Requires-Dist: python-libsbml
26
+ Requires-Dist: libroadrunner
27
+ Requires-Dist: SALib
28
+ Requires-Dist: matplotlib
29
+ Requires-Dist: seaborn
30
+ Requires-Dist: plotly
31
+ Requires-Dist: networkx
32
+ Provides-Extra: network
33
+ Requires-Dist: pygraphviz; extra == "network"
34
+ Provides-Extra: dev
35
+ Requires-Dist: build; extra == "dev"
36
+ Requires-Dist: pytest; extra == "dev"
37
+ Requires-Dist: pytest-cov; extra == "dev"
38
+ Requires-Dist: ruff; extra == "dev"
39
+ Requires-Dist: twine; extra == "dev"
40
+ Dynamic: license-file
41
+
42
+ # ShapCRN
43
+
44
+ <p align="right">
45
+ <br><br>
46
+ <br><br>
47
+ There is no learning without having to pose a question.<br>
48
+ And a question requires doubt.<br>
49
+ — <b>Richard Feynman</b>
50
+ <br><br>
51
+ <br><br>
52
+ </p>
53
+
54
+
55
+ ## Introduction
56
+
57
+ ShapCRN is a command-line application for studying SBML biochemical reaction-network models through simulation and controlled perturbations. It is designed to support both exploratory analysis and reproducible experiments: you can run model dynamics over time, inspect behavior near steady state, generate publication-friendly outputs (CSV and plots), and compare how system behavior changes when species or reactions are altered.
58
+
59
+ Beyond plain simulation, the project provides analysis pipelines to quantify influence and robustness at network level. In practice, this includes knockout/knockin workflows, Shapley-style importance assessment (with optional random or fixed perturbation scenarios), and Sobol-based global sensitivity analysis for selected targets. The file `src/shapcrn/examples/usage_example.py` is the CLI runner used by both module execution and the `shapcrn` console command.
60
+
61
+ ## Table of contents
62
+
63
+ - [Overview](#overview)
64
+ - [Architecture and code map](#architecture-and-code-map)
65
+ - [Main functionalities](#main-functionalities)
66
+ - [Additional functionalities](#additional-functionalities)
67
+ - [Requirements](#requirements)
68
+ - [Quickstart](#quickstart)
69
+ - [Commands](#commands)
70
+ - [Python API](#python-api)
71
+ - [Output structure](#output-structure)
72
+ - [Examples](#examples)
73
+ - [Tips and troubleshooting](#tips-and-troubleshooting)
74
+ - [Project layout](#project-layout)
75
+
76
+ ## Overview
77
+
78
+ This project lets you load an SBML model and run one of several workflows:
79
+
80
+ - `simulate`: run time-course simulation with selectable integrators, optional steady-state mode, and CSV/plot exports.
81
+ - `importance_assessment`: estimate influence of species/reactions with knockout or knockin scenarios using a Shapley-style workflow.
82
+ - `importance_assessment` with perturbations: compare behavior under random or fixed perturbations of selected input species.
83
+ - `sensitivity_analysis`: compute Sobol indices for selected targets and optionally run convergence checks.
84
+ - `knockout_species`: create and save a modified SBML model where one species is disabled.
85
+ - `knockout_reaction`: create and save a modified SBML model where one reaction is disabled.
86
+ - `knockin_species`: create and save a modified SBML model where one species is reinforced/activated.
87
+ - `knockin_reaction`: create and save a modified SBML model where one reaction is reinforced/activated.
88
+
89
+ In a typical run, the flow is:
90
+
91
+ 1. Parse command-line arguments (`src/shapcrn/utils/utils.py`).
92
+ 2. Load and prepare SBML (`src/shapcrn/utils/sbml/io.py` + `src/shapcrn/utils/sbml/reactions.py`).
93
+ 3. Dispatch to a pipeline (`src/shapcrn/pipelines/...`).
94
+ 4. Run simulations/analysis (`src/shapcrn/utils/simulation.py`, `src/shapcrn/utils/sensitivity.py`).
95
+ 5. Save artifacts (CSV, plots, reports, edited SBML).
96
+ 6. Return logs and outputs under the selected output folder.
97
+
98
+ ## Architecture and code map
99
+
100
+ The codebase follows a layered structure:
101
+
102
+ - Example runner layer:
103
+ `src/shapcrn/examples/usage_example.py` demonstrates how to wire commands to pipelines.
104
+ It is also the CLI entry implementation used by `python -m ...` and by the `shapcrn` console script.
105
+ - Pipeline layer:
106
+ `src/shapcrn/pipelines/*` contains command-oriented orchestration.
107
+ Each pipeline parses command-specific arguments, coordinates utilities, and writes outputs.
108
+ - Utility layer:
109
+ `src/shapcrn/utils/*` contains reusable logic split by domain:
110
+ - `src/shapcrn/utils/sbml/`: SBML I/O, reaction preprocessing, and knock operations.
111
+ - `src/shapcrn/utils/simulation.py`: RoadRunner setup, simulation, perturbation sampling and aggregation helpers.
112
+ - `src/shapcrn/utils/sensitivity.py`: Sobol setup/execution, convergence checks, and statistics.
113
+ - `src/shapcrn/utils/plot.py`: static and interactive plotting utilities.
114
+ - `src/shapcrn/utils/graph.py`: model-to-network conversion and graph rendering.
115
+ - `src/shapcrn/utils/utils.py`: CLI parser construction, normalization helpers, logging, and shared helpers.
116
+
117
+ Design intent:
118
+
119
+ - Keep pipelines thin and scenario-focused.
120
+ - Keep model/math/plot logic reusable in `utils`.
121
+ - Keep output organization consistent across commands (`images/`, `csv/`, `reports/`, `dot/`).
122
+
123
+ ## Main functionalities
124
+
125
+ This section describes the core capabilities and maps them to the main functions in the codebase.
126
+
127
+ ### 1) Simulate
128
+
129
+ Main execution path:
130
+
131
+ - Example runner: `src/shapcrn/examples/usage_example.py` (command `simulate`)
132
+ - Model loading and normalization: `src/shapcrn/utils/sbml/io.py::load_and_prepare_model`
133
+ - RoadRunner setup: `src/shapcrn/utils/simulation.py::load_roadrunner_model`
134
+ - Simulation engine: `src/shapcrn/utils/simulation.py::simulate`
135
+ - Steady-state mode (if enabled): `src/shapcrn/utils/simulation.py::simulate_with_steady_state`
136
+ - Output plots: `src/shapcrn/utils/plot.py::plot_results` and `plot_results_interactive`
137
+
138
+ How it works:
139
+
140
+ - `load_roadrunner_model(...)` converts the SBML model to a RoadRunner instance and configures integrator/tolerances.
141
+ - `simulate(...)` supports two modes:
142
+ - Standard mode: one run from `start_time` to `end_time`.
143
+ - Steady-state mode: adaptive block simulation until variation is below threshold.
144
+ - `simulate_with_steady_state(...)` compares the last point of consecutive blocks and tracks relative/absolute variation per monitored species. When all monitored species stay below threshold for consecutive checks, it flags steady state.
145
+ - Results are exported to CSV and plotted (static PNG or interactive HTML).
146
+
147
+ ### 2) Species/Reactions Knockout
148
+
149
+ Main execution path:
150
+
151
+ - Species KO pipeline: `src/shapcrn/pipelines/knockout/knockout_species.py::knockout_species`
152
+ - Reaction KO pipeline: `src/shapcrn/pipelines/knockout/knockout_reaction.py::knockout_reaction`
153
+ - Core KO logic: `src/shapcrn/utils/sbml/knock.py::knockout_species` and `knockout_reaction`
154
+
155
+ How species knockout works (`knockout_species` in `knock.py`):
156
+
157
+ - Forces assignment/initial rules for the target species to `0` when present.
158
+ - Scans events and initial assignments and sets the target species update math to `0`.
159
+ - If the species is a reactant in a reaction, that reaction is marked for knockout.
160
+ - If the species is only a product, the product entry is removed from that reaction; if no products remain, the reaction is also knocked out.
161
+ - Finalizes by setting target species initial concentration to `0.0` and boundary condition `True` (fixed species).
162
+
163
+ How reaction knockout works (`knockout_reaction` in `knock.py`):
164
+
165
+ - Looks up the target reaction.
166
+ - Replaces the kinetic law AST with constant `0`, disabling flux while preserving the reaction object in the SBML structure.
167
+
168
+ ### 3) Species/Reactions Knockin
169
+
170
+ Main execution path:
171
+
172
+ - Species KI pipeline: `src/shapcrn/pipelines/knockin/knockin_species.py::knockin_species`
173
+ - Reaction KI pipeline: `src/shapcrn/pipelines/knockin/knockin_reaction.py::knockin_reaction`
174
+ - Core KI logic: `src/shapcrn/utils/sbml/knock.py::knockin_species` and `knockin_reaction`
175
+
176
+ How species knockin works:
177
+
178
+ - `get_species_peak_value(...)` runs a short simulation (`end_time=60`) and uses the target species maximum simulated value as the knock-in value.
179
+ - `knockin_species(...)` then sets that value as initial concentration/amount (depending on species representation) and marks the species as fixed (`boundaryCondition=True`, `constant=True`).
180
+
181
+ How reaction knockin works:
182
+
183
+ - `get_reactants_peak_values(...)` collects max simulated values for each reactant of the target reaction.
184
+ - `knockin_reaction(...)` creates constant reactant copies, one per original reactant.
185
+ - The target reaction is cloned, its reactants are replaced with these new constant species, and the kinetic law expression is rewritten to reference species.
186
+ - The original reaction is removed and the modified cloned reaction is added back to the model.
187
+
188
+ ## Additional functionalities
189
+
190
+ ### Importance assessment
191
+
192
+ Main path:
193
+
194
+ - Pipeline: `src/shapcrn/pipelines/importance.py::importance_assessment`
195
+ - Model setup: `model_preparation(...)`
196
+ - Sampling setup: `generate_samples(...)`
197
+ - Baseline simulation: `simulate_original_model(...)`
198
+ - KO/KI simulation batch: `simulate_knocked_data(...)`
199
+ - Payoff/Shapley: `run_shap_analysis(...)`
200
+ - Perturbation diagnostics: `assess_perturbation_importance(...)` and report generation
201
+
202
+ What it produces:
203
+
204
+ - Variation matrices (log-ratio based)
205
+ - Shapley matrices (raw and normalized for plotting)
206
+ - Heatmaps and optional text reports
207
+ - Optional fixed-vs-random perturbation comparison outputs
208
+
209
+ ### Sensitivity analysis
210
+
211
+ Main path:
212
+
213
+ - Pipeline: `src/shapcrn/pipelines/sensitivity_analysis.py::sensitivity_analysis`
214
+ - Problem specification: `src/shapcrn/utils/sensitivity.py::get_problem_parameters`
215
+ - Sobol sampling/analysis: SALib (`sobol.sample`, `sobol.analyze`)
216
+ - Batch simulation backend: `src/shapcrn/utils/sensitivity.py::run_simulation_with_params`
217
+ - Optional convergence workflow: `run_convergence_analysis(...)` + convergence plots
218
+
219
+ What it produces:
220
+
221
+ - Sobol indices per target species
222
+ - Optional convergence diagnostics and plots
223
+ - Fixed-vs-sampled perturbation comparison CSV (when requested)
224
+
225
+ ### Network generation
226
+
227
+ Main path:
228
+
229
+ - Pipeline: `src/shapcrn/pipelines/network.py::create_model_network`
230
+ - Graph extraction: `src/shapcrn/utils/graph.py::get_network_from_sbml`
231
+ - Rendering: `src/shapcrn/utils/graph.py::plot_network`
232
+
233
+ What it produces:
234
+
235
+ - Network image (PNG)
236
+ - DOT graph source (`.gv`) for external graph tooling
237
+
238
+ ## Requirements
239
+
240
+ ShapCRN supports Python 3.10, 3.11, and 3.12.
241
+
242
+ Core runtime dependencies:
243
+
244
+ - `numpy`
245
+ - `pandas`
246
+ - `scipy`
247
+ - `scikit-learn`
248
+ - `python-libsbml`
249
+ - `libroadrunner`
250
+ - `SALib`
251
+ - `matplotlib`
252
+ - `seaborn`
253
+ - `plotly`
254
+ - `networkx`
255
+
256
+ Install the released package:
257
+
258
+ ```bash
259
+ python -m pip install shapcrn
260
+ ```
261
+
262
+ Network rendering uses PyGraphviz and the Graphviz system package. Install the
263
+ optional Python dependency with:
264
+
265
+ ```bash
266
+ python -m pip install "shapcrn[network]"
267
+ ```
268
+
269
+ For development from a source checkout:
270
+
271
+ ```bash
272
+ python -m pip install -e ".[dev,network]"
273
+ ```
274
+
275
+ ## Quickstart
276
+
277
+ After installation, check the CLI:
278
+
279
+ ```bash
280
+ shapcrn -h
281
+ ```
282
+
283
+ You can also run the module entrypoint directly:
284
+
285
+ ```bash
286
+ python -m shapcrn.examples.usage_example -h
287
+ ```
288
+
289
+ The following command assumes a source checkout. For an installed package,
290
+ replace the model path with your own SBML file:
291
+
292
+ ```bash
293
+ shapcrn simulate models/KnockinModelV2.xml -t 120 -o results
294
+ ```
295
+
296
+ Inspect command-specific options:
297
+
298
+ ```bash
299
+ python -m shapcrn.examples.usage_example simulate -h
300
+ python -m shapcrn.examples.usage_example importance_assessment -h
301
+ python -m shapcrn.examples.usage_example sensitivity_analysis -h
302
+ ```
303
+
304
+ ## Commands
305
+
306
+ The `shapcrn` console command is canonical. The historical
307
+ `shapcrn.examples.usage_example` module remains as a compatibility wrapper.
308
+
309
+ General form:
310
+
311
+ ```bash
312
+ python -m shapcrn.examples.usage_example <command> [options]
313
+ ```
314
+
315
+ Equivalent console-script form after install:
316
+
317
+ ```bash
318
+ shapcrn <command> [options]
319
+ ```
320
+
321
+ Available commands:
322
+
323
+ - `simulate`
324
+ Time-course model simulation with optional steady-state termination and plotting.
325
+ - `importance_assessment`
326
+ Shapley-style influence analysis with knockout/knockin scenarios, optionally with perturbations.
327
+ - `sensitivity_analysis`
328
+ Global Sobol sensitivity analysis for selected species/targets.
329
+ - `knockout_species`
330
+ Build and save a model where one species is disabled.
331
+ - `knockout_reaction`
332
+ Build and save a model where one reaction is disabled.
333
+ - `knockin_species`
334
+ Build and save a model where one species is fixed to a computed reinforced value.
335
+ - `knockin_reaction`
336
+ Build and save a model where one reaction is reinforced via reactant replacement strategy.
337
+ - `create_network`
338
+ Build and save a reaction-network graph from the SBML model.
339
+
340
+ ## Python API
341
+
342
+ The high-level API returns typed result objects and does not write files unless
343
+ an output directory or output path is explicitly supplied:
344
+
345
+ ```python
346
+ from shapcrn import analyze_sensitivity, assess_importance, simulate_model
347
+
348
+ simulation = simulate_model("model.xml", end_time=120, points=500)
349
+ print(simulation.data.tail())
350
+
351
+ importance = assess_importance(
352
+ "model.xml",
353
+ operation="knockout",
354
+ input_species=["S1", "S2"],
355
+ use_perturbations=True,
356
+ seed=42,
357
+ )
358
+
359
+ sensitivity = analyze_sensitivity(
360
+ "model.xml",
361
+ input_species=["S1", "S2"],
362
+ base_samples=1024,
363
+ seed=42,
364
+ )
365
+ ```
366
+
367
+ In-memory SBML helpers and low-level simulation functions remain available:
368
+
369
+ ```python
370
+ from shapcrn import load_model, load_roadrunner_model, simulate
371
+ from shapcrn import knockout_species, save_sbml_model
372
+ ```
373
+
374
+ ## Output structure
375
+
376
+ By default, outputs are written under `./results` in a model-specific folder:
377
+
378
+ ```text
379
+ <output>/<model_name>/
380
+ ├── csv/
381
+ ├── dot/
382
+ ├── images/
383
+ └── reports/
384
+ ```
385
+
386
+ Simulation writes `simulation.csv` plus a PNG or HTML plot. Sensitivity writes
387
+ `sobol_indices.csv`, `sobol_interactions.csv`, and a text report; convergence
388
+ and fixed-perturbation artifacts are added only when requested.
389
+
390
+ ## Examples
391
+
392
+ ### 1) Simulate a model (static plot + CSV)
393
+
394
+ ```bash
395
+ python -m shapcrn.examples.usage_example simulate models/KnockinModelV2.xml \
396
+ -t 120 \
397
+ -i cvode \
398
+ -o results
399
+ ```
400
+
401
+ ### 2) Simulate until steady state (interactive HTML plot)
402
+
403
+ ```bash
404
+ python -m shapcrn.examples.usage_example simulate models/KnockinModelV2.xml \
405
+ --steady-state \
406
+ --max-time 2000 \
407
+ --sim-step 10 \
408
+ --threshold 1e-7 \
409
+ --interactive \
410
+ -o results
411
+ ```
412
+
413
+ ### 3) Importance assessment (knockout, no perturbations)
414
+
415
+ ```bash
416
+ python -m shapcrn.examples.usage_example importance_assessment models/KnockinModelV2.xml \
417
+ --operation knockout \
418
+ --payoff-function last \
419
+ -t 120 \
420
+ -o results
421
+ ```
422
+
423
+ ### 4) Importance assessment with random perturbations
424
+
425
+ ```bash
426
+ python -m shapcrn.examples.usage_example importance_assessment models/KnockinModelV2.xml \
427
+ --operation knockout \
428
+ --input-species S1 S2 \
429
+ --use-perturbations \
430
+ --num-samples 10 \
431
+ --max-combinations 2000 \
432
+ --variation 20 \
433
+ --payoff-function max \
434
+ -t 120 \
435
+ -o results
436
+ ```
437
+
438
+ ### 5) Importance assessment with fixed perturbations
439
+
440
+ ```bash
441
+ python -m shapcrn.examples.usage_example importance_assessment models/KnockinModelV2.xml \
442
+ --operation knockin \
443
+ --input-species S1 S2 \
444
+ --use-perturbations \
445
+ --use-fixed-perturbations \
446
+ --fixed-perturbations -20 20 \
447
+ --payoff-function min \
448
+ -t 120 \
449
+ -o results
450
+ ```
451
+
452
+ ### 6) Sensitivity analysis (Sobol)
453
+
454
+ ```bash
455
+ python -m shapcrn.examples.usage_example sensitivity_analysis models/KnockinModelV2.xml \
456
+ --input-species S1 S2 \
457
+ --base-samples 1024 \
458
+ --perturbation-range 20 \
459
+ --seed 42 \
460
+ -o results
461
+ ```
462
+
463
+ ### 7) Sensitivity analysis with convergence check
464
+
465
+ ```bash
466
+ python -m shapcrn.examples.usage_example sensitivity_analysis models/KnockinModelV2.xml \
467
+ --input-species S1 S2 \
468
+ --check-convergence \
469
+ -o results
470
+ ```
471
+
472
+ ### 8) Knock out one species and save edited model
473
+
474
+ ```bash
475
+ python -m shapcrn.examples.usage_example knockout_species models/KnockinModelV2.xml S1 \
476
+ --model-dir models \
477
+ -o results
478
+ ```
479
+
480
+ ### 9) Knock out one reaction and save edited model
481
+
482
+ ```bash
483
+ python -m shapcrn.examples.usage_example knockout_reaction models/KnockinModelV2.xml R1_MassAction_Explicit \
484
+ --model-dir models \
485
+ -o results
486
+ ```
487
+
488
+ ### 10) Knock in one species and save edited model
489
+
490
+ ```bash
491
+ python -m shapcrn.examples.usage_example knockin_species models/KnockinModelV2.xml S1 \
492
+ --model-dir models \
493
+ -o results
494
+ ```
495
+
496
+ ### 11) Knock in one reaction and save edited model
497
+
498
+ ```bash
499
+ python -m shapcrn.examples.usage_example knockin_reaction models/KnockinModelV2.xml R1_MassAction_Explicit \
500
+ --model-dir models \
501
+ -o results
502
+ ```
503
+
504
+ ## Tips and troubleshooting
505
+
506
+ - `models/KnockinModelV2.xml` works with the IDs used in these examples (`S1`, `S2`, `R1_MassAction_Explicit`).
507
+ - The files under `models/` are repository examples and are intentionally not included in PyPI artifacts.
508
+ - Add logging to any command with `-l <log_file_path>`.
509
+ - For large perturbation spaces, use `--max-combinations` to cap Cartesian-product runs and avoid RAM saturation.
510
+ - If simulation fails immediately, first run `simulate -h` and verify required options and valid integrator/model values.
511
+ - If you see `ModuleNotFoundError: No module named 'shapcrn'`, run `python -m pip install -e .` from repo root or run commands with `PYTHONPATH=src`.
512
+
513
+ ## Project layout
514
+
515
+ - `pyproject.toml`: package metadata and console-script definition
516
+ - `src/shapcrn/`: Python package root
517
+ - `src/shapcrn/api.py`: stable programmatic API and result types
518
+ - `src/shapcrn/cli.py`: console command adapter
519
+ - `src/shapcrn/examples/usage_example.py`: compatibility entry point
520
+ - `models/`: sample SBML models
521
+ - `results/`: default output directory
522
+
523
+ ## License
524
+
525
+ ShapCRN is distributed under the MIT License. See `LICENSE`.
526
+
527
+ ## Acknowledgments
528
+ <p align="right">
529
+ <br><br>
530
+ <br><br>
531
+ To Aurora<br>
532
+ Thank you for your constant support, encouragement, and guidance.<br>
533
+ This work wouldn't be what it is without you.
534
+ <br><br>
535
+ <br><br>
536
+ </p>
537
+ <hr>