Skip to content

Commit

Permalink
Merge pull request #19 from biosimulators/fixes
Browse files Browse the repository at this point in the history
Two fixes:
  • Loading branch information
luciansmith authored Aug 16, 2023
2 parents eed7e34 + e8c71cd commit e8cf9ec
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 8 deletions.
2 changes: 1 addition & 1 deletion biosimulators_tellurium/_version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '0.1.40'
__version__ = '0.1.41'
33 changes: 26 additions & 7 deletions biosimulators_tellurium/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,8 +316,22 @@ def get_all_tasks_from_task(task):
return ret
elif isinstance(task, RepeatedTask):
for sub_task in task.sub_tasks:
submodels = get_all_tasks_from_task(sub_task.task)
ret.update(submodels)
subtasks = get_all_tasks_from_task(sub_task.task)
ret.update(subtasks)
return ret
else:
raise NotImplementedError("Tasks other than 'Task' or 'RepeatedTask' are not supported.")


def get_all_task_changes_from_task(task):
ret = set()
if isinstance(task, Task):
return ret
elif isinstance(task, RepeatedTask):
ret.update(task.changes)
for sub_task in task.sub_tasks:
subtask_changes = get_all_task_changes_from_task(sub_task.task)
ret.update(subtask_changes)
return ret
else:
raise NotImplementedError("Tasks other than 'Task' or 'RepeatedTask' are not supported.")
Expand Down Expand Up @@ -352,6 +366,7 @@ def preprocess_sed_task(task, variables, config=None, simulator_config=None):
config = get_config()

alltasks = get_all_tasks_from_task(task)
alltaskchanges = get_all_task_changes_from_task(task)

if config.VALIDATE_SEDML:
for subtask in alltasks:
Expand All @@ -377,9 +392,7 @@ def preprocess_sed_task(task, variables, config=None, simulator_config=None):
solvers = {}
for subtasks in alltasks:
model = subtask.model
allchanges = model.changes
if isinstance(task, RepeatedTask):
allchanges = allchanges + task.changes
allchanges = model.changes + list(alltaskchanges)
sim = subtask.simulation
model_etree = lxml.etree.parse(model.source)

Expand Down Expand Up @@ -548,13 +561,19 @@ def get_model_change_target_tellurium_change_map(model_etree, changes, alg_kisao
if not isinstance(change, ModelAttributeChange) and not isinstance(change, ComputeModelChange):
continue
if hasattr(model, "change") and change.model.id != model_id:
raise NotImplementedError("Unable to process a change to model " + change.model_id + " inside a task concerning model " + model_id)
raise NotImplementedError("Unable to process a change to model '" + change.model_id
+ "' inside a task concerning model '" + model_id + "'")
if hasattr(model, "symbol") and change.symbol:
raise NotImplementedError("Unable to process a change to model " + change.model_id + " with the symbol " + change.symbol)
raise NotImplementedError("Unable to process a change to model '" + change.model_id
+ "' with the symbol '" + change.symbol + "'")
else:
change.symbol = None
__, sep, __ = change.target.rpartition('/@')

if "reaction[" in change.target and "kineticLaw/" in change.target:
raise NotImplementedError("Unable to process a change to model '" + model_id + "' with the target "
+ change.target + " because changing local parameters is not yet implemented.")

sbml_id = change_targets_to_sbml_ids[change.target]

if alg_kisao_id == 'KISAO_0000029' and sbml_id in species_ids:
Expand Down

0 comments on commit e8cf9ec

Please sign in to comment.