sopsim 0.2.3__tar.gz → 0.2.5__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 (53) hide show
  1. sopsim-0.2.5/PKG-INFO +230 -0
  2. sopsim-0.2.5/README.md +213 -0
  3. {sopsim-0.2.3 → sopsim-0.2.5}/pyproject.toml +1 -1
  4. {sopsim-0.2.3 → sopsim-0.2.5}/sopsim/artifacts.py +3 -3
  5. {sopsim-0.2.3 → sopsim-0.2.5}/sopsim/cli.py +11 -20
  6. {sopsim-0.2.3 → sopsim-0.2.5}/sopsim/config.py +13 -38
  7. {sopsim-0.2.3 → sopsim-0.2.5}/sopsim/core.py +4 -7
  8. {sopsim-0.2.3 → sopsim-0.2.5}/sopsim/filop_lent.py +31 -26
  9. sopsim-0.2.5/sopsim/mat_files/Ang.mat +0 -0
  10. sopsim-0.2.5/sopsim/mat_files/Delta.mat +0 -0
  11. sopsim-0.2.5/sopsim/mat_files/Notch.mat +0 -0
  12. sopsim-0.2.5/sopsim/mat_files/kappa.mat +0 -0
  13. {sopsim-0.2.3 → sopsim-0.2.5}/sopsim/reference_data.py +2 -3
  14. {sopsim-0.2.3 → sopsim-0.2.5}/sopsim/run_sopsim.py +5 -8
  15. {sopsim-0.2.3 → sopsim-0.2.5}/sopsim/server.py +0 -11
  16. sopsim-0.2.5/sopsim/web_dist/assets/index-BwDTYCM6.js +32 -0
  17. sopsim-0.2.5/sopsim/web_dist/assets/index-CROLemY3.js +32 -0
  18. sopsim-0.2.5/sopsim/web_dist/assets/index-CY6Qs6iF.js +32 -0
  19. sopsim-0.2.5/sopsim/web_dist/assets/index-Cf-_Tx0y.css +1 -0
  20. sopsim-0.2.5/sopsim/web_dist/assets/index-Cr0O0uLv.js +32 -0
  21. sopsim-0.2.5/sopsim/web_dist/assets/index-CtnLOlUl.js +32 -0
  22. {sopsim-0.2.3 → sopsim-0.2.5}/sopsim/web_dist/index.html +2 -2
  23. sopsim-0.2.5/sopsim.egg-info/PKG-INFO +230 -0
  24. {sopsim-0.2.3 → sopsim-0.2.5}/sopsim.egg-info/SOURCES.txt +7 -4
  25. {sopsim-0.2.3 → sopsim-0.2.5}/tests/test_cli.py +1 -13
  26. {sopsim-0.2.3 → sopsim-0.2.5}/tests/test_config.py +16 -9
  27. sopsim-0.2.5/tests/test_filop_lent.py +61 -0
  28. {sopsim-0.2.3 → sopsim-0.2.5}/tests/test_server.py +6 -6
  29. sopsim-0.2.3/PKG-INFO +0 -135
  30. sopsim-0.2.3/README.md +0 -118
  31. sopsim-0.2.3/sopsim/mat_files/Ang.mat +0 -0
  32. sopsim-0.2.3/sopsim/mat_files/Delta.mat +0 -0
  33. sopsim-0.2.3/sopsim/mat_files/F2.mat +0 -0
  34. sopsim-0.2.3/sopsim/mat_files/Notch.mat +0 -0
  35. sopsim-0.2.3/sopsim/mat_files/kappa.mat +0 -0
  36. sopsim-0.2.3/sopsim/web_dist/assets/index-BU1bhlot.js +0 -32
  37. sopsim-0.2.3/sopsim/web_dist/assets/index-Bg57AWq2.js +0 -32
  38. sopsim-0.2.3/sopsim/web_dist/assets/index-Bop8xgS8.css +0 -1
  39. sopsim-0.2.3/sopsim.egg-info/PKG-INFO +0 -135
  40. {sopsim-0.2.3 → sopsim-0.2.5}/MANIFEST.in +0 -0
  41. {sopsim-0.2.3 → sopsim-0.2.5}/setup.cfg +0 -0
  42. {sopsim-0.2.3 → sopsim-0.2.5}/sopsim/__init__.py +0 -0
  43. {sopsim-0.2.3 → sopsim-0.2.5}/sopsim/__main__.py +0 -0
  44. {sopsim-0.2.3 → sopsim-0.2.5}/sopsim/delta_in.py +0 -0
  45. {sopsim-0.2.3 → sopsim-0.2.5}/sopsim/filop_vectors.py +0 -0
  46. {sopsim-0.2.3 → sopsim-0.2.5}/sopsim/two_d_geom.py +0 -0
  47. {sopsim-0.2.3 → sopsim-0.2.5}/sopsim/web_dist/__init__.py +0 -0
  48. {sopsim-0.2.3 → sopsim-0.2.5}/sopsim/web_dist/assets/index-DqOYPuAV.css +0 -0
  49. {sopsim-0.2.3 → sopsim-0.2.5}/sopsim.egg-info/dependency_links.txt +0 -0
  50. {sopsim-0.2.3 → sopsim-0.2.5}/sopsim.egg-info/entry_points.txt +0 -0
  51. {sopsim-0.2.3 → sopsim-0.2.5}/sopsim.egg-info/requires.txt +0 -0
  52. {sopsim-0.2.3 → sopsim-0.2.5}/sopsim.egg-info/top_level.txt +0 -0
  53. {sopsim-0.2.3 → sopsim-0.2.5}/tests/test_api_types.py +0 -0
sopsim-0.2.5/PKG-INFO ADDED
@@ -0,0 +1,230 @@
1
+ Metadata-Version: 2.4
2
+ Name: sopsim
3
+ Version: 0.2.5
4
+ Summary: SOPSim simulation library
5
+ Author: Olaolu Olugbenle, Dr. William Annan
6
+ Requires-Python: >=3.9
7
+ Description-Content-Type: text/markdown
8
+ Requires-Dist: numpy
9
+ Requires-Dist: scipy
10
+ Requires-Dist: tqdm
11
+ Requires-Dist: shapely
12
+ Requires-Dist: matplotlib
13
+ Requires-Dist: fastapi
14
+ Requires-Dist: uvicorn[standard]
15
+ Requires-Dist: pydantic
16
+ Requires-Dist: python-dotenv
17
+
18
+ # SOPSim
19
+
20
+ SOPSim is a Python simulation package for investigating SOP pattern formation. The package exposes the same simulation engine through three user-facing workflows:
21
+
22
+ 1. Command-line interface
23
+ 2. Local web application
24
+ 3. Python API
25
+
26
+ ## Quick start
27
+
28
+ Install from PyPI:
29
+
30
+ ```bash
31
+ pip install sopsim
32
+ ```
33
+
34
+ Run a sample simulation from the terminal:
35
+
36
+ ```bash
37
+ sopsim run --nc 4 --filopodia-life-time 10 --out-dir output
38
+ ```
39
+
40
+ This writes plots and metadata into the `output/` directory.
41
+
42
+ For help:
43
+
44
+ ```bash
45
+ sopsim run -h
46
+ sopsim serve -h
47
+ ```
48
+
49
+ ## CLI workflow
50
+
51
+ The command-line tool is the most direct way to run a single simulation.
52
+
53
+ ```bash
54
+ sopsim run --nc 4 --filopodia-life-time 10 --out-dir output
55
+ ```
56
+
57
+ Key points:
58
+
59
+ - `--nc` is required and must be an integer greater than or equal to 1
60
+ - `--filopodia-life-time` must be an integer greater than or equal to 1
61
+ - `--use-mat-files` is only supported when `Nc = 4`
62
+
63
+ ## Local web app workflow
64
+
65
+ Start the local web application:
66
+
67
+ ```bash
68
+ sopsim serve
69
+ ```
70
+
71
+ This launches a FastAPI server locally. The frontend sends simulation requests to the server, which runs the simulation asynchronously and returns result files and summaries.
72
+
73
+ ## Python API workflow
74
+
75
+ Use the package directly from Python:
76
+
77
+ ```python
78
+ from sopsim import sopsim
79
+
80
+ results = sopsim(
81
+ Nc=4,
82
+ filopodia_life_time=10,
83
+ )
84
+
85
+ print(results["FData"])
86
+ ```
87
+
88
+ The returned dictionary contains:
89
+
90
+ - `FData`
91
+ - `LSA`
92
+ - `MeanDin`
93
+ - `Notch_time_step`
94
+ - `MeanSOPNotch`
95
+ - `MeanEPNotch`
96
+ - `FinalNotch`
97
+ - `inputs`
98
+
99
+ The first three values in `results["FData"]` are:
100
+
101
+ - `results["FData"][0]` → convergence time
102
+ - `results["FData"][1]` → RSA
103
+ - `results["FData"][2]` → mean LSA
104
+
105
+ ## Input rules
106
+
107
+ | Input | Allowed values |
108
+ | --- | --- |
109
+ | `Nc` | Integer `>= 1` |
110
+ | `filopodia_life_time` | Integer `>= 1` |
111
+ | `use_mat_files` | Only valid when `Nc = 4` |
112
+
113
+ Important notes:
114
+
115
+ - `Nc = 4` implies a `4 x 4` tissue
116
+ - `Nc >= 10` can take many hours to run, so use smaller values for testing
117
+ - MATLAB reference mode is intended for deterministic comparison with the legacy MATLAB workflow
118
+
119
+ ## Repository structure
120
+
121
+ The codebase is organized into layers:
122
+
123
+ - `sopsim/core.py` — public Python API entry point
124
+ - `sopsim/config.py` — validation and parameter construction
125
+ - `sopsim/cli.py` — terminal command parsing and dispatch
126
+ - `sopsim/server.py` — FastAPI web service
127
+ - `sopsim/artifacts.py` — metadata and file output handling
128
+ - `sopsim/run_sopsim.py` — solver execution path
129
+ - `frontend/` — React frontend for the local web UI
130
+ - `tests/` — project tests
131
+
132
+ ## Output files
133
+
134
+ Running a simulation creates a results directory containing:
135
+
136
+ - plots
137
+ - `metadata.json`
138
+ - the generated result files from the simulation run
139
+
140
+ ## Developer notes
141
+
142
+ The following notes are intended to help someone clone the repository and continue development.
143
+
144
+ ### Clone and setup
145
+
146
+ ```bash
147
+ git clone <repo-url>
148
+ cd SOPSim
149
+ python -m venv .venv
150
+ .venv\Scripts\activate
151
+ pip install -U pip
152
+ pip install -e .
153
+ ```
154
+
155
+ ### Install development extras
156
+
157
+ If you need the build tooling for packaging and release work:
158
+
159
+ ```bash
160
+ pip install build twine
161
+ ```
162
+
163
+ ### Run tests
164
+
165
+ ```bash
166
+ pytest
167
+ ```
168
+
169
+ ### Local development workflow
170
+
171
+ 1. Make changes in the package code under `sopsim/`
172
+ 2. Reinstall the editable package if needed:
173
+
174
+ ```bash
175
+ pip install -e .
176
+ ```
177
+
178
+ 3. Test the CLI locally:
179
+
180
+ ```bash
181
+ sopsim run --nc 4 --out-dir output
182
+ ```
183
+
184
+ 4. Test the web app:
185
+
186
+ ```bash
187
+ sopsim serve
188
+ ```
189
+
190
+ ### Environment configuration notes
191
+
192
+ - The server uses `python-dotenv` and reads environment variables from a local `.env` file if present.
193
+ - The web server supports an optional `CORS_ALLOW_ORIGINS` environment variable for frontend origin control.
194
+ - Do not commit secrets or local credentials to the repository.
195
+
196
+ ## Publishing to PyPI
197
+
198
+ ### Did you make updates to the library and now want to publish them? Here's how to publish
199
+
200
+ Before publishing a new release:
201
+
202
+ 1. Update the package version in `pyproject.toml` and verify that all details are correct
203
+ 2. Update `README.md` if the usage instructions or package description need to change
204
+ 3. Build the distribution:
205
+
206
+ ```bash
207
+ python -m build
208
+ ```
209
+
210
+ 5. Validate the built package:
211
+
212
+ ```bash
213
+ twine check dist/*
214
+ ```
215
+
216
+ 6. Upload the release:
217
+
218
+ ```bash
219
+ twine upload dist/*
220
+ ```
221
+
222
+ You may need to configure an API key to complete this process.
223
+
224
+ ## Bug fixes
225
+
226
+ - `0.2.5`: Updated the README to be more comprehensive for developers & updated bundled frontend to include link to live frontend (on the web)
227
+ - `0.2.4`: Improved documentation for `FData`
228
+ - `0.2.3`: Backend now works; frontend layout adjustments; help text wording improvement
229
+ - `0.2.2`: Fixed default value handling for filopodia type and lifetime
230
+ - `0.2.1`: Fixed default value handling for filopodia type and lifetime
sopsim-0.2.5/README.md ADDED
@@ -0,0 +1,213 @@
1
+ # SOPSim
2
+
3
+ SOPSim is a Python simulation package for investigating SOP pattern formation. The package exposes the same simulation engine through three user-facing workflows:
4
+
5
+ 1. Command-line interface
6
+ 2. Local web application
7
+ 3. Python API
8
+
9
+ ## Quick start
10
+
11
+ Install from PyPI:
12
+
13
+ ```bash
14
+ pip install sopsim
15
+ ```
16
+
17
+ Run a sample simulation from the terminal:
18
+
19
+ ```bash
20
+ sopsim run --nc 4 --filopodia-life-time 10 --out-dir output
21
+ ```
22
+
23
+ This writes plots and metadata into the `output/` directory.
24
+
25
+ For help:
26
+
27
+ ```bash
28
+ sopsim run -h
29
+ sopsim serve -h
30
+ ```
31
+
32
+ ## CLI workflow
33
+
34
+ The command-line tool is the most direct way to run a single simulation.
35
+
36
+ ```bash
37
+ sopsim run --nc 4 --filopodia-life-time 10 --out-dir output
38
+ ```
39
+
40
+ Key points:
41
+
42
+ - `--nc` is required and must be an integer greater than or equal to 1
43
+ - `--filopodia-life-time` must be an integer greater than or equal to 1
44
+ - `--use-mat-files` is only supported when `Nc = 4`
45
+
46
+ ## Local web app workflow
47
+
48
+ Start the local web application:
49
+
50
+ ```bash
51
+ sopsim serve
52
+ ```
53
+
54
+ This launches a FastAPI server locally. The frontend sends simulation requests to the server, which runs the simulation asynchronously and returns result files and summaries.
55
+
56
+ ## Python API workflow
57
+
58
+ Use the package directly from Python:
59
+
60
+ ```python
61
+ from sopsim import sopsim
62
+
63
+ results = sopsim(
64
+ Nc=4,
65
+ filopodia_life_time=10,
66
+ )
67
+
68
+ print(results["FData"])
69
+ ```
70
+
71
+ The returned dictionary contains:
72
+
73
+ - `FData`
74
+ - `LSA`
75
+ - `MeanDin`
76
+ - `Notch_time_step`
77
+ - `MeanSOPNotch`
78
+ - `MeanEPNotch`
79
+ - `FinalNotch`
80
+ - `inputs`
81
+
82
+ The first three values in `results["FData"]` are:
83
+
84
+ - `results["FData"][0]` → convergence time
85
+ - `results["FData"][1]` → RSA
86
+ - `results["FData"][2]` → mean LSA
87
+
88
+ ## Input rules
89
+
90
+ | Input | Allowed values |
91
+ | --- | --- |
92
+ | `Nc` | Integer `>= 1` |
93
+ | `filopodia_life_time` | Integer `>= 1` |
94
+ | `use_mat_files` | Only valid when `Nc = 4` |
95
+
96
+ Important notes:
97
+
98
+ - `Nc = 4` implies a `4 x 4` tissue
99
+ - `Nc >= 10` can take many hours to run, so use smaller values for testing
100
+ - MATLAB reference mode is intended for deterministic comparison with the legacy MATLAB workflow
101
+
102
+ ## Repository structure
103
+
104
+ The codebase is organized into layers:
105
+
106
+ - `sopsim/core.py` — public Python API entry point
107
+ - `sopsim/config.py` — validation and parameter construction
108
+ - `sopsim/cli.py` — terminal command parsing and dispatch
109
+ - `sopsim/server.py` — FastAPI web service
110
+ - `sopsim/artifacts.py` — metadata and file output handling
111
+ - `sopsim/run_sopsim.py` — solver execution path
112
+ - `frontend/` — React frontend for the local web UI
113
+ - `tests/` — project tests
114
+
115
+ ## Output files
116
+
117
+ Running a simulation creates a results directory containing:
118
+
119
+ - plots
120
+ - `metadata.json`
121
+ - the generated result files from the simulation run
122
+
123
+ ## Developer notes
124
+
125
+ The following notes are intended to help someone clone the repository and continue development.
126
+
127
+ ### Clone and setup
128
+
129
+ ```bash
130
+ git clone <repo-url>
131
+ cd SOPSim
132
+ python -m venv .venv
133
+ .venv\Scripts\activate
134
+ pip install -U pip
135
+ pip install -e .
136
+ ```
137
+
138
+ ### Install development extras
139
+
140
+ If you need the build tooling for packaging and release work:
141
+
142
+ ```bash
143
+ pip install build twine
144
+ ```
145
+
146
+ ### Run tests
147
+
148
+ ```bash
149
+ pytest
150
+ ```
151
+
152
+ ### Local development workflow
153
+
154
+ 1. Make changes in the package code under `sopsim/`
155
+ 2. Reinstall the editable package if needed:
156
+
157
+ ```bash
158
+ pip install -e .
159
+ ```
160
+
161
+ 3. Test the CLI locally:
162
+
163
+ ```bash
164
+ sopsim run --nc 4 --out-dir output
165
+ ```
166
+
167
+ 4. Test the web app:
168
+
169
+ ```bash
170
+ sopsim serve
171
+ ```
172
+
173
+ ### Environment configuration notes
174
+
175
+ - The server uses `python-dotenv` and reads environment variables from a local `.env` file if present.
176
+ - The web server supports an optional `CORS_ALLOW_ORIGINS` environment variable for frontend origin control.
177
+ - Do not commit secrets or local credentials to the repository.
178
+
179
+ ## Publishing to PyPI
180
+
181
+ ### Did you make updates to the library and now want to publish them? Here's how to publish
182
+
183
+ Before publishing a new release:
184
+
185
+ 1. Update the package version in `pyproject.toml` and verify that all details are correct
186
+ 2. Update `README.md` if the usage instructions or package description need to change
187
+ 3. Build the distribution:
188
+
189
+ ```bash
190
+ python -m build
191
+ ```
192
+
193
+ 5. Validate the built package:
194
+
195
+ ```bash
196
+ twine check dist/*
197
+ ```
198
+
199
+ 6. Upload the release:
200
+
201
+ ```bash
202
+ twine upload dist/*
203
+ ```
204
+
205
+ You may need to configure an API key to complete this process.
206
+
207
+ ## Bug fixes
208
+
209
+ - `0.2.5`: Updated the README to be more comprehensive for developers & updated bundled frontend to include link to live frontend (on the web)
210
+ - `0.2.4`: Improved documentation for `FData`
211
+ - `0.2.3`: Backend now works; frontend layout adjustments; help text wording improvement
212
+ - `0.2.2`: Fixed default value handling for filopodia type and lifetime
213
+ - `0.2.1`: Fixed default value handling for filopodia type and lifetime
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "sopsim"
7
- version = "0.2.3"
7
+ version = "0.2.5"
8
8
  description = "SOPSim simulation library"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.9"
@@ -9,7 +9,7 @@ import numpy as np
9
9
 
10
10
  from .run_sopsim import generate_plots
11
11
 
12
-
12
+ # Process each value to ensure it is serializable by JSON, converting numpy types to native Python types as needed.
13
13
  def _jsonable(value: Any) -> Any:
14
14
  if isinstance(value, np.ndarray):
15
15
  return value.tolist()
@@ -21,7 +21,7 @@ def _jsonable(value: Any) -> Any:
21
21
  return [_jsonable(item) for item in value]
22
22
  return value
23
23
 
24
-
24
+ # Writes the metadata of the simulation
25
25
  def write_metadata(out_dir: pathlib.Path, inputs: Dict[str, Any], FData, extra: Dict[str, Any] | None = None) -> dict:
26
26
  out_dir.mkdir(parents=True, exist_ok=True)
27
27
  metadata = {
@@ -39,7 +39,7 @@ def write_metadata(out_dir: pathlib.Path, inputs: Dict[str, Any], FData, extra:
39
39
  (out_dir / "metadata.json").write_text(json.dumps(metadata, indent=2))
40
40
  return metadata
41
41
 
42
-
42
+ # Generate the plots and save the metadata for a completed simulation
43
43
  def save_simulation_outputs(
44
44
  out_dir: pathlib.Path,
45
45
  inputs: Dict[str, Any],
@@ -12,8 +12,6 @@ import uvicorn
12
12
  from .artifacts import save_simulation_outputs
13
13
  from .config import (
14
14
  FILOPODIA_LIFE_TIME_VALIDATION_MESSAGE,
15
- FILOPODIA_TYPE_VALIDATION_MESSAGE,
16
- FILOPODIA_TYPES,
17
15
  MATLAB_REFERENCE_NC,
18
16
  MATLAB_REFERENCE_VALIDATION_MESSAGE,
19
17
  MIN_FILOPODIA_LIFE_TIME,
@@ -24,7 +22,6 @@ from .config import (
24
22
  )
25
23
  from .core import sopsim
26
24
 
27
- DEFAULT_FILOPODIA_TYPE = SimulationInputs.__dataclass_fields__["filopodia_type"].default
28
25
  DEFAULT_FILOPODIA_LIFE_TIME = SimulationInputs.__dataclass_fields__["filopodia_life_time"].default
29
26
 
30
27
  class SOPSimArgumentParser(argparse.ArgumentParser):
@@ -32,7 +29,7 @@ class SOPSimArgumentParser(argparse.ArgumentParser):
32
29
  self.print_help(sys.stderr)
33
30
  self.exit(2, f"\nError: {message}\n")
34
31
 
35
-
32
+ # Used for input validation of positive integers in CLI arguments
36
33
  def positive_int(value: str, *, minimum: int, label: str) -> int:
37
34
  try:
38
35
  parsed = int(value)
@@ -42,18 +39,16 @@ def positive_int(value: str, *, minimum: int, label: str) -> int:
42
39
  raise argparse.ArgumentTypeError(f"{label} must be an integer >= {minimum}.")
43
40
  return parsed
44
41
 
45
-
42
+ # Expose and run the main sopsim simulation
46
43
  def run_simulation(args: argparse.Namespace) -> int:
47
44
  inputs = SimulationInputs(
48
45
  Nc=args.nc,
49
- filopodia_type=args.filopodia_type,
50
46
  filopodia_life_time=args.filopodia_life_time,
51
47
  use_mat_files=args.use_mat_files,
52
48
  )
53
49
  params = build_simulation_parameters(inputs)
54
50
  result = sopsim(
55
51
  Nc=inputs.Nc,
56
- filopodia_type=inputs.filopodia_type,
57
52
  filopodia_life_time=inputs.filopodia_life_time,
58
53
  use_mat_files=inputs.use_mat_files,
59
54
  )
@@ -76,7 +71,7 @@ def run_simulation(args: argparse.Namespace) -> int:
76
71
  print(f"Saved outputs to {out_dir}")
77
72
  return 0
78
73
 
79
-
74
+ # Used to run the local web server for SOPSim
80
75
  def serve_app(args: argparse.Namespace) -> int:
81
76
  uvicorn.run("sopsim.server:app", host=args.host, port=args.port, reload=args.reload)
82
77
  return 0
@@ -90,31 +85,26 @@ def build_parser() -> argparse.ArgumentParser:
90
85
  epilog=(
91
86
  "Input summary:\n"
92
87
  f" Nc: integer >= {MIN_NC}. Required input.\n"
93
- f" filopodia_type: one of {', '.join(FILOPODIA_TYPES)}. Default is {DEFAULT_FILOPODIA_TYPE}.\n"
94
88
  f" filopodia_life_time: integer >= {MIN_FILOPODIA_LIFE_TIME}. Default is {DEFAULT_FILOPODIA_LIFE_TIME}.\n"
95
89
  f" use_mat_files: only valid when Nc={MATLAB_REFERENCE_NC}\n"
96
90
  " r: fixed at 1.0\n\n"
97
91
  "Examples:\n"
98
- " sopsim run --nc 4 --filopodia-type A --filopodia-life-time 10 --out-dir output\n"
92
+ " sopsim run --nc 4 --filopodia-life-time 10 --out-dir output\n"
99
93
  " sopsim run --nc 4 --use-mat-files --out-dir output\n"
100
94
  " sopsim serve" #ALT: sopsim serve --host 127.0.0.1 --port 8000
101
95
  ),
102
96
  )
103
97
  subparsers = parser.add_subparsers(dest="command")
104
98
 
99
+ # Define the CLI "sopsim run" command
105
100
  run_parser = subparsers.add_parser("run", help="Run one simulation and write local outputs.")
101
+ #define the CLI arguments for the "sopsim run" command
106
102
  run_parser.add_argument(
107
103
  "--nc",
108
104
  type=lambda value: positive_int(value, minimum=MIN_NC, label="Nc"),
109
105
  required=True,
110
106
  help=NC_VALIDATION_MESSAGE,
111
107
  )
112
- run_parser.add_argument(
113
- "--filopodia-type",
114
- choices=FILOPODIA_TYPES,
115
- default=DEFAULT_FILOPODIA_TYPE,
116
- help=f"{FILOPODIA_TYPE_VALIDATION_MESSAGE} (default: {DEFAULT_FILOPODIA_TYPE})",
117
- )
118
108
  run_parser.add_argument(
119
109
  "--filopodia-life-time",
120
110
  type=lambda value: positive_int(value, minimum=1, label="filopodia_life_time"),
@@ -135,6 +125,7 @@ def build_parser() -> argparse.ArgumentParser:
135
125
  )
136
126
  run_parser.set_defaults(func=run_simulation)
137
127
 
128
+ # Define the CLI "sopsim serve" command
138
129
  serve_parser = subparsers.add_parser("serve", help="Start SOPSim as a website, local to your computer.")
139
130
  serve_parser.add_argument("--host", default="127.0.0.1", help="Host interface to bind")
140
131
  serve_parser.add_argument("--port", type=int, default=8000, help="Port to bind")
@@ -145,12 +136,12 @@ def build_parser() -> argparse.ArgumentParser:
145
136
 
146
137
 
147
138
  def main(argv: Sequence[str] | None = None) -> int:
148
- parser = build_parser()
139
+ parser = build_parser() #build the argument parser with subcommands and options
149
140
  try:
150
- args = parser.parse_args(argv)
151
- if not hasattr(args, "func"):
141
+ args = parser.parse_args(argv) #read user CLI input
142
+ if not hasattr(args, "func"): #if no subcommand was provided, print help and exit
152
143
  parser.print_help()
153
144
  return 0
154
- return int(args.func(args))
145
+ return int(args.func(args)) #pass to the appropriate function (run_simulation or serve_app)
155
146
  except ValueError as exc:
156
147
  parser.error(str(exc))