You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying to use pytfa to analyze my genome-scale metabolic model, but I am encountering an error when following the eQuilibrator tutorial to create a thermodynamics database for my model.
Here is the script I am using:
import os
import cobra
import pytfa
import pytfa.io
from cobra.io import load_json_model
from pytfa.thermo.equilibrator import build_thermo_from_equilibrator
Set the solver for the thermodynamics model to CPLEX
tmodel.solver = "optlang-cplex"
Prepare the thermodynamics model
tmodel.prepare()
Convert the model
tmodel.convert()
Optimize the model
solution = tmodel.optimize()
Display some of the results
print("Some fluxes")
print(solution.fluxes.head())
print("\nObjective solution:", solution.objective_value)
print("\nTotal sum of fluxes:", solution.fluxes.sum())
When I run this script, I receive the following error:
Downloading package metadata...
Fragments already downloaded
Downloading package metadata...
Fragments already downloaded
Downloading package metadata...
Fragments already downloaded
Traceback (most recent call last):
File "iSJ444_pytfa_equilib.py", line 25, in
thermo_data = build_thermo_from_equilibrator(cobra_model)
File "/src/pytfa/pytfa/thermo/equilibrator.py", line 49, in build_thermo_from_equilibrator
compound_to_entry(met, cc) for met in met_to_comps
File "/src/pytfa/pytfa/thermo/equilibrator.py", line 49, in
compound_to_entry(met, cc) for met in met_to_comps
File "/src/pytfa/pytfa/thermo/equilibrator.py", line 76, in compound_to_entry
nH_std = compound.atom_bag["H"] if "H" in compound.atom_bag else 0
AttributeError: 'str' object has no attribute 'atom_bag'
It appears that during the execution of build_thermo_from_equilibrator, an AttributeError is raised because a string object is being accessed as if it has an atom_bag attribute.
Additional Information:
I am using the latest version of pytfa (installed via pip).
My model (iSJ444_annotated.json) is a genome-scale metabolic model with metabolite annotations.
I have verified that the model loads correctly in COBRApy and that the solver is properly set to CPLEX.
Could you please help me identify the cause of this error and suggest a solution?
Thank you for your assistance!
Best,
W
The text was updated successfully, but these errors were encountered:
Dear pytfa developers (@Midnighter @psalvy @Wealing )
I am trying to use pytfa to analyze my genome-scale metabolic model, but I am encountering an error when following the eQuilibrator tutorial to create a thermodynamics database for my model.
Here is the script I am using:
import os
import cobra
import pytfa
import pytfa.io
from cobra.io import load_json_model
from pytfa.thermo.equilibrator import build_thermo_from_equilibrator
Load the cobra_model
cobra_model = load_json_model('../models/iSJ444_annotated.json')
Set the optimizer to CPLEX
cobra_model.solver = "cplex"
Build the thermodynamics structure from eQuilibrator
thermo_data = build_thermo_from_equilibrator(cobra_model)
Initialize the ThermoModel with the thermodynamics data
tmodel = pytfa.ThermoModel(thermo_data, cobra_model)
Set the solver for the thermodynamics model to CPLEX
tmodel.solver = "optlang-cplex"
Prepare the thermodynamics model
tmodel.prepare()
Convert the model
tmodel.convert()
Optimize the model
solution = tmodel.optimize()
Display some of the results
print("Some fluxes")
print(solution.fluxes.head())
print("\nObjective solution:", solution.objective_value)
print("\nTotal sum of fluxes:", solution.fluxes.sum())
When I run this script, I receive the following error:
Downloading package metadata...
Fragments already downloaded
Downloading package metadata...
Fragments already downloaded
Downloading package metadata...
Fragments already downloaded
Traceback (most recent call last):
File "iSJ444_pytfa_equilib.py", line 25, in
thermo_data = build_thermo_from_equilibrator(cobra_model)
File "/src/pytfa/pytfa/thermo/equilibrator.py", line 49, in build_thermo_from_equilibrator
compound_to_entry(met, cc) for met in met_to_comps
File "/src/pytfa/pytfa/thermo/equilibrator.py", line 49, in
compound_to_entry(met, cc) for met in met_to_comps
File "/src/pytfa/pytfa/thermo/equilibrator.py", line 76, in compound_to_entry
nH_std = compound.atom_bag["H"] if "H" in compound.atom_bag else 0
AttributeError: 'str' object has no attribute 'atom_bag'
It appears that during the execution of build_thermo_from_equilibrator, an AttributeError is raised because a string object is being accessed as if it has an atom_bag attribute.
Additional Information:
I am using the latest version of pytfa (installed via pip).
My model (iSJ444_annotated.json) is a genome-scale metabolic model with metabolite annotations.
I have verified that the model loads correctly in COBRApy and that the solver is properly set to CPLEX.
Could you please help me identify the cause of this error and suggest a solution?
Thank you for your assistance!
Best,
W
The text was updated successfully, but these errors were encountered: