cnapy-org / CNApy

An integrated visual environment for metabolic modeling with common methods such as FBA, FVA and Elementary Flux Modes, and advanced features such as thermodynamic methods, extended Minimal Cut Sets, OptKnock, RobustKnock, OptCouple and more!
https://cnapy-org.github.io/CNApy-guide/
Apache License 2.0
46 stars 7 forks source link

Error while due to space in reaction id #487

Closed MaaikeRemeijer closed 1 year ago

MaaikeRemeijer commented 1 year ago

Hi,

When making a toy model I accidentally put a space in a reaction id and after removing it I still cannot save my project. I get the following error:

Traceback (most recent call last): File "C:\Users\mre283\Anaconda3\envs\cnapy-1.1.6\lib\site-packages\optlang\container.py", line 82, in __getitem__ return self._object_list[item] # Try treating item as int or slice TypeError: list indices must be integers or slices, not str During handling of the above exception, another exception occurred: Traceback (most recent call last): File "C:\Users\mre283\Anaconda3\envs\cnapy-1.1.6\lib\site-packages\cnapy\gui_elements\main_window.py", line 1344, in save_project self.continue_save_project() File "C:\Users\mre283\Anaconda3\envs\cnapy-1.1.6\lib\site-packages\cnapy\gui_elements\main_window.py", line 1354, in continue_save_project self.save_sbml(tmp_dir + "model.sbml") File "C:\Users\mre283\Anaconda3\envs\cnapy-1.1.6\lib\site-packages\cnapy\gui_elements\main_window.py", line 1315, in save_sbml cobra.io.write_sbml_model( File "C:\Users\mre283\Anaconda3\envs\cnapy-1.1.6\lib\site-packages\cobra\io\sbml.py", line 1174, in write_sbml_model doc = _model_to_sbml(cobra_model, f_replace=f_replace, **kwargs) File "C:\Users\mre283\Anaconda3\envs\cnapy-1.1.6\lib\site-packages\cobra\io\sbml.py", line 1360, in _model_to_sbml reaction_coefficients = linear_reaction_coefficients(cobra_model) File "C:\Users\mre283\Anaconda3\envs\cnapy-1.1.6\lib\site-packages\cobra\util\solver.py", line 100, in linear_reaction_coefficients forward_coefficient = coefficients.get(rxn.forward_variable, 0) File "C:\Users\mre283\Anaconda3\envs\cnapy-1.1.6\lib\site-packages\cobra\core\reaction.py", line 190, in forward_variable return self.model.variables[self.id] File "C:\Users\mre283\Anaconda3\envs\cnapy-1.1.6\lib\site-packages\optlang\container.py", line 84, in __getitem__ return self._dict[item] # Treat item as key (name) KeyError: 'NAD de'

I get the same error when I try to export to SBML to save my progress.

Is there any way to fix this?

Paulocracy commented 1 year ago

Closing as duplicate of #488 (if this is not a duplicate, please notify us, e.g. by commenting here)

MaaikeRemeijer commented 1 year ago

I see, I don't know how I forgot that I already opened an issue, sorry!