Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 27 additions & 31 deletions modelseedpy/fbapkg/flexiblebiomasspkg.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,11 @@ def build_package(self, parameters):
newrxns = []
class_coef = {"rna": {}, "dna": {}, "protein": {}, "energy": {}}
refcpd = {
"cpd00001": None,
"cpd00009": None,
"cpd00012": None,
"cpd00067": None,
"cpd00002": None,
"cpd00001": None, # Water
"cpd00009": None, # Orthophosphate
"cpd00012": None, # Pyrophosphate
"cpd00067": None, # Proton
"cpd00002": None, # ATP
}
# Finding all reference compounds in the model
msid_hash = self.modelutl.msid_hash()
Expand All @@ -94,10 +94,10 @@ def build_package(self, parameters):
met_class[metabolite] = None
msid = MSModelUtil.metabolite_msid(metabolite)
if (
msid != "cpd11416"
and msid != "cpd11463"
and msid != "cpd11462"
and msid != "cpd11461"
msid != "cpd11416" # Biomass
and msid != "cpd11463" # Protein
and msid != "cpd11462" # RNA
and msid != "cpd11461" # DNA
and msid != None
):
if msid in refcpd:
Expand Down Expand Up @@ -209,7 +209,7 @@ def build_package(self, parameters):
self.build_constraint(
self.new_reactions[met_class + "_flex"], "flxcls"
)
if parameters["add_total_biomass_constraint"]:
if self.parameters["add_total_biomass_constraint"]:
self.build_constraint(self.parameters["bio_rxn"], "flxbio")

def build_variable(self, object, type): # !!! can the function be removed?
Expand Down Expand Up @@ -254,7 +254,7 @@ def build_constraint(self, cobra_obj, obj_type):
if abs(massdiff) > 0.00001:
coef[rxn.forward_variable] = massdiff
coef[rxn.reverse_variable] = -massdiff
return BaseFBAPkg.build_constraint(self, obj_type, 0, 0, coef, cobra_obj)
return super().build_constraint(obj_type, 0, 0, coef, cobra_obj)
elif obj_type == "flxcpd" or obj_type == "flxcls":
first_entry = None
second_entry = None
Expand Down Expand Up @@ -293,7 +293,7 @@ def build_constraint(self, cobra_obj, obj_type):
# If the value is positive, lock in the forward variable and set the reverse to zero
if first_entry > 0:
if product:
const = self.build_constraint(
const = super().build_constraint(
"f" + obj_type,
0,
0,
Expand All @@ -302,7 +302,7 @@ def build_constraint(self, cobra_obj, obj_type):
)
object.lower_bound = 0
else:
const = self.build_constraint(
const = super().build_constraint(
"f" + obj_type,
0,
0,
Expand All @@ -313,7 +313,7 @@ def build_constraint(self, cobra_obj, obj_type):
# If the value is negative, lock in the reverse variable and set the forward to zero
elif first_entry < 0:
if product:
const = self.build_constraint(
const = super().build_constraint(
"r" + obj_type,
0,
0,
Expand All @@ -322,7 +322,7 @@ def build_constraint(self, cobra_obj, obj_type):
)
object.upper_bound = 0
else:
const = self.build_constraint(
const = super().build_constraint(
"r" + obj_type,
0,
0,
Expand All @@ -337,8 +337,7 @@ def build_constraint(self, cobra_obj, obj_type):
elif second_entry >= 0:
if first_entry >= 0:
if product:
const = BaseFBAPkg.build_constraint(
self,
const = super().build_constraint(
"f" + obj_type,
0,
None,
Expand All @@ -347,17 +346,15 @@ def build_constraint(self, cobra_obj, obj_type):
)
object.lower_bound = 0
if first_entry > 0:
BaseFBAPkg.build_constraint(
self,
super().build_constraint(
"r" + obj_type,
0,
None,
{biovar: -first_entry, object.forward_variable: 1},
cobra_obj,
)
else:
const = BaseFBAPkg.build_constraint(
self,
const = super().build_constraint(
"f" + obj_type,
0,
None,
Expand All @@ -366,8 +363,7 @@ def build_constraint(self, cobra_obj, obj_type):
)
object.upper_bound = 0
if first_entry > 0:
BaseFBAPkg.build_constraint(
self,
super().build_constraint(
"r" + obj_type,
0,
None,
Expand All @@ -376,29 +372,29 @@ def build_constraint(self, cobra_obj, obj_type):
)
else:
if product:
const = self.build_constraint(
const = super().build_constraint(
"f" + obj_type,
0,
None,
{biovar: second_entry, object.forward_variable: -1},
cobra_obj,
)
self.build_constraint(
super().build_constraint(
"r" + obj_type,
0,
None,
{biovar: -first_entry, object.reverse_variable: -1},
cobra_obj,
)
else:
const = self.build_constraint(
const = super().build_constraint(
"f" + obj_type,
0,
None,
{biovar: second_entry, object.reverse_variable: -1},
cobra_obj,
)
self.build_constraint(
super().build_constraint(
"r" + obj_type,
0,
None,
Expand All @@ -408,23 +404,23 @@ def build_constraint(self, cobra_obj, obj_type):
else:
if second_entry < 0:
if product:
const = self.build_constraint(
const = super().build_constraint(
"f" + obj_type,
0,
None,
{biovar: second_entry, object.reverse_variable: 1},
cobra_obj,
)
else:
const = self.build_constraint(
const = super().build_constraint(
"f" + obj_type,
0,
None,
{biovar: second_entry, object.forward_variable: 1},
cobra_obj,
)
if product:
self.build_constraint(
super().build_constraint(
"r" + obj_type,
0,
None,
Expand All @@ -433,7 +429,7 @@ def build_constraint(self, cobra_obj, obj_type):
)
object.lower_bound = 0
else:
self.build_constraint(
super().build_constraint(
"r" + obj_type,
0,
None,
Expand Down
Loading