Closed xuejun1214 closed 1 year ago
Hmm, looks like one of your reaction ids contains a white space. You could try reading the model with:
import cobra
model = cobra.io.read_sbml_model('41598_2020_64721_MOESM2_ESM.xml', f_replace=None)
If that still behaves odd you could also open the file in a text editor look for "R02921 "
and remove the space at the end.
Hi, Christian:
It is very glad to receive your email regarding my issue to run the SBML file. It worked now. Thank you so much again for your kind help... Do you have personal email that I may ask few more questions on the Genome-scale model?
Thanks, Jun
Xuejun Qian, D. Eng. Postdoc Research Associate The DAN Lab: https://danlab.bact.wisc.edu Great Lakes Bioenergy Research Center (GLBRC): https://www.glbrc.org University of Wisconsin-Madison 1550 Linden Dr, Madison, WI 53706-1521
From: Christian Diener @.> Sent: Thursday, April 13, 2023 2:39 PM To: opencobra/cobrapy @.> Cc: XUEJUN QIAN @.>; Author @.> Subject: Re: [opencobra/cobrapy] Can Not Open the SBML File (Issue #1327)
Hmm, looks like one of your reaction ids contains a white space. You could try reading the model with:
import cobra model = cobra.io.read_sbml_model('41598_2020_64721_MOESM2_ESM.xml', f_replace=None)
If that still behaves odd you could also open the file in a text editor look for "R02921 " and remove the space at the end.
— Reply to this email directly, view it on GitHubhttps://github.com/opencobra/cobrapy/issues/1327#issuecomment-1507515802, or unsubscribehttps://github.com/notifications/unsubscribe-auth/A6KYGDT2PUMUFDUSN5UYFT3XBBI6XANCNFSM6AAAAAAW5MWEIQ. You are receiving this because you authored the thread.Message ID: @.***>
Hi Jun,
You can ask them in the Discussion section or on Gitter chat.
Yes. I will. Thank you so much again for your kind help
Hello, All:
I had downloaded SMBL from Biomodels and try to run using the Jupyter Note Book. This code is working for another two models. But, I had problem for this model:
Input: import cobra model=cobra.io.read_sbml_model('41598_2020_64721_MOESM2_ESM.xml')
Error Message: ValueError Traceback (most recent call last) ~/opt/anaconda3/lib/python3.9/site-packages/cobra/io/sbml.py in read_sbml_model(filename, number, f_replace, kwargs) 457 doc = _get_doc_from_filename(filename) --> 458 return _sbml_to_model(doc, number=number, f_replace=f_replace, kwargs) 459 except IOError as e:
~/opt/anaconda3/lib/python3.9/site-packages/cobra/io/sbml.py in _sbml_to_model(doc, number, f_replace, set_missing_bounds, **kwargs) 957 --> 958 cobra_model.add_reactions(reactions) 959
~/opt/anaconda3/lib/python3.9/site-packages/cobra/core/model.py in add_reactions(self, reaction_list) 755 # from cameo ... --> 756 self._populate_solver(pruned) 757
~/opt/anaconda3/lib/python3.9/site-packages/cobra/core/model.py in _populate_solver(self, reaction_list, metabolite_list) 1133 if reaction.id not in self.variables: -> 1134 forward_variable = self.problem.Variable(reaction.id) 1135 reverse_variable = self.problem.Variable(reaction.reverse_id)
~/opt/anaconda3/lib/python3.9/site-packages/optlang/symbolics.py in new(cls, name, **kwargs) 128 --> 129 obj.name = name 130 obj._assumptions = FactKB(_assume_rules)
~/opt/anaconda3/lib/python3.9/site-packages/optlang/cplex_interface.py in name(self, value) 207 old_name = getattr(self, "name", None) --> 208 super(Variable, Variable).name.fset(self, value) 209 if getattr(self, "problem", None) is not None:
~/opt/anaconda3/lib/python3.9/site-packages/optlang/interface.py in name(self, value) 194 def name(self, value): --> 195 self.__validate_variable_name(value) 196 old_name = getattr(self, 'name', None)
~/opt/anaconda3/lib/python3.9/site-packages/optlang/interface.py in __validate_variable_name(name) 148 if char.isspace(): --> 149 raise ValueError( 150 'Variable names cannot contain whitespace characters. "%s" contains whitespace character "%s".' % (
ValueError: Variable names cannot contain whitespace characters. "R02921 " contains whitespace character " ".
The above exception was the direct cause of the following exception:
CobraSBMLError Traceback (most recent call last) /var/folders/zc/4ykxfy_j1978z0m96rymdwdh0000gn/T/ipykernel_5293/3860646278.py in
1 import cobra
----> 2 model = cobra.io.read_sbml_model ('41598_2020_64721_MOESM2_ESM.xml')
~/opt/anaconda3/lib/python3.9/site-packages/cobra/io/sbml.py in read_sbml_model(filename, number, f_replace, **kwargs) 470 "at https://github.com/opencobra/cobrapy/issues ." 471 ) --> 472 raise cobra_error from original_error 473 474
CobraSBMLError: Something went wrong reading the SBML model. Most likely the SBML model is not valid. Please check that your model is valid using the
cobra.io.sbml.validate_sbml_model
function or via the online validator at https://sbml.org/validator_servlet/ .(model, errors) = validate_sbml_model(filename)
If the model is valid and cannot be read please open an issue at https://github.com/opencobra/cobrapy/issues .Does any one have solutions for my problem? Thanks, Jun