sopsim 0.2.4__tar.gz → 0.2.6__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.6/PKG-INFO +175 -0
  2. sopsim-0.2.6/README.md +158 -0
  3. {sopsim-0.2.4 → sopsim-0.2.6}/pyproject.toml +1 -1
  4. {sopsim-0.2.4 → sopsim-0.2.6}/sopsim/artifacts.py +3 -3
  5. {sopsim-0.2.4 → sopsim-0.2.6}/sopsim/cli.py +11 -20
  6. {sopsim-0.2.4 → sopsim-0.2.6}/sopsim/config.py +14 -39
  7. {sopsim-0.2.4 → sopsim-0.2.6}/sopsim/core.py +4 -7
  8. {sopsim-0.2.4 → sopsim-0.2.6}/sopsim/filop_lent.py +31 -26
  9. sopsim-0.2.6/sopsim/mat_files/Ang.mat +0 -0
  10. sopsim-0.2.6/sopsim/mat_files/Delta.mat +0 -0
  11. sopsim-0.2.6/sopsim/mat_files/Notch.mat +0 -0
  12. sopsim-0.2.6/sopsim/mat_files/kappa.mat +0 -0
  13. {sopsim-0.2.4 → sopsim-0.2.6}/sopsim/reference_data.py +2 -3
  14. {sopsim-0.2.4 → sopsim-0.2.6}/sopsim/run_sopsim.py +5 -8
  15. {sopsim-0.2.4 → sopsim-0.2.6}/sopsim/server.py +0 -11
  16. sopsim-0.2.6/sopsim/web_dist/assets/index-BwDTYCM6.js +32 -0
  17. sopsim-0.2.6/sopsim/web_dist/assets/index-CROLemY3.js +32 -0
  18. sopsim-0.2.6/sopsim/web_dist/assets/index-CY6Qs6iF.js +32 -0
  19. sopsim-0.2.6/sopsim/web_dist/assets/index-Cf-_Tx0y.css +1 -0
  20. sopsim-0.2.6/sopsim/web_dist/assets/index-Cr0O0uLv.js +32 -0
  21. sopsim-0.2.6/sopsim/web_dist/assets/index-CtnLOlUl.js +32 -0
  22. {sopsim-0.2.4 → sopsim-0.2.6}/sopsim/web_dist/index.html +2 -2
  23. sopsim-0.2.6/sopsim.egg-info/PKG-INFO +175 -0
  24. {sopsim-0.2.4 → sopsim-0.2.6}/sopsim.egg-info/SOURCES.txt +7 -4
  25. {sopsim-0.2.4 → sopsim-0.2.6}/tests/test_cli.py +1 -13
  26. {sopsim-0.2.4 → sopsim-0.2.6}/tests/test_config.py +16 -9
  27. sopsim-0.2.6/tests/test_filop_lent.py +61 -0
  28. {sopsim-0.2.4 → sopsim-0.2.6}/tests/test_server.py +6 -6
  29. sopsim-0.2.4/PKG-INFO +0 -140
  30. sopsim-0.2.4/README.md +0 -123
  31. sopsim-0.2.4/sopsim/mat_files/Ang.mat +0 -0
  32. sopsim-0.2.4/sopsim/mat_files/Delta.mat +0 -0
  33. sopsim-0.2.4/sopsim/mat_files/F2.mat +0 -0
  34. sopsim-0.2.4/sopsim/mat_files/Notch.mat +0 -0
  35. sopsim-0.2.4/sopsim/mat_files/kappa.mat +0 -0
  36. sopsim-0.2.4/sopsim/web_dist/assets/index-BU1bhlot.js +0 -32
  37. sopsim-0.2.4/sopsim/web_dist/assets/index-Bg57AWq2.js +0 -32
  38. sopsim-0.2.4/sopsim/web_dist/assets/index-Bop8xgS8.css +0 -1
  39. sopsim-0.2.4/sopsim.egg-info/PKG-INFO +0 -140
  40. {sopsim-0.2.4 → sopsim-0.2.6}/MANIFEST.in +0 -0
  41. {sopsim-0.2.4 → sopsim-0.2.6}/setup.cfg +0 -0
  42. {sopsim-0.2.4 → sopsim-0.2.6}/sopsim/__init__.py +0 -0
  43. {sopsim-0.2.4 → sopsim-0.2.6}/sopsim/__main__.py +0 -0
  44. {sopsim-0.2.4 → sopsim-0.2.6}/sopsim/delta_in.py +0 -0
  45. {sopsim-0.2.4 → sopsim-0.2.6}/sopsim/filop_vectors.py +0 -0
  46. {sopsim-0.2.4 → sopsim-0.2.6}/sopsim/two_d_geom.py +0 -0
  47. {sopsim-0.2.4 → sopsim-0.2.6}/sopsim/web_dist/__init__.py +0 -0
  48. {sopsim-0.2.4 → sopsim-0.2.6}/sopsim/web_dist/assets/index-DqOYPuAV.css +0 -0
  49. {sopsim-0.2.4 → sopsim-0.2.6}/sopsim.egg-info/dependency_links.txt +0 -0
  50. {sopsim-0.2.4 → sopsim-0.2.6}/sopsim.egg-info/entry_points.txt +0 -0
  51. {sopsim-0.2.4 → sopsim-0.2.6}/sopsim.egg-info/requires.txt +0 -0
  52. {sopsim-0.2.4 → sopsim-0.2.6}/sopsim.egg-info/top_level.txt +0 -0
  53. {sopsim-0.2.4 → sopsim-0.2.6}/tests/test_api_types.py +0 -0
sopsim-0.2.6/PKG-INFO ADDED
@@ -0,0 +1,175 @@
1
+ Metadata-Version: 2.4
2
+ Name: sopsim
3
+ Version: 0.2.6
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 (RNG=12)
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
+ ## Publishing to PyPI
141
+
142
+ ### Did you make updates to the library and now want to publish them? Here's how to publish
143
+
144
+ Before publishing a new release:
145
+
146
+ 1. Update the package version in `pyproject.toml` and verify that all details are correct
147
+ 2. Update `README.md` if the usage instructions or package description need to change
148
+ 3. Build the distribution:
149
+
150
+ ```bash
151
+ python -m build
152
+ ```
153
+
154
+ 5. Validate the built package:
155
+
156
+ ```bash
157
+ twine check dist/*
158
+ ```
159
+
160
+ 6. Upload the release:
161
+
162
+ ```bash
163
+ twine upload dist/*
164
+ ```
165
+
166
+ You may need to configure an API key to complete this process.
167
+
168
+ ## Bug fixes
169
+
170
+ - `0.2.6`: Updated READMES & re-built front-end
171
+ - `0.2.5`: Updated the README to be more comprehensive for developers & updated bundled frontend to include link to live frontend (on the web)
172
+ - `0.2.4`: Improved documentation for `FData`
173
+ - `0.2.3`: Backend now works; frontend layout adjustments; help text wording improvement
174
+ - `0.2.2`: Fixed default value handling for filopodia type and lifetime
175
+ - `0.2.1`: Fixed default value handling for filopodia type and lifetime
sopsim-0.2.6/README.md ADDED
@@ -0,0 +1,158 @@
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 (RNG=12)
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
+ ## Publishing to PyPI
124
+
125
+ ### Did you make updates to the library and now want to publish them? Here's how to publish
126
+
127
+ Before publishing a new release:
128
+
129
+ 1. Update the package version in `pyproject.toml` and verify that all details are correct
130
+ 2. Update `README.md` if the usage instructions or package description need to change
131
+ 3. Build the distribution:
132
+
133
+ ```bash
134
+ python -m build
135
+ ```
136
+
137
+ 5. Validate the built package:
138
+
139
+ ```bash
140
+ twine check dist/*
141
+ ```
142
+
143
+ 6. Upload the release:
144
+
145
+ ```bash
146
+ twine upload dist/*
147
+ ```
148
+
149
+ You may need to configure an API key to complete this process.
150
+
151
+ ## Bug fixes
152
+
153
+ - `0.2.6`: Updated READMES & re-built front-end
154
+ - `0.2.5`: Updated the README to be more comprehensive for developers & updated bundled frontend to include link to live frontend (on the web)
155
+ - `0.2.4`: Improved documentation for `FData`
156
+ - `0.2.3`: Backend now works; frontend layout adjustments; help text wording improvement
157
+ - `0.2.2`: Fixed default value handling for filopodia type and lifetime
158
+ - `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.4"
7
+ version = "0.2.6"
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))
@@ -5,41 +5,21 @@ from dataclasses import dataclass
5
5
  from numbers import Integral
6
6
  from typing import Any, Dict
7
7
 
8
- import numpy as np
9
-
10
8
  from .reference_data import load_reference_data
11
9
 
12
- FILOPODIA_PROFILES: Dict[str, Dict[str, Any]] = {
13
- "A": {"k_mu": [0.0125, 4, 6], "t_frac": [0.45, 0.45]},
14
- "B": {"k_mu": [0.0125, 4, 6], "t_frac": [0.4, 0.65]},
15
- "C": {"k_mu": [0.0125, 4, 12], "t_frac": [0.65, 0.65]},
16
- "D": {"k_mu": [0.0125, 5, 9], "t_frac": [0.25, 0.8]},
17
- }
18
-
19
- DEFAULT_ALPHA = np.array(
20
- [
21
- [0.3, 0.65, 0.8],
22
- [0.25, 0.6, 0.75],
23
- [0.2, 0.75, 0.90],
24
- ]
25
- )
26
-
27
10
  DEFAULT_RADIUS = 1.0
28
11
  MATLAB_REFERENCE_NC = 4
29
12
  MIN_NC = 1
30
13
  MIN_FILOPODIA_LIFE_TIME = 1
31
14
  NC_RUNTIME_WARNING_THRESHOLD = 10
32
- FILOPODIA_TYPES = tuple(FILOPODIA_PROFILES.keys())
33
15
  NC_VALIDATION_MESSAGE = f"Number of cells per row (Nc). Must be an integer >= {MIN_NC}."
34
16
  FILOPODIA_LIFE_TIME_VALIDATION_MESSAGE = f"filopodia_life_time must be an integer >= {MIN_FILOPODIA_LIFE_TIME}."
35
- FILOPODIA_TYPE_VALIDATION_MESSAGE = f"filopodia_type must be one of {', '.join(FILOPODIA_TYPES)}."
36
- MATLAB_REFERENCE_VALIDATION_MESSAGE = f"MATLAB reference mode is only supported when Nc={MATLAB_REFERENCE_NC}."
17
+ MATLAB_REFERENCE_VALIDATION_MESSAGE = f"MATLAB reference mode (uses MATLAB RNG=12) is only supported when Nc={MATLAB_REFERENCE_NC}."
37
18
 
38
19
 
39
20
  @dataclass(frozen=True)
40
21
  class SimulationInputs:
41
22
  Nc: int
42
- filopodia_type: str = "A"
43
23
  filopodia_life_time: int = 10
44
24
  use_mat_files: bool = False
45
25
 
@@ -52,12 +32,10 @@ class SimulationInputs:
52
32
  raise ValueError(NC_VALIDATION_MESSAGE)
53
33
  if self.filopodia_life_time < MIN_FILOPODIA_LIFE_TIME:
54
34
  raise ValueError(FILOPODIA_LIFE_TIME_VALIDATION_MESSAGE)
55
- if self.filopodia_type not in FILOPODIA_PROFILES:
56
- raise ValueError(FILOPODIA_TYPE_VALIDATION_MESSAGE)
57
35
  if self.use_mat_files and self.Nc != MATLAB_REFERENCE_NC:
58
36
  raise ValueError(MATLAB_REFERENCE_VALIDATION_MESSAGE)
59
37
 
60
-
38
+ # Validates input paramters and creates a dictionary of simulation parameters
61
39
  def build_simulation_parameters(inputs: SimulationInputs) -> Dict[str, Any]:
62
40
  """Build the low-level arrays used by the simulator."""
63
41
  inputs.validate()
@@ -73,10 +51,10 @@ def build_simulation_parameters(inputs: SimulationInputs) -> Dict[str, Any]:
73
51
 
74
52
  tf = 3000
75
53
  dt = 1.0
76
- t_check = 120
54
+ t_check = 60
77
55
  MinConvergeTime = 600
78
56
  MinSaveTime = 0
79
- FreqSave = 10
57
+ FreqSave = 1
80
58
  MaxIt = tf / dt + 1
81
59
  LifeTime = int(inputs.filopodia_life_time)
82
60
 
@@ -92,7 +70,7 @@ def build_simulation_parameters(inputs: SimulationInputs) -> Dict[str, Any]:
92
70
  k = 9
93
71
  ModelP = [R_N, R_D, mu, rho, a, b, h, k]
94
72
 
95
- MinStableValue = 2
73
+ MinStableValue = 1.6
96
74
  F_rate = 0.01
97
75
  N_sigma = 0.01
98
76
  D_sigma = 0.01
@@ -109,23 +87,25 @@ def build_simulation_parameters(inputs: SimulationInputs) -> Dict[str, Any]:
109
87
  FixVals = [N_mu, D_mu, F_mu, a_apical, a_basal]
110
88
 
111
89
  fdelta = 2.7e-3
112
- fa0 = 10
90
+ fa0 = 20
113
91
  fKbT = 4.1e-3
114
92
  fN = 15
115
93
  fD = 5
116
94
  feta = 20
117
95
  fFt = 20
118
- ftau = 2000
96
+ ftau = 2400
119
97
  fK0 = 10
120
- fm = 0.1
98
+ fm = 100
121
99
  fw = 0.01
122
- fk_sigma = 6e-3
100
+ fk_sigma = 3.6
123
101
  fNum_filop = inputs.Nc * inputs.Nc * 6
124
- fdt = 0.1
102
+ fdt = 0.01
125
103
  ftf = LifeTime * 60
126
104
  fselectIndx = 60 / fdt
127
105
  fFs = fKbT * fN / fdelta
128
106
  fP = 60
107
+ fFm = 20
108
+ fPauseK0Percent = 0.14
129
109
 
130
110
  LentPar = [
131
111
  fdelta,
@@ -147,18 +127,16 @@ def build_simulation_parameters(inputs: SimulationInputs) -> Dict[str, Any]:
147
127
  fFs,
148
128
  LifeTime,
149
129
  fP,
130
+ fFm,
131
+ fPauseK0Percent,
150
132
  ]
151
133
 
152
- selected_profile = FILOPODIA_PROFILES[inputs.filopodia_type]
153
- k_mu = selected_profile["k_mu"]
154
- Tswitch = np.array(selected_profile["t_frac"]) * ftf
155
134
  reference_data = load_reference_data(inputs.Nc) if inputs.use_mat_files else None
156
135
 
157
136
  return {
158
137
  "inputs": {
159
138
  "Nc": inputs.Nc,
160
139
  "r": DEFAULT_RADIUS,
161
- "filopodia_type": inputs.filopodia_type,
162
140
  "filopodia_life_time": LifeTime,
163
141
  "use_mat_files": inputs.use_mat_files,
164
142
  },
@@ -167,8 +145,5 @@ def build_simulation_parameters(inputs: SimulationInputs) -> Dict[str, Any]:
167
145
  "ContP": ContP,
168
146
  "FixVals": FixVals,
169
147
  "LentPar": LentPar,
170
- "k_mu": k_mu,
171
- "alpha": DEFAULT_ALPHA.copy(),
172
- "Tswitch": Tswitch,
173
148
  "reference_data": reference_data,
174
149
  }
@@ -9,10 +9,9 @@ from .config import SimulationInputs, build_simulation_parameters
9
9
  from .config import NC_RUNTIME_WARNING_THRESHOLD
10
10
  from .run_sopsim import run_sopsim
11
11
 
12
-
12
+ # Define the public API which calls run_sopsim with validated parameters and returns results in a structured dictionary.
13
13
  def sopsim(
14
14
  Nc: int,
15
- filopodia_type: str = "A",
16
15
  filopodia_life_time: int = 10,
17
16
  use_mat_files: bool = False,
18
17
  cancel_event: threading.Event | None = None,
@@ -21,7 +20,6 @@ def sopsim(
21
20
 
22
21
  Args:
23
22
  Nc: Number of cells per row.
24
- filopodia_type: Filopodia profile type (A, B, C, D).
25
23
  filopodia_life_time: Filopodia lifetime in minutes.
26
24
  use_mat_files: Use bundled MATLAB reference inputs for Nc=4.
27
25
 
@@ -35,28 +33,27 @@ def sopsim(
35
33
  stacklevel=2,
36
34
  )
37
35
 
36
+ #Validate the input parameters
38
37
  params = build_simulation_parameters(
39
38
  SimulationInputs(
40
39
  Nc=Nc,
41
- filopodia_type=filopodia_type,
42
40
  filopodia_life_time=filopodia_life_time,
43
41
  use_mat_files=use_mat_files,
44
42
  )
45
43
  )
46
44
 
45
+ #run the simulation with the validated parameters
47
46
  FData, LSA, MeanDin, Notch_time_step, MeanSOPNotch, MeanEPNotch, FinalNotch = run_sopsim(
48
47
  params["LentPar"],
49
48
  params["TimeP"],
50
49
  params["ModelP"],
51
50
  params["ContP"],
52
51
  params["FixVals"],
53
- params["k_mu"],
54
- params["alpha"],
55
- params["Tswitch"],
56
52
  reference_data=params["reference_data"],
57
53
  cancel_event=cancel_event,
58
54
  )
59
55
 
56
+ #return values as a dictionary
60
57
  return {
61
58
  "FData": FData,
62
59
  "LSA": LSA,