Skip to content

Commit

Permalink
rename biomass_function to objective_function
Browse files Browse the repository at this point in the history
  • Loading branch information
hritikb committed Apr 24, 2024
1 parent c51f0a5 commit a39608f
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 25 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ You could also set an alternative objective function. For example, to maximize t
n = model.num_of_reactions()
obj_fun = np.zeros(n)
obj_fun[0] = 1
model.biomass_function(obj_fun)
model.objective_function(obj_fun)

# apply FVA using the new objective function
fva_output = model.fva()
Expand Down
26 changes: 13 additions & 13 deletions dingo/MetabolicNetwork.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def __init__(self, tuple_args):
self._metabolites = tuple_args[3]
self._reactions = tuple_args[4]
self._biomass_index = tuple_args[5]
self._biomass_function = tuple_args[6]
self._objective_function = tuple_args[6]
self._medium = tuple_args[7]
self._medium_indices = tuple_args[8]
self._exchanges = tuple_args[9]
Expand All @@ -58,9 +58,9 @@ def __init__(self, tuple_args):
or self._lb.size != self._S.shape[1]
or len(self._metabolites) != self._S.shape[0]
or len(self._reactions) != self._S.shape[1]
or self._biomass_function.size != self._S.shape[1]
or self._objective_function.size != self._S.shape[1]
or (self._biomass_index < 0)
or (self._biomass_index > self._biomass_function.size)
or (self._biomass_index > self._objective_function.size)
):
raise Exception(
"Wrong tuple format given to initialize a metabolic network object."
Expand Down Expand Up @@ -112,25 +112,25 @@ def fva(self):
self._lb,
self._ub,
self._S,
self._biomass_function,
self._objective_function,
self._parameters["opt_percentage"],
)
else:
return slow_fva(
self._lb,
self._ub,
self._S,
self._biomass_function,
self._objective_function,
self._parameters["opt_percentage"],
)

def fba(self):
"""A member function to apply the FBA method on the metabolic network."""

if self._parameters["fast_computations"]:
return fast_fba(self._lb, self._ub, self._S, self._biomass_function)
return fast_fba(self._lb, self._ub, self._S, self._objective_function)
else:
return slow_fba(self._lb, self._ub, self._S, self._biomass_function)
return slow_fba(self._lb, self._ub, self._S, self._objective_function)

@property
def lb(self):
Expand All @@ -157,8 +157,8 @@ def biomass_index(self):
return self._biomass_index

@property
def biomass_function(self):
return self._biomass_function
def objective_function(self):
return self._objective_function

@property
def medium(self):
Expand All @@ -181,7 +181,7 @@ def get_as_tuple(self):
self._metabolites,
self._reactions,
self._biomass_index,
self._biomass_function,
self._objective_function,
self._medium,
self._inter_medium,
self._exchanges
Expand Down Expand Up @@ -217,9 +217,9 @@ def reactions(self, value):
def biomass_index(self, value):
self._biomass_index = value

@biomass_function.setter
def biomass_function(self, value):
self._biomass_function = value
@objective_function.setter
def objective_function(self, value):
self._objective_function = value


@medium.setter
Expand Down
10 changes: 5 additions & 5 deletions dingo/PolytopeSampler.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def get_polytope(self):
self._metabolic_network.lb,
self._metabolic_network.ub,
self._metabolic_network.S,
self._metabolic_network.biomass_function,
self._metabolic_network.objective_function,
self._parameters["opt_percentage"],
)
else:
Expand Down Expand Up @@ -123,7 +123,7 @@ def get_polytope(self):
):
raise Exception("Preprocess for full dimensional polytope failed.")

A = np.vstack((A, -self._metabolic_network.biomass_function))
A = np.vstack((A, -self._metabolic_network.objective_function))

b = np.append(
b,
Expand Down Expand Up @@ -293,7 +293,7 @@ def round_polytope(
def sample_from_fva_output(
min_fluxes,
max_fluxes,
biomass_function,
objective_function,
max_biomass_objective,
S,
opt_percentage=100,
Expand All @@ -307,7 +307,7 @@ def sample_from_fva_output(
Keyword arguments:
min_fluxes -- minimum values of the fluxes, i.e., a n-dimensional vector
max_fluxes -- maximum values for the fluxes, i.e., a n-dimensional vector
biomass_function -- the biomass objective function
objective_function -- the biomass objective function
max_biomass_objective -- the maximum value of the biomass objective function
S -- stoichiometric matrix
opt_percentage -- consider solutions that give you at least a certain
Expand All @@ -323,7 +323,7 @@ def sample_from_fva_output(
S, min_fluxes, max_fluxes, opt_percentage, tol
)

A = np.vstack((A, -biomass_function))
A = np.vstack((A, -objective_function))
b = np.append(
b,
-(opt_percentage / 100)
Expand Down
12 changes: 6 additions & 6 deletions tutorials/dingo_tutorial.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -874,7 +874,7 @@
},
"outputs": [],
"source": [
"model.biomass_function"
"model.objective_function"
]
},
{
Expand Down Expand Up @@ -1118,7 +1118,7 @@
"id": "jWEhcWmJm1Qu"
},
"source": [
"Now we can replace the `biomass_function` parameter of our model with our new objective function"
"Now we can replace the `objective_function` parameter of our model with our new objective function"
]
},
{
Expand All @@ -1129,7 +1129,7 @@
},
"outputs": [],
"source": [
"model.biomass_function = obj_fun"
"model.objective_function = obj_fun"
]
},
{
Expand All @@ -1153,7 +1153,7 @@
},
"outputs": [],
"source": [
"model.biomass_function"
"model.objective_function"
]
},
{
Expand Down Expand Up @@ -1249,7 +1249,7 @@
"\n",
"**Remember!** \n",
"\n",
"In the previous step, we replaced the `biomass_function` of our model. So if we run FVA in our current model, then the first reaction of our model "
"In the previous step, we replaced the `objective_function` of our model. So if we run FVA in our current model, then the first reaction of our model "
]
},
{
Expand Down Expand Up @@ -1279,7 +1279,7 @@
"id": "qGVto8ckp7LS"
},
"source": [
"We can go with that or if we need to go back in using the actual biomass function of our model, we can either do the same process as before to change again the `biomass_function` or we can just build a new instance of the `MetabolicNetwork` class. "
"We can go with that or if we need to go back in using the actual biomass function of our model, we can either do the same process as before to change again the `objective_function` or we can just build a new instance of the `MetabolicNetwork` class. "
]
},
{
Expand Down

0 comments on commit a39608f

Please sign in to comment.