diff --git a/biosimulator_processes/__init__.py b/biosimulator_processes/__init__.py index 76911536f..e69de29bb 100644 --- a/biosimulator_processes/__init__.py +++ b/biosimulator_processes/__init__.py @@ -1,25 +0,0 @@ -from process_bigraph import process_registry - - -# Define a list of processes to attempt to import and register -processes_to_register = [ - ('cobra', 'cobra_process.CobraProcess'), - ('copasi', 'copasi_process.CopasiProcess'), - ('smoldyn', 'smoldyn_process.SmoldynProcess'), - ('tellurium', 'tellurium_process.TelluriumProcess'), -] - -for process_name, process_path in processes_to_register: - module_name, class_name = process_path.rsplit('.', 1) - try: - # Dynamically import the module - process_module = __import__( - f'biosimulator_processes.processes.{module_name}', fromlist=[class_name]) - # Get the class from the module - process_class = getattr(process_module, class_name) - - # Register the process - process_registry.register(process_name, process_class) - print(f"{class_name} registered successfully.") - except ImportError as e: - print(f"{class_name} not available. Error: {e}") diff --git a/biosimulator_processes/processes/copasi_process.py b/biosimulator_processes/processes/copasi_process.py index 6ee893e3c..7bc127274 100644 --- a/biosimulator_processes/processes/copasi_process.py +++ b/biosimulator_processes/processes/copasi_process.py @@ -5,9 +5,18 @@ # 'reactions': 'tree[string]', # 'model_changes': 'tree[string]', + # Newton/Raphson method distance/rate: steady state Use newton method and time course simulation + + # try newton stopp if epsilon satistfies + # run tc for 0.1unit of time stop if ep satis + # try newton stop if e satisfied + # run tc for 10x longer time stop if e + # if time>10^10 units of time stop otherwise go back to number 3 + """ +from typing import Dict from basico import ( load_model, get_species, @@ -78,7 +87,7 @@ class CopasiProcess(Process): '_type': 'tree[string]', '_default': MODEL_TYPE }, - 'biomodel_id': 'string', # <-- implies the lack of either model_file or model_reactions + 'biomodel_id': 'maybe[string]', # <-- implies the lack of either model_file or model_reactions 'units': 'maybe[tree[string]]', 'method': { '_type': 'string', @@ -89,11 +98,13 @@ class CopasiProcess(Process): def __init__(self, config=None, core=None): super().__init__(config, core) + # exact values from configuration model_file = self.config.get('model').get('model_source') sed_model_id = self.config.get('model').get('model_id') biomodel_id = self.config.get('biomodel_id') source_model_id = biomodel_id or sed_model_id + # ensure only model_file OR biomodel_id assert not (model_file and biomodel_id), 'You can only pass either a model_file or a biomodel_id.' # A. enter with model_file @@ -106,16 +117,18 @@ def __init__(self, config=None, core=None): else: self.copasi_model_object = new_model(name='CopasiProcess Model') + self.model_changes: Dict = self.config['model']['model_changes'] + reaction_changes: Dict = self.model_changes.get('reaction_changes') + # add reactions - if self.config.get('reactions'): - for reaction_name, reaction_spec in self.config['reactions'].items(): + if reaction_changes: + for reaction_name, reaction_spec in reaction_changes.items(): add_reaction( name=reaction_name, scheme=reaction_spec, model=self.copasi_model_object ) - # self.model_changes = # Get the species (floating only) TODO: add boundary species self.floating_species_list = get_species(model=self.copasi_model_object).index.tolist() self.floating_species_initial = get_species(model=self.copasi_model_object)['concentration'].tolist() @@ -127,14 +140,11 @@ def __init__(self, config=None, core=None): # Get a list of reactions self.reaction_list = get_reactions(model=self.copasi_model_object).index.tolist() if not self.reaction_list: - raise AttributeError('You must provide either a model filepath, a biomodel id, or reaction definitions.') + raise AttributeError('No reactions could be parsed from this model. Your model must contain reactions to run.') # Get a list of compartments self.compartments_list = get_compartments(model=self.copasi_model_object).index.tolist() - if self.config.get('method'): - pass - def initial_state(self): floating_species_dict = dict( zip(self.floating_species_list, self.floating_species_initial)) diff --git a/notebooks/copasi_process_composer.ipynb b/notebooks/copasi_process_composer.ipynb index f75edf82d..a604e3083 100644 --- a/notebooks/copasi_process_composer.ipynb +++ b/notebooks/copasi_process_composer.ipynb @@ -29,13 +29,13 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": 1, "id": "c6c10dc5988e52d4", "metadata": { "collapsed": false, "ExecuteTime": { - "end_time": "2024-02-28T16:57:16.121555Z", - "start_time": "2024-02-28T16:57:14.285002Z" + "end_time": "2024-02-28T18:42:15.497044Z", + "start_time": "2024-02-28T18:42:13.902065Z" } }, "outputs": [