partition
stringclasses
3 values
func_name
stringlengths
1
134
docstring
stringlengths
1
46.9k
path
stringlengths
4
223
original_string
stringlengths
75
104k
code
stringlengths
75
104k
docstring_tokens
listlengths
1
1.97k
repo
stringlengths
7
55
language
stringclasses
1 value
url
stringlengths
87
315
code_tokens
listlengths
19
28.4k
sha
stringlengths
40
40
valid
add_absolute_expression
Add the absolute value of an expression to the model. Also defines a variable for the absolute value that can be used in other objectives or constraints. Parameters ---------- model : a cobra model The model to which to add the absolute expression. expression : A sympy expression ...
cobra/util/solver.py
def add_absolute_expression(model, expression, name="abs_var", ub=None, difference=0, add=True): """Add the absolute value of an expression to the model. Also defines a variable for the absolute value that can be used in other objectives or constraints. Parameters -----...
def add_absolute_expression(model, expression, name="abs_var", ub=None, difference=0, add=True): """Add the absolute value of an expression to the model. Also defines a variable for the absolute value that can be used in other objectives or constraints. Parameters -----...
[ "Add", "the", "absolute", "value", "of", "an", "expression", "to", "the", "model", "." ]
opencobra/cobrapy
python
https://github.com/opencobra/cobrapy/blob/9d1987cdb3a395cf4125a3439c3b002ff2be2009/cobra/util/solver.py#L316-L360
[ "def", "add_absolute_expression", "(", "model", ",", "expression", ",", "name", "=", "\"abs_var\"", ",", "ub", "=", "None", ",", "difference", "=", "0", ",", "add", "=", "True", ")", ":", "Components", "=", "namedtuple", "(", "'Components'", ",", "[", "'...
9d1987cdb3a395cf4125a3439c3b002ff2be2009
valid
fix_objective_as_constraint
Fix current objective as an additional constraint. When adding constraints to a model, such as done in pFBA which minimizes total flux, these constraints can become too powerful, resulting in solutions that satisfy optimality but sacrifices too much for the original objective function. To avoid that, w...
cobra/util/solver.py
def fix_objective_as_constraint(model, fraction=1, bound=None, name='fixed_objective_{}'): """Fix current objective as an additional constraint. When adding constraints to a model, such as done in pFBA which minimizes total flux, these constraints can become too powerful, ...
def fix_objective_as_constraint(model, fraction=1, bound=None, name='fixed_objective_{}'): """Fix current objective as an additional constraint. When adding constraints to a model, such as done in pFBA which minimizes total flux, these constraints can become too powerful, ...
[ "Fix", "current", "objective", "as", "an", "additional", "constraint", "." ]
opencobra/cobrapy
python
https://github.com/opencobra/cobrapy/blob/9d1987cdb3a395cf4125a3439c3b002ff2be2009/cobra/util/solver.py#L363-L408
[ "def", "fix_objective_as_constraint", "(", "model", ",", "fraction", "=", "1", ",", "bound", "=", "None", ",", "name", "=", "'fixed_objective_{}'", ")", ":", "fix_objective_name", "=", "name", ".", "format", "(", "model", ".", "objective", ".", "name", ")", ...
9d1987cdb3a395cf4125a3439c3b002ff2be2009
valid
check_solver_status
Perform standard checks on a solver's status.
cobra/util/solver.py
def check_solver_status(status, raise_error=False): """Perform standard checks on a solver's status.""" if status == OPTIMAL: return elif (status in has_primals) and not raise_error: warn("solver status is '{}'".format(status), UserWarning) elif status is None: raise Optimization...
def check_solver_status(status, raise_error=False): """Perform standard checks on a solver's status.""" if status == OPTIMAL: return elif (status in has_primals) and not raise_error: warn("solver status is '{}'".format(status), UserWarning) elif status is None: raise Optimization...
[ "Perform", "standard", "checks", "on", "a", "solver", "s", "status", "." ]
opencobra/cobrapy
python
https://github.com/opencobra/cobrapy/blob/9d1987cdb3a395cf4125a3439c3b002ff2be2009/cobra/util/solver.py#L411-L421
[ "def", "check_solver_status", "(", "status", ",", "raise_error", "=", "False", ")", ":", "if", "status", "==", "OPTIMAL", ":", "return", "elif", "(", "status", "in", "has_primals", ")", "and", "not", "raise_error", ":", "warn", "(", "\"solver status is '{}'\""...
9d1987cdb3a395cf4125a3439c3b002ff2be2009
valid
assert_optimal
Assert model solver status is optimal. Do nothing if model solver status is optimal, otherwise throw appropriate exception depending on the status. Parameters ---------- model : cobra.Model The model to check the solver status for. message : str (optional) Message to for the ex...
cobra/util/solver.py
def assert_optimal(model, message='optimization failed'): """Assert model solver status is optimal. Do nothing if model solver status is optimal, otherwise throw appropriate exception depending on the status. Parameters ---------- model : cobra.Model The model to check the solver statu...
def assert_optimal(model, message='optimization failed'): """Assert model solver status is optimal. Do nothing if model solver status is optimal, otherwise throw appropriate exception depending on the status. Parameters ---------- model : cobra.Model The model to check the solver statu...
[ "Assert", "model", "solver", "status", "is", "optimal", "." ]
opencobra/cobrapy
python
https://github.com/opencobra/cobrapy/blob/9d1987cdb3a395cf4125a3439c3b002ff2be2009/cobra/util/solver.py#L424-L441
[ "def", "assert_optimal", "(", "model", ",", "message", "=", "'optimization failed'", ")", ":", "status", "=", "model", ".", "solver", ".", "status", "if", "status", "!=", "OPTIMAL", ":", "exception_cls", "=", "OPTLANG_TO_EXCEPTIONS_DICT", ".", "get", "(", "sta...
9d1987cdb3a395cf4125a3439c3b002ff2be2009
valid
add_lp_feasibility
Add a new objective and variables to ensure a feasible solution. The optimized objective will be zero for a feasible solution and otherwise represent the distance from feasibility (please see [1]_ for more information). Parameters ---------- model : cobra.Model The model whose feasibil...
cobra/util/solver.py
def add_lp_feasibility(model): """ Add a new objective and variables to ensure a feasible solution. The optimized objective will be zero for a feasible solution and otherwise represent the distance from feasibility (please see [1]_ for more information). Parameters ---------- model : c...
def add_lp_feasibility(model): """ Add a new objective and variables to ensure a feasible solution. The optimized objective will be zero for a feasible solution and otherwise represent the distance from feasibility (please see [1]_ for more information). Parameters ---------- model : c...
[ "Add", "a", "new", "objective", "and", "variables", "to", "ensure", "a", "feasible", "solution", "." ]
opencobra/cobrapy
python
https://github.com/opencobra/cobrapy/blob/9d1987cdb3a395cf4125a3439c3b002ff2be2009/cobra/util/solver.py#L444-L479
[ "def", "add_lp_feasibility", "(", "model", ")", ":", "obj_vars", "=", "[", "]", "prob", "=", "model", ".", "problem", "for", "met", "in", "model", ".", "metabolites", ":", "s_plus", "=", "prob", ".", "Variable", "(", "\"s_plus_\"", "+", "met", ".", "id...
9d1987cdb3a395cf4125a3439c3b002ff2be2009
valid
add_lexicographic_constraints
Successively optimize separate targets in a specific order. For each objective, optimize the model and set the optimal value as a constraint. Proceed in the order of the objectives given. Due to the specific order this is called lexicographic FBA [1]_. This procedure is useful for returning unique solu...
cobra/util/solver.py
def add_lexicographic_constraints(model, objectives, objective_direction='max'): """ Successively optimize separate targets in a specific order. For each objective, optimize the model and set the optimal value as a constraint. Proceed ...
def add_lexicographic_constraints(model, objectives, objective_direction='max'): """ Successively optimize separate targets in a specific order. For each objective, optimize the model and set the optimal value as a constraint. Proceed ...
[ "Successively", "optimize", "separate", "targets", "in", "a", "specific", "order", "." ]
opencobra/cobrapy
python
https://github.com/opencobra/cobrapy/blob/9d1987cdb3a395cf4125a3439c3b002ff2be2009/cobra/util/solver.py#L482-L529
[ "def", "add_lexicographic_constraints", "(", "model", ",", "objectives", ",", "objective_direction", "=", "'max'", ")", ":", "if", "type", "(", "objective_direction", ")", "is", "not", "list", ":", "objective_direction", "=", "[", "objective_direction", "]", "*", ...
9d1987cdb3a395cf4125a3439c3b002ff2be2009
valid
shared_np_array
Create a new numpy array that resides in shared memory. Parameters ---------- shape : tuple of ints The shape of the new array. data : numpy.array Data to copy to the new array. Has to have the same shape. integer : boolean Whether to use an integer array. Defaults to False ...
cobra/sampling/hr_sampler.py
def shared_np_array(shape, data=None, integer=False): """Create a new numpy array that resides in shared memory. Parameters ---------- shape : tuple of ints The shape of the new array. data : numpy.array Data to copy to the new array. Has to have the same shape. integer : boolea...
def shared_np_array(shape, data=None, integer=False): """Create a new numpy array that resides in shared memory. Parameters ---------- shape : tuple of ints The shape of the new array. data : numpy.array Data to copy to the new array. Has to have the same shape. integer : boolea...
[ "Create", "a", "new", "numpy", "array", "that", "resides", "in", "shared", "memory", "." ]
opencobra/cobrapy
python
https://github.com/opencobra/cobrapy/blob/9d1987cdb3a395cf4125a3439c3b002ff2be2009/cobra/sampling/hr_sampler.py#L59-L96
[ "def", "shared_np_array", "(", "shape", ",", "data", "=", "None", ",", "integer", "=", "False", ")", ":", "size", "=", "np", ".", "prod", "(", "shape", ")", "if", "integer", ":", "array", "=", "Array", "(", "ctypes", ".", "c_int64", ",", "int", "("...
9d1987cdb3a395cf4125a3439c3b002ff2be2009
valid
step
Sample a new feasible point from the point `x` in direction `delta`.
cobra/sampling/hr_sampler.py
def step(sampler, x, delta, fraction=None, tries=0): """Sample a new feasible point from the point `x` in direction `delta`.""" prob = sampler.problem valid = ((np.abs(delta) > sampler.feasibility_tol) & np.logical_not(prob.variable_fixed)) # permissible alphas for staying in variable bou...
def step(sampler, x, delta, fraction=None, tries=0): """Sample a new feasible point from the point `x` in direction `delta`.""" prob = sampler.problem valid = ((np.abs(delta) > sampler.feasibility_tol) & np.logical_not(prob.variable_fixed)) # permissible alphas for staying in variable bou...
[ "Sample", "a", "new", "feasible", "point", "from", "the", "point", "x", "in", "direction", "delta", "." ]
opencobra/cobrapy
python
https://github.com/opencobra/cobrapy/blob/9d1987cdb3a395cf4125a3439c3b002ff2be2009/cobra/sampling/hr_sampler.py#L497-L552
[ "def", "step", "(", "sampler", ",", "x", ",", "delta", ",", "fraction", "=", "None", ",", "tries", "=", "0", ")", ":", "prob", "=", "sampler", ".", "problem", "valid", "=", "(", "(", "np", ".", "abs", "(", "delta", ")", ">", "sampler", ".", "fe...
9d1987cdb3a395cf4125a3439c3b002ff2be2009
valid
HRSampler.__build_problem
Build the matrix representation of the sampling problem.
cobra/sampling/hr_sampler.py
def __build_problem(self): """Build the matrix representation of the sampling problem.""" # Set up the mathematical problem prob = constraint_matrices(self.model, zero_tol=self.feasibility_tol) # check if there any non-zero equality constraints equalities = prob.equalities ...
def __build_problem(self): """Build the matrix representation of the sampling problem.""" # Set up the mathematical problem prob = constraint_matrices(self.model, zero_tol=self.feasibility_tol) # check if there any non-zero equality constraints equalities = prob.equalities ...
[ "Build", "the", "matrix", "representation", "of", "the", "sampling", "problem", "." ]
opencobra/cobrapy
python
https://github.com/opencobra/cobrapy/blob/9d1987cdb3a395cf4125a3439c3b002ff2be2009/cobra/sampling/hr_sampler.py#L194-L236
[ "def", "__build_problem", "(", "self", ")", ":", "# Set up the mathematical problem", "prob", "=", "constraint_matrices", "(", "self", ".", "model", ",", "zero_tol", "=", "self", ".", "feasibility_tol", ")", "# check if there any non-zero equality constraints", "equalitie...
9d1987cdb3a395cf4125a3439c3b002ff2be2009
valid
HRSampler.generate_fva_warmup
Generate the warmup points for the sampler. Generates warmup points by setting each flux as the sole objective and minimizing/maximizing it. Also caches the projection of the warmup points into the nullspace for non-homogeneous problems (only if necessary).
cobra/sampling/hr_sampler.py
def generate_fva_warmup(self): """Generate the warmup points for the sampler. Generates warmup points by setting each flux as the sole objective and minimizing/maximizing it. Also caches the projection of the warmup points into the nullspace for non-homogeneous problems (only if...
def generate_fva_warmup(self): """Generate the warmup points for the sampler. Generates warmup points by setting each flux as the sole objective and minimizing/maximizing it. Also caches the projection of the warmup points into the nullspace for non-homogeneous problems (only if...
[ "Generate", "the", "warmup", "points", "for", "the", "sampler", "." ]
opencobra/cobrapy
python
https://github.com/opencobra/cobrapy/blob/9d1987cdb3a395cf4125a3439c3b002ff2be2009/cobra/sampling/hr_sampler.py#L238-L306
[ "def", "generate_fva_warmup", "(", "self", ")", ":", "self", ".", "n_warmup", "=", "0", "reactions", "=", "self", ".", "model", ".", "reactions", "self", ".", "warmup", "=", "np", ".", "zeros", "(", "(", "2", "*", "len", "(", "reactions", ")", ",", ...
9d1987cdb3a395cf4125a3439c3b002ff2be2009
valid
HRSampler._reproject
Reproject a point into the feasibility region. This function is guaranteed to return a new feasible point. However, no guarantees in terms of proximity to the original point can be made. Parameters ---------- p : numpy.array The current sample point. Return...
cobra/sampling/hr_sampler.py
def _reproject(self, p): """Reproject a point into the feasibility region. This function is guaranteed to return a new feasible point. However, no guarantees in terms of proximity to the original point can be made. Parameters ---------- p : numpy.array The c...
def _reproject(self, p): """Reproject a point into the feasibility region. This function is guaranteed to return a new feasible point. However, no guarantees in terms of proximity to the original point can be made. Parameters ---------- p : numpy.array The c...
[ "Reproject", "a", "point", "into", "the", "feasibility", "region", "." ]
opencobra/cobrapy
python
https://github.com/opencobra/cobrapy/blob/9d1987cdb3a395cf4125a3439c3b002ff2be2009/cobra/sampling/hr_sampler.py#L308-L345
[ "def", "_reproject", "(", "self", ",", "p", ")", ":", "nulls", "=", "self", ".", "problem", ".", "nullspace", "equalities", "=", "self", ".", "problem", ".", "equalities", "# don't reproject if point is feasible", "if", "np", ".", "allclose", "(", "equalities"...
9d1987cdb3a395cf4125a3439c3b002ff2be2009
valid
HRSampler._random_point
Find an approximately random point in the flux cone.
cobra/sampling/hr_sampler.py
def _random_point(self): """Find an approximately random point in the flux cone.""" idx = np.random.randint(self.n_warmup, size=min(2, np.ceil(np.sqrt(self.n_warmup)))) return self.warmup[idx, :].mean(axis=0)
def _random_point(self): """Find an approximately random point in the flux cone.""" idx = np.random.randint(self.n_warmup, size=min(2, np.ceil(np.sqrt(self.n_warmup)))) return self.warmup[idx, :].mean(axis=0)
[ "Find", "an", "approximately", "random", "point", "in", "the", "flux", "cone", "." ]
opencobra/cobrapy
python
https://github.com/opencobra/cobrapy/blob/9d1987cdb3a395cf4125a3439c3b002ff2be2009/cobra/sampling/hr_sampler.py#L347-L352
[ "def", "_random_point", "(", "self", ")", ":", "idx", "=", "np", ".", "random", ".", "randint", "(", "self", ".", "n_warmup", ",", "size", "=", "min", "(", "2", ",", "np", ".", "ceil", "(", "np", ".", "sqrt", "(", "self", ".", "n_warmup", ")", ...
9d1987cdb3a395cf4125a3439c3b002ff2be2009
valid
HRSampler._is_redundant
Identify rdeundant rows in a matrix that can be removed.
cobra/sampling/hr_sampler.py
def _is_redundant(self, matrix, cutoff=None): """Identify rdeundant rows in a matrix that can be removed.""" cutoff = 1.0 - self.feasibility_tol # Avoid zero variances extra_col = matrix[:, 0] + 1 # Avoid zero rows being correlated with constant rows extra_col[matrix.s...
def _is_redundant(self, matrix, cutoff=None): """Identify rdeundant rows in a matrix that can be removed.""" cutoff = 1.0 - self.feasibility_tol # Avoid zero variances extra_col = matrix[:, 0] + 1 # Avoid zero rows being correlated with constant rows extra_col[matrix.s...
[ "Identify", "rdeundant", "rows", "in", "a", "matrix", "that", "can", "be", "removed", "." ]
opencobra/cobrapy
python
https://github.com/opencobra/cobrapy/blob/9d1987cdb3a395cf4125a3439c3b002ff2be2009/cobra/sampling/hr_sampler.py#L354-L367
[ "def", "_is_redundant", "(", "self", ",", "matrix", ",", "cutoff", "=", "None", ")", ":", "cutoff", "=", "1.0", "-", "self", ".", "feasibility_tol", "# Avoid zero variances", "extra_col", "=", "matrix", "[", ":", ",", "0", "]", "+", "1", "# Avoid zero rows...
9d1987cdb3a395cf4125a3439c3b002ff2be2009
valid
HRSampler._bounds_dist
Get the lower and upper bound distances. Negative is bad.
cobra/sampling/hr_sampler.py
def _bounds_dist(self, p): """Get the lower and upper bound distances. Negative is bad.""" prob = self.problem lb_dist = (p - prob.variable_bounds[0, ]).min() ub_dist = (prob.variable_bounds[1, ] - p).min() if prob.bounds.shape[0] > 0: const = prob.inequalities.dot(...
def _bounds_dist(self, p): """Get the lower and upper bound distances. Negative is bad.""" prob = self.problem lb_dist = (p - prob.variable_bounds[0, ]).min() ub_dist = (prob.variable_bounds[1, ] - p).min() if prob.bounds.shape[0] > 0: const = prob.inequalities.dot(...
[ "Get", "the", "lower", "and", "upper", "bound", "distances", ".", "Negative", "is", "bad", "." ]
opencobra/cobrapy
python
https://github.com/opencobra/cobrapy/blob/9d1987cdb3a395cf4125a3439c3b002ff2be2009/cobra/sampling/hr_sampler.py#L369-L383
[ "def", "_bounds_dist", "(", "self", ",", "p", ")", ":", "prob", "=", "self", ".", "problem", "lb_dist", "=", "(", "p", "-", "prob", ".", "variable_bounds", "[", "0", ",", "]", ")", ".", "min", "(", ")", "ub_dist", "=", "(", "prob", ".", "variable...
9d1987cdb3a395cf4125a3439c3b002ff2be2009
valid
HRSampler.batch
Create a batch generator. This is useful to generate n batches of m samples each. Parameters ---------- batch_size : int The number of samples contained in each batch (m). batch_num : int The number of batches in the generator (n). fluxes : boole...
cobra/sampling/hr_sampler.py
def batch(self, batch_size, batch_num, fluxes=True): """Create a batch generator. This is useful to generate n batches of m samples each. Parameters ---------- batch_size : int The number of samples contained in each batch (m). batch_num : int Th...
def batch(self, batch_size, batch_num, fluxes=True): """Create a batch generator. This is useful to generate n batches of m samples each. Parameters ---------- batch_size : int The number of samples contained in each batch (m). batch_num : int Th...
[ "Create", "a", "batch", "generator", "." ]
opencobra/cobrapy
python
https://github.com/opencobra/cobrapy/blob/9d1987cdb3a395cf4125a3439c3b002ff2be2009/cobra/sampling/hr_sampler.py#L393-L420
[ "def", "batch", "(", "self", ",", "batch_size", ",", "batch_num", ",", "fluxes", "=", "True", ")", ":", "for", "i", "in", "range", "(", "batch_num", ")", ":", "yield", "self", ".", "sample", "(", "batch_size", ",", "fluxes", "=", "fluxes", ")" ]
9d1987cdb3a395cf4125a3439c3b002ff2be2009
valid
HRSampler.validate
Validate a set of samples for equality and inequality feasibility. Can be used to check whether the generated samples and warmup points are feasible. Parameters ---------- samples : numpy.matrix Must be of dimension (n_samples x n_reactions). Contains the ...
cobra/sampling/hr_sampler.py
def validate(self, samples): """Validate a set of samples for equality and inequality feasibility. Can be used to check whether the generated samples and warmup points are feasible. Parameters ---------- samples : numpy.matrix Must be of dimension (n_samples...
def validate(self, samples): """Validate a set of samples for equality and inequality feasibility. Can be used to check whether the generated samples and warmup points are feasible. Parameters ---------- samples : numpy.matrix Must be of dimension (n_samples...
[ "Validate", "a", "set", "of", "samples", "for", "equality", "and", "inequality", "feasibility", "." ]
opencobra/cobrapy
python
https://github.com/opencobra/cobrapy/blob/9d1987cdb3a395cf4125a3439c3b002ff2be2009/cobra/sampling/hr_sampler.py#L422-L492
[ "def", "validate", "(", "self", ",", "samples", ")", ":", "samples", "=", "np", ".", "atleast_2d", "(", "samples", ")", "prob", "=", "self", ".", "problem", "if", "samples", ".", "shape", "[", "1", "]", "==", "len", "(", "self", ".", "model", ".", ...
9d1987cdb3a395cf4125a3439c3b002ff2be2009
valid
prune_unused_metabolites
Remove metabolites that are not involved in any reactions and returns pruned model Parameters ---------- cobra_model: class:`~cobra.core.Model.Model` object the model to remove unused metabolites from Returns ------- output_model: class:`~cobra.core.Model.Model` object inpu...
cobra/manipulation/delete.py
def prune_unused_metabolites(cobra_model): """Remove metabolites that are not involved in any reactions and returns pruned model Parameters ---------- cobra_model: class:`~cobra.core.Model.Model` object the model to remove unused metabolites from Returns ------- output_model: c...
def prune_unused_metabolites(cobra_model): """Remove metabolites that are not involved in any reactions and returns pruned model Parameters ---------- cobra_model: class:`~cobra.core.Model.Model` object the model to remove unused metabolites from Returns ------- output_model: c...
[ "Remove", "metabolites", "that", "are", "not", "involved", "in", "any", "reactions", "and", "returns", "pruned", "model" ]
opencobra/cobrapy
python
https://github.com/opencobra/cobrapy/blob/9d1987cdb3a395cf4125a3439c3b002ff2be2009/cobra/manipulation/delete.py#L12-L33
[ "def", "prune_unused_metabolites", "(", "cobra_model", ")", ":", "output_model", "=", "cobra_model", ".", "copy", "(", ")", "inactive_metabolites", "=", "[", "m", "for", "m", "in", "output_model", ".", "metabolites", "if", "len", "(", "m", ".", "reactions", ...
9d1987cdb3a395cf4125a3439c3b002ff2be2009
valid
prune_unused_reactions
Remove reactions with no assigned metabolites, returns pruned model Parameters ---------- cobra_model: class:`~cobra.core.Model.Model` object the model to remove unused reactions from Returns ------- output_model: class:`~cobra.core.Model.Model` object input model with unused r...
cobra/manipulation/delete.py
def prune_unused_reactions(cobra_model): """Remove reactions with no assigned metabolites, returns pruned model Parameters ---------- cobra_model: class:`~cobra.core.Model.Model` object the model to remove unused reactions from Returns ------- output_model: class:`~cobra.core.Model...
def prune_unused_reactions(cobra_model): """Remove reactions with no assigned metabolites, returns pruned model Parameters ---------- cobra_model: class:`~cobra.core.Model.Model` object the model to remove unused reactions from Returns ------- output_model: class:`~cobra.core.Model...
[ "Remove", "reactions", "with", "no", "assigned", "metabolites", "returns", "pruned", "model" ]
opencobra/cobrapy
python
https://github.com/opencobra/cobrapy/blob/9d1987cdb3a395cf4125a3439c3b002ff2be2009/cobra/manipulation/delete.py#L36-L56
[ "def", "prune_unused_reactions", "(", "cobra_model", ")", ":", "output_model", "=", "cobra_model", ".", "copy", "(", ")", "reactions_to_prune", "=", "[", "r", "for", "r", "in", "output_model", ".", "reactions", "if", "len", "(", "r", ".", "metabolites", ")",...
9d1987cdb3a395cf4125a3439c3b002ff2be2009
valid
undelete_model_genes
Undoes the effects of a call to delete_model_genes in place. cobra_model: A cobra.Model which will be modified in place
cobra/manipulation/delete.py
def undelete_model_genes(cobra_model): """Undoes the effects of a call to delete_model_genes in place. cobra_model: A cobra.Model which will be modified in place """ if cobra_model._trimmed_genes is not None: for x in cobra_model._trimmed_genes: x.functional = True if cobra_...
def undelete_model_genes(cobra_model): """Undoes the effects of a call to delete_model_genes in place. cobra_model: A cobra.Model which will be modified in place """ if cobra_model._trimmed_genes is not None: for x in cobra_model._trimmed_genes: x.functional = True if cobra_...
[ "Undoes", "the", "effects", "of", "a", "call", "to", "delete_model_genes", "in", "place", "." ]
opencobra/cobrapy
python
https://github.com/opencobra/cobrapy/blob/9d1987cdb3a395cf4125a3439c3b002ff2be2009/cobra/manipulation/delete.py#L59-L78
[ "def", "undelete_model_genes", "(", "cobra_model", ")", ":", "if", "cobra_model", ".", "_trimmed_genes", "is", "not", "None", ":", "for", "x", "in", "cobra_model", ".", "_trimmed_genes", ":", "x", ".", "functional", "=", "True", "if", "cobra_model", ".", "_t...
9d1987cdb3a395cf4125a3439c3b002ff2be2009
valid
find_gene_knockout_reactions
identify reactions which will be disabled when the genes are knocked out cobra_model: :class:`~cobra.core.Model.Model` gene_list: iterable of :class:`~cobra.core.Gene.Gene` compiled_gene_reaction_rules: dict of {reaction_id: compiled_string} If provided, this gives pre-compiled gene_reaction_rule...
cobra/manipulation/delete.py
def find_gene_knockout_reactions(cobra_model, gene_list, compiled_gene_reaction_rules=None): """identify reactions which will be disabled when the genes are knocked out cobra_model: :class:`~cobra.core.Model.Model` gene_list: iterable of :class:`~cobra.core.Gene.Gene` ...
def find_gene_knockout_reactions(cobra_model, gene_list, compiled_gene_reaction_rules=None): """identify reactions which will be disabled when the genes are knocked out cobra_model: :class:`~cobra.core.Model.Model` gene_list: iterable of :class:`~cobra.core.Gene.Gene` ...
[ "identify", "reactions", "which", "will", "be", "disabled", "when", "the", "genes", "are", "knocked", "out" ]
opencobra/cobrapy
python
https://github.com/opencobra/cobrapy/blob/9d1987cdb3a395cf4125a3439c3b002ff2be2009/cobra/manipulation/delete.py#L94-L121
[ "def", "find_gene_knockout_reactions", "(", "cobra_model", ",", "gene_list", ",", "compiled_gene_reaction_rules", "=", "None", ")", ":", "potential_reactions", "=", "set", "(", ")", "for", "gene", "in", "gene_list", ":", "if", "isinstance", "(", "gene", ",", "st...
9d1987cdb3a395cf4125a3439c3b002ff2be2009
valid
delete_model_genes
delete_model_genes will set the upper and lower bounds for reactions catalysed by the genes in gene_list if deleting the genes means that the reaction cannot proceed according to cobra_model.reactions[:].gene_reaction_rule cumulative_deletions: False or True. If True then any previous deletions wi...
cobra/manipulation/delete.py
def delete_model_genes(cobra_model, gene_list, cumulative_deletions=True, disable_orphans=False): """delete_model_genes will set the upper and lower bounds for reactions catalysed by the genes in gene_list if deleting the genes means that the reaction cannot proceed according to c...
def delete_model_genes(cobra_model, gene_list, cumulative_deletions=True, disable_orphans=False): """delete_model_genes will set the upper and lower bounds for reactions catalysed by the genes in gene_list if deleting the genes means that the reaction cannot proceed according to c...
[ "delete_model_genes", "will", "set", "the", "upper", "and", "lower", "bounds", "for", "reactions", "catalysed", "by", "the", "genes", "in", "gene_list", "if", "deleting", "the", "genes", "means", "that", "the", "reaction", "cannot", "proceed", "according", "to",...
opencobra/cobrapy
python
https://github.com/opencobra/cobrapy/blob/9d1987cdb3a395cf4125a3439c3b002ff2be2009/cobra/manipulation/delete.py#L124-L182
[ "def", "delete_model_genes", "(", "cobra_model", ",", "gene_list", ",", "cumulative_deletions", "=", "True", ",", "disable_orphans", "=", "False", ")", ":", "if", "disable_orphans", ":", "raise", "NotImplementedError", "(", "\"disable_orphans not implemented\"", ")", ...
9d1987cdb3a395cf4125a3439c3b002ff2be2009
valid
remove_genes
remove genes entirely from the model This will also simplify all gene_reaction_rules with this gene inactivated.
cobra/manipulation/delete.py
def remove_genes(cobra_model, gene_list, remove_reactions=True): """remove genes entirely from the model This will also simplify all gene_reaction_rules with this gene inactivated.""" gene_set = {cobra_model.genes.get_by_id(str(i)) for i in gene_list} gene_id_set = {i.id for i in gene_set} remo...
def remove_genes(cobra_model, gene_list, remove_reactions=True): """remove genes entirely from the model This will also simplify all gene_reaction_rules with this gene inactivated.""" gene_set = {cobra_model.genes.get_by_id(str(i)) for i in gene_list} gene_id_set = {i.id for i in gene_set} remo...
[ "remove", "genes", "entirely", "from", "the", "model" ]
opencobra/cobrapy
python
https://github.com/opencobra/cobrapy/blob/9d1987cdb3a395cf4125a3439c3b002ff2be2009/cobra/manipulation/delete.py#L207-L237
[ "def", "remove_genes", "(", "cobra_model", ",", "gene_list", ",", "remove_reactions", "=", "True", ")", ":", "gene_set", "=", "{", "cobra_model", ".", "genes", ".", "get_by_id", "(", "str", "(", "i", ")", ")", "for", "i", "in", "gene_list", "}", "gene_id...
9d1987cdb3a395cf4125a3439c3b002ff2be2009
valid
gapfill
Perform gapfilling on a model. See documentation for the class GapFiller. Parameters ---------- model : cobra.Model The model to perform gap filling on. universal : cobra.Model, None A universal model with reactions that can be used to complete the model. Only gapfill consi...
cobra/flux_analysis/gapfilling.py
def gapfill(model, universal=None, lower_bound=0.05, penalties=None, demand_reactions=True, exchange_reactions=False, iterations=1): """Perform gapfilling on a model. See documentation for the class GapFiller. Parameters ---------- model : cobra.Model The model to p...
def gapfill(model, universal=None, lower_bound=0.05, penalties=None, demand_reactions=True, exchange_reactions=False, iterations=1): """Perform gapfilling on a model. See documentation for the class GapFiller. Parameters ---------- model : cobra.Model The model to p...
[ "Perform", "gapfilling", "on", "a", "model", "." ]
opencobra/cobrapy
python
https://github.com/opencobra/cobrapy/blob/9d1987cdb3a395cf4125a3439c3b002ff2be2009/cobra/flux_analysis/gapfilling.py#L256-L313
[ "def", "gapfill", "(", "model", ",", "universal", "=", "None", ",", "lower_bound", "=", "0.05", ",", "penalties", "=", "None", ",", "demand_reactions", "=", "True", ",", "exchange_reactions", "=", "False", ",", "iterations", "=", "1", ")", ":", "gapfiller"...
9d1987cdb3a395cf4125a3439c3b002ff2be2009
valid
GapFiller.extend_model
Extend gapfilling model. Add reactions from universal model and optionally exchange and demand reactions for all metabolites in the model to perform gapfilling on. Parameters ---------- exchange_reactions : bool Consider adding exchange (uptake) reactions fo...
cobra/flux_analysis/gapfilling.py
def extend_model(self, exchange_reactions=False, demand_reactions=True): """Extend gapfilling model. Add reactions from universal model and optionally exchange and demand reactions for all metabolites in the model to perform gapfilling on. Parameters ---------- ...
def extend_model(self, exchange_reactions=False, demand_reactions=True): """Extend gapfilling model. Add reactions from universal model and optionally exchange and demand reactions for all metabolites in the model to perform gapfilling on. Parameters ---------- ...
[ "Extend", "gapfilling", "model", "." ]
opencobra/cobrapy
python
https://github.com/opencobra/cobrapy/blob/9d1987cdb3a395cf4125a3439c3b002ff2be2009/cobra/flux_analysis/gapfilling.py#L104-L147
[ "def", "extend_model", "(", "self", ",", "exchange_reactions", "=", "False", ",", "demand_reactions", "=", "True", ")", ":", "for", "rxn", "in", "self", ".", "universal", ".", "reactions", ":", "rxn", ".", "gapfilling_type", "=", "'universal'", "new_metabolite...
9d1987cdb3a395cf4125a3439c3b002ff2be2009
valid
GapFiller.update_costs
Update the coefficients for the indicator variables in the objective. Done incrementally so that second time the function is called, active indicators in the current solutions gets higher cost than the unused indicators.
cobra/flux_analysis/gapfilling.py
def update_costs(self): """Update the coefficients for the indicator variables in the objective. Done incrementally so that second time the function is called, active indicators in the current solutions gets higher cost than the unused indicators. """ for var in self.ind...
def update_costs(self): """Update the coefficients for the indicator variables in the objective. Done incrementally so that second time the function is called, active indicators in the current solutions gets higher cost than the unused indicators. """ for var in self.ind...
[ "Update", "the", "coefficients", "for", "the", "indicator", "variables", "in", "the", "objective", "." ]
opencobra/cobrapy
python
https://github.com/opencobra/cobrapy/blob/9d1987cdb3a395cf4125a3439c3b002ff2be2009/cobra/flux_analysis/gapfilling.py#L149-L162
[ "def", "update_costs", "(", "self", ")", ":", "for", "var", "in", "self", ".", "indicators", ":", "if", "var", "not", "in", "self", ".", "costs", ":", "self", ".", "costs", "[", "var", "]", "=", "var", ".", "cost", "else", ":", "if", "var", ".", ...
9d1987cdb3a395cf4125a3439c3b002ff2be2009
valid
GapFiller.add_switches_and_objective
Update gapfilling model with switches and the indicator objective.
cobra/flux_analysis/gapfilling.py
def add_switches_and_objective(self): """ Update gapfilling model with switches and the indicator objective. """ constraints = list() big_m = max(max(abs(b) for b in r.bounds) for r in self.model.reactions) prob = self.model.problem for rxn in self.mod...
def add_switches_and_objective(self): """ Update gapfilling model with switches and the indicator objective. """ constraints = list() big_m = max(max(abs(b) for b in r.bounds) for r in self.model.reactions) prob = self.model.problem for rxn in self.mod...
[ "Update", "gapfilling", "model", "with", "switches", "and", "the", "indicator", "objective", "." ]
opencobra/cobrapy
python
https://github.com/opencobra/cobrapy/blob/9d1987cdb3a395cf4125a3439c3b002ff2be2009/cobra/flux_analysis/gapfilling.py#L164-L200
[ "def", "add_switches_and_objective", "(", "self", ")", ":", "constraints", "=", "list", "(", ")", "big_m", "=", "max", "(", "max", "(", "abs", "(", "b", ")", "for", "b", "in", "r", ".", "bounds", ")", "for", "r", "in", "self", ".", "model", ".", ...
9d1987cdb3a395cf4125a3439c3b002ff2be2009
valid
GapFiller.fill
Perform the gapfilling by iteratively solving the model, updating the costs and recording the used reactions. Parameters ---------- iterations : int The number of rounds of gapfilling to perform. For every iteration, the penalty for every used reaction increases...
cobra/flux_analysis/gapfilling.py
def fill(self, iterations=1): """Perform the gapfilling by iteratively solving the model, updating the costs and recording the used reactions. Parameters ---------- iterations : int The number of rounds of gapfilling to perform. For every iteration, the ...
def fill(self, iterations=1): """Perform the gapfilling by iteratively solving the model, updating the costs and recording the used reactions. Parameters ---------- iterations : int The number of rounds of gapfilling to perform. For every iteration, the ...
[ "Perform", "the", "gapfilling", "by", "iteratively", "solving", "the", "model", "updating", "the", "costs", "and", "recording", "the", "used", "reactions", "." ]
opencobra/cobrapy
python
https://github.com/opencobra/cobrapy/blob/9d1987cdb3a395cf4125a3439c3b002ff2be2009/cobra/flux_analysis/gapfilling.py#L202-L243
[ "def", "fill", "(", "self", ",", "iterations", "=", "1", ")", ":", "used_reactions", "=", "list", "(", ")", "for", "i", "in", "range", "(", "iterations", ")", ":", "self", ".", "model", ".", "slim_optimize", "(", "error_value", "=", "None", ",", "mes...
9d1987cdb3a395cf4125a3439c3b002ff2be2009
valid
find_external_compartment
Find the external compartment in the model. Uses a simple heuristic where the external compartment should be the one with the most exchange reactions. Arguments --------- model : cobra.Model A cobra model. Returns ------- str The putative external compartment.
cobra/medium/boundary_types.py
def find_external_compartment(model): """Find the external compartment in the model. Uses a simple heuristic where the external compartment should be the one with the most exchange reactions. Arguments --------- model : cobra.Model A cobra model. Returns ------- str ...
def find_external_compartment(model): """Find the external compartment in the model. Uses a simple heuristic where the external compartment should be the one with the most exchange reactions. Arguments --------- model : cobra.Model A cobra model. Returns ------- str ...
[ "Find", "the", "external", "compartment", "in", "the", "model", "." ]
opencobra/cobrapy
python
https://github.com/opencobra/cobrapy/blob/9d1987cdb3a395cf4125a3439c3b002ff2be2009/cobra/medium/boundary_types.py#L26-L82
[ "def", "find_external_compartment", "(", "model", ")", ":", "if", "model", ".", "boundary", ":", "counts", "=", "pd", ".", "Series", "(", "tuple", "(", "r", ".", "compartments", ")", "[", "0", "]", "for", "r", "in", "model", ".", "boundary", ")", "mo...
9d1987cdb3a395cf4125a3439c3b002ff2be2009
valid
is_boundary_type
Check whether a reaction is an exchange reaction. Arguments --------- reaction : cobra.Reaction The reaction to check. boundary_type : str What boundary type to check for. Must be one of "exchange", "demand", or "sink". external_compartment : str The id for the exter...
cobra/medium/boundary_types.py
def is_boundary_type(reaction, boundary_type, external_compartment): """Check whether a reaction is an exchange reaction. Arguments --------- reaction : cobra.Reaction The reaction to check. boundary_type : str What boundary type to check for. Must be one of "exchange", "dem...
def is_boundary_type(reaction, boundary_type, external_compartment): """Check whether a reaction is an exchange reaction. Arguments --------- reaction : cobra.Reaction The reaction to check. boundary_type : str What boundary type to check for. Must be one of "exchange", "dem...
[ "Check", "whether", "a", "reaction", "is", "an", "exchange", "reaction", "." ]
opencobra/cobrapy
python
https://github.com/opencobra/cobrapy/blob/9d1987cdb3a395cf4125a3439c3b002ff2be2009/cobra/medium/boundary_types.py#L85-L129
[ "def", "is_boundary_type", "(", "reaction", ",", "boundary_type", ",", "external_compartment", ")", ":", "# Check if the reaction has an annotation. Annotations dominate everything.", "sbo_term", "=", "reaction", ".", "annotation", ".", "get", "(", "\"sbo\"", ",", "\"\"", ...
9d1987cdb3a395cf4125a3439c3b002ff2be2009
valid
find_boundary_types
Find specific boundary reactions. Arguments --------- model : cobra.Model A cobra model. boundary_type : str What boundary type to check for. Must be one of "exchange", "demand", or "sink". external_compartment : str or None The id for the external compartment. If No...
cobra/medium/boundary_types.py
def find_boundary_types(model, boundary_type, external_compartment=None): """Find specific boundary reactions. Arguments --------- model : cobra.Model A cobra model. boundary_type : str What boundary type to check for. Must be one of "exchange", "demand", or "sink". exte...
def find_boundary_types(model, boundary_type, external_compartment=None): """Find specific boundary reactions. Arguments --------- model : cobra.Model A cobra model. boundary_type : str What boundary type to check for. Must be one of "exchange", "demand", or "sink". exte...
[ "Find", "specific", "boundary", "reactions", "." ]
opencobra/cobrapy
python
https://github.com/opencobra/cobrapy/blob/9d1987cdb3a395cf4125a3439c3b002ff2be2009/cobra/medium/boundary_types.py#L132-L160
[ "def", "find_boundary_types", "(", "model", ",", "boundary_type", ",", "external_compartment", "=", "None", ")", ":", "if", "not", "model", ".", "boundary", ":", "LOGGER", ".", "warning", "(", "\"There are no boundary reactions in this model. \"", "\"Therefore specific ...
9d1987cdb3a395cf4125a3439c3b002ff2be2009
valid
normalize_cutoff
Return a valid zero cutoff value.
cobra/flux_analysis/helpers.py
def normalize_cutoff(model, zero_cutoff=None): """Return a valid zero cutoff value.""" if zero_cutoff is None: return model.tolerance else: if zero_cutoff < model.tolerance: raise ValueError( "The chosen zero cutoff cannot be less than the model's " ...
def normalize_cutoff(model, zero_cutoff=None): """Return a valid zero cutoff value.""" if zero_cutoff is None: return model.tolerance else: if zero_cutoff < model.tolerance: raise ValueError( "The chosen zero cutoff cannot be less than the model's " ...
[ "Return", "a", "valid", "zero", "cutoff", "value", "." ]
opencobra/cobrapy
python
https://github.com/opencobra/cobrapy/blob/9d1987cdb3a395cf4125a3439c3b002ff2be2009/cobra/flux_analysis/helpers.py#L13-L24
[ "def", "normalize_cutoff", "(", "model", ",", "zero_cutoff", "=", "None", ")", ":", "if", "zero_cutoff", "is", "None", ":", "return", "model", ".", "tolerance", "else", ":", "if", "zero_cutoff", "<", "model", ".", "tolerance", ":", "raise", "ValueError", "...
9d1987cdb3a395cf4125a3439c3b002ff2be2009
valid
_sample_chain
Sample a single chain for OptGPSampler. center and n_samples are updated locally and forgotten afterwards.
cobra/sampling/optgp.py
def _sample_chain(args): """Sample a single chain for OptGPSampler. center and n_samples are updated locally and forgotten afterwards. """ n, idx = args # has to be this way to work in Python 2.7 center = sampler.center np.random.seed((sampler._seed + idx) % np.iinfo(np.int32).max) ...
def _sample_chain(args): """Sample a single chain for OptGPSampler. center and n_samples are updated locally and forgotten afterwards. """ n, idx = args # has to be this way to work in Python 2.7 center = sampler.center np.random.seed((sampler._seed + idx) % np.iinfo(np.int32).max) ...
[ "Sample", "a", "single", "chain", "for", "OptGPSampler", "." ]
opencobra/cobrapy
python
https://github.com/opencobra/cobrapy/blob/9d1987cdb3a395cf4125a3439c3b002ff2be2009/cobra/sampling/optgp.py#L31-L67
[ "def", "_sample_chain", "(", "args", ")", ":", "n", ",", "idx", "=", "args", "# has to be this way to work in Python 2.7", "center", "=", "sampler", ".", "center", "np", ".", "random", ".", "seed", "(", "(", "sampler", ".", "_seed", "+", "idx", ")", "%", ...
9d1987cdb3a395cf4125a3439c3b002ff2be2009
valid
OptGPSampler.sample
Generate a set of samples. This is the basic sampling function for all hit-and-run samplers. Paramters --------- n : int The minimum number of samples that are generated at once (see Notes). fluxes : boolean Whether to return fluxes or the in...
cobra/sampling/optgp.py
def sample(self, n, fluxes=True): """Generate a set of samples. This is the basic sampling function for all hit-and-run samplers. Paramters --------- n : int The minimum number of samples that are generated at once (see Notes). fluxes : boolean ...
def sample(self, n, fluxes=True): """Generate a set of samples. This is the basic sampling function for all hit-and-run samplers. Paramters --------- n : int The minimum number of samples that are generated at once (see Notes). fluxes : boolean ...
[ "Generate", "a", "set", "of", "samples", "." ]
opencobra/cobrapy
python
https://github.com/opencobra/cobrapy/blob/9d1987cdb3a395cf4125a3439c3b002ff2be2009/cobra/sampling/optgp.py#L175-L246
[ "def", "sample", "(", "self", ",", "n", ",", "fluxes", "=", "True", ")", ":", "if", "self", ".", "processes", ">", "1", ":", "n_process", "=", "np", ".", "ceil", "(", "n", "/", "self", ".", "processes", ")", ".", "astype", "(", "int", ")", "n",...
9d1987cdb3a395cf4125a3439c3b002ff2be2009
valid
ast2str
convert compiled ast to gene_reaction_rule str Parameters ---------- expr : str string for a gene reaction rule, e.g "a and b" level : int internal use only names : dict Dict where each element id a gene identifier and the value is the gene name. Use this to get a ru...
cobra/core/gene.py
def ast2str(expr, level=0, names=None): """convert compiled ast to gene_reaction_rule str Parameters ---------- expr : str string for a gene reaction rule, e.g "a and b" level : int internal use only names : dict Dict where each element id a gene identifier and the value...
def ast2str(expr, level=0, names=None): """convert compiled ast to gene_reaction_rule str Parameters ---------- expr : str string for a gene reaction rule, e.g "a and b" level : int internal use only names : dict Dict where each element id a gene identifier and the value...
[ "convert", "compiled", "ast", "to", "gene_reaction_rule", "str" ]
opencobra/cobrapy
python
https://github.com/opencobra/cobrapy/blob/9d1987cdb3a395cf4125a3439c3b002ff2be2009/cobra/core/gene.py#L37-L76
[ "def", "ast2str", "(", "expr", ",", "level", "=", "0", ",", "names", "=", "None", ")", ":", "if", "isinstance", "(", "expr", ",", "Expression", ")", ":", "return", "ast2str", "(", "expr", ".", "body", ",", "0", ",", "names", ")", "if", "hasattr", ...
9d1987cdb3a395cf4125a3439c3b002ff2be2009
valid
eval_gpr
evaluate compiled ast of gene_reaction_rule with knockouts Parameters ---------- expr : Expression The ast of the gene reaction rule knockouts : DictList, set Set of genes that are knocked out Returns ------- bool True if the gene reaction rule is true with the give...
cobra/core/gene.py
def eval_gpr(expr, knockouts): """evaluate compiled ast of gene_reaction_rule with knockouts Parameters ---------- expr : Expression The ast of the gene reaction rule knockouts : DictList, set Set of genes that are knocked out Returns ------- bool True if the ge...
def eval_gpr(expr, knockouts): """evaluate compiled ast of gene_reaction_rule with knockouts Parameters ---------- expr : Expression The ast of the gene reaction rule knockouts : DictList, set Set of genes that are knocked out Returns ------- bool True if the ge...
[ "evaluate", "compiled", "ast", "of", "gene_reaction_rule", "with", "knockouts" ]
opencobra/cobrapy
python
https://github.com/opencobra/cobrapy/blob/9d1987cdb3a395cf4125a3439c3b002ff2be2009/cobra/core/gene.py#L79-L110
[ "def", "eval_gpr", "(", "expr", ",", "knockouts", ")", ":", "if", "isinstance", "(", "expr", ",", "Expression", ")", ":", "return", "eval_gpr", "(", "expr", ".", "body", ",", "knockouts", ")", "elif", "isinstance", "(", "expr", ",", "Name", ")", ":", ...
9d1987cdb3a395cf4125a3439c3b002ff2be2009
valid
parse_gpr
parse gpr into AST Parameters ---------- str_expr : string string with the gene reaction rule to parse Returns ------- tuple elements ast_tree and gene_ids as a set
cobra/core/gene.py
def parse_gpr(str_expr): """parse gpr into AST Parameters ---------- str_expr : string string with the gene reaction rule to parse Returns ------- tuple elements ast_tree and gene_ids as a set """ str_expr = str_expr.strip() if len(str_expr) == 0: return...
def parse_gpr(str_expr): """parse gpr into AST Parameters ---------- str_expr : string string with the gene reaction rule to parse Returns ------- tuple elements ast_tree and gene_ids as a set """ str_expr = str_expr.strip() if len(str_expr) == 0: return...
[ "parse", "gpr", "into", "AST" ]
opencobra/cobrapy
python
https://github.com/opencobra/cobrapy/blob/9d1987cdb3a395cf4125a3439c3b002ff2be2009/cobra/core/gene.py#L143-L168
[ "def", "parse_gpr", "(", "str_expr", ")", ":", "str_expr", "=", "str_expr", ".", "strip", "(", ")", "if", "len", "(", "str_expr", ")", "==", "0", ":", "return", "None", ",", "set", "(", ")", "for", "char", ",", "escaped", "in", "replacements", ":", ...
9d1987cdb3a395cf4125a3439c3b002ff2be2009
valid
Gene.knock_out
Knockout gene by marking it as non-functional and setting all associated reactions bounds to zero. The change is reverted upon exit if executed within the model as context.
cobra/core/gene.py
def knock_out(self): """Knockout gene by marking it as non-functional and setting all associated reactions bounds to zero. The change is reverted upon exit if executed within the model as context. """ self.functional = False for reaction in self.reactions: ...
def knock_out(self): """Knockout gene by marking it as non-functional and setting all associated reactions bounds to zero. The change is reverted upon exit if executed within the model as context. """ self.functional = False for reaction in self.reactions: ...
[ "Knockout", "gene", "by", "marking", "it", "as", "non", "-", "functional", "and", "setting", "all", "associated", "reactions", "bounds", "to", "zero", "." ]
opencobra/cobrapy
python
https://github.com/opencobra/cobrapy/blob/9d1987cdb3a395cf4125a3439c3b002ff2be2009/cobra/core/gene.py#L206-L216
[ "def", "knock_out", "(", "self", ")", ":", "self", ".", "functional", "=", "False", "for", "reaction", "in", "self", ".", "reactions", ":", "if", "not", "reaction", ".", "functional", ":", "reaction", ".", "bounds", "=", "(", "0", ",", "0", ")" ]
9d1987cdb3a395cf4125a3439c3b002ff2be2009
valid
Gene.remove_from_model
Removes the association Parameters ---------- model : cobra model The model to remove the gene from make_dependent_reactions_nonfunctional : bool If True then replace the gene with 'False' in the gene association, else replace the gene with 'True' ...
cobra/core/gene.py
def remove_from_model(self, model=None, make_dependent_reactions_nonfunctional=True): """Removes the association Parameters ---------- model : cobra model The model to remove the gene from make_dependent_reactions_nonfunctional : bool ...
def remove_from_model(self, model=None, make_dependent_reactions_nonfunctional=True): """Removes the association Parameters ---------- model : cobra model The model to remove the gene from make_dependent_reactions_nonfunctional : bool ...
[ "Removes", "the", "association" ]
opencobra/cobrapy
python
https://github.com/opencobra/cobrapy/blob/9d1987cdb3a395cf4125a3439c3b002ff2be2009/cobra/core/gene.py#L218-L277
[ "def", "remove_from_model", "(", "self", ",", "model", "=", "None", ",", "make_dependent_reactions_nonfunctional", "=", "True", ")", ":", "warn", "(", "\"Use cobra.manipulation.remove_genes instead\"", ")", "if", "model", "is", "not", "None", ":", "if", "model", "...
9d1987cdb3a395cf4125a3439c3b002ff2be2009
valid
moma
Compute a single solution based on (linear) MOMA. Compute a new flux distribution that is at a minimal distance to a previous reference solution. Minimization of metabolic adjustment (MOMA) is generally used to assess the impact of knock-outs. Thus the typical usage is to provide a wildtype flux di...
cobra/flux_analysis/moma.py
def moma(model, solution=None, linear=True): """ Compute a single solution based on (linear) MOMA. Compute a new flux distribution that is at a minimal distance to a previous reference solution. Minimization of metabolic adjustment (MOMA) is generally used to assess the impact of knock-outs. Th...
def moma(model, solution=None, linear=True): """ Compute a single solution based on (linear) MOMA. Compute a new flux distribution that is at a minimal distance to a previous reference solution. Minimization of metabolic adjustment (MOMA) is generally used to assess the impact of knock-outs. Th...
[ "Compute", "a", "single", "solution", "based", "on", "(", "linear", ")", "MOMA", "." ]
opencobra/cobrapy
python
https://github.com/opencobra/cobrapy/blob/9d1987cdb3a395cf4125a3439c3b002ff2be2009/cobra/flux_analysis/moma.py#L13-L46
[ "def", "moma", "(", "model", ",", "solution", "=", "None", ",", "linear", "=", "True", ")", ":", "with", "model", ":", "add_moma", "(", "model", "=", "model", ",", "solution", "=", "solution", ",", "linear", "=", "linear", ")", "solution", "=", "mode...
9d1987cdb3a395cf4125a3439c3b002ff2be2009
valid
add_moma
r"""Add constraints and objective representing for MOMA. This adds variables and constraints for the minimization of metabolic adjustment (MOMA) to the model. Parameters ---------- model : cobra.Model The model to add MOMA constraints and objective to. solution : cobra.Solution, option...
cobra/flux_analysis/moma.py
def add_moma(model, solution=None, linear=True): r"""Add constraints and objective representing for MOMA. This adds variables and constraints for the minimization of metabolic adjustment (MOMA) to the model. Parameters ---------- model : cobra.Model The model to add MOMA constraints an...
def add_moma(model, solution=None, linear=True): r"""Add constraints and objective representing for MOMA. This adds variables and constraints for the minimization of metabolic adjustment (MOMA) to the model. Parameters ---------- model : cobra.Model The model to add MOMA constraints an...
[ "r", "Add", "constraints", "and", "objective", "representing", "for", "MOMA", "." ]
opencobra/cobrapy
python
https://github.com/opencobra/cobrapy/blob/9d1987cdb3a395cf4125a3439c3b002ff2be2009/cobra/flux_analysis/moma.py#L49-L148
[ "def", "add_moma", "(", "model", ",", "solution", "=", "None", ",", "linear", "=", "True", ")", ":", "if", "'moma_old_objective'", "in", "model", ".", "solver", ".", "variables", ":", "raise", "ValueError", "(", "'model is already adjusted for MOMA'", ")", "# ...
9d1987cdb3a395cf4125a3439c3b002ff2be2009
valid
_fix_type
convert possible types to str, float, and bool
cobra/io/dict.py
def _fix_type(value): """convert possible types to str, float, and bool""" # Because numpy floats can not be pickled to json if isinstance(value, string_types): return str(value) if isinstance(value, float_): return float(value) if isinstance(value, bool_): return bool(value)...
def _fix_type(value): """convert possible types to str, float, and bool""" # Because numpy floats can not be pickled to json if isinstance(value, string_types): return str(value) if isinstance(value, float_): return float(value) if isinstance(value, bool_): return bool(value)...
[ "convert", "possible", "types", "to", "str", "float", "and", "bool" ]
opencobra/cobrapy
python
https://github.com/opencobra/cobrapy/blob/9d1987cdb3a395cf4125a3439c3b002ff2be2009/cobra/io/dict.py#L56-L74
[ "def", "_fix_type", "(", "value", ")", ":", "# Because numpy floats can not be pickled to json", "if", "isinstance", "(", "value", ",", "string_types", ")", ":", "return", "str", "(", "value", ")", "if", "isinstance", "(", "value", ",", "float_", ")", ":", "re...
9d1987cdb3a395cf4125a3439c3b002ff2be2009
valid
_update_optional
update new_dict with optional attributes from cobra_object
cobra/io/dict.py
def _update_optional(cobra_object, new_dict, optional_attribute_dict, ordered_keys): """update new_dict with optional attributes from cobra_object""" for key in ordered_keys: default = optional_attribute_dict[key] value = getattr(cobra_object, key) if value is None o...
def _update_optional(cobra_object, new_dict, optional_attribute_dict, ordered_keys): """update new_dict with optional attributes from cobra_object""" for key in ordered_keys: default = optional_attribute_dict[key] value = getattr(cobra_object, key) if value is None o...
[ "update", "new_dict", "with", "optional", "attributes", "from", "cobra_object" ]
opencobra/cobrapy
python
https://github.com/opencobra/cobrapy/blob/9d1987cdb3a395cf4125a3439c3b002ff2be2009/cobra/io/dict.py#L77-L85
[ "def", "_update_optional", "(", "cobra_object", ",", "new_dict", ",", "optional_attribute_dict", ",", "ordered_keys", ")", ":", "for", "key", "in", "ordered_keys", ":", "default", "=", "optional_attribute_dict", "[", "key", "]", "value", "=", "getattr", "(", "co...
9d1987cdb3a395cf4125a3439c3b002ff2be2009
valid
model_to_dict
Convert model to a dict. Parameters ---------- model : cobra.Model The model to reformulate as a dict. sort : bool, optional Whether to sort the metabolites, reactions, and genes or maintain the order defined in the model. Returns ------- OrderedDict A dicti...
cobra/io/dict.py
def model_to_dict(model, sort=False): """Convert model to a dict. Parameters ---------- model : cobra.Model The model to reformulate as a dict. sort : bool, optional Whether to sort the metabolites, reactions, and genes or maintain the order defined in the model. Return...
def model_to_dict(model, sort=False): """Convert model to a dict. Parameters ---------- model : cobra.Model The model to reformulate as a dict. sort : bool, optional Whether to sort the metabolites, reactions, and genes or maintain the order defined in the model. Return...
[ "Convert", "model", "to", "a", "dict", "." ]
opencobra/cobrapy
python
https://github.com/opencobra/cobrapy/blob/9d1987cdb3a395cf4125a3439c3b002ff2be2009/cobra/io/dict.py#L149-L184
[ "def", "model_to_dict", "(", "model", ",", "sort", "=", "False", ")", ":", "obj", "=", "OrderedDict", "(", ")", "obj", "[", "\"metabolites\"", "]", "=", "list", "(", "map", "(", "metabolite_to_dict", ",", "model", ".", "metabolites", ")", ")", "obj", "...
9d1987cdb3a395cf4125a3439c3b002ff2be2009
valid
model_from_dict
Build a model from a dict. Models stored in json are first formulated as a dict that can be read to cobra model using this function. Parameters ---------- obj : dict A dictionary with elements, 'genes', 'compartments', 'id', 'metabolites', 'notes' and 'reactions'; where 'metabolite...
cobra/io/dict.py
def model_from_dict(obj): """Build a model from a dict. Models stored in json are first formulated as a dict that can be read to cobra model using this function. Parameters ---------- obj : dict A dictionary with elements, 'genes', 'compartments', 'id', 'metabolites', 'notes' a...
def model_from_dict(obj): """Build a model from a dict. Models stored in json are first formulated as a dict that can be read to cobra model using this function. Parameters ---------- obj : dict A dictionary with elements, 'genes', 'compartments', 'id', 'metabolites', 'notes' a...
[ "Build", "a", "model", "from", "a", "dict", "." ]
opencobra/cobrapy
python
https://github.com/opencobra/cobrapy/blob/9d1987cdb3a395cf4125a3439c3b002ff2be2009/cobra/io/dict.py#L187-L229
[ "def", "model_from_dict", "(", "obj", ")", ":", "if", "'reactions'", "not", "in", "obj", ":", "raise", "ValueError", "(", "'Object has no reactions attribute. Cannot load.'", ")", "model", "=", "Model", "(", ")", "model", ".", "add_metabolites", "(", "[", "metab...
9d1987cdb3a395cf4125a3439c3b002ff2be2009
valid
_get_id_compartment
extract the compartment from the id string
cobra/io/mat.py
def _get_id_compartment(id): """extract the compartment from the id string""" bracket_search = _bracket_re.findall(id) if len(bracket_search) == 1: return bracket_search[0][1] underscore_search = _underscore_re.findall(id) if len(underscore_search) == 1: return underscore_search[0][1...
def _get_id_compartment(id): """extract the compartment from the id string""" bracket_search = _bracket_re.findall(id) if len(bracket_search) == 1: return bracket_search[0][1] underscore_search = _underscore_re.findall(id) if len(underscore_search) == 1: return underscore_search[0][1...
[ "extract", "the", "compartment", "from", "the", "id", "string" ]
opencobra/cobrapy
python
https://github.com/opencobra/cobrapy/blob/9d1987cdb3a395cf4125a3439c3b002ff2be2009/cobra/io/mat.py#L32-L40
[ "def", "_get_id_compartment", "(", "id", ")", ":", "bracket_search", "=", "_bracket_re", ".", "findall", "(", "id", ")", "if", "len", "(", "bracket_search", ")", "==", "1", ":", "return", "bracket_search", "[", "0", "]", "[", "1", "]", "underscore_search",...
9d1987cdb3a395cf4125a3439c3b002ff2be2009
valid
_cell
translate an array x into a MATLAB cell array
cobra/io/mat.py
def _cell(x): """translate an array x into a MATLAB cell array""" x_no_none = [i if i is not None else "" for i in x] return array(x_no_none, dtype=np_object)
def _cell(x): """translate an array x into a MATLAB cell array""" x_no_none = [i if i is not None else "" for i in x] return array(x_no_none, dtype=np_object)
[ "translate", "an", "array", "x", "into", "a", "MATLAB", "cell", "array" ]
opencobra/cobrapy
python
https://github.com/opencobra/cobrapy/blob/9d1987cdb3a395cf4125a3439c3b002ff2be2009/cobra/io/mat.py#L43-L46
[ "def", "_cell", "(", "x", ")", ":", "x_no_none", "=", "[", "i", "if", "i", "is", "not", "None", "else", "\"\"", "for", "i", "in", "x", "]", "return", "array", "(", "x_no_none", ",", "dtype", "=", "np_object", ")" ]
9d1987cdb3a395cf4125a3439c3b002ff2be2009
valid
load_matlab_model
Load a cobra model stored as a .mat file Parameters ---------- infile_path: str path to the file to to read variable_name: str, optional The variable name of the model in the .mat file. If this is not specified, then the first MATLAB variable which looks like a COBRA mod...
cobra/io/mat.py
def load_matlab_model(infile_path, variable_name=None, inf=inf): """Load a cobra model stored as a .mat file Parameters ---------- infile_path: str path to the file to to read variable_name: str, optional The variable name of the model in the .mat file. If this is not specif...
def load_matlab_model(infile_path, variable_name=None, inf=inf): """Load a cobra model stored as a .mat file Parameters ---------- infile_path: str path to the file to to read variable_name: str, optional The variable name of the model in the .mat file. If this is not specif...
[ "Load", "a", "cobra", "model", "stored", "as", "a", ".", "mat", "file" ]
opencobra/cobrapy
python
https://github.com/opencobra/cobrapy/blob/9d1987cdb3a395cf4125a3439c3b002ff2be2009/cobra/io/mat.py#L49-L91
[ "def", "load_matlab_model", "(", "infile_path", ",", "variable_name", "=", "None", ",", "inf", "=", "inf", ")", ":", "if", "not", "scipy_io", ":", "raise", "ImportError", "(", "'load_matlab_model requires scipy'", ")", "data", "=", "scipy_io", ".", "loadmat", ...
9d1987cdb3a395cf4125a3439c3b002ff2be2009
valid
save_matlab_model
Save the cobra model as a .mat file. This .mat file can be used directly in the MATLAB version of COBRA. Parameters ---------- model : cobra.core.Model.Model object The model to save file_name : str or file-like object The file to save to varname : string The name of the...
cobra/io/mat.py
def save_matlab_model(model, file_name, varname=None): """Save the cobra model as a .mat file. This .mat file can be used directly in the MATLAB version of COBRA. Parameters ---------- model : cobra.core.Model.Model object The model to save file_name : str or file-like object T...
def save_matlab_model(model, file_name, varname=None): """Save the cobra model as a .mat file. This .mat file can be used directly in the MATLAB version of COBRA. Parameters ---------- model : cobra.core.Model.Model object The model to save file_name : str or file-like object T...
[ "Save", "the", "cobra", "model", "as", "a", ".", "mat", "file", "." ]
opencobra/cobrapy
python
https://github.com/opencobra/cobrapy/blob/9d1987cdb3a395cf4125a3439c3b002ff2be2009/cobra/io/mat.py#L94-L117
[ "def", "save_matlab_model", "(", "model", ",", "file_name", ",", "varname", "=", "None", ")", ":", "if", "not", "scipy_io", ":", "raise", "ImportError", "(", "'load_matlab_model requires scipy'", ")", "if", "varname", "is", "None", ":", "varname", "=", "str", ...
9d1987cdb3a395cf4125a3439c3b002ff2be2009
valid
create_mat_dict
create a dict mapping model attributes to arrays
cobra/io/mat.py
def create_mat_dict(model): """create a dict mapping model attributes to arrays""" rxns = model.reactions mets = model.metabolites mat = OrderedDict() mat["mets"] = _cell([met_id for met_id in create_mat_metabolite_id(model)]) mat["metNames"] = _cell(mets.list_attr("name")) mat["metFormulas"...
def create_mat_dict(model): """create a dict mapping model attributes to arrays""" rxns = model.reactions mets = model.metabolites mat = OrderedDict() mat["mets"] = _cell([met_id for met_id in create_mat_metabolite_id(model)]) mat["metNames"] = _cell(mets.list_attr("name")) mat["metFormulas"...
[ "create", "a", "dict", "mapping", "model", "attributes", "to", "arrays" ]
opencobra/cobrapy
python
https://github.com/opencobra/cobrapy/blob/9d1987cdb3a395cf4125a3439c3b002ff2be2009/cobra/io/mat.py#L129-L166
[ "def", "create_mat_dict", "(", "model", ")", ":", "rxns", "=", "model", ".", "reactions", "mets", "=", "model", ".", "metabolites", "mat", "=", "OrderedDict", "(", ")", "mat", "[", "\"mets\"", "]", "=", "_cell", "(", "[", "met_id", "for", "met_id", "in...
9d1987cdb3a395cf4125a3439c3b002ff2be2009
valid
from_mat_struct
create a model from the COBRA toolbox struct The struct will be a dict read in by scipy.io.loadmat
cobra/io/mat.py
def from_mat_struct(mat_struct, model_id=None, inf=inf): """create a model from the COBRA toolbox struct The struct will be a dict read in by scipy.io.loadmat """ m = mat_struct if m.dtype.names is None: raise ValueError("not a valid mat struct") if not {"rxns", "mets", "S", "lb", "ub"...
def from_mat_struct(mat_struct, model_id=None, inf=inf): """create a model from the COBRA toolbox struct The struct will be a dict read in by scipy.io.loadmat """ m = mat_struct if m.dtype.names is None: raise ValueError("not a valid mat struct") if not {"rxns", "mets", "S", "lb", "ub"...
[ "create", "a", "model", "from", "the", "COBRA", "toolbox", "struct" ]
opencobra/cobrapy
python
https://github.com/opencobra/cobrapy/blob/9d1987cdb3a395cf4125a3439c3b002ff2be2009/cobra/io/mat.py#L169-L259
[ "def", "from_mat_struct", "(", "mat_struct", ",", "model_id", "=", "None", ",", "inf", "=", "inf", ")", ":", "m", "=", "mat_struct", "if", "m", ".", "dtype", ".", "names", "is", "None", ":", "raise", "ValueError", "(", "\"not a valid mat struct\"", ")", ...
9d1987cdb3a395cf4125a3439c3b002ff2be2009
valid
model_to_pymatbridge
send the model to a MATLAB workspace through pymatbridge This model can then be manipulated through the COBRA toolbox Parameters ---------- variable_name : str The variable name to which the model will be assigned in the MATLAB workspace matlab : None or pymatbridge.Matlab instanc...
cobra/io/mat.py
def model_to_pymatbridge(model, variable_name="model", matlab=None): """send the model to a MATLAB workspace through pymatbridge This model can then be manipulated through the COBRA toolbox Parameters ---------- variable_name : str The variable name to which the model will be assigned in t...
def model_to_pymatbridge(model, variable_name="model", matlab=None): """send the model to a MATLAB workspace through pymatbridge This model can then be manipulated through the COBRA toolbox Parameters ---------- variable_name : str The variable name to which the model will be assigned in t...
[ "send", "the", "model", "to", "a", "MATLAB", "workspace", "through", "pymatbridge" ]
opencobra/cobrapy
python
https://github.com/opencobra/cobrapy/blob/9d1987cdb3a395cf4125a3439c3b002ff2be2009/cobra/io/mat.py#L268-L302
[ "def", "model_to_pymatbridge", "(", "model", ",", "variable_name", "=", "\"model\"", ",", "matlab", "=", "None", ")", ":", "if", "scipy_sparse", "is", "None", ":", "raise", "ImportError", "(", "\"`model_to_pymatbridge` requires scipy!\"", ")", "if", "matlab", "is"...
9d1987cdb3a395cf4125a3439c3b002ff2be2009
valid
get_context
Search for a context manager
cobra/util/context.py
def get_context(obj): """Search for a context manager""" try: return obj._contexts[-1] except (AttributeError, IndexError): pass try: return obj._model._contexts[-1] except (AttributeError, IndexError): pass return None
def get_context(obj): """Search for a context manager""" try: return obj._contexts[-1] except (AttributeError, IndexError): pass try: return obj._model._contexts[-1] except (AttributeError, IndexError): pass return None
[ "Search", "for", "a", "context", "manager" ]
opencobra/cobrapy
python
https://github.com/opencobra/cobrapy/blob/9d1987cdb3a395cf4125a3439c3b002ff2be2009/cobra/util/context.py#L39-L51
[ "def", "get_context", "(", "obj", ")", ":", "try", ":", "return", "obj", ".", "_contexts", "[", "-", "1", "]", "except", "(", "AttributeError", ",", "IndexError", ")", ":", "pass", "try", ":", "return", "obj", ".", "_model", ".", "_contexts", "[", "-...
9d1987cdb3a395cf4125a3439c3b002ff2be2009
valid
resettable
A decorator to simplify the context management of simple object attributes. Gets the value of the attribute prior to setting it, and stores a function to set the value to the old value in the HistoryManager.
cobra/util/context.py
def resettable(f): """A decorator to simplify the context management of simple object attributes. Gets the value of the attribute prior to setting it, and stores a function to set the value to the old value in the HistoryManager. """ def wrapper(self, new_value): context = get_context(self)...
def resettable(f): """A decorator to simplify the context management of simple object attributes. Gets the value of the attribute prior to setting it, and stores a function to set the value to the old value in the HistoryManager. """ def wrapper(self, new_value): context = get_context(self)...
[ "A", "decorator", "to", "simplify", "the", "context", "management", "of", "simple", "object", "attributes", ".", "Gets", "the", "value", "of", "the", "attribute", "prior", "to", "setting", "it", "and", "stores", "a", "function", "to", "set", "the", "value", ...
opencobra/cobrapy
python
https://github.com/opencobra/cobrapy/blob/9d1987cdb3a395cf4125a3439c3b002ff2be2009/cobra/util/context.py#L54-L71
[ "def", "resettable", "(", "f", ")", ":", "def", "wrapper", "(", "self", ",", "new_value", ")", ":", "context", "=", "get_context", "(", "self", ")", "if", "context", ":", "old_value", "=", "getattr", "(", "self", ",", "f", ".", "__name__", ")", "# Do...
9d1987cdb3a395cf4125a3439c3b002ff2be2009
valid
get_solution
Generate a solution representation of the current solver state. Parameters --------- model : cobra.Model The model whose reactions to retrieve values for. reactions : list, optional An iterable of `cobra.Reaction` objects. Uses `model.reactions` by default. metabolites : lis...
cobra/core/solution.py
def get_solution(model, reactions=None, metabolites=None, raise_error=False): """ Generate a solution representation of the current solver state. Parameters --------- model : cobra.Model The model whose reactions to retrieve values for. reactions : list, optional An iterable of ...
def get_solution(model, reactions=None, metabolites=None, raise_error=False): """ Generate a solution representation of the current solver state. Parameters --------- model : cobra.Model The model whose reactions to retrieve values for. reactions : list, optional An iterable of ...
[ "Generate", "a", "solution", "representation", "of", "the", "current", "solver", "state", "." ]
opencobra/cobrapy
python
https://github.com/opencobra/cobrapy/blob/9d1987cdb3a395cf4125a3439c3b002ff2be2009/cobra/core/solution.py#L196-L257
[ "def", "get_solution", "(", "model", ",", "reactions", "=", "None", ",", "metabolites", "=", "None", ",", "raise_error", "=", "False", ")", ":", "check_solver_status", "(", "model", ".", "solver", ".", "status", ",", "raise_error", "=", "raise_error", ")", ...
9d1987cdb3a395cf4125a3439c3b002ff2be2009
valid
Model.get_metabolite_compartments
Return all metabolites' compartments.
cobra/core/model.py
def get_metabolite_compartments(self): """Return all metabolites' compartments.""" warn('use Model.compartments instead', DeprecationWarning) return {met.compartment for met in self.metabolites if met.compartment is not None}
def get_metabolite_compartments(self): """Return all metabolites' compartments.""" warn('use Model.compartments instead', DeprecationWarning) return {met.compartment for met in self.metabolites if met.compartment is not None}
[ "Return", "all", "metabolites", "compartments", "." ]
opencobra/cobrapy
python
https://github.com/opencobra/cobrapy/blob/9d1987cdb3a395cf4125a3439c3b002ff2be2009/cobra/core/model.py#L203-L207
[ "def", "get_metabolite_compartments", "(", "self", ")", ":", "warn", "(", "'use Model.compartments instead'", ",", "DeprecationWarning", ")", "return", "{", "met", ".", "compartment", "for", "met", "in", "self", ".", "metabolites", "if", "met", ".", "compartment",...
9d1987cdb3a395cf4125a3439c3b002ff2be2009
valid
Model.medium
Get or set the constraints on the model exchanges. `model.medium` returns a dictionary of the bounds for each of the boundary reactions, in the form of `{rxn_id: bound}`, where `bound` specifies the absolute value of the bound in direction of metabolite creation (i.e., lower_bound for `...
cobra/core/model.py
def medium(self, medium): """Get or set the constraints on the model exchanges. `model.medium` returns a dictionary of the bounds for each of the boundary reactions, in the form of `{rxn_id: bound}`, where `bound` specifies the absolute value of the bound in direction of metabolite ...
def medium(self, medium): """Get or set the constraints on the model exchanges. `model.medium` returns a dictionary of the bounds for each of the boundary reactions, in the form of `{rxn_id: bound}`, where `bound` specifies the absolute value of the bound in direction of metabolite ...
[ "Get", "or", "set", "the", "constraints", "on", "the", "model", "exchanges", "." ]
opencobra/cobrapy
python
https://github.com/opencobra/cobrapy/blob/9d1987cdb3a395cf4125a3439c3b002ff2be2009/cobra/core/model.py#L257-L295
[ "def", "medium", "(", "self", ",", "medium", ")", ":", "def", "set_active_bound", "(", "reaction", ",", "bound", ")", ":", "if", "reaction", ".", "reactants", ":", "reaction", ".", "lower_bound", "=", "-", "bound", "elif", "reaction", ".", "products", ":...
9d1987cdb3a395cf4125a3439c3b002ff2be2009
valid
Model.copy
Provides a partial 'deepcopy' of the Model. All of the Metabolite, Gene, and Reaction objects are created anew but in a faster fashion than deepcopy
cobra/core/model.py
def copy(self): """Provides a partial 'deepcopy' of the Model. All of the Metabolite, Gene, and Reaction objects are created anew but in a faster fashion than deepcopy """ new = self.__class__() do_not_copy_by_ref = {"metabolites", "reactions", "genes", "notes", ...
def copy(self): """Provides a partial 'deepcopy' of the Model. All of the Metabolite, Gene, and Reaction objects are created anew but in a faster fashion than deepcopy """ new = self.__class__() do_not_copy_by_ref = {"metabolites", "reactions", "genes", "notes", ...
[ "Provides", "a", "partial", "deepcopy", "of", "the", "Model", ".", "All", "of", "the", "Metabolite", "Gene", "and", "Reaction", "objects", "are", "created", "anew", "but", "in", "a", "faster", "fashion", "than", "deepcopy" ]
opencobra/cobrapy
python
https://github.com/opencobra/cobrapy/blob/9d1987cdb3a395cf4125a3439c3b002ff2be2009/cobra/core/model.py#L318-L414
[ "def", "copy", "(", "self", ")", ":", "new", "=", "self", ".", "__class__", "(", ")", "do_not_copy_by_ref", "=", "{", "\"metabolites\"", ",", "\"reactions\"", ",", "\"genes\"", ",", "\"notes\"", ",", "\"annotation\"", ",", "\"groups\"", "}", "for", "attr", ...
9d1987cdb3a395cf4125a3439c3b002ff2be2009
valid
Model.add_metabolites
Will add a list of metabolites to the model object and add new constraints accordingly. The change is reverted upon exit when using the model as a context. Parameters ---------- metabolite_list : A list of `cobra.core.Metabolite` objects
cobra/core/model.py
def add_metabolites(self, metabolite_list): """Will add a list of metabolites to the model object and add new constraints accordingly. The change is reverted upon exit when using the model as a context. Parameters ---------- metabolite_list : A list of `cobra.core.Metab...
def add_metabolites(self, metabolite_list): """Will add a list of metabolites to the model object and add new constraints accordingly. The change is reverted upon exit when using the model as a context. Parameters ---------- metabolite_list : A list of `cobra.core.Metab...
[ "Will", "add", "a", "list", "of", "metabolites", "to", "the", "model", "object", "and", "add", "new", "constraints", "accordingly", "." ]
opencobra/cobrapy
python
https://github.com/opencobra/cobrapy/blob/9d1987cdb3a395cf4125a3439c3b002ff2be2009/cobra/core/model.py#L416-L460
[ "def", "add_metabolites", "(", "self", ",", "metabolite_list", ")", ":", "if", "not", "hasattr", "(", "metabolite_list", ",", "'__iter__'", ")", ":", "metabolite_list", "=", "[", "metabolite_list", "]", "if", "len", "(", "metabolite_list", ")", "==", "0", ":...
9d1987cdb3a395cf4125a3439c3b002ff2be2009
valid
Model.remove_metabolites
Remove a list of metabolites from the the object. The change is reverted upon exit when using the model as a context. Parameters ---------- metabolite_list : list A list with `cobra.Metabolite` objects as elements. destructive : bool If False then the m...
cobra/core/model.py
def remove_metabolites(self, metabolite_list, destructive=False): """Remove a list of metabolites from the the object. The change is reverted upon exit when using the model as a context. Parameters ---------- metabolite_list : list A list with `cobra.Metabolite` obj...
def remove_metabolites(self, metabolite_list, destructive=False): """Remove a list of metabolites from the the object. The change is reverted upon exit when using the model as a context. Parameters ---------- metabolite_list : list A list with `cobra.Metabolite` obj...
[ "Remove", "a", "list", "of", "metabolites", "from", "the", "the", "object", "." ]
opencobra/cobrapy
python
https://github.com/opencobra/cobrapy/blob/9d1987cdb3a395cf4125a3439c3b002ff2be2009/cobra/core/model.py#L462-L509
[ "def", "remove_metabolites", "(", "self", ",", "metabolite_list", ",", "destructive", "=", "False", ")", ":", "if", "not", "hasattr", "(", "metabolite_list", ",", "'__iter__'", ")", ":", "metabolite_list", "=", "[", "metabolite_list", "]", "# Make sure metabolites...
9d1987cdb3a395cf4125a3439c3b002ff2be2009
valid
Model.add_boundary
Add a boundary reaction for a given metabolite. There are three different types of pre-defined boundary reactions: exchange, demand, and sink reactions. An exchange reaction is a reversible, unbalanced reaction that adds to or removes an extracellular metabolite from the extracellular ...
cobra/core/model.py
def add_boundary(self, metabolite, type="exchange", reaction_id=None, lb=None, ub=None, sbo_term=None): """ Add a boundary reaction for a given metabolite. There are three different types of pre-defined boundary reactions: exchange, demand, and sink reactions. ...
def add_boundary(self, metabolite, type="exchange", reaction_id=None, lb=None, ub=None, sbo_term=None): """ Add a boundary reaction for a given metabolite. There are three different types of pre-defined boundary reactions: exchange, demand, and sink reactions. ...
[ "Add", "a", "boundary", "reaction", "for", "a", "given", "metabolite", "." ]
opencobra/cobrapy
python
https://github.com/opencobra/cobrapy/blob/9d1987cdb3a395cf4125a3439c3b002ff2be2009/cobra/core/model.py#L527-L625
[ "def", "add_boundary", "(", "self", ",", "metabolite", ",", "type", "=", "\"exchange\"", ",", "reaction_id", "=", "None", ",", "lb", "=", "None", ",", "ub", "=", "None", ",", "sbo_term", "=", "None", ")", ":", "ub", "=", "CONFIGURATION", ".", "upper_bo...
9d1987cdb3a395cf4125a3439c3b002ff2be2009
valid
Model.add_reactions
Add reactions to the model. Reactions with identifiers identical to a reaction already in the model are ignored. The change is reverted upon exit when using the model as a context. Parameters ---------- reaction_list : list A list of `cobra.Reaction` object...
cobra/core/model.py
def add_reactions(self, reaction_list): """Add reactions to the model. Reactions with identifiers identical to a reaction already in the model are ignored. The change is reverted upon exit when using the model as a context. Parameters ---------- reaction_list :...
def add_reactions(self, reaction_list): """Add reactions to the model. Reactions with identifiers identical to a reaction already in the model are ignored. The change is reverted upon exit when using the model as a context. Parameters ---------- reaction_list :...
[ "Add", "reactions", "to", "the", "model", "." ]
opencobra/cobrapy
python
https://github.com/opencobra/cobrapy/blob/9d1987cdb3a395cf4125a3439c3b002ff2be2009/cobra/core/model.py#L627-L697
[ "def", "add_reactions", "(", "self", ",", "reaction_list", ")", ":", "def", "existing_filter", "(", "rxn", ")", ":", "if", "rxn", ".", "id", "in", "self", ".", "reactions", ":", "LOGGER", ".", "warning", "(", "\"Ignoring reaction '%s' since it already exists.\""...
9d1987cdb3a395cf4125a3439c3b002ff2be2009
valid
Model.remove_reactions
Remove reactions from the model. The change is reverted upon exit when using the model as a context. Parameters ---------- reactions : list A list with reactions (`cobra.Reaction`), or their id's, to remove remove_orphans : bool Remove orphaned genes an...
cobra/core/model.py
def remove_reactions(self, reactions, remove_orphans=False): """Remove reactions from the model. The change is reverted upon exit when using the model as a context. Parameters ---------- reactions : list A list with reactions (`cobra.Reaction`), or their id's, to re...
def remove_reactions(self, reactions, remove_orphans=False): """Remove reactions from the model. The change is reverted upon exit when using the model as a context. Parameters ---------- reactions : list A list with reactions (`cobra.Reaction`), or their id's, to re...
[ "Remove", "reactions", "from", "the", "model", "." ]
opencobra/cobrapy
python
https://github.com/opencobra/cobrapy/blob/9d1987cdb3a395cf4125a3439c3b002ff2be2009/cobra/core/model.py#L699-L770
[ "def", "remove_reactions", "(", "self", ",", "reactions", ",", "remove_orphans", "=", "False", ")", ":", "if", "isinstance", "(", "reactions", ",", "string_types", ")", "or", "hasattr", "(", "reactions", ",", "\"id\"", ")", ":", "warn", "(", "\"need to pass ...
9d1987cdb3a395cf4125a3439c3b002ff2be2009
valid
Model.add_groups
Add groups to the model. Groups with identifiers identical to a group already in the model are ignored. If any group contains members that are not in the model, these members are added to the model as well. Only metabolites, reactions, and genes can have groups. Parame...
cobra/core/model.py
def add_groups(self, group_list): """Add groups to the model. Groups with identifiers identical to a group already in the model are ignored. If any group contains members that are not in the model, these members are added to the model as well. Only metabolites, reactions, and g...
def add_groups(self, group_list): """Add groups to the model. Groups with identifiers identical to a group already in the model are ignored. If any group contains members that are not in the model, these members are added to the model as well. Only metabolites, reactions, and g...
[ "Add", "groups", "to", "the", "model", "." ]
opencobra/cobrapy
python
https://github.com/opencobra/cobrapy/blob/9d1987cdb3a395cf4125a3439c3b002ff2be2009/cobra/core/model.py#L772-L817
[ "def", "add_groups", "(", "self", ",", "group_list", ")", ":", "def", "existing_filter", "(", "group", ")", ":", "if", "group", ".", "id", "in", "self", ".", "groups", ":", "LOGGER", ".", "warning", "(", "\"Ignoring group '%s' since it already exists.\"", ",",...
9d1987cdb3a395cf4125a3439c3b002ff2be2009
valid
Model.remove_groups
Remove groups from the model. Members of each group are not removed from the model (i.e. metabolites, reactions, and genes in the group stay in the model after any groups containing them are removed). Parameters ---------- group_list : list A list of `cobra....
cobra/core/model.py
def remove_groups(self, group_list): """Remove groups from the model. Members of each group are not removed from the model (i.e. metabolites, reactions, and genes in the group stay in the model after any groups containing them are removed). Parameters ---------- ...
def remove_groups(self, group_list): """Remove groups from the model. Members of each group are not removed from the model (i.e. metabolites, reactions, and genes in the group stay in the model after any groups containing them are removed). Parameters ---------- ...
[ "Remove", "groups", "from", "the", "model", "." ]
opencobra/cobrapy
python
https://github.com/opencobra/cobrapy/blob/9d1987cdb3a395cf4125a3439c3b002ff2be2009/cobra/core/model.py#L819-L843
[ "def", "remove_groups", "(", "self", ",", "group_list", ")", ":", "if", "isinstance", "(", "group_list", ",", "string_types", ")", "or", "hasattr", "(", "group_list", ",", "\"id\"", ")", ":", "warn", "(", "\"need to pass in a list\"", ")", "group_list", "=", ...
9d1987cdb3a395cf4125a3439c3b002ff2be2009
valid
Model.get_associated_groups
Returns a list of groups that an element (reaction, metabolite, gene) is associated with. Parameters ---------- element: `cobra.Reaction`, `cobra.Metabolite`, or `cobra.Gene` Returns ------- list of `cobra.Group` All groups that the provided object i...
cobra/core/model.py
def get_associated_groups(self, element): """Returns a list of groups that an element (reaction, metabolite, gene) is associated with. Parameters ---------- element: `cobra.Reaction`, `cobra.Metabolite`, or `cobra.Gene` Returns ------- list of `cobra.Gro...
def get_associated_groups(self, element): """Returns a list of groups that an element (reaction, metabolite, gene) is associated with. Parameters ---------- element: `cobra.Reaction`, `cobra.Metabolite`, or `cobra.Gene` Returns ------- list of `cobra.Gro...
[ "Returns", "a", "list", "of", "groups", "that", "an", "element", "(", "reaction", "metabolite", "gene", ")", "is", "associated", "with", "." ]
opencobra/cobrapy
python
https://github.com/opencobra/cobrapy/blob/9d1987cdb3a395cf4125a3439c3b002ff2be2009/cobra/core/model.py#L845-L859
[ "def", "get_associated_groups", "(", "self", ",", "element", ")", ":", "# check whether the element is associated with the model", "return", "[", "g", "for", "g", "in", "self", ".", "groups", "if", "element", "in", "g", ".", "members", "]" ]
9d1987cdb3a395cf4125a3439c3b002ff2be2009
valid
Model._populate_solver
Populate attached solver with constraints and variables that model the provided reactions.
cobra/core/model.py
def _populate_solver(self, reaction_list, metabolite_list=None): """Populate attached solver with constraints and variables that model the provided reactions. """ constraint_terms = AutoVivification() to_add = [] if metabolite_list is not None: for met in meta...
def _populate_solver(self, reaction_list, metabolite_list=None): """Populate attached solver with constraints and variables that model the provided reactions. """ constraint_terms = AutoVivification() to_add = [] if metabolite_list is not None: for met in meta...
[ "Populate", "attached", "solver", "with", "constraints", "and", "variables", "that", "model", "the", "provided", "reactions", "." ]
opencobra/cobrapy
python
https://github.com/opencobra/cobrapy/blob/9d1987cdb3a395cf4125a3439c3b002ff2be2009/cobra/core/model.py#L978-L1016
[ "def", "_populate_solver", "(", "self", ",", "reaction_list", ",", "metabolite_list", "=", "None", ")", ":", "constraint_terms", "=", "AutoVivification", "(", ")", "to_add", "=", "[", "]", "if", "metabolite_list", "is", "not", "None", ":", "for", "met", "in"...
9d1987cdb3a395cf4125a3439c3b002ff2be2009
valid
Model.slim_optimize
Optimize model without creating a solution object. Creating a full solution object implies fetching shadow prices and flux values for all reactions and metabolites from the solver object. This necessarily takes some time and in cases where only one or two values are of interest, it is r...
cobra/core/model.py
def slim_optimize(self, error_value=float('nan'), message=None): """Optimize model without creating a solution object. Creating a full solution object implies fetching shadow prices and flux values for all reactions and metabolites from the solver object. This necessarily takes some tim...
def slim_optimize(self, error_value=float('nan'), message=None): """Optimize model without creating a solution object. Creating a full solution object implies fetching shadow prices and flux values for all reactions and metabolites from the solver object. This necessarily takes some tim...
[ "Optimize", "model", "without", "creating", "a", "solution", "object", "." ]
opencobra/cobrapy
python
https://github.com/opencobra/cobrapy/blob/9d1987cdb3a395cf4125a3439c3b002ff2be2009/cobra/core/model.py#L1018-L1053
[ "def", "slim_optimize", "(", "self", ",", "error_value", "=", "float", "(", "'nan'", ")", ",", "message", "=", "None", ")", ":", "self", ".", "solver", ".", "optimize", "(", ")", "if", "self", ".", "solver", ".", "status", "==", "optlang", ".", "inte...
9d1987cdb3a395cf4125a3439c3b002ff2be2009
valid
Model.optimize
Optimize the model using flux balance analysis. Parameters ---------- objective_sense : {None, 'maximize' 'minimize'}, optional Whether fluxes should be maximized or minimized. In case of None, the previous direction is used. raise_error : bool If tru...
cobra/core/model.py
def optimize(self, objective_sense=None, raise_error=False): """ Optimize the model using flux balance analysis. Parameters ---------- objective_sense : {None, 'maximize' 'minimize'}, optional Whether fluxes should be maximized or minimized. In case of None, ...
def optimize(self, objective_sense=None, raise_error=False): """ Optimize the model using flux balance analysis. Parameters ---------- objective_sense : {None, 'maximize' 'minimize'}, optional Whether fluxes should be maximized or minimized. In case of None, ...
[ "Optimize", "the", "model", "using", "flux", "balance", "analysis", "." ]
opencobra/cobrapy
python
https://github.com/opencobra/cobrapy/blob/9d1987cdb3a395cf4125a3439c3b002ff2be2009/cobra/core/model.py#L1055-L1082
[ "def", "optimize", "(", "self", ",", "objective_sense", "=", "None", ",", "raise_error", "=", "False", ")", ":", "original_direction", "=", "self", ".", "objective", ".", "direction", "self", ".", "objective", ".", "direction", "=", "{", "\"maximize\"", ":",...
9d1987cdb3a395cf4125a3439c3b002ff2be2009
valid
Model.repair
Update all indexes and pointers in a model Parameters ---------- rebuild_index : bool rebuild the indices kept in reactions, metabolites and genes rebuild_relationships : bool reset all associations between genes, metabolites, model and then re-add ...
cobra/core/model.py
def repair(self, rebuild_index=True, rebuild_relationships=True): """Update all indexes and pointers in a model Parameters ---------- rebuild_index : bool rebuild the indices kept in reactions, metabolites and genes rebuild_relationships : bool reset all...
def repair(self, rebuild_index=True, rebuild_relationships=True): """Update all indexes and pointers in a model Parameters ---------- rebuild_index : bool rebuild the indices kept in reactions, metabolites and genes rebuild_relationships : bool reset all...
[ "Update", "all", "indexes", "and", "pointers", "in", "a", "model" ]
opencobra/cobrapy
python
https://github.com/opencobra/cobrapy/blob/9d1987cdb3a395cf4125a3439c3b002ff2be2009/cobra/core/model.py#L1084-L1114
[ "def", "repair", "(", "self", ",", "rebuild_index", "=", "True", ",", "rebuild_relationships", "=", "True", ")", ":", "if", "rebuild_index", ":", "# DictList indexes", "self", ".", "reactions", ".", "_generate_index", "(", ")", "self", ".", "metabolites", ".",...
9d1987cdb3a395cf4125a3439c3b002ff2be2009
valid
Model.summary
Print a summary of the input and output fluxes of the model. Parameters ---------- solution: cobra.Solution, optional A previously solved model solution to use for generating the summary. If none provided (default), the summary method will resolve the model. ...
cobra/core/model.py
def summary(self, solution=None, threshold=1E-06, fva=None, names=False, floatfmt='.3g'): """ Print a summary of the input and output fluxes of the model. Parameters ---------- solution: cobra.Solution, optional A previously solved model solution to u...
def summary(self, solution=None, threshold=1E-06, fva=None, names=False, floatfmt='.3g'): """ Print a summary of the input and output fluxes of the model. Parameters ---------- solution: cobra.Solution, optional A previously solved model solution to u...
[ "Print", "a", "summary", "of", "the", "input", "and", "output", "fluxes", "of", "the", "model", "." ]
opencobra/cobrapy
python
https://github.com/opencobra/cobrapy/blob/9d1987cdb3a395cf4125a3439c3b002ff2be2009/cobra/core/model.py#L1172-L1202
[ "def", "summary", "(", "self", ",", "solution", "=", "None", ",", "threshold", "=", "1E-06", ",", "fva", "=", "None", ",", "names", "=", "False", ",", "floatfmt", "=", "'.3g'", ")", ":", "from", "cobra", ".", "flux_analysis", ".", "summary", "import", ...
9d1987cdb3a395cf4125a3439c3b002ff2be2009
valid
Model.merge
Merge two models to create a model with the reactions from both models. Custom constraints and variables from right models are also copied to left model, however note that, constraints and variables are assumed to be the same if they have the same name. right : cobra.Model ...
cobra/core/model.py
def merge(self, right, prefix_existing=None, inplace=True, objective='left'): """Merge two models to create a model with the reactions from both models. Custom constraints and variables from right models are also copied to left model, however note that, constraints and var...
def merge(self, right, prefix_existing=None, inplace=True, objective='left'): """Merge two models to create a model with the reactions from both models. Custom constraints and variables from right models are also copied to left model, however note that, constraints and var...
[ "Merge", "two", "models", "to", "create", "a", "model", "with", "the", "reactions", "from", "both", "models", "." ]
opencobra/cobrapy
python
https://github.com/opencobra/cobrapy/blob/9d1987cdb3a395cf4125a3439c3b002ff2be2009/cobra/core/model.py#L1221-L1270
[ "def", "merge", "(", "self", ",", "right", ",", "prefix_existing", "=", "None", ",", "inplace", "=", "True", ",", "objective", "=", "'left'", ")", ":", "if", "inplace", ":", "new_model", "=", "self", "else", ":", "new_model", "=", "self", ".", "copy", ...
9d1987cdb3a395cf4125a3439c3b002ff2be2009
valid
_escape_str_id
make a single string id SBML compliant
cobra/manipulation/modify.py
def _escape_str_id(id_str): """make a single string id SBML compliant""" for c in ("'", '"'): if id_str.startswith(c) and id_str.endswith(c) \ and id_str.count(c) == 2: id_str = id_str.strip(c) for char, escaped_char in _renames: id_str = id_str.replace(char, esca...
def _escape_str_id(id_str): """make a single string id SBML compliant""" for c in ("'", '"'): if id_str.startswith(c) and id_str.endswith(c) \ and id_str.count(c) == 2: id_str = id_str.strip(c) for char, escaped_char in _renames: id_str = id_str.replace(char, esca...
[ "make", "a", "single", "string", "id", "SBML", "compliant" ]
opencobra/cobrapy
python
https://github.com/opencobra/cobrapy/blob/9d1987cdb3a395cf4125a3439c3b002ff2be2009/cobra/manipulation/modify.py#L38-L46
[ "def", "_escape_str_id", "(", "id_str", ")", ":", "for", "c", "in", "(", "\"'\"", ",", "'\"'", ")", ":", "if", "id_str", ".", "startswith", "(", "c", ")", "and", "id_str", ".", "endswith", "(", "c", ")", "and", "id_str", ".", "count", "(", "c", "...
9d1987cdb3a395cf4125a3439c3b002ff2be2009
valid
escape_ID
makes all ids SBML compliant
cobra/manipulation/modify.py
def escape_ID(cobra_model): """makes all ids SBML compliant""" for x in chain([cobra_model], cobra_model.metabolites, cobra_model.reactions, cobra_model.genes): x.id = _escape_str_id(x.id) cobra_model.repair() gene_renamer = _GeneEscaper()...
def escape_ID(cobra_model): """makes all ids SBML compliant""" for x in chain([cobra_model], cobra_model.metabolites, cobra_model.reactions, cobra_model.genes): x.id = _escape_str_id(x.id) cobra_model.repair() gene_renamer = _GeneEscaper()...
[ "makes", "all", "ids", "SBML", "compliant" ]
opencobra/cobrapy
python
https://github.com/opencobra/cobrapy/blob/9d1987cdb3a395cf4125a3439c3b002ff2be2009/cobra/manipulation/modify.py#L55-L66
[ "def", "escape_ID", "(", "cobra_model", ")", ":", "for", "x", "in", "chain", "(", "[", "cobra_model", "]", ",", "cobra_model", ".", "metabolites", ",", "cobra_model", ".", "reactions", ",", "cobra_model", ".", "genes", ")", ":", "x", ".", "id", "=", "_...
9d1987cdb3a395cf4125a3439c3b002ff2be2009
valid
rename_genes
renames genes in a model from the rename_dict
cobra/manipulation/modify.py
def rename_genes(cobra_model, rename_dict): """renames genes in a model from the rename_dict""" recompute_reactions = set() # need to recomptue related genes remove_genes = [] for old_name, new_name in iteritems(rename_dict): # undefined if there a value matches a different key # becaus...
def rename_genes(cobra_model, rename_dict): """renames genes in a model from the rename_dict""" recompute_reactions = set() # need to recomptue related genes remove_genes = [] for old_name, new_name in iteritems(rename_dict): # undefined if there a value matches a different key # becaus...
[ "renames", "genes", "in", "a", "model", "from", "the", "rename_dict" ]
opencobra/cobrapy
python
https://github.com/opencobra/cobrapy/blob/9d1987cdb3a395cf4125a3439c3b002ff2be2009/cobra/manipulation/modify.py#L69-L118
[ "def", "rename_genes", "(", "cobra_model", ",", "rename_dict", ")", ":", "recompute_reactions", "=", "set", "(", ")", "# need to recomptue related genes", "remove_genes", "=", "[", "]", "for", "old_name", ",", "new_name", "in", "iteritems", "(", "rename_dict", ")"...
9d1987cdb3a395cf4125a3439c3b002ff2be2009
valid
to_json
Return the model as a JSON document. ``kwargs`` are passed on to ``json.dumps``. Parameters ---------- model : cobra.Model The cobra model to represent. sort : bool, optional Whether to sort the metabolites, reactions, and genes or maintain the order defined in the model. ...
cobra/io/json.py
def to_json(model, sort=False, **kwargs): """ Return the model as a JSON document. ``kwargs`` are passed on to ``json.dumps``. Parameters ---------- model : cobra.Model The cobra model to represent. sort : bool, optional Whether to sort the metabolites, reactions, and genes...
def to_json(model, sort=False, **kwargs): """ Return the model as a JSON document. ``kwargs`` are passed on to ``json.dumps``. Parameters ---------- model : cobra.Model The cobra model to represent. sort : bool, optional Whether to sort the metabolites, reactions, and genes...
[ "Return", "the", "model", "as", "a", "JSON", "document", "." ]
opencobra/cobrapy
python
https://github.com/opencobra/cobrapy/blob/9d1987cdb3a395cf4125a3439c3b002ff2be2009/cobra/io/json.py#L19-L45
[ "def", "to_json", "(", "model", ",", "sort", "=", "False", ",", "*", "*", "kwargs", ")", ":", "obj", "=", "model_to_dict", "(", "model", ",", "sort", "=", "sort", ")", "obj", "[", "u\"version\"", "]", "=", "JSON_SPEC", "return", "json", ".", "dumps",...
9d1987cdb3a395cf4125a3439c3b002ff2be2009
valid
save_json_model
Write the cobra model to a file in JSON format. ``kwargs`` are passed on to ``json.dump``. Parameters ---------- model : cobra.Model The cobra model to represent. filename : str or file-like File path or descriptor that the JSON representation should be written to. sort...
cobra/io/json.py
def save_json_model(model, filename, sort=False, pretty=False, **kwargs): """ Write the cobra model to a file in JSON format. ``kwargs`` are passed on to ``json.dump``. Parameters ---------- model : cobra.Model The cobra model to represent. filename : str or file-like File ...
def save_json_model(model, filename, sort=False, pretty=False, **kwargs): """ Write the cobra model to a file in JSON format. ``kwargs`` are passed on to ``json.dump``. Parameters ---------- model : cobra.Model The cobra model to represent. filename : str or file-like File ...
[ "Write", "the", "cobra", "model", "to", "a", "file", "in", "JSON", "format", "." ]
opencobra/cobrapy
python
https://github.com/opencobra/cobrapy/blob/9d1987cdb3a395cf4125a3439c3b002ff2be2009/cobra/io/json.py#L69-L112
[ "def", "save_json_model", "(", "model", ",", "filename", ",", "sort", "=", "False", ",", "pretty", "=", "False", ",", "*", "*", "kwargs", ")", ":", "obj", "=", "model_to_dict", "(", "model", ",", "sort", "=", "sort", ")", "obj", "[", "u\"version\"", ...
9d1987cdb3a395cf4125a3439c3b002ff2be2009
valid
load_json_model
Load a cobra model from a file in JSON format. Parameters ---------- filename : str or file-like File path or descriptor that contains the JSON document describing the cobra model. Returns ------- cobra.Model The cobra model as represented in the JSON document. See...
cobra/io/json.py
def load_json_model(filename): """ Load a cobra model from a file in JSON format. Parameters ---------- filename : str or file-like File path or descriptor that contains the JSON document describing the cobra model. Returns ------- cobra.Model The cobra model as...
def load_json_model(filename): """ Load a cobra model from a file in JSON format. Parameters ---------- filename : str or file-like File path or descriptor that contains the JSON document describing the cobra model. Returns ------- cobra.Model The cobra model as...
[ "Load", "a", "cobra", "model", "from", "a", "file", "in", "JSON", "format", "." ]
opencobra/cobrapy
python
https://github.com/opencobra/cobrapy/blob/9d1987cdb3a395cf4125a3439c3b002ff2be2009/cobra/io/json.py#L115-L138
[ "def", "load_json_model", "(", "filename", ")", ":", "if", "isinstance", "(", "filename", ",", "string_types", ")", ":", "with", "open", "(", "filename", ",", "\"r\"", ")", "as", "file_handle", ":", "return", "model_from_dict", "(", "json", ".", "load", "(...
9d1987cdb3a395cf4125a3439c3b002ff2be2009
valid
add_linear_obj
Add a linear version of a minimal medium to the model solver. Changes the optimization objective to finding the growth medium requiring the smallest total import flux:: minimize sum |r_i| for r_i in import_reactions Arguments --------- model : cobra.Model The model to modify.
cobra/medium/minimal_medium.py
def add_linear_obj(model): """Add a linear version of a minimal medium to the model solver. Changes the optimization objective to finding the growth medium requiring the smallest total import flux:: minimize sum |r_i| for r_i in import_reactions Arguments --------- model : cobra.Model...
def add_linear_obj(model): """Add a linear version of a minimal medium to the model solver. Changes the optimization objective to finding the growth medium requiring the smallest total import flux:: minimize sum |r_i| for r_i in import_reactions Arguments --------- model : cobra.Model...
[ "Add", "a", "linear", "version", "of", "a", "minimal", "medium", "to", "the", "model", "solver", "." ]
opencobra/cobrapy
python
https://github.com/opencobra/cobrapy/blob/9d1987cdb3a395cf4125a3439c3b002ff2be2009/cobra/medium/minimal_medium.py#L17-L38
[ "def", "add_linear_obj", "(", "model", ")", ":", "coefs", "=", "{", "}", "for", "rxn", "in", "find_boundary_types", "(", "model", ",", "\"exchange\"", ")", ":", "export", "=", "len", "(", "rxn", ".", "reactants", ")", "==", "1", "if", "export", ":", ...
9d1987cdb3a395cf4125a3439c3b002ff2be2009
valid
add_mip_obj
Add a mixed-integer version of a minimal medium to the model. Changes the optimization objective to finding the medium with the least components:: minimize size(R) where R part of import_reactions Arguments --------- model : cobra.model The model to modify.
cobra/medium/minimal_medium.py
def add_mip_obj(model): """Add a mixed-integer version of a minimal medium to the model. Changes the optimization objective to finding the medium with the least components:: minimize size(R) where R part of import_reactions Arguments --------- model : cobra.model The model to ...
def add_mip_obj(model): """Add a mixed-integer version of a minimal medium to the model. Changes the optimization objective to finding the medium with the least components:: minimize size(R) where R part of import_reactions Arguments --------- model : cobra.model The model to ...
[ "Add", "a", "mixed", "-", "integer", "version", "of", "a", "minimal", "medium", "to", "the", "model", "." ]
opencobra/cobrapy
python
https://github.com/opencobra/cobrapy/blob/9d1987cdb3a395cf4125a3439c3b002ff2be2009/cobra/medium/minimal_medium.py#L41-L78
[ "def", "add_mip_obj", "(", "model", ")", ":", "if", "len", "(", "model", ".", "variables", ")", ">", "1e4", ":", "LOGGER", ".", "warning", "(", "\"the MIP version of minimal media is extremely slow for\"", "\" models that large :(\"", ")", "exchange_rxns", "=", "fin...
9d1987cdb3a395cf4125a3439c3b002ff2be2009
valid
_as_medium
Convert a solution to medium. Arguments --------- exchanges : list of cobra.reaction The exchange reactions to consider. tolerance : positive double The absolute tolerance for fluxes. Fluxes with an absolute value smaller than this number will be ignored. exports : bool ...
cobra/medium/minimal_medium.py
def _as_medium(exchanges, tolerance=1e-6, exports=False): """Convert a solution to medium. Arguments --------- exchanges : list of cobra.reaction The exchange reactions to consider. tolerance : positive double The absolute tolerance for fluxes. Fluxes with an absolute value ...
def _as_medium(exchanges, tolerance=1e-6, exports=False): """Convert a solution to medium. Arguments --------- exchanges : list of cobra.reaction The exchange reactions to consider. tolerance : positive double The absolute tolerance for fluxes. Fluxes with an absolute value ...
[ "Convert", "a", "solution", "to", "medium", "." ]
opencobra/cobrapy
python
https://github.com/opencobra/cobrapy/blob/9d1987cdb3a395cf4125a3439c3b002ff2be2009/cobra/medium/minimal_medium.py#L81-L113
[ "def", "_as_medium", "(", "exchanges", ",", "tolerance", "=", "1e-6", ",", "exports", "=", "False", ")", ":", "LOGGER", ".", "debug", "(", "\"Formatting medium.\"", ")", "medium", "=", "pd", ".", "Series", "(", ")", "for", "rxn", "in", "exchanges", ":", ...
9d1987cdb3a395cf4125a3439c3b002ff2be2009
valid
minimal_medium
Find the minimal growth medium for the model. Finds the minimal growth medium for the model which allows for model as well as individual growth. Here, a minimal medium can either be the medium requiring the smallest total import flux or the medium requiring the least components (ergo ingredients), whic...
cobra/medium/minimal_medium.py
def minimal_medium(model, min_objective_value=0.1, exports=False, minimize_components=False, open_exchanges=False): """ Find the minimal growth medium for the model. Finds the minimal growth medium for the model which allows for model as well as individual growth. Here, a minimal med...
def minimal_medium(model, min_objective_value=0.1, exports=False, minimize_components=False, open_exchanges=False): """ Find the minimal growth medium for the model. Finds the minimal growth medium for the model which allows for model as well as individual growth. Here, a minimal med...
[ "Find", "the", "minimal", "growth", "medium", "for", "the", "model", "." ]
opencobra/cobrapy
python
https://github.com/opencobra/cobrapy/blob/9d1987cdb3a395cf4125a3439c3b002ff2be2009/cobra/medium/minimal_medium.py#L116-L231
[ "def", "minimal_medium", "(", "model", ",", "min_objective_value", "=", "0.1", ",", "exports", "=", "False", ",", "minimize_components", "=", "False", ",", "open_exchanges", "=", "False", ")", ":", "exchange_rxns", "=", "find_boundary_types", "(", "model", ",", ...
9d1987cdb3a395cf4125a3439c3b002ff2be2009
valid
_init_worker
Initialize a global model object for multiprocessing.
cobra/flux_analysis/variability.py
def _init_worker(model, loopless, sense): """Initialize a global model object for multiprocessing.""" global _model global _loopless _model = model _model.solver.objective.direction = sense _loopless = loopless
def _init_worker(model, loopless, sense): """Initialize a global model object for multiprocessing.""" global _model global _loopless _model = model _model.solver.objective.direction = sense _loopless = loopless
[ "Initialize", "a", "global", "model", "object", "for", "multiprocessing", "." ]
opencobra/cobrapy
python
https://github.com/opencobra/cobrapy/blob/9d1987cdb3a395cf4125a3439c3b002ff2be2009/cobra/flux_analysis/variability.py#L27-L33
[ "def", "_init_worker", "(", "model", ",", "loopless", ",", "sense", ")", ":", "global", "_model", "global", "_loopless", "_model", "=", "model", "_model", ".", "solver", ".", "objective", ".", "direction", "=", "sense", "_loopless", "=", "loopless" ]
9d1987cdb3a395cf4125a3439c3b002ff2be2009
valid
flux_variability_analysis
Determine the minimum and maximum possible flux value for each reaction. Parameters ---------- model : cobra.Model The model for which to run the analysis. It will *not* be modified. reaction_list : list of cobra.Reaction or str, optional The reactions for which to obtain min/max fluxes...
cobra/flux_analysis/variability.py
def flux_variability_analysis(model, reaction_list=None, loopless=False, fraction_of_optimum=1.0, pfba_factor=None, processes=None): """ Determine the minimum and maximum possible flux value for each reaction. Parameters ---------- model :...
def flux_variability_analysis(model, reaction_list=None, loopless=False, fraction_of_optimum=1.0, pfba_factor=None, processes=None): """ Determine the minimum and maximum possible flux value for each reaction. Parameters ---------- model :...
[ "Determine", "the", "minimum", "and", "maximum", "possible", "flux", "value", "for", "each", "reaction", "." ]
opencobra/cobrapy
python
https://github.com/opencobra/cobrapy/blob/9d1987cdb3a395cf4125a3439c3b002ff2be2009/cobra/flux_analysis/variability.py#L57-L200
[ "def", "flux_variability_analysis", "(", "model", ",", "reaction_list", "=", "None", ",", "loopless", "=", "False", ",", "fraction_of_optimum", "=", "1.0", ",", "pfba_factor", "=", "None", ",", "processes", "=", "None", ")", ":", "if", "reaction_list", "is", ...
9d1987cdb3a395cf4125a3439c3b002ff2be2009
valid
find_blocked_reactions
Find reactions that cannot carry any flux. The question whether or not a reaction is blocked is highly dependent on the current exchange reaction settings for a COBRA model. Hence an argument is provided to open all exchange reactions. Notes ----- Sink and demand reactions are left untouched. ...
cobra/flux_analysis/variability.py
def find_blocked_reactions(model, reaction_list=None, zero_cutoff=None, open_exchanges=False, processes=None): """ Find reactions that cannot carry any flux. The question whether or not a reaction is...
def find_blocked_reactions(model, reaction_list=None, zero_cutoff=None, open_exchanges=False, processes=None): """ Find reactions that cannot carry any flux. The question whether or not a reaction is...
[ "Find", "reactions", "that", "cannot", "carry", "any", "flux", "." ]
opencobra/cobrapy
python
https://github.com/opencobra/cobrapy/blob/9d1987cdb3a395cf4125a3439c3b002ff2be2009/cobra/flux_analysis/variability.py#L203-L265
[ "def", "find_blocked_reactions", "(", "model", ",", "reaction_list", "=", "None", ",", "zero_cutoff", "=", "None", ",", "open_exchanges", "=", "False", ",", "processes", "=", "None", ")", ":", "zero_cutoff", "=", "normalize_cutoff", "(", "model", ",", "zero_cu...
9d1987cdb3a395cf4125a3439c3b002ff2be2009
valid
find_essential_genes
Return a set of essential genes. A gene is considered essential if restricting the flux of all reactions that depend on it to zero causes the objective, e.g., the growth rate, to also be zero, below the threshold, or infeasible. Parameters ---------- model : cobra.Model The model to fi...
cobra/flux_analysis/variability.py
def find_essential_genes(model, threshold=None, processes=None): """ Return a set of essential genes. A gene is considered essential if restricting the flux of all reactions that depend on it to zero causes the objective, e.g., the growth rate, to also be zero, below the threshold, or infeasible. ...
def find_essential_genes(model, threshold=None, processes=None): """ Return a set of essential genes. A gene is considered essential if restricting the flux of all reactions that depend on it to zero causes the objective, e.g., the growth rate, to also be zero, below the threshold, or infeasible. ...
[ "Return", "a", "set", "of", "essential", "genes", "." ]
opencobra/cobrapy
python
https://github.com/opencobra/cobrapy/blob/9d1987cdb3a395cf4125a3439c3b002ff2be2009/cobra/flux_analysis/variability.py#L268-L301
[ "def", "find_essential_genes", "(", "model", ",", "threshold", "=", "None", ",", "processes", "=", "None", ")", ":", "if", "threshold", "is", "None", ":", "threshold", "=", "model", ".", "slim_optimize", "(", "error_value", "=", "None", ")", "*", "1E-02", ...
9d1987cdb3a395cf4125a3439c3b002ff2be2009
valid
find_essential_reactions
Return a set of essential reactions. A reaction is considered essential if restricting its flux to zero causes the objective, e.g., the growth rate, to also be zero, below the threshold, or infeasible. Parameters ---------- model : cobra.Model The model to find the essential reactions...
cobra/flux_analysis/variability.py
def find_essential_reactions(model, threshold=None, processes=None): """Return a set of essential reactions. A reaction is considered essential if restricting its flux to zero causes the objective, e.g., the growth rate, to also be zero, below the threshold, or infeasible. Parameters --------...
def find_essential_reactions(model, threshold=None, processes=None): """Return a set of essential reactions. A reaction is considered essential if restricting its flux to zero causes the objective, e.g., the growth rate, to also be zero, below the threshold, or infeasible. Parameters --------...
[ "Return", "a", "set", "of", "essential", "reactions", "." ]
opencobra/cobrapy
python
https://github.com/opencobra/cobrapy/blob/9d1987cdb3a395cf4125a3439c3b002ff2be2009/cobra/flux_analysis/variability.py#L304-L335
[ "def", "find_essential_reactions", "(", "model", ",", "threshold", "=", "None", ",", "processes", "=", "None", ")", ":", "if", "threshold", "is", "None", ":", "threshold", "=", "model", ".", "slim_optimize", "(", "error_value", "=", "None", ")", "*", "1E-0...
9d1987cdb3a395cf4125a3439c3b002ff2be2009
valid
add_SBO
adds SBO terms for demands and exchanges This works for models which follow the standard convention for constructing and naming these reactions. The reaction should only contain the single metabolite being exchanged, and the id should be EX_metid or DM_metid
cobra/manipulation/annotate.py
def add_SBO(model): """adds SBO terms for demands and exchanges This works for models which follow the standard convention for constructing and naming these reactions. The reaction should only contain the single metabolite being exchanged, and the id should be EX_metid or DM_metid """ for ...
def add_SBO(model): """adds SBO terms for demands and exchanges This works for models which follow the standard convention for constructing and naming these reactions. The reaction should only contain the single metabolite being exchanged, and the id should be EX_metid or DM_metid """ for ...
[ "adds", "SBO", "terms", "for", "demands", "and", "exchanges" ]
opencobra/cobrapy
python
https://github.com/opencobra/cobrapy/blob/9d1987cdb3a395cf4125a3439c3b002ff2be2009/cobra/manipulation/annotate.py#L6-L26
[ "def", "add_SBO", "(", "model", ")", ":", "for", "r", "in", "model", ".", "reactions", ":", "# don't annotate already annotated reactions", "if", "r", ".", "annotation", ".", "get", "(", "\"sbo\"", ")", ":", "continue", "# only doing exchanges", "if", "len", "...
9d1987cdb3a395cf4125a3439c3b002ff2be2009
valid
Formula.weight
Calculate the mol mass of the compound Returns ------- float the mol mass
cobra/core/formula.py
def weight(self): """Calculate the mol mass of the compound Returns ------- float the mol mass """ try: return sum([count * elements_and_molecular_weights[element] for element, count in self.elements.items()]) excep...
def weight(self): """Calculate the mol mass of the compound Returns ------- float the mol mass """ try: return sum([count * elements_and_molecular_weights[element] for element, count in self.elements.items()]) excep...
[ "Calculate", "the", "mol", "mass", "of", "the", "compound" ]
opencobra/cobrapy
python
https://github.com/opencobra/cobrapy/blob/9d1987cdb3a395cf4125a3439c3b002ff2be2009/cobra/core/formula.py#L83-L95
[ "def", "weight", "(", "self", ")", ":", "try", ":", "return", "sum", "(", "[", "count", "*", "elements_and_molecular_weights", "[", "element", "]", "for", "element", ",", "count", "in", "self", ".", "elements", ".", "items", "(", ")", "]", ")", "except...
9d1987cdb3a395cf4125a3439c3b002ff2be2009
valid
insert_break
Insert a <!--more--> tag for larger release notes. Parameters ---------- lines : list of str The content of the release note. break_pos : int Line number before which a break should approximately be inserted. Returns ------- list of str The text with the inserted ta...
scripts/publish_release.py
def insert_break(lines, break_pos=9): """ Insert a <!--more--> tag for larger release notes. Parameters ---------- lines : list of str The content of the release note. break_pos : int Line number before which a break should approximately be inserted. Returns ------- ...
def insert_break(lines, break_pos=9): """ Insert a <!--more--> tag for larger release notes. Parameters ---------- lines : list of str The content of the release note. break_pos : int Line number before which a break should approximately be inserted. Returns ------- ...
[ "Insert", "a", "<!", "--", "more", "--", ">", "tag", "for", "larger", "release", "notes", "." ]
opencobra/cobrapy
python
https://github.com/opencobra/cobrapy/blob/9d1987cdb3a395cf4125a3439c3b002ff2be2009/scripts/publish_release.py#L15-L45
[ "def", "insert_break", "(", "lines", ",", "break_pos", "=", "9", ")", ":", "def", "line_filter", "(", "line", ")", ":", "if", "len", "(", "line", ")", "==", "0", ":", "return", "True", "return", "any", "(", "line", ".", "startswith", "(", "c", ")",...
9d1987cdb3a395cf4125a3439c3b002ff2be2009
valid
build_hugo_md
Build the markdown release notes for Hugo. Inserts the required TOML header with specific values and adds a break for long release notes. Parameters ---------- filename : str, path The release notes file. tag : str The tag, following semantic versioning, of the current release....
scripts/publish_release.py
def build_hugo_md(filename, tag, bump): """ Build the markdown release notes for Hugo. Inserts the required TOML header with specific values and adds a break for long release notes. Parameters ---------- filename : str, path The release notes file. tag : str The tag, fo...
def build_hugo_md(filename, tag, bump): """ Build the markdown release notes for Hugo. Inserts the required TOML header with specific values and adds a break for long release notes. Parameters ---------- filename : str, path The release notes file. tag : str The tag, fo...
[ "Build", "the", "markdown", "release", "notes", "for", "Hugo", "." ]
opencobra/cobrapy
python
https://github.com/opencobra/cobrapy/blob/9d1987cdb3a395cf4125a3439c3b002ff2be2009/scripts/publish_release.py#L48-L78
[ "def", "build_hugo_md", "(", "filename", ",", "tag", ",", "bump", ")", ":", "header", "=", "[", "'+++\\n'", ",", "'date = \"{}\"\\n'", ".", "format", "(", "date", ".", "today", "(", ")", ".", "isoformat", "(", ")", ")", ",", "'title = \"{}\"\\n'", ".", ...
9d1987cdb3a395cf4125a3439c3b002ff2be2009
valid
find_bump
Identify the kind of release by comparing to existing ones.
scripts/publish_release.py
def find_bump(target, tag): """Identify the kind of release by comparing to existing ones.""" tmp = tag.split(".") existing = [intify(basename(f)) for f in glob(join(target, "[0-9]*.md"))] latest = max(existing) if int(tmp[0]) > latest[0]: return "major" elif int(tmp[1]) > latest[1]: ...
def find_bump(target, tag): """Identify the kind of release by comparing to existing ones.""" tmp = tag.split(".") existing = [intify(basename(f)) for f in glob(join(target, "[0-9]*.md"))] latest = max(existing) if int(tmp[0]) > latest[0]: return "major" elif int(tmp[1]) > latest[1]: ...
[ "Identify", "the", "kind", "of", "release", "by", "comparing", "to", "existing", "ones", "." ]
opencobra/cobrapy
python
https://github.com/opencobra/cobrapy/blob/9d1987cdb3a395cf4125a3439c3b002ff2be2009/scripts/publish_release.py#L100-L110
[ "def", "find_bump", "(", "target", ",", "tag", ")", ":", "tmp", "=", "tag", ".", "split", "(", "\".\"", ")", "existing", "=", "[", "intify", "(", "basename", "(", "f", ")", ")", "for", "f", "in", "glob", "(", "join", "(", "target", ",", "\"[0-9]*...
9d1987cdb3a395cf4125a3439c3b002ff2be2009
valid
main
Identify the release type and create a new target file with TOML header. Requires three arguments.
scripts/publish_release.py
def main(argv): """ Identify the release type and create a new target file with TOML header. Requires three arguments. """ source, target, tag = argv if "a" in tag: bump = "alpha" if "b" in tag: bump = "beta" else: bump = find_bump(target, tag) filename = "{...
def main(argv): """ Identify the release type and create a new target file with TOML header. Requires three arguments. """ source, target, tag = argv if "a" in tag: bump = "alpha" if "b" in tag: bump = "beta" else: bump = find_bump(target, tag) filename = "{...
[ "Identify", "the", "release", "type", "and", "create", "a", "new", "target", "file", "with", "TOML", "header", "." ]
opencobra/cobrapy
python
https://github.com/opencobra/cobrapy/blob/9d1987cdb3a395cf4125a3439c3b002ff2be2009/scripts/publish_release.py#L113-L129
[ "def", "main", "(", "argv", ")", ":", "source", ",", "target", ",", "tag", "=", "argv", "if", "\"a\"", "in", "tag", ":", "bump", "=", "\"alpha\"", "if", "\"b\"", "in", "tag", ":", "bump", "=", "\"beta\"", "else", ":", "bump", "=", "find_bump", "(",...
9d1987cdb3a395cf4125a3439c3b002ff2be2009
valid
_multi_deletion
Provide a common interface for single or multiple knockouts. Parameters ---------- model : cobra.Model The metabolic model to perform deletions in. entity : 'gene' or 'reaction' The entity to knockout (``cobra.Gene`` or ``cobra.Reaction``). element_lists : list List of itera...
cobra/flux_analysis/deletion.py
def _multi_deletion(model, entity, element_lists, method="fba", solution=None, processes=None, **kwargs): """ Provide a common interface for single or multiple knockouts. Parameters ---------- model : cobra.Model The metabolic model to perform deletions in. entity : ...
def _multi_deletion(model, entity, element_lists, method="fba", solution=None, processes=None, **kwargs): """ Provide a common interface for single or multiple knockouts. Parameters ---------- model : cobra.Model The metabolic model to perform deletions in. entity : ...
[ "Provide", "a", "common", "interface", "for", "single", "or", "multiple", "knockouts", "." ]
opencobra/cobrapy
python
https://github.com/opencobra/cobrapy/blob/9d1987cdb3a395cf4125a3439c3b002ff2be2009/cobra/flux_analysis/deletion.py#L77-L161
[ "def", "_multi_deletion", "(", "model", ",", "entity", ",", "element_lists", ",", "method", "=", "\"fba\"", ",", "solution", "=", "None", ",", "processes", "=", "None", ",", "*", "*", "kwargs", ")", ":", "solver", "=", "sutil", ".", "interface_to_str", "...
9d1987cdb3a395cf4125a3439c3b002ff2be2009
valid
single_reaction_deletion
Knock out each reaction from a given list. Parameters ---------- model : cobra.Model The metabolic model to perform deletions in. reaction_list : iterable, optional ``cobra.Reaction``s to be deleted. If not passed, all the reactions from the model are used. method: {"fba", "...
cobra/flux_analysis/deletion.py
def single_reaction_deletion(model, reaction_list=None, method="fba", solution=None, processes=None, **kwargs): """ Knock out each reaction from a given list. Parameters ---------- model : cobra.Model The metabolic model to perform deletions in. reaction_lis...
def single_reaction_deletion(model, reaction_list=None, method="fba", solution=None, processes=None, **kwargs): """ Knock out each reaction from a given list. Parameters ---------- model : cobra.Model The metabolic model to perform deletions in. reaction_lis...
[ "Knock", "out", "each", "reaction", "from", "a", "given", "list", "." ]
opencobra/cobrapy
python
https://github.com/opencobra/cobrapy/blob/9d1987cdb3a395cf4125a3439c3b002ff2be2009/cobra/flux_analysis/deletion.py#L184-L225
[ "def", "single_reaction_deletion", "(", "model", ",", "reaction_list", "=", "None", ",", "method", "=", "\"fba\"", ",", "solution", "=", "None", ",", "processes", "=", "None", ",", "*", "*", "kwargs", ")", ":", "return", "_multi_deletion", "(", "model", ",...
9d1987cdb3a395cf4125a3439c3b002ff2be2009
valid
single_gene_deletion
Knock out each gene from a given list. Parameters ---------- model : cobra.Model The metabolic model to perform deletions in. gene_list : iterable ``cobra.Gene``s to be deleted. If not passed, all the genes from the model are used. method: {"fba", "moma", "linear moma", "roo...
cobra/flux_analysis/deletion.py
def single_gene_deletion(model, gene_list=None, method="fba", solution=None, processes=None, **kwargs): """ Knock out each gene from a given list. Parameters ---------- model : cobra.Model The metabolic model to perform deletions in. gene_list : iterable ...
def single_gene_deletion(model, gene_list=None, method="fba", solution=None, processes=None, **kwargs): """ Knock out each gene from a given list. Parameters ---------- model : cobra.Model The metabolic model to perform deletions in. gene_list : iterable ...
[ "Knock", "out", "each", "gene", "from", "a", "given", "list", "." ]
opencobra/cobrapy
python
https://github.com/opencobra/cobrapy/blob/9d1987cdb3a395cf4125a3439c3b002ff2be2009/cobra/flux_analysis/deletion.py#L228-L268
[ "def", "single_gene_deletion", "(", "model", ",", "gene_list", "=", "None", ",", "method", "=", "\"fba\"", ",", "solution", "=", "None", ",", "processes", "=", "None", ",", "*", "*", "kwargs", ")", ":", "return", "_multi_deletion", "(", "model", ",", "'g...
9d1987cdb3a395cf4125a3439c3b002ff2be2009
valid
double_reaction_deletion
Knock out each reaction pair from the combinations of two given lists. We say 'pair' here but the order order does not matter. Parameters ---------- model : cobra.Model The metabolic model to perform deletions in. reaction_list1 : iterable, optional First iterable of ``cobra.Reacti...
cobra/flux_analysis/deletion.py
def double_reaction_deletion(model, reaction_list1=None, reaction_list2=None, method="fba", solution=None, processes=None, **kwargs): """ Knock out each reaction pair from the combinations of two given lists. We say 'pair' here but the order order d...
def double_reaction_deletion(model, reaction_list1=None, reaction_list2=None, method="fba", solution=None, processes=None, **kwargs): """ Knock out each reaction pair from the combinations of two given lists. We say 'pair' here but the order order d...
[ "Knock", "out", "each", "reaction", "pair", "from", "the", "combinations", "of", "two", "given", "lists", "." ]
opencobra/cobrapy
python
https://github.com/opencobra/cobrapy/blob/9d1987cdb3a395cf4125a3439c3b002ff2be2009/cobra/flux_analysis/deletion.py#L271-L321
[ "def", "double_reaction_deletion", "(", "model", ",", "reaction_list1", "=", "None", ",", "reaction_list2", "=", "None", ",", "method", "=", "\"fba\"", ",", "solution", "=", "None", ",", "processes", "=", "None", ",", "*", "*", "kwargs", ")", ":", "reactio...
9d1987cdb3a395cf4125a3439c3b002ff2be2009
valid
double_gene_deletion
Knock out each gene pair from the combination of two given lists. We say 'pair' here but the order order does not matter. Parameters ---------- model : cobra.Model The metabolic model to perform deletions in. gene_list1 : iterable, optional First iterable of ``cobra.Gene``s to be d...
cobra/flux_analysis/deletion.py
def double_gene_deletion(model, gene_list1=None, gene_list2=None, method="fba", solution=None, processes=None, **kwargs): """ Knock out each gene pair from the combination of two given lists. We say 'pair' here but the order order does not matter. Parameters ---------- ...
def double_gene_deletion(model, gene_list1=None, gene_list2=None, method="fba", solution=None, processes=None, **kwargs): """ Knock out each gene pair from the combination of two given lists. We say 'pair' here but the order order does not matter. Parameters ---------- ...
[ "Knock", "out", "each", "gene", "pair", "from", "the", "combination", "of", "two", "given", "lists", "." ]
opencobra/cobrapy
python
https://github.com/opencobra/cobrapy/blob/9d1987cdb3a395cf4125a3439c3b002ff2be2009/cobra/flux_analysis/deletion.py#L324-L372
[ "def", "double_gene_deletion", "(", "model", ",", "gene_list1", "=", "None", ",", "gene_list2", "=", "None", ",", "method", "=", "\"fba\"", ",", "solution", "=", "None", ",", "processes", "=", "None", ",", "*", "*", "kwargs", ")", ":", "gene_list1", ",",...
9d1987cdb3a395cf4125a3439c3b002ff2be2009
valid
Reaction.reverse_id
Generate the id of reverse_variable from the reaction's id.
cobra/core/reaction.py
def reverse_id(self): """Generate the id of reverse_variable from the reaction's id.""" return '_'.join((self.id, 'reverse', hashlib.md5( self.id.encode('utf-8')).hexdigest()[0:5]))
def reverse_id(self): """Generate the id of reverse_variable from the reaction's id.""" return '_'.join((self.id, 'reverse', hashlib.md5( self.id.encode('utf-8')).hexdigest()[0:5]))
[ "Generate", "the", "id", "of", "reverse_variable", "from", "the", "reaction", "s", "id", "." ]
opencobra/cobrapy
python
https://github.com/opencobra/cobrapy/blob/9d1987cdb3a395cf4125a3439c3b002ff2be2009/cobra/core/reaction.py#L107-L111
[ "def", "reverse_id", "(", "self", ")", ":", "return", "'_'", ".", "join", "(", "(", "self", ".", "id", ",", "'reverse'", ",", "hashlib", ".", "md5", "(", "self", ".", "id", ".", "encode", "(", "'utf-8'", ")", ")", ".", "hexdigest", "(", ")", "[",...
9d1987cdb3a395cf4125a3439c3b002ff2be2009
valid
Reaction.flux
The flux value in the most recent solution. Flux is the primal value of the corresponding variable in the model. Warnings -------- * Accessing reaction fluxes through a `Solution` object is the safer, preferred, and only guaranteed to be correct way. You can see how to ...
cobra/core/reaction.py
def flux(self): """ The flux value in the most recent solution. Flux is the primal value of the corresponding variable in the model. Warnings -------- * Accessing reaction fluxes through a `Solution` object is the safer, preferred, and only guaranteed to be co...
def flux(self): """ The flux value in the most recent solution. Flux is the primal value of the corresponding variable in the model. Warnings -------- * Accessing reaction fluxes through a `Solution` object is the safer, preferred, and only guaranteed to be co...
[ "The", "flux", "value", "in", "the", "most", "recent", "solution", "." ]
opencobra/cobrapy
python
https://github.com/opencobra/cobrapy/blob/9d1987cdb3a395cf4125a3439c3b002ff2be2009/cobra/core/reaction.py#L304-L355
[ "def", "flux", "(", "self", ")", ":", "try", ":", "check_solver_status", "(", "self", ".", "_model", ".", "solver", ".", "status", ")", "return", "self", ".", "forward_variable", ".", "primal", "-", "self", ".", "reverse_variable", ".", "primal", "except",...
9d1987cdb3a395cf4125a3439c3b002ff2be2009
valid
Reaction.gene_name_reaction_rule
Display gene_reaction_rule with names intead. Do NOT use this string for computation. It is intended to give a representation of the rule using more familiar gene names instead of the often cryptic ids.
cobra/core/reaction.py
def gene_name_reaction_rule(self): """Display gene_reaction_rule with names intead. Do NOT use this string for computation. It is intended to give a representation of the rule using more familiar gene names instead of the often cryptic ids. """ names = {i.id: i.name for...
def gene_name_reaction_rule(self): """Display gene_reaction_rule with names intead. Do NOT use this string for computation. It is intended to give a representation of the rule using more familiar gene names instead of the often cryptic ids. """ names = {i.id: i.name for...
[ "Display", "gene_reaction_rule", "with", "names", "intead", "." ]
opencobra/cobrapy
python
https://github.com/opencobra/cobrapy/blob/9d1987cdb3a395cf4125a3439c3b002ff2be2009/cobra/core/reaction.py#L477-L487
[ "def", "gene_name_reaction_rule", "(", "self", ")", ":", "names", "=", "{", "i", ".", "id", ":", "i", ".", "name", "for", "i", "in", "self", ".", "_genes", "}", "ast", "=", "parse_gpr", "(", "self", ".", "_gene_reaction_rule", ")", "[", "0", "]", "...
9d1987cdb3a395cf4125a3439c3b002ff2be2009