Commit 6adf71f6 authored by Moritz E. Beber's avatar Moritz E. Beber

refactor: use reaction identifiers in mapping

parent 6a142294
Pipeline #103495962 failed with stages
in 4 minutes and 49 seconds
......@@ -40,7 +40,7 @@ logger = logging.getLogger(__name__)
def map_cobra_reactions(
cache: CompoundCache, reactions: List["cobra.Reaction"], **kwargs
) -> Dict["cobra.Reaction", PhasedReaction]:
) -> Dict[str, PhasedReaction]:
"""
Translate COBRA reactions to eQuilibrator phased reactions.
......@@ -59,8 +59,12 @@ def map_cobra_reactions(
Returns
-------
dict
A mapping from COBRA to equilibrator phased reactions where such a
mapping could be established.
A mapping from COBRA reaction identifiers to equilibrator phased
reactions where such a mapping can be established.
See Also
--------
equilibrator_cache.compatibility.map_cobra_metabolites
"""
metabolites = sorted(
......@@ -71,12 +75,12 @@ def map_cobra_reactions(
for rxn in reactions:
try:
stoichiometry = {
met2cmpnd[met]: coef for met, coef in rxn.metabolites.items()
met2cmpnd[met.id]: coef for met, coef in rxn.metabolites.items()
}
except KeyError:
logger.warning("Incomplete compound stoichiometry in '%s'.", rxn.id)
continue
mapping[rxn] = PhasedReaction(
mapping[rxn.id] = PhasedReaction(
sparse=stoichiometry,
arrow="<=>" if rxn.reversibility else "=>",
rid=rxn.id,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment