File tree 2 files changed +13
-1
lines changed
2 files changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -1615,7 +1615,7 @@ def build_reaction_from_string(
1615
1615
except KeyError :
1616
1616
if verbose :
1617
1617
print (f"unknown metabolite '{ met_id } ' created" )
1618
- met = Metabolite (met_id )
1618
+ met = Metabolite (met_id , compartment = compartment or None )
1619
1619
self .add_metabolites ({met : num })
1620
1620
1621
1621
def summary (
Original file line number Diff line number Diff line change @@ -380,6 +380,18 @@ def test_build_from_string(model: Model) -> None:
380
380
assert pgi .bounds == (0 , 1000 )
381
381
382
382
383
+ def test_build_from_string_creating_metabolites () -> None :
384
+ # https://github.com/opencobra/cobrapy/issues/1418
385
+ model = Model ()
386
+ reaction = Reaction ("R1" )
387
+ model .add_reactions ([reaction ])
388
+ reaction .build_reaction_from_string ("[c]: a --> b" )
389
+ assert len (model .metabolites ) == 2
390
+ assert model .metabolites .a .compartment == "c"
391
+ assert model .metabolites .b .compartment == "c"
392
+ assert model .reaction .R1 .compartments == set (["c" ])
393
+
394
+
383
395
def test_bounds_setter (model : Model ) -> None :
384
396
"""Test reaction bounds setter."""
385
397
rxn = model .reactions .get_by_id ("PGI" )
You can’t perform that action at this time.
0 commit comments