Skip to content
This repository has been archived by the owner on Mar 6, 2024. It is now read-only.

Commit

Permalink
fix: minor utils refacor
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexPatrie committed Feb 29, 2024
1 parent ae00edc commit 39f224d
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 2 deletions.
2 changes: 1 addition & 1 deletion biosimulator_processes/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ def generate_copasi_parameter_scan_instance(
instance_name=f'copasi_{n}',
config=iteration_model_config
)
for iter_name, iter_config in iteration_instance:
for iter_name, iter_config in iteration_instance.items():
parameter_scan_instance[iter_name] = iteration_instance

emitter_schema = generate_emitter_schema(floating_species='tree[float]', time='float')
Expand Down
47 changes: 46 additions & 1 deletion notebooks/copasi_process_composer.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -653,14 +653,59 @@
"id": "9e11e97613ec9e16",
"execution_count": 3
},
{
"cell_type": "code",
"outputs": [],
"source": [
"from biosimulator_processes.utils import generate_copasi_parameter_scan_instance as param_scan"
],
"metadata": {
"collapsed": false,
"ExecuteTime": {
"end_time": "2024-02-29T00:57:43.236081Z",
"start_time": "2024-02-29T00:57:42.393787Z"
}
},
"id": "1ecc10e496abe9cb",
"execution_count": 1
},
{
"cell_type": "code",
"outputs": [
{
"ename": "ValueError",
"evalue": "too many values to unpack (expected 2)",
"output_type": "error",
"traceback": [
"\u001B[0;31m---------------------------------------------------------------------------\u001B[0m",
"\u001B[0;31mValueError\u001B[0m Traceback (most recent call last)",
"Cell \u001B[0;32mIn[2], line 1\u001B[0m\n\u001B[0;32m----> 1\u001B[0m parameter_scan_instance \u001B[38;5;241m=\u001B[39m \u001B[43mparam_scan\u001B[49m\u001B[43m(\u001B[49m\u001B[43mnum_iterations\u001B[49m\u001B[38;5;241;43m=\u001B[39;49m\u001B[38;5;241;43m100\u001B[39;49m\u001B[43m,\u001B[49m\u001B[43m \u001B[49m\u001B[43mentry_config\u001B[49m\u001B[38;5;241;43m=\u001B[39;49m\u001B[43m{\u001B[49m\u001B[38;5;124;43m'\u001B[39;49m\u001B[38;5;124;43mbiomodel_id\u001B[39;49m\u001B[38;5;124;43m'\u001B[39;49m\u001B[43m:\u001B[49m\u001B[43m \u001B[49m\u001B[38;5;124;43m'\u001B[39;49m\u001B[38;5;124;43mBIOMD0000000051\u001B[39;49m\u001B[38;5;124;43m'\u001B[39;49m\u001B[43m}\u001B[49m\u001B[43m)\u001B[49m\n",
"File \u001B[0;32m~/Desktop/uchc_work/biosimulator-processes/biosimulator_processes/utils.py:164\u001B[0m, in \u001B[0;36mgenerate_copasi_parameter_scan_instance\u001B[0;34m(num_iterations, entry_config)\u001B[0m\n\u001B[1;32m 155\u001B[0m iteration_model_config \u001B[38;5;241m=\u001B[39m generate_sed_model_config_schema(\n\u001B[1;32m 156\u001B[0m entrypoint\u001B[38;5;241m=\u001B[39m{\u001B[38;5;124m'\u001B[39m\u001B[38;5;124mbiomodel_id\u001B[39m\u001B[38;5;124m'\u001B[39m: \u001B[38;5;124m'\u001B[39m\u001B[38;5;124mBIOMD0000000051\u001B[39m\u001B[38;5;124m'\u001B[39m},\n\u001B[1;32m 157\u001B[0m species_changes\u001B[38;5;241m=\u001B[39m{\u001B[38;5;124m'\u001B[39m\u001B[38;5;124mExtracellular Glucose\u001B[39m\u001B[38;5;124m'\u001B[39m: {\u001B[38;5;124m'\u001B[39m\u001B[38;5;124minitial_concentration\u001B[39m\u001B[38;5;124m'\u001B[39m: origin_value\u001B[38;5;241m*\u001B[39m\u001B[38;5;241m*\u001B[39mn}},\n\u001B[1;32m 158\u001B[0m parameter_changes\u001B[38;5;241m=\u001B[39m{\u001B[38;5;124m'\u001B[39m\u001B[38;5;124mcatp\u001B[39m\u001B[38;5;124m'\u001B[39m: {\u001B[38;5;124m'\u001B[39m\u001B[38;5;124minitial_value\u001B[39m\u001B[38;5;124m'\u001B[39m: (origin_value \u001B[38;5;241m-\u001B[39m n)\u001B[38;5;241m*\u001B[39m\u001B[38;5;241m*\u001B[39mn}}\n\u001B[1;32m 159\u001B[0m )\n\u001B[1;32m 160\u001B[0m iteration_instance \u001B[38;5;241m=\u001B[39m generate_single_copasi_process_instance(\n\u001B[1;32m 161\u001B[0m instance_name\u001B[38;5;241m=\u001B[39m\u001B[38;5;124mf\u001B[39m\u001B[38;5;124m'\u001B[39m\u001B[38;5;124mcopasi_\u001B[39m\u001B[38;5;132;01m{\u001B[39;00mn\u001B[38;5;132;01m}\u001B[39;00m\u001B[38;5;124m'\u001B[39m,\n\u001B[1;32m 162\u001B[0m config\u001B[38;5;241m=\u001B[39miteration_model_config\n\u001B[1;32m 163\u001B[0m )\n\u001B[0;32m--> 164\u001B[0m \u001B[38;5;28;01mfor\u001B[39;00m iter_name, iter_config \u001B[38;5;129;01min\u001B[39;00m iteration_instance:\n\u001B[1;32m 165\u001B[0m parameter_scan_instance[iter_name] \u001B[38;5;241m=\u001B[39m iteration_instance\n\u001B[1;32m 167\u001B[0m emitter_schema \u001B[38;5;241m=\u001B[39m generate_emitter_schema(floating_species\u001B[38;5;241m=\u001B[39m\u001B[38;5;124m'\u001B[39m\u001B[38;5;124mtree[float]\u001B[39m\u001B[38;5;124m'\u001B[39m, time\u001B[38;5;241m=\u001B[39m\u001B[38;5;124m'\u001B[39m\u001B[38;5;124mfloat\u001B[39m\u001B[38;5;124m'\u001B[39m)\n",
"\u001B[0;31mValueError\u001B[0m: too many values to unpack (expected 2)"
]
}
],
"source": [
"parameter_scan_instance = param_scan(num_iterations=100, entry_config={'biomodel_id': 'BIOMD0000000051'})"
],
"metadata": {
"collapsed": false,
"ExecuteTime": {
"end_time": "2024-02-29T00:58:43.335233Z",
"start_time": "2024-02-29T00:58:43.188913Z"
}
},
"id": "35ea2649d0f98801",
"execution_count": 2
},
{
"cell_type": "code",
"outputs": [],
"source": [],
"metadata": {
"collapsed": false
},
"id": "1ecc10e496abe9cb"
"id": "ed3c8d517ac54852"
}
],
"metadata": {
Expand Down

0 comments on commit 39f224d

Please sign in to comment.