id
int32
0
252k
repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
75
19.8k
code_tokens
list
docstring
stringlengths
3
17.3k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
87
242
48,200
zhanglab/psamm
psamm/datasource/reaction.py
parse_compound
def parse_compound(s, global_compartment=None): """Parse a compound specification. If no compartment is specified in the string, the global compartment will be used. """ m = re.match(r'^\|(.*)\|$', s) if m: s = m.group(1) m = re.match(r'^(.+)\[(\S+)\]$', s) if m: compou...
python
def parse_compound(s, global_compartment=None): """Parse a compound specification. If no compartment is specified in the string, the global compartment will be used. """ m = re.match(r'^\|(.*)\|$', s) if m: s = m.group(1) m = re.match(r'^(.+)\[(\S+)\]$', s) if m: compou...
[ "def", "parse_compound", "(", "s", ",", "global_compartment", "=", "None", ")", ":", "m", "=", "re", ".", "match", "(", "r'^\\|(.*)\\|$'", ",", "s", ")", "if", "m", ":", "s", "=", "m", ".", "group", "(", "1", ")", "m", "=", "re", ".", "match", ...
Parse a compound specification. If no compartment is specified in the string, the global compartment will be used.
[ "Parse", "a", "compound", "specification", "." ]
dc427848c4f9d109ca590f0afa024c63b685b3f4
https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/datasource/reaction.py#L226-L244
48,201
zhanglab/psamm
psamm/randomsparse.py
random_sparse
def random_sparse(strategy, prob, obj_reaction, flux_threshold): """Find a random minimal network of model reactions. Given a reaction to optimize and a threshold, delete entities randomly until the flux of the reaction to optimize falls under the threshold. Keep deleting until no more entities can be ...
python
def random_sparse(strategy, prob, obj_reaction, flux_threshold): """Find a random minimal network of model reactions. Given a reaction to optimize and a threshold, delete entities randomly until the flux of the reaction to optimize falls under the threshold. Keep deleting until no more entities can be ...
[ "def", "random_sparse", "(", "strategy", ",", "prob", ",", "obj_reaction", ",", "flux_threshold", ")", ":", "essential", "=", "set", "(", ")", "deleted", "=", "set", "(", ")", "for", "entity", ",", "deleted_reactions", "in", "strategy", ".", "iter_tests", ...
Find a random minimal network of model reactions. Given a reaction to optimize and a threshold, delete entities randomly until the flux of the reaction to optimize falls under the threshold. Keep deleting until no more entities can be deleted. It works with two strategies: deleting reactions or deletin...
[ "Find", "a", "random", "minimal", "network", "of", "model", "reactions", "." ]
dc427848c4f9d109ca590f0afa024c63b685b3f4
https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/randomsparse.py#L152-L224
48,202
zhanglab/psamm
psamm/commands/gapcheck.py
GapCheckCommand.run_sink_check
def run_sink_check(self, model, solver, threshold, implicit_sinks=True): """Run sink production check method.""" prob = solver.create_problem() # Create flux variables v = prob.namespace() for reaction_id in model.reactions: lower, upper = model.limits[reaction_id] ...
python
def run_sink_check(self, model, solver, threshold, implicit_sinks=True): """Run sink production check method.""" prob = solver.create_problem() # Create flux variables v = prob.namespace() for reaction_id in model.reactions: lower, upper = model.limits[reaction_id] ...
[ "def", "run_sink_check", "(", "self", ",", "model", ",", "solver", ",", "threshold", ",", "implicit_sinks", "=", "True", ")", ":", "prob", "=", "solver", ".", "create_problem", "(", ")", "# Create flux variables", "v", "=", "prob", ".", "namespace", "(", "...
Run sink production check method.
[ "Run", "sink", "production", "check", "method", "." ]
dc427848c4f9d109ca590f0afa024c63b685b3f4
https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/commands/gapcheck.py#L112-L157
48,203
zhanglab/psamm
psamm/commands/gapcheck.py
GapCheckCommand.run_reaction_production_check
def run_reaction_production_check(self, model, solver, threshold, implicit_sinks=True): """Run reaction production check method.""" prob = solver.create_problem() # Create flux variables v = prob.namespace() for reaction_id in model.reaction...
python
def run_reaction_production_check(self, model, solver, threshold, implicit_sinks=True): """Run reaction production check method.""" prob = solver.create_problem() # Create flux variables v = prob.namespace() for reaction_id in model.reaction...
[ "def", "run_reaction_production_check", "(", "self", ",", "model", ",", "solver", ",", "threshold", ",", "implicit_sinks", "=", "True", ")", ":", "prob", "=", "solver", ".", "create_problem", "(", ")", "# Create flux variables", "v", "=", "prob", ".", "namespa...
Run reaction production check method.
[ "Run", "reaction", "production", "check", "method", "." ]
dc427848c4f9d109ca590f0afa024c63b685b3f4
https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/commands/gapcheck.py#L159-L217
48,204
zhanglab/psamm
psamm/lpsolver/cplex.py
Problem.add_linear_constraints
def add_linear_constraints(self, *relations): """Add constraints to the problem Each constraint is represented by a Relation, and the expression in that relation can be a set expression. """ constraints = [] for relation in relations: if self._check_relation...
python
def add_linear_constraints(self, *relations): """Add constraints to the problem Each constraint is represented by a Relation, and the expression in that relation can be a set expression. """ constraints = [] for relation in relations: if self._check_relation...
[ "def", "add_linear_constraints", "(", "self", ",", "*", "relations", ")", ":", "constraints", "=", "[", "]", "for", "relation", "in", "relations", ":", "if", "self", ".", "_check_relation", "(", "relation", ")", ":", "constraints", ".", "append", "(", "Con...
Add constraints to the problem Each constraint is represented by a Relation, and the expression in that relation can be a set expression.
[ "Add", "constraints", "to", "the", "problem" ]
dc427848c4f9d109ca590f0afa024c63b685b3f4
https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/lpsolver/cplex.py#L206-L221
48,205
zhanglab/psamm
psamm/lpsolver/cplex.py
Problem.set_objective
def set_objective(self, expression): """Set objective expression of the problem.""" if isinstance(expression, numbers.Number): # Allow expressions with no variables as objective, # represented as a number expression = Expression(offset=expression) linear = [...
python
def set_objective(self, expression): """Set objective expression of the problem.""" if isinstance(expression, numbers.Number): # Allow expressions with no variables as objective, # represented as a number expression = Expression(offset=expression) linear = [...
[ "def", "set_objective", "(", "self", ",", "expression", ")", ":", "if", "isinstance", "(", "expression", ",", "numbers", ".", "Number", ")", ":", "# Allow expressions with no variables as objective,", "# represented as a number", "expression", "=", "Expression", "(", ...
Set objective expression of the problem.
[ "Set", "objective", "expression", "of", "the", "problem", "." ]
dc427848c4f9d109ca590f0afa024c63b685b3f4
https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/lpsolver/cplex.py#L223-L270
48,206
zhanglab/psamm
psamm/lpsolver/cplex.py
Problem._reset_problem_type
def _reset_problem_type(self): """Reset problem type to whatever is appropriate.""" # Only need to reset the type after the first solve. This also works # around a bug in Cplex where get_num_binary() is some rare cases # causes a segfault. if self._solve_count > 0: i...
python
def _reset_problem_type(self): """Reset problem type to whatever is appropriate.""" # Only need to reset the type after the first solve. This also works # around a bug in Cplex where get_num_binary() is some rare cases # causes a segfault. if self._solve_count > 0: i...
[ "def", "_reset_problem_type", "(", "self", ")", ":", "# Only need to reset the type after the first solve. This also works", "# around a bug in Cplex where get_num_binary() is some rare cases", "# causes a segfault.", "if", "self", ".", "_solve_count", ">", "0", ":", "integer_count",...
Reset problem type to whatever is appropriate.
[ "Reset", "problem", "type", "to", "whatever", "is", "appropriate", "." ]
dc427848c4f9d109ca590f0afa024c63b685b3f4
https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/lpsolver/cplex.py#L288-L341
48,207
zhanglab/psamm
psamm/lpsolver/cplex.py
Result.get_value
def get_value(self, expression): """Return value of expression.""" self._check_valid() return super(Result, self).get_value(expression)
python
def get_value(self, expression): """Return value of expression.""" self._check_valid() return super(Result, self).get_value(expression)
[ "def", "get_value", "(", "self", ",", "expression", ")", ":", "self", ".", "_check_valid", "(", ")", "return", "super", "(", "Result", ",", "self", ")", ".", "get_value", "(", "expression", ")" ]
Return value of expression.
[ "Return", "value", "of", "expression", "." ]
dc427848c4f9d109ca590f0afa024c63b685b3f4
https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/lpsolver/cplex.py#L468-L471
48,208
zhanglab/psamm
psamm/formula.py
_parse_formula
def _parse_formula(s): """Parse formula string.""" scanner = re.compile(r''' (\s+) | # whitespace (\(|\)) | # group ([A-Z][a-z]*) | # element (\d+) | # number ([a-z]) | # variable (\Z) | # end (.) # error ...
python
def _parse_formula(s): """Parse formula string.""" scanner = re.compile(r''' (\s+) | # whitespace (\(|\)) | # group ([A-Z][a-z]*) | # element (\d+) | # number ([a-z]) | # variable (\Z) | # end (.) # error ...
[ "def", "_parse_formula", "(", "s", ")", ":", "scanner", "=", "re", ".", "compile", "(", "r'''\n (\\s+) | # whitespace\n (\\(|\\)) | # group\n ([A-Z][a-z]*) | # element\n (\\d+) | # number\n ([a-z]) | # variable\n (\\Z) | ...
Parse formula string.
[ "Parse", "formula", "string", "." ]
dc427848c4f9d109ca590f0afa024c63b685b3f4
https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/formula.py#L425-L510
48,209
hearsaycorp/normalize
normalize/visitor.py
Visitor.copy
def copy(self): """Be sure to implement this method when sub-classing, otherwise you will lose any specialization context.""" doppel = type(self)( self.unpack, self.apply, self.collect, self.reduce, apply_empty_slots=self.apply_empty_slots, extraneous=self.ext...
python
def copy(self): """Be sure to implement this method when sub-classing, otherwise you will lose any specialization context.""" doppel = type(self)( self.unpack, self.apply, self.collect, self.reduce, apply_empty_slots=self.apply_empty_slots, extraneous=self.ext...
[ "def", "copy", "(", "self", ")", ":", "doppel", "=", "type", "(", "self", ")", "(", "self", ".", "unpack", ",", "self", ".", "apply", ",", "self", ".", "collect", ",", "self", ".", "reduce", ",", "apply_empty_slots", "=", "self", ".", "apply_empty_sl...
Be sure to implement this method when sub-classing, otherwise you will lose any specialization context.
[ "Be", "sure", "to", "implement", "this", "method", "when", "sub", "-", "classing", "otherwise", "you", "will", "lose", "any", "specialization", "context", "." ]
8b36522ddca6d41b434580bd848f3bdaa7a999c8
https://github.com/hearsaycorp/normalize/blob/8b36522ddca6d41b434580bd848f3bdaa7a999c8/normalize/visitor.py#L105-L119
48,210
hearsaycorp/normalize
normalize/visitor.py
VisitorPattern.unpack
def unpack(cls, value, value_type, visitor): """Unpack a value during a 'visit' args: ``value=``\ *object* The instance being visited ``value_type=``\ *RecordType* The expected type of the instance ``visitor=``\ *Visitor* ...
python
def unpack(cls, value, value_type, visitor): """Unpack a value during a 'visit' args: ``value=``\ *object* The instance being visited ``value_type=``\ *RecordType* The expected type of the instance ``visitor=``\ *Visitor* ...
[ "def", "unpack", "(", "cls", ",", "value", ",", "value_type", ",", "visitor", ")", ":", "if", "issubclass", "(", "value_type", ",", "Collection", ")", ":", "try", ":", "generator", "=", "value", ".", "itertuples", "(", ")", "except", "AttributeError", ":...
Unpack a value during a 'visit' args: ``value=``\ *object* The instance being visited ``value_type=``\ *RecordType* The expected type of the instance ``visitor=``\ *Visitor* The context/options returns a tuple with ...
[ "Unpack", "a", "value", "during", "a", "visit" ]
8b36522ddca6d41b434580bd848f3bdaa7a999c8
https://github.com/hearsaycorp/normalize/blob/8b36522ddca6d41b434580bd848f3bdaa7a999c8/normalize/visitor.py#L196-L247
48,211
hearsaycorp/normalize
normalize/visitor.py
VisitorPattern.apply
def apply(cls, value, prop, visitor): """'apply' is a general place to put a function which is called on every extant record slot. This is usually the most important function to implement when sub-classing. The default implementation passes through the slot value as-is, but exp...
python
def apply(cls, value, prop, visitor): """'apply' is a general place to put a function which is called on every extant record slot. This is usually the most important function to implement when sub-classing. The default implementation passes through the slot value as-is, but exp...
[ "def", "apply", "(", "cls", ",", "value", ",", "prop", ",", "visitor", ")", ":", "return", "(", "None", "if", "isinstance", "(", "value", ",", "(", "AttributeError", ",", "KeyError", ")", ")", "else", "value", ")" ]
apply' is a general place to put a function which is called on every extant record slot. This is usually the most important function to implement when sub-classing. The default implementation passes through the slot value as-is, but expected exceptions are converted to ``None``. ...
[ "apply", "is", "a", "general", "place", "to", "put", "a", "function", "which", "is", "called", "on", "every", "extant", "record", "slot", ".", "This", "is", "usually", "the", "most", "important", "function", "to", "implement", "when", "sub", "-", "classing...
8b36522ddca6d41b434580bd848f3bdaa7a999c8
https://github.com/hearsaycorp/normalize/blob/8b36522ddca6d41b434580bd848f3bdaa7a999c8/normalize/visitor.py#L250-L284
48,212
hearsaycorp/normalize
normalize/visitor.py
VisitorPattern.aggregate
def aggregate(self, mapped_coll_generator, coll_type, visitor): """Hook called for each normalize.coll.Collection, after mapping over each of the items in the collection. The default implementation calls :py:meth:`normalize.coll.Collection.tuples_to_coll` with ``coerce=False``, ...
python
def aggregate(self, mapped_coll_generator, coll_type, visitor): """Hook called for each normalize.coll.Collection, after mapping over each of the items in the collection. The default implementation calls :py:meth:`normalize.coll.Collection.tuples_to_coll` with ``coerce=False``, ...
[ "def", "aggregate", "(", "self", ",", "mapped_coll_generator", ",", "coll_type", ",", "visitor", ")", ":", "return", "coll_type", ".", "tuples_to_coll", "(", "mapped_coll_generator", ",", "coerce", "=", "False", ")" ]
Hook called for each normalize.coll.Collection, after mapping over each of the items in the collection. The default implementation calls :py:meth:`normalize.coll.Collection.tuples_to_coll` with ``coerce=False``, which just re-assembles the collection into a native python collect...
[ "Hook", "called", "for", "each", "normalize", ".", "coll", ".", "Collection", "after", "mapping", "over", "each", "of", "the", "items", "in", "the", "collection", "." ]
8b36522ddca6d41b434580bd848f3bdaa7a999c8
https://github.com/hearsaycorp/normalize/blob/8b36522ddca6d41b434580bd848f3bdaa7a999c8/normalize/visitor.py#L287-L309
48,213
hearsaycorp/normalize
normalize/visitor.py
VisitorPattern.reduce
def reduce(self, mapped_props, aggregated, value_type, visitor): """This reduction is called to combine the mapped slot and collection item values into a single value for return. The default implementation tries to behave naturally; you'll almost always get a dict back when mapping over...
python
def reduce(self, mapped_props, aggregated, value_type, visitor): """This reduction is called to combine the mapped slot and collection item values into a single value for return. The default implementation tries to behave naturally; you'll almost always get a dict back when mapping over...
[ "def", "reduce", "(", "self", ",", "mapped_props", ",", "aggregated", ",", "value_type", ",", "visitor", ")", ":", "reduced", "=", "None", "if", "mapped_props", ":", "reduced", "=", "dict", "(", "(", "k", ".", "name", ",", "v", ")", "for", "k", ",", ...
This reduction is called to combine the mapped slot and collection item values into a single value for return. The default implementation tries to behave naturally; you'll almost always get a dict back when mapping over a record, and list or some other collection when mapping over colle...
[ "This", "reduction", "is", "called", "to", "combine", "the", "mapped", "slot", "and", "collection", "item", "values", "into", "a", "single", "value", "for", "return", "." ]
8b36522ddca6d41b434580bd848f3bdaa7a999c8
https://github.com/hearsaycorp/normalize/blob/8b36522ddca6d41b434580bd848f3bdaa7a999c8/normalize/visitor.py#L312-L359
48,214
hearsaycorp/normalize
normalize/visitor.py
VisitorPattern.reflect
def reflect(cls, X, **kwargs): """Reflect is for visitors where you are exposing some information about the types reachable from a starting type to an external system. For example, a front-end, a REST URL router and documentation framework, an avro schema definition, etc. X can ...
python
def reflect(cls, X, **kwargs): """Reflect is for visitors where you are exposing some information about the types reachable from a starting type to an external system. For example, a front-end, a REST URL router and documentation framework, an avro schema definition, etc. X can ...
[ "def", "reflect", "(", "cls", ",", "X", ",", "*", "*", "kwargs", ")", ":", "if", "isinstance", "(", "X", ",", "type", ")", ":", "value", "=", "None", "value_type", "=", "X", "else", ":", "value", "=", "X", "value_type", "=", "type", "(", "X", "...
Reflect is for visitors where you are exposing some information about the types reachable from a starting type to an external system. For example, a front-end, a REST URL router and documentation framework, an avro schema definition, etc. X can be a type or an instance. This AP...
[ "Reflect", "is", "for", "visitors", "where", "you", "are", "exposing", "some", "information", "about", "the", "types", "reachable", "from", "a", "starting", "type", "to", "an", "external", "system", ".", "For", "example", "a", "front", "-", "end", "a", "RE...
8b36522ddca6d41b434580bd848f3bdaa7a999c8
https://github.com/hearsaycorp/normalize/blob/8b36522ddca6d41b434580bd848f3bdaa7a999c8/normalize/visitor.py#L482-L506
48,215
hearsaycorp/normalize
normalize/visitor.py
VisitorPattern.map
def map(cls, visitor, value, value_type): """The common visitor API used by all three visitor implementations. args: ``visitor=``\ *Visitor* Visitor options instance: contains the callbacks to use to implement the visiting, as well as traversal & filtering ...
python
def map(cls, visitor, value, value_type): """The common visitor API used by all three visitor implementations. args: ``visitor=``\ *Visitor* Visitor options instance: contains the callbacks to use to implement the visiting, as well as traversal & filtering ...
[ "def", "map", "(", "cls", ",", "visitor", ",", "value", ",", "value_type", ")", ":", "unpacked", "=", "visitor", ".", "unpack", "(", "value", ",", "value_type", ",", "visitor", ")", "if", "unpacked", "==", "cls", ".", "StopVisiting", "or", "isinstance", ...
The common visitor API used by all three visitor implementations. args: ``visitor=``\ *Visitor* Visitor options instance: contains the callbacks to use to implement the visiting, as well as traversal & filtering options. ``value=``\ *Obj...
[ "The", "common", "visitor", "API", "used", "by", "all", "three", "visitor", "implementations", "." ]
8b36522ddca6d41b434580bd848f3bdaa7a999c8
https://github.com/hearsaycorp/normalize/blob/8b36522ddca6d41b434580bd848f3bdaa7a999c8/normalize/visitor.py#L591-L639
48,216
zhanglab/psamm
psamm/fluxanalysis.py
_get_fba_problem
def _get_fba_problem(model, tfba, solver): """Convenience function for returning the right FBA problem instance""" p = FluxBalanceProblem(model, solver) if tfba: p.add_thermodynamic() return p
python
def _get_fba_problem(model, tfba, solver): """Convenience function for returning the right FBA problem instance""" p = FluxBalanceProblem(model, solver) if tfba: p.add_thermodynamic() return p
[ "def", "_get_fba_problem", "(", "model", ",", "tfba", ",", "solver", ")", ":", "p", "=", "FluxBalanceProblem", "(", "model", ",", "solver", ")", "if", "tfba", ":", "p", ".", "add_thermodynamic", "(", ")", "return", "p" ]
Convenience function for returning the right FBA problem instance
[ "Convenience", "function", "for", "returning", "the", "right", "FBA", "problem", "instance" ]
dc427848c4f9d109ca590f0afa024c63b685b3f4
https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/fluxanalysis.py#L35-L40
48,217
zhanglab/psamm
psamm/fluxanalysis.py
flux_balance
def flux_balance(model, reaction, tfba, solver): """Run flux balance analysis on the given model. Yields the reaction id and flux value for each reaction in the model. This is a convenience function for sertting up and running the FluxBalanceProblem. If the FBA is solved for more than one parameter ...
python
def flux_balance(model, reaction, tfba, solver): """Run flux balance analysis on the given model. Yields the reaction id and flux value for each reaction in the model. This is a convenience function for sertting up and running the FluxBalanceProblem. If the FBA is solved for more than one parameter ...
[ "def", "flux_balance", "(", "model", ",", "reaction", ",", "tfba", ",", "solver", ")", ":", "fba", "=", "_get_fba_problem", "(", "model", ",", "tfba", ",", "solver", ")", "fba", ".", "maximize", "(", "reaction", ")", "for", "reaction", "in", "model", "...
Run flux balance analysis on the given model. Yields the reaction id and flux value for each reaction in the model. This is a convenience function for sertting up and running the FluxBalanceProblem. If the FBA is solved for more than one parameter it is recommended to setup and reuse the FluxBalancePr...
[ "Run", "flux", "balance", "analysis", "on", "the", "given", "model", "." ]
dc427848c4f9d109ca590f0afa024c63b685b3f4
https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/fluxanalysis.py#L293-L320
48,218
zhanglab/psamm
psamm/fluxanalysis.py
flux_variability
def flux_variability(model, reactions, fixed, tfba, solver): """Find the variability of each reaction while fixing certain fluxes. Yields the reaction id, and a tuple of minimum and maximum value for each of the given reactions. The fixed reactions are given in a dictionary as a reaction id to value ma...
python
def flux_variability(model, reactions, fixed, tfba, solver): """Find the variability of each reaction while fixing certain fluxes. Yields the reaction id, and a tuple of minimum and maximum value for each of the given reactions. The fixed reactions are given in a dictionary as a reaction id to value ma...
[ "def", "flux_variability", "(", "model", ",", "reactions", ",", "fixed", ",", "tfba", ",", "solver", ")", ":", "fba", "=", "_get_fba_problem", "(", "model", ",", "tfba", ",", "solver", ")", "for", "reaction_id", ",", "value", "in", "iteritems", "(", "fix...
Find the variability of each reaction while fixing certain fluxes. Yields the reaction id, and a tuple of minimum and maximum value for each of the given reactions. The fixed reactions are given in a dictionary as a reaction id to value mapping. This is an implementation of flux variability analysis (...
[ "Find", "the", "variability", "of", "each", "reaction", "while", "fixing", "certain", "fluxes", "." ]
dc427848c4f9d109ca590f0afa024c63b685b3f4
https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/fluxanalysis.py#L323-L357
48,219
zhanglab/psamm
psamm/fluxanalysis.py
flux_minimization
def flux_minimization(model, fixed, solver, weights={}): """Minimize flux of all reactions while keeping certain fluxes fixed. The fixed reactions are given in a dictionary as reaction id to value mapping. The weighted L1-norm of the fluxes is minimized. Args: model: MetabolicModel to solve. ...
python
def flux_minimization(model, fixed, solver, weights={}): """Minimize flux of all reactions while keeping certain fluxes fixed. The fixed reactions are given in a dictionary as reaction id to value mapping. The weighted L1-norm of the fluxes is minimized. Args: model: MetabolicModel to solve. ...
[ "def", "flux_minimization", "(", "model", ",", "fixed", ",", "solver", ",", "weights", "=", "{", "}", ")", ":", "fba", "=", "FluxBalanceProblem", "(", "model", ",", "solver", ")", "for", "reaction_id", ",", "value", "in", "iteritems", "(", "fixed", ")", ...
Minimize flux of all reactions while keeping certain fluxes fixed. The fixed reactions are given in a dictionary as reaction id to value mapping. The weighted L1-norm of the fluxes is minimized. Args: model: MetabolicModel to solve. fixed: dict of additional lower bounds on reaction fluxes...
[ "Minimize", "flux", "of", "all", "reactions", "while", "keeping", "certain", "fluxes", "fixed", "." ]
dc427848c4f9d109ca590f0afa024c63b685b3f4
https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/fluxanalysis.py#L360-L385
48,220
zhanglab/psamm
psamm/fluxanalysis.py
flux_randomization
def flux_randomization(model, threshold, tfba, solver): """Find a random flux solution on the boundary of the solution space. The reactions in the threshold dictionary are constrained with the associated lower bound. Args: model: MetabolicModel to solve. threshold: dict of additional l...
python
def flux_randomization(model, threshold, tfba, solver): """Find a random flux solution on the boundary of the solution space. The reactions in the threshold dictionary are constrained with the associated lower bound. Args: model: MetabolicModel to solve. threshold: dict of additional l...
[ "def", "flux_randomization", "(", "model", ",", "threshold", ",", "tfba", ",", "solver", ")", ":", "optimize", "=", "{", "}", "for", "reaction_id", "in", "model", ".", "reactions", ":", "if", "model", ".", "is_reversible", "(", "reaction_id", ")", ":", "...
Find a random flux solution on the boundary of the solution space. The reactions in the threshold dictionary are constrained with the associated lower bound. Args: model: MetabolicModel to solve. threshold: dict of additional lower bounds on reaction fluxes. tfba: If True enable th...
[ "Find", "a", "random", "flux", "solution", "on", "the", "boundary", "of", "the", "solution", "space", "." ]
dc427848c4f9d109ca590f0afa024c63b685b3f4
https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/fluxanalysis.py#L388-L417
48,221
zhanglab/psamm
psamm/fluxanalysis.py
consistency_check
def consistency_check(model, subset, epsilon, tfba, solver): """Check that reaction subset of model is consistent using FBA. Yields all reactions that are *not* flux consistent. A reaction is consistent if there is at least one flux solution to the model that both respects the model constraints and als...
python
def consistency_check(model, subset, epsilon, tfba, solver): """Check that reaction subset of model is consistent using FBA. Yields all reactions that are *not* flux consistent. A reaction is consistent if there is at least one flux solution to the model that both respects the model constraints and als...
[ "def", "consistency_check", "(", "model", ",", "subset", ",", "epsilon", ",", "tfba", ",", "solver", ")", ":", "fba", "=", "_get_fba_problem", "(", "model", ",", "tfba", ",", "solver", ")", "subset", "=", "set", "(", "subset", ")", "while", "len", "(",...
Check that reaction subset of model is consistent using FBA. Yields all reactions that are *not* flux consistent. A reaction is consistent if there is at least one flux solution to the model that both respects the model constraints and also allows the reaction in question to have non-zero flux. Th...
[ "Check", "that", "reaction", "subset", "of", "model", "is", "consistent", "using", "FBA", "." ]
dc427848c4f9d109ca590f0afa024c63b685b3f4
https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/fluxanalysis.py#L420-L470
48,222
zhanglab/psamm
psamm/fluxanalysis.py
FluxBalanceProblem.add_thermodynamic
def add_thermodynamic(self, em=1000): """Apply thermodynamic constraints to the model. Adding these constraints restricts the solution space to only contain solutions that have no internal loops [Schilling00]_. This is solved as a MILP problem as described in [Muller13]_. The time to so...
python
def add_thermodynamic(self, em=1000): """Apply thermodynamic constraints to the model. Adding these constraints restricts the solution space to only contain solutions that have no internal loops [Schilling00]_. This is solved as a MILP problem as described in [Muller13]_. The time to so...
[ "def", "add_thermodynamic", "(", "self", ",", "em", "=", "1000", ")", ":", "internal", "=", "set", "(", "r", "for", "r", "in", "self", ".", "_model", ".", "reactions", "if", "not", "self", ".", "_model", ".", "is_exchange", "(", "r", ")", ")", "# R...
Apply thermodynamic constraints to the model. Adding these constraints restricts the solution space to only contain solutions that have no internal loops [Schilling00]_. This is solved as a MILP problem as described in [Muller13]_. The time to solve a problem with thermodynamic constrai...
[ "Apply", "thermodynamic", "constraints", "to", "the", "model", "." ]
dc427848c4f9d109ca590f0afa024c63b685b3f4
https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/fluxanalysis.py#L110-L168
48,223
zhanglab/psamm
psamm/fluxanalysis.py
FluxBalanceProblem.maximize
def maximize(self, reaction): """Solve the model by maximizing the given reaction. If reaction is a dictionary object, each entry is interpreted as a weight on the objective for that reaction (non-existent reaction will have zero weight). """ self._prob.set_objective(se...
python
def maximize(self, reaction): """Solve the model by maximizing the given reaction. If reaction is a dictionary object, each entry is interpreted as a weight on the objective for that reaction (non-existent reaction will have zero weight). """ self._prob.set_objective(se...
[ "def", "maximize", "(", "self", ",", "reaction", ")", ":", "self", ".", "_prob", ".", "set_objective", "(", "self", ".", "flux_expr", "(", "reaction", ")", ")", "self", ".", "_solve", "(", ")" ]
Solve the model by maximizing the given reaction. If reaction is a dictionary object, each entry is interpreted as a weight on the objective for that reaction (non-existent reaction will have zero weight).
[ "Solve", "the", "model", "by", "maximizing", "the", "given", "reaction", "." ]
dc427848c4f9d109ca590f0afa024c63b685b3f4
https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/fluxanalysis.py#L170-L179
48,224
zhanglab/psamm
psamm/fluxanalysis.py
FluxBalanceProblem.flux_bound
def flux_bound(self, reaction, direction): """Return the flux bound of the reaction. Direction must be a positive number to obtain the upper bound or a negative number to obtain the lower bound. A value of inf or -inf is returned if the problem is unbounded. """ try: ...
python
def flux_bound(self, reaction, direction): """Return the flux bound of the reaction. Direction must be a positive number to obtain the upper bound or a negative number to obtain the lower bound. A value of inf or -inf is returned if the problem is unbounded. """ try: ...
[ "def", "flux_bound", "(", "self", ",", "reaction", ",", "direction", ")", ":", "try", ":", "self", ".", "maximize", "(", "{", "reaction", ":", "direction", "}", ")", "except", "FluxBalanceError", "as", "e", ":", "if", "not", "e", ".", "result", ".", ...
Return the flux bound of the reaction. Direction must be a positive number to obtain the upper bound or a negative number to obtain the lower bound. A value of inf or -inf is returned if the problem is unbounded.
[ "Return", "the", "flux", "bound", "of", "the", "reaction", "." ]
dc427848c4f9d109ca590f0afa024c63b685b3f4
https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/fluxanalysis.py#L181-L195
48,225
zhanglab/psamm
psamm/fluxanalysis.py
FluxBalanceProblem._add_minimization_vars
def _add_minimization_vars(self): """Add variables and constraints for L1 norm minimization.""" self._z = self._prob.namespace(self._model.reactions, lower=0) # Define constraints v = self._v.set(self._model.reactions) z = self._z.set(self._model.reactions) self._prob....
python
def _add_minimization_vars(self): """Add variables and constraints for L1 norm minimization.""" self._z = self._prob.namespace(self._model.reactions, lower=0) # Define constraints v = self._v.set(self._model.reactions) z = self._z.set(self._model.reactions) self._prob....
[ "def", "_add_minimization_vars", "(", "self", ")", ":", "self", ".", "_z", "=", "self", ".", "_prob", ".", "namespace", "(", "self", ".", "_model", ".", "reactions", ",", "lower", "=", "0", ")", "# Define constraints", "v", "=", "self", ".", "_v", ".",...
Add variables and constraints for L1 norm minimization.
[ "Add", "variables", "and", "constraints", "for", "L1", "norm", "minimization", "." ]
dc427848c4f9d109ca590f0afa024c63b685b3f4
https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/fluxanalysis.py#L197-L206
48,226
zhanglab/psamm
psamm/fluxanalysis.py
FluxBalanceProblem.minimize_l1
def minimize_l1(self, weights={}): """Solve the model by minimizing the L1 norm of the fluxes. If the weights dictionary is given, the weighted L1 norm if minimized instead. The dictionary contains the weights of each reaction (default 1). """ if self._z is None: ...
python
def minimize_l1(self, weights={}): """Solve the model by minimizing the L1 norm of the fluxes. If the weights dictionary is given, the weighted L1 norm if minimized instead. The dictionary contains the weights of each reaction (default 1). """ if self._z is None: ...
[ "def", "minimize_l1", "(", "self", ",", "weights", "=", "{", "}", ")", ":", "if", "self", ".", "_z", "is", "None", ":", "self", ".", "_add_minimization_vars", "(", ")", "objective", "=", "self", ".", "_z", ".", "expr", "(", "(", "reaction_id", ",", ...
Solve the model by minimizing the L1 norm of the fluxes. If the weights dictionary is given, the weighted L1 norm if minimized instead. The dictionary contains the weights of each reaction (default 1).
[ "Solve", "the", "model", "by", "minimizing", "the", "L1", "norm", "of", "the", "fluxes", "." ]
dc427848c4f9d109ca590f0afa024c63b685b3f4
https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/fluxanalysis.py#L208-L224
48,227
zhanglab/psamm
psamm/fluxanalysis.py
FluxBalanceProblem.max_min_l1
def max_min_l1(self, reaction, weights={}): """Maximize flux of reaction then minimize the L1 norm. During minimization the given reaction will be fixed at the maximum obtained from the first solution. If reaction is a dictionary object, each entry is interpreted as a weight on the obje...
python
def max_min_l1(self, reaction, weights={}): """Maximize flux of reaction then minimize the L1 norm. During minimization the given reaction will be fixed at the maximum obtained from the first solution. If reaction is a dictionary object, each entry is interpreted as a weight on the obje...
[ "def", "max_min_l1", "(", "self", ",", "reaction", ",", "weights", "=", "{", "}", ")", ":", "self", ".", "maximize", "(", "reaction", ")", "if", "isinstance", "(", "reaction", ",", "dict", ")", ":", "reactions", "=", "list", "(", "reaction", ")", "el...
Maximize flux of reaction then minimize the L1 norm. During minimization the given reaction will be fixed at the maximum obtained from the first solution. If reaction is a dictionary object, each entry is interpreted as a weight on the objective for that reaction (non-existent reaction ...
[ "Maximize", "flux", "of", "reaction", "then", "minimize", "the", "L1", "norm", "." ]
dc427848c4f9d109ca590f0afa024c63b685b3f4
https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/fluxanalysis.py#L226-L251
48,228
zhanglab/psamm
psamm/fluxanalysis.py
FluxBalanceProblem._solve
def _solve(self): """Solve the problem with the current objective.""" # Remove temporary constraints while len(self._remove_constr) > 0: self._remove_constr.pop().delete() try: self._prob.solve(lp.ObjectiveSense.Maximize) except lp.SolverError as e: ...
python
def _solve(self): """Solve the problem with the current objective.""" # Remove temporary constraints while len(self._remove_constr) > 0: self._remove_constr.pop().delete() try: self._prob.solve(lp.ObjectiveSense.Maximize) except lp.SolverError as e: ...
[ "def", "_solve", "(", "self", ")", ":", "# Remove temporary constraints", "while", "len", "(", "self", ".", "_remove_constr", ")", ">", "0", ":", "self", ".", "_remove_constr", ".", "pop", "(", ")", ".", "delete", "(", ")", "try", ":", "self", ".", "_p...
Solve the problem with the current objective.
[ "Solve", "the", "problem", "with", "the", "current", "objective", "." ]
dc427848c4f9d109ca590f0afa024c63b685b3f4
https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/fluxanalysis.py#L261-L276
48,229
zhanglab/psamm
psamm/fluxanalysis.py
FluxBalanceProblem.flux_expr
def flux_expr(self, reaction): """Get LP expression representing the reaction flux.""" if isinstance(reaction, dict): return self._v.expr(iteritems(reaction)) return self._v(reaction)
python
def flux_expr(self, reaction): """Get LP expression representing the reaction flux.""" if isinstance(reaction, dict): return self._v.expr(iteritems(reaction)) return self._v(reaction)
[ "def", "flux_expr", "(", "self", ",", "reaction", ")", ":", "if", "isinstance", "(", "reaction", ",", "dict", ")", ":", "return", "self", ".", "_v", ".", "expr", "(", "iteritems", "(", "reaction", ")", ")", "return", "self", ".", "_v", "(", "reaction...
Get LP expression representing the reaction flux.
[ "Get", "LP", "expression", "representing", "the", "reaction", "flux", "." ]
dc427848c4f9d109ca590f0afa024c63b685b3f4
https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/fluxanalysis.py#L282-L286
48,230
zhanglab/psamm
psamm/fluxanalysis.py
FluxBalanceProblem.get_flux
def get_flux(self, reaction): """Get resulting flux value for reaction.""" return self._prob.result.get_value(self._v(reaction))
python
def get_flux(self, reaction): """Get resulting flux value for reaction.""" return self._prob.result.get_value(self._v(reaction))
[ "def", "get_flux", "(", "self", ",", "reaction", ")", ":", "return", "self", ".", "_prob", ".", "result", ".", "get_value", "(", "self", ".", "_v", "(", "reaction", ")", ")" ]
Get resulting flux value for reaction.
[ "Get", "resulting", "flux", "value", "for", "reaction", "." ]
dc427848c4f9d109ca590f0afa024c63b685b3f4
https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/fluxanalysis.py#L288-L290
48,231
zhanglab/psamm
psamm/lpsolver/qsoptex.py
Problem.set_objective
def set_objective(self, expression): """Set linear objective of problem""" if isinstance(expression, numbers.Number): # Allow expressions with no variables as objective, # represented as a number expression = Expression() self._p.set_linear_objective( ...
python
def set_objective(self, expression): """Set linear objective of problem""" if isinstance(expression, numbers.Number): # Allow expressions with no variables as objective, # represented as a number expression = Expression() self._p.set_linear_objective( ...
[ "def", "set_objective", "(", "self", ",", "expression", ")", ":", "if", "isinstance", "(", "expression", ",", "numbers", ".", "Number", ")", ":", "# Allow expressions with no variables as objective,", "# represented as a number", "expression", "=", "Expression", "(", ...
Set linear objective of problem
[ "Set", "linear", "objective", "of", "problem" ]
dc427848c4f9d109ca590f0afa024c63b685b3f4
https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/lpsolver/qsoptex.py#L150-L160
48,232
zhanglab/psamm
psamm/lpsolver/qsoptex.py
Result.unbounded
def unbounded(self): """Whether the solution is unbounded""" self._check_valid() return (self._problem._p.get_status() == qsoptex.SolutionStatus.UNBOUNDED)
python
def unbounded(self): """Whether the solution is unbounded""" self._check_valid() return (self._problem._p.get_status() == qsoptex.SolutionStatus.UNBOUNDED)
[ "def", "unbounded", "(", "self", ")", ":", "self", ".", "_check_valid", "(", ")", "return", "(", "self", ".", "_problem", ".", "_p", ".", "get_status", "(", ")", "==", "qsoptex", ".", "SolutionStatus", ".", "UNBOUNDED", ")" ]
Whether the solution is unbounded
[ "Whether", "the", "solution", "is", "unbounded" ]
dc427848c4f9d109ca590f0afa024c63b685b3f4
https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/lpsolver/qsoptex.py#L245-L249
48,233
smartfile/python-librsync
librsync/__init__.py
_execute
def _execute(job, f, o=None): """ Executes a librsync "job" by reading bytes from `f` and writing results to `o` if provided. If `o` is omitted, the output is ignored. """ # Re-use the same buffer for output, we will read from it after each # iteration. out = ctypes.create_string_buffer(RS_J...
python
def _execute(job, f, o=None): """ Executes a librsync "job" by reading bytes from `f` and writing results to `o` if provided. If `o` is omitted, the output is ignored. """ # Re-use the same buffer for output, we will read from it after each # iteration. out = ctypes.create_string_buffer(RS_J...
[ "def", "_execute", "(", "job", ",", "f", ",", "o", "=", "None", ")", ":", "# Re-use the same buffer for output, we will read from it after each", "# iteration.", "out", "=", "ctypes", ".", "create_string_buffer", "(", "RS_JOB_BLOCKSIZE", ")", "while", "True", ":", "...
Executes a librsync "job" by reading bytes from `f` and writing results to `o` if provided. If `o` is omitted, the output is ignored.
[ "Executes", "a", "librsync", "job", "by", "reading", "bytes", "from", "f", "and", "writing", "results", "to", "o", "if", "provided", ".", "If", "o", "is", "omitted", "the", "output", "is", "ignored", "." ]
1859a5f44317dce3e0997c740ac0f8675d77c4e3
https://github.com/smartfile/python-librsync/blob/1859a5f44317dce3e0997c740ac0f8675d77c4e3/librsync/__init__.py#L118-L152
48,234
smartfile/python-librsync
librsync/__init__.py
signature
def signature(f, s=None, block_size=RS_DEFAULT_BLOCK_LEN): """ Generate a signature for the file `f`. The signature will be written to `s`. If `s` is omitted, a temporary file will be used. This function returns the signature file `s`. You can specify the size of the blocks using the optional `block...
python
def signature(f, s=None, block_size=RS_DEFAULT_BLOCK_LEN): """ Generate a signature for the file `f`. The signature will be written to `s`. If `s` is omitted, a temporary file will be used. This function returns the signature file `s`. You can specify the size of the blocks using the optional `block...
[ "def", "signature", "(", "f", ",", "s", "=", "None", ",", "block_size", "=", "RS_DEFAULT_BLOCK_LEN", ")", ":", "if", "s", "is", "None", ":", "s", "=", "tempfile", ".", "SpooledTemporaryFile", "(", "max_size", "=", "MAX_SPOOL", ",", "mode", "=", "'wb+'", ...
Generate a signature for the file `f`. The signature will be written to `s`. If `s` is omitted, a temporary file will be used. This function returns the signature file `s`. You can specify the size of the blocks using the optional `block_size` parameter.
[ "Generate", "a", "signature", "for", "the", "file", "f", ".", "The", "signature", "will", "be", "written", "to", "s", ".", "If", "s", "is", "omitted", "a", "temporary", "file", "will", "be", "used", ".", "This", "function", "returns", "the", "signature",...
1859a5f44317dce3e0997c740ac0f8675d77c4e3
https://github.com/smartfile/python-librsync/blob/1859a5f44317dce3e0997c740ac0f8675d77c4e3/librsync/__init__.py#L161-L175
48,235
smartfile/python-librsync
librsync/__init__.py
delta
def delta(f, s, d=None): """ Create a delta for the file `f` using the signature read from `s`. The delta will be written to `d`. If `d` is omitted, a temporary file will be used. This function returns the delta file `d`. All parameters must be file-like objects. """ if d is None: d ...
python
def delta(f, s, d=None): """ Create a delta for the file `f` using the signature read from `s`. The delta will be written to `d`. If `d` is omitted, a temporary file will be used. This function returns the delta file `d`. All parameters must be file-like objects. """ if d is None: d ...
[ "def", "delta", "(", "f", ",", "s", ",", "d", "=", "None", ")", ":", "if", "d", "is", "None", ":", "d", "=", "tempfile", ".", "SpooledTemporaryFile", "(", "max_size", "=", "MAX_SPOOL", ",", "mode", "=", "'wb+'", ")", "sig", "=", "ctypes", ".", "c...
Create a delta for the file `f` using the signature read from `s`. The delta will be written to `d`. If `d` is omitted, a temporary file will be used. This function returns the delta file `d`. All parameters must be file-like objects.
[ "Create", "a", "delta", "for", "the", "file", "f", "using", "the", "signature", "read", "from", "s", ".", "The", "delta", "will", "be", "written", "to", "d", ".", "If", "d", "is", "omitted", "a", "temporary", "file", "will", "be", "used", ".", "This"...
1859a5f44317dce3e0997c740ac0f8675d77c4e3
https://github.com/smartfile/python-librsync/blob/1859a5f44317dce3e0997c740ac0f8675d77c4e3/librsync/__init__.py#L179-L205
48,236
smartfile/python-librsync
librsync/__init__.py
patch
def patch(f, d, o=None): """ Patch the file `f` using the delta `d`. The patched file will be written to `o`. If `o` is omitted, a temporary file will be used. This function returns the be patched file `o`. All parameters should be file-like objects. `f` is required to be seekable. """ if o ...
python
def patch(f, d, o=None): """ Patch the file `f` using the delta `d`. The patched file will be written to `o`. If `o` is omitted, a temporary file will be used. This function returns the be patched file `o`. All parameters should be file-like objects. `f` is required to be seekable. """ if o ...
[ "def", "patch", "(", "f", ",", "d", ",", "o", "=", "None", ")", ":", "if", "o", "is", "None", ":", "o", "=", "tempfile", ".", "SpooledTemporaryFile", "(", "max_size", "=", "MAX_SPOOL", ",", "mode", "=", "'wb+'", ")", "@", "patch_callback", "def", "...
Patch the file `f` using the delta `d`. The patched file will be written to `o`. If `o` is omitted, a temporary file will be used. This function returns the be patched file `o`. All parameters should be file-like objects. `f` is required to be seekable.
[ "Patch", "the", "file", "f", "using", "the", "delta", "d", ".", "The", "patched", "file", "will", "be", "written", "to", "o", ".", "If", "o", "is", "omitted", "a", "temporary", "file", "will", "be", "used", ".", "This", "function", "returns", "the", ...
1859a5f44317dce3e0997c740ac0f8675d77c4e3
https://github.com/smartfile/python-librsync/blob/1859a5f44317dce3e0997c740ac0f8675d77c4e3/librsync/__init__.py#L209-L235
48,237
zhanglab/psamm
psamm/gapfill.py
_find_integer_tolerance
def _find_integer_tolerance(epsilon, v_max, min_tol): """Find appropriate integer tolerance for gap-filling problems.""" int_tol = min(epsilon / (10 * v_max), 0.1) min_tol = max(1e-10, min_tol) if int_tol < min_tol: eps_lower = min_tol * 10 * v_max logger.warning( 'When the m...
python
def _find_integer_tolerance(epsilon, v_max, min_tol): """Find appropriate integer tolerance for gap-filling problems.""" int_tol = min(epsilon / (10 * v_max), 0.1) min_tol = max(1e-10, min_tol) if int_tol < min_tol: eps_lower = min_tol * 10 * v_max logger.warning( 'When the m...
[ "def", "_find_integer_tolerance", "(", "epsilon", ",", "v_max", ",", "min_tol", ")", ":", "int_tol", "=", "min", "(", "epsilon", "/", "(", "10", "*", "v_max", ")", ",", "0.1", ")", "min_tol", "=", "max", "(", "1e-10", ",", "min_tol", ")", "if", "int_...
Find appropriate integer tolerance for gap-filling problems.
[ "Find", "appropriate", "integer", "tolerance", "for", "gap", "-", "filling", "problems", "." ]
dc427848c4f9d109ca590f0afa024c63b685b3f4
https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/gapfill.py#L36-L49
48,238
zhanglab/psamm
psamm/gapfill.py
gapfind
def gapfind(model, solver, epsilon=0.001, v_max=1000, implicit_sinks=True): """Identify compounds in the model that cannot be produced. Yields all compounds that cannot be produced. This method assumes implicit sinks for all compounds in the model so the only factor that influences whether a compound c...
python
def gapfind(model, solver, epsilon=0.001, v_max=1000, implicit_sinks=True): """Identify compounds in the model that cannot be produced. Yields all compounds that cannot be produced. This method assumes implicit sinks for all compounds in the model so the only factor that influences whether a compound c...
[ "def", "gapfind", "(", "model", ",", "solver", ",", "epsilon", "=", "0.001", ",", "v_max", "=", "1000", ",", "implicit_sinks", "=", "True", ")", ":", "prob", "=", "solver", ".", "create_problem", "(", ")", "# Set integrality tolerance such that w constraints are...
Identify compounds in the model that cannot be produced. Yields all compounds that cannot be produced. This method assumes implicit sinks for all compounds in the model so the only factor that influences whether a compound can be produced is the presence of the compounds needed to produce it. Epsi...
[ "Identify", "compounds", "in", "the", "model", "that", "cannot", "be", "produced", "." ]
dc427848c4f9d109ca590f0afa024c63b685b3f4
https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/gapfill.py#L52-L140
48,239
zhanglab/psamm
psamm/datasource/native.py
float_constructor
def float_constructor(loader, node): """Construct Decimal from YAML float encoding.""" s = loader.construct_scalar(node) if s == '.inf': return Decimal('Infinity') elif s == '-.inf': return -Decimal('Infinity') elif s == '.nan': return Decimal('NaN') return Decimal(s)
python
def float_constructor(loader, node): """Construct Decimal from YAML float encoding.""" s = loader.construct_scalar(node) if s == '.inf': return Decimal('Infinity') elif s == '-.inf': return -Decimal('Infinity') elif s == '.nan': return Decimal('NaN') return Decimal(s)
[ "def", "float_constructor", "(", "loader", ",", "node", ")", ":", "s", "=", "loader", ".", "construct_scalar", "(", "node", ")", "if", "s", "==", "'.inf'", ":", "return", "Decimal", "(", "'Infinity'", ")", "elif", "s", "==", "'-.inf'", ":", "return", "...
Construct Decimal from YAML float encoding.
[ "Construct", "Decimal", "from", "YAML", "float", "encoding", "." ]
dc427848c4f9d109ca590f0afa024c63b685b3f4
https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/datasource/native.py#L64-L73
48,240
zhanglab/psamm
psamm/datasource/native.py
yaml_load
def yaml_load(stream): """Load YAML file using safe loader.""" # Surprisingly, the CSafeLoader does not seem to be used by default. # Check whether the CSafeLoader is available and provide a log message # if it is not available. global _HAS_YAML_LIBRARY if _HAS_YAML_LIBRARY is None: _HA...
python
def yaml_load(stream): """Load YAML file using safe loader.""" # Surprisingly, the CSafeLoader does not seem to be used by default. # Check whether the CSafeLoader is available and provide a log message # if it is not available. global _HAS_YAML_LIBRARY if _HAS_YAML_LIBRARY is None: _HA...
[ "def", "yaml_load", "(", "stream", ")", ":", "# Surprisingly, the CSafeLoader does not seem to be used by default.", "# Check whether the CSafeLoader is available and provide a log message", "# if it is not available.", "global", "_HAS_YAML_LIBRARY", "if", "_HAS_YAML_LIBRARY", "is", "Non...
Load YAML file using safe loader.
[ "Load", "YAML", "file", "using", "safe", "loader", "." ]
dc427848c4f9d109ca590f0afa024c63b685b3f4
https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/datasource/native.py#L76-L94
48,241
zhanglab/psamm
psamm/datasource/native.py
_check_id
def _check_id(entity, entity_type): """Check whether the ID is valid. First check if the ID is missing, and then check if it is a qualified string type, finally check if the string is empty. For all checks, it would raise a ParseError with the corresponding message. Args: entity: a string ...
python
def _check_id(entity, entity_type): """Check whether the ID is valid. First check if the ID is missing, and then check if it is a qualified string type, finally check if the string is empty. For all checks, it would raise a ParseError with the corresponding message. Args: entity: a string ...
[ "def", "_check_id", "(", "entity", ",", "entity_type", ")", ":", "if", "entity", "is", "None", ":", "raise", "ParseError", "(", "'{} ID missing'", ".", "format", "(", "entity_type", ")", ")", "elif", "not", "isinstance", "(", "entity", ",", "string_types", ...
Check whether the ID is valid. First check if the ID is missing, and then check if it is a qualified string type, finally check if the string is empty. For all checks, it would raise a ParseError with the corresponding message. Args: entity: a string type object to be checked. entity_t...
[ "Check", "whether", "the", "ID", "is", "valid", "." ]
dc427848c4f9d109ca590f0afa024c63b685b3f4
https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/datasource/native.py#L620-L644
48,242
zhanglab/psamm
psamm/datasource/native.py
parse_compound
def parse_compound(compound_def, context=None): """Parse a structured compound definition as obtained from a YAML file Returns a CompoundEntry.""" compound_id = compound_def.get('id') _check_id(compound_id, 'Compound') mark = FileMark(context, None, None) return CompoundEntry(compound_def, ma...
python
def parse_compound(compound_def, context=None): """Parse a structured compound definition as obtained from a YAML file Returns a CompoundEntry.""" compound_id = compound_def.get('id') _check_id(compound_id, 'Compound') mark = FileMark(context, None, None) return CompoundEntry(compound_def, ma...
[ "def", "parse_compound", "(", "compound_def", ",", "context", "=", "None", ")", ":", "compound_id", "=", "compound_def", ".", "get", "(", "'id'", ")", "_check_id", "(", "compound_id", ",", "'Compound'", ")", "mark", "=", "FileMark", "(", "context", ",", "N...
Parse a structured compound definition as obtained from a YAML file Returns a CompoundEntry.
[ "Parse", "a", "structured", "compound", "definition", "as", "obtained", "from", "a", "YAML", "file" ]
dc427848c4f9d109ca590f0afa024c63b685b3f4
https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/datasource/native.py#L647-L656
48,243
zhanglab/psamm
psamm/datasource/native.py
parse_compound_list
def parse_compound_list(path, compounds): """Parse a structured list of compounds as obtained from a YAML file Yields CompoundEntries. Path can be given as a string or a context. """ context = FilePathContext(path) for compound_def in compounds: if 'include' in compound_def: f...
python
def parse_compound_list(path, compounds): """Parse a structured list of compounds as obtained from a YAML file Yields CompoundEntries. Path can be given as a string or a context. """ context = FilePathContext(path) for compound_def in compounds: if 'include' in compound_def: f...
[ "def", "parse_compound_list", "(", "path", ",", "compounds", ")", ":", "context", "=", "FilePathContext", "(", "path", ")", "for", "compound_def", "in", "compounds", ":", "if", "'include'", "in", "compound_def", ":", "file_format", "=", "compound_def", ".", "g...
Parse a structured list of compounds as obtained from a YAML file Yields CompoundEntries. Path can be given as a string or a context.
[ "Parse", "a", "structured", "list", "of", "compounds", "as", "obtained", "from", "a", "YAML", "file" ]
dc427848c4f9d109ca590f0afa024c63b685b3f4
https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/datasource/native.py#L659-L674
48,244
zhanglab/psamm
psamm/datasource/native.py
parse_compound_table_file
def parse_compound_table_file(path, f): """Parse a tab-separated file containing compound IDs and properties The compound properties are parsed according to the header which specifies which property is contained in each column. """ context = FilePathContext(path) for i, row in enumerate(csv.D...
python
def parse_compound_table_file(path, f): """Parse a tab-separated file containing compound IDs and properties The compound properties are parsed according to the header which specifies which property is contained in each column. """ context = FilePathContext(path) for i, row in enumerate(csv.D...
[ "def", "parse_compound_table_file", "(", "path", ",", "f", ")", ":", "context", "=", "FilePathContext", "(", "path", ")", "for", "i", ",", "row", "in", "enumerate", "(", "csv", ".", "DictReader", "(", "f", ",", "delimiter", "=", "str", "(", "'\\t'", ")...
Parse a tab-separated file containing compound IDs and properties The compound properties are parsed according to the header which specifies which property is contained in each column.
[ "Parse", "a", "tab", "-", "separated", "file", "containing", "compound", "IDs", "and", "properties" ]
dc427848c4f9d109ca590f0afa024c63b685b3f4
https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/datasource/native.py#L677-L696
48,245
zhanglab/psamm
psamm/datasource/native.py
parse_compound_file
def parse_compound_file(path, format): """Open and parse reaction file based on file extension or given format Path can be given as a string or a context. """ context = FilePathContext(path) # YAML files do not need to explicitly specify format format = resolve_format(format, context.filepath...
python
def parse_compound_file(path, format): """Open and parse reaction file based on file extension or given format Path can be given as a string or a context. """ context = FilePathContext(path) # YAML files do not need to explicitly specify format format = resolve_format(format, context.filepath...
[ "def", "parse_compound_file", "(", "path", ",", "format", ")", ":", "context", "=", "FilePathContext", "(", "path", ")", "# YAML files do not need to explicitly specify format", "format", "=", "resolve_format", "(", "format", ",", "context", ".", "filepath", ")", "i...
Open and parse reaction file based on file extension or given format Path can be given as a string or a context.
[ "Open", "and", "parse", "reaction", "file", "based", "on", "file", "extension", "or", "given", "format" ]
dc427848c4f9d109ca590f0afa024c63b685b3f4
https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/datasource/native.py#L720-L750
48,246
zhanglab/psamm
psamm/datasource/native.py
parse_reaction_equation_string
def parse_reaction_equation_string(equation, default_compartment): """Parse a string representation of a reaction equation. Converts undefined compartments to the default compartment. """ def _translate_compartments(reaction, compartment): """Translate compound with missing compartments. ...
python
def parse_reaction_equation_string(equation, default_compartment): """Parse a string representation of a reaction equation. Converts undefined compartments to the default compartment. """ def _translate_compartments(reaction, compartment): """Translate compound with missing compartments. ...
[ "def", "parse_reaction_equation_string", "(", "equation", ",", "default_compartment", ")", ":", "def", "_translate_compartments", "(", "reaction", ",", "compartment", ")", ":", "\"\"\"Translate compound with missing compartments.\n\n These compounds will have the specified com...
Parse a string representation of a reaction equation. Converts undefined compartments to the default compartment.
[ "Parse", "a", "string", "representation", "of", "a", "reaction", "equation", "." ]
dc427848c4f9d109ca590f0afa024c63b685b3f4
https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/datasource/native.py#L753-L772
48,247
zhanglab/psamm
psamm/datasource/native.py
parse_reaction_equation
def parse_reaction_equation(equation_def, default_compartment): """Parse a structured reaction equation as obtained from a YAML file Returns a Reaction. """ def parse_compound_list(l, compartment): """Parse a list of reactants or metabolites""" for compound_def in l: compou...
python
def parse_reaction_equation(equation_def, default_compartment): """Parse a structured reaction equation as obtained from a YAML file Returns a Reaction. """ def parse_compound_list(l, compartment): """Parse a list of reactants or metabolites""" for compound_def in l: compou...
[ "def", "parse_reaction_equation", "(", "equation_def", ",", "default_compartment", ")", ":", "def", "parse_compound_list", "(", "l", ",", "compartment", ")", ":", "\"\"\"Parse a list of reactants or metabolites\"\"\"", "for", "compound_def", "in", "l", ":", "compound_id",...
Parse a structured reaction equation as obtained from a YAML file Returns a Reaction.
[ "Parse", "a", "structured", "reaction", "equation", "as", "obtained", "from", "a", "YAML", "file" ]
dc427848c4f9d109ca590f0afa024c63b685b3f4
https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/datasource/native.py#L775-L812
48,248
zhanglab/psamm
psamm/datasource/native.py
parse_reaction
def parse_reaction(reaction_def, default_compartment, context=None): """Parse a structured reaction definition as obtained from a YAML file Returns a ReactionEntry. """ reaction_id = reaction_def.get('id') _check_id(reaction_id, 'Reaction') reaction_props = dict(reaction_def) # Parse rea...
python
def parse_reaction(reaction_def, default_compartment, context=None): """Parse a structured reaction definition as obtained from a YAML file Returns a ReactionEntry. """ reaction_id = reaction_def.get('id') _check_id(reaction_id, 'Reaction') reaction_props = dict(reaction_def) # Parse rea...
[ "def", "parse_reaction", "(", "reaction_def", ",", "default_compartment", ",", "context", "=", "None", ")", ":", "reaction_id", "=", "reaction_def", ".", "get", "(", "'id'", ")", "_check_id", "(", "reaction_id", ",", "'Reaction'", ")", "reaction_props", "=", "...
Parse a structured reaction definition as obtained from a YAML file Returns a ReactionEntry.
[ "Parse", "a", "structured", "reaction", "definition", "as", "obtained", "from", "a", "YAML", "file" ]
dc427848c4f9d109ca590f0afa024c63b685b3f4
https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/datasource/native.py#L815-L832
48,249
zhanglab/psamm
psamm/datasource/native.py
parse_reaction_list
def parse_reaction_list(path, reactions, default_compartment=None): """Parse a structured list of reactions as obtained from a YAML file Yields tuples of reaction ID and reaction object. Path can be given as a string or a context. """ context = FilePathContext(path) for reaction_def in reacti...
python
def parse_reaction_list(path, reactions, default_compartment=None): """Parse a structured list of reactions as obtained from a YAML file Yields tuples of reaction ID and reaction object. Path can be given as a string or a context. """ context = FilePathContext(path) for reaction_def in reacti...
[ "def", "parse_reaction_list", "(", "path", ",", "reactions", ",", "default_compartment", "=", "None", ")", ":", "context", "=", "FilePathContext", "(", "path", ")", "for", "reaction_def", "in", "reactions", ":", "if", "'include'", "in", "reaction_def", ":", "i...
Parse a structured list of reactions as obtained from a YAML file Yields tuples of reaction ID and reaction object. Path can be given as a string or a context.
[ "Parse", "a", "structured", "list", "of", "reactions", "as", "obtained", "from", "a", "YAML", "file" ]
dc427848c4f9d109ca590f0afa024c63b685b3f4
https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/datasource/native.py#L835-L851
48,250
zhanglab/psamm
psamm/datasource/native.py
parse_reaction_table_file
def parse_reaction_table_file(path, f, default_compartment): """Parse a tab-separated file containing reaction IDs and properties The reaction properties are parsed according to the header which specifies which property is contained in each column. """ context = FilePathContext(path) for line...
python
def parse_reaction_table_file(path, f, default_compartment): """Parse a tab-separated file containing reaction IDs and properties The reaction properties are parsed according to the header which specifies which property is contained in each column. """ context = FilePathContext(path) for line...
[ "def", "parse_reaction_table_file", "(", "path", ",", "f", ",", "default_compartment", ")", ":", "context", "=", "FilePathContext", "(", "path", ")", "for", "lineno", ",", "row", "in", "enumerate", "(", "csv", ".", "DictReader", "(", "f", ",", "delimiter", ...
Parse a tab-separated file containing reaction IDs and properties The reaction properties are parsed according to the header which specifies which property is contained in each column.
[ "Parse", "a", "tab", "-", "separated", "file", "containing", "reaction", "IDs", "and", "properties" ]
dc427848c4f9d109ca590f0afa024c63b685b3f4
https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/datasource/native.py#L863-L883
48,251
zhanglab/psamm
psamm/datasource/native.py
parse_reaction_file
def parse_reaction_file(path, default_compartment=None): """Open and parse reaction file based on file extension Path can be given as a string or a context. """ context = FilePathContext(path) format = resolve_format(None, context.filepath) if format == 'tsv': logger.debug('Parsing re...
python
def parse_reaction_file(path, default_compartment=None): """Open and parse reaction file based on file extension Path can be given as a string or a context. """ context = FilePathContext(path) format = resolve_format(None, context.filepath) if format == 'tsv': logger.debug('Parsing re...
[ "def", "parse_reaction_file", "(", "path", ",", "default_compartment", "=", "None", ")", ":", "context", "=", "FilePathContext", "(", "path", ")", "format", "=", "resolve_format", "(", "None", ",", "context", ".", "filepath", ")", "if", "format", "==", "'tsv...
Open and parse reaction file based on file extension Path can be given as a string or a context.
[ "Open", "and", "parse", "reaction", "file", "based", "on", "file", "extension" ]
dc427848c4f9d109ca590f0afa024c63b685b3f4
https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/datasource/native.py#L886-L911
48,252
zhanglab/psamm
psamm/datasource/native.py
parse_exchange
def parse_exchange(exchange_def, default_compartment): """Parse a structured exchange definition as obtained from a YAML file. Returns in iterator of compound, reaction, lower and upper bounds. """ default_compartment = exchange_def.get('compartment', default_compartment) for compound_def in exch...
python
def parse_exchange(exchange_def, default_compartment): """Parse a structured exchange definition as obtained from a YAML file. Returns in iterator of compound, reaction, lower and upper bounds. """ default_compartment = exchange_def.get('compartment', default_compartment) for compound_def in exch...
[ "def", "parse_exchange", "(", "exchange_def", ",", "default_compartment", ")", ":", "default_compartment", "=", "exchange_def", ".", "get", "(", "'compartment'", ",", "default_compartment", ")", "for", "compound_def", "in", "exchange_def", ".", "get", "(", "'compoun...
Parse a structured exchange definition as obtained from a YAML file. Returns in iterator of compound, reaction, lower and upper bounds.
[ "Parse", "a", "structured", "exchange", "definition", "as", "obtained", "from", "a", "YAML", "file", "." ]
dc427848c4f9d109ca590f0afa024c63b685b3f4
https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/datasource/native.py#L929-L942
48,253
zhanglab/psamm
psamm/datasource/native.py
parse_exchange_list
def parse_exchange_list(path, exchange, default_compartment): """Parse a structured exchange list as obtained from a YAML file. Yields tuples of compound, reaction ID, lower and upper flux bounds. Path can be given as a string or a context. """ context = FilePathContext(path) for exchange_def...
python
def parse_exchange_list(path, exchange, default_compartment): """Parse a structured exchange list as obtained from a YAML file. Yields tuples of compound, reaction ID, lower and upper flux bounds. Path can be given as a string or a context. """ context = FilePathContext(path) for exchange_def...
[ "def", "parse_exchange_list", "(", "path", ",", "exchange", ",", "default_compartment", ")", ":", "context", "=", "FilePathContext", "(", "path", ")", "for", "exchange_def", "in", "exchange", ":", "if", "'include'", "in", "exchange_def", ":", "include_context", ...
Parse a structured exchange list as obtained from a YAML file. Yields tuples of compound, reaction ID, lower and upper flux bounds. Path can be given as a string or a context.
[ "Parse", "a", "structured", "exchange", "list", "as", "obtained", "from", "a", "YAML", "file", "." ]
dc427848c4f9d109ca590f0afa024c63b685b3f4
https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/datasource/native.py#L953-L971
48,254
zhanglab/psamm
psamm/datasource/native.py
parse_exchange_table_file
def parse_exchange_table_file(f): """Parse a space-separated file containing exchange compound flux limits. The first two columns contain compound IDs and compartment while the third column contains the lower flux limits. The fourth column is optional and contains the upper flux limit. """ for...
python
def parse_exchange_table_file(f): """Parse a space-separated file containing exchange compound flux limits. The first two columns contain compound IDs and compartment while the third column contains the lower flux limits. The fourth column is optional and contains the upper flux limit. """ for...
[ "def", "parse_exchange_table_file", "(", "f", ")", ":", "for", "line", "in", "f", ":", "line", ",", "_", ",", "comment", "=", "line", ".", "partition", "(", "'#'", ")", "line", "=", "line", ".", "strip", "(", ")", "if", "line", "==", "''", ":", "...
Parse a space-separated file containing exchange compound flux limits. The first two columns contain compound IDs and compartment while the third column contains the lower flux limits. The fourth column is optional and contains the upper flux limit.
[ "Parse", "a", "space", "-", "separated", "file", "containing", "exchange", "compound", "flux", "limits", "." ]
dc427848c4f9d109ca590f0afa024c63b685b3f4
https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/datasource/native.py#L999-L1027
48,255
zhanglab/psamm
psamm/datasource/native.py
parse_exchange_file
def parse_exchange_file(path, default_compartment): """Parse a file as a list of exchange compounds with flux limits. The file format is detected and the file is parsed accordingly. Path can be given as a string or a context. """ context = FilePathContext(path) format = resolve_format(None, c...
python
def parse_exchange_file(path, default_compartment): """Parse a file as a list of exchange compounds with flux limits. The file format is detected and the file is parsed accordingly. Path can be given as a string or a context. """ context = FilePathContext(path) format = resolve_format(None, c...
[ "def", "parse_exchange_file", "(", "path", ",", "default_compartment", ")", ":", "context", "=", "FilePathContext", "(", "path", ")", "format", "=", "resolve_format", "(", "None", ",", "context", ".", "filepath", ")", "if", "format", "==", "'tsv'", ":", "log...
Parse a file as a list of exchange compounds with flux limits. The file format is detected and the file is parsed accordingly. Path can be given as a string or a context.
[ "Parse", "a", "file", "as", "a", "list", "of", "exchange", "compounds", "with", "flux", "limits", "." ]
dc427848c4f9d109ca590f0afa024c63b685b3f4
https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/datasource/native.py#L1038-L1063
48,256
zhanglab/psamm
psamm/datasource/native.py
parse_limit
def parse_limit(limit_def): """Parse a structured flux limit definition as obtained from a YAML file Returns a tuple of reaction, lower and upper bound. """ lower, upper = get_limits(limit_def) reaction = limit_def.get('reaction') return reaction, lower, upper
python
def parse_limit(limit_def): """Parse a structured flux limit definition as obtained from a YAML file Returns a tuple of reaction, lower and upper bound. """ lower, upper = get_limits(limit_def) reaction = limit_def.get('reaction') return reaction, lower, upper
[ "def", "parse_limit", "(", "limit_def", ")", ":", "lower", ",", "upper", "=", "get_limits", "(", "limit_def", ")", "reaction", "=", "limit_def", ".", "get", "(", "'reaction'", ")", "return", "reaction", ",", "lower", ",", "upper" ]
Parse a structured flux limit definition as obtained from a YAML file Returns a tuple of reaction, lower and upper bound.
[ "Parse", "a", "structured", "flux", "limit", "definition", "as", "obtained", "from", "a", "YAML", "file" ]
dc427848c4f9d109ca590f0afa024c63b685b3f4
https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/datasource/native.py#L1074-L1083
48,257
zhanglab/psamm
psamm/datasource/native.py
parse_limits_list
def parse_limits_list(path, limits): """Parse a structured list of flux limits as obtained from a YAML file Yields tuples of reaction ID, lower and upper flux bounds. Path can be given as a string or a context. """ context = FilePathContext(path) for limit_def in limits: if 'include' ...
python
def parse_limits_list(path, limits): """Parse a structured list of flux limits as obtained from a YAML file Yields tuples of reaction ID, lower and upper flux bounds. Path can be given as a string or a context. """ context = FilePathContext(path) for limit_def in limits: if 'include' ...
[ "def", "parse_limits_list", "(", "path", ",", "limits", ")", ":", "context", "=", "FilePathContext", "(", "path", ")", "for", "limit_def", "in", "limits", ":", "if", "'include'", "in", "limit_def", ":", "include_context", "=", "context", ".", "resolve", "(",...
Parse a structured list of flux limits as obtained from a YAML file Yields tuples of reaction ID, lower and upper flux bounds. Path can be given as a string or a context.
[ "Parse", "a", "structured", "list", "of", "flux", "limits", "as", "obtained", "from", "a", "YAML", "file" ]
dc427848c4f9d109ca590f0afa024c63b685b3f4
https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/datasource/native.py#L1086-L1101
48,258
zhanglab/psamm
psamm/datasource/native.py
parse_limits_table_file
def parse_limits_table_file(f): """Parse a space-separated file containing reaction flux limits The first column contains reaction IDs while the second column contains the lower flux limits. The third column is optional and contains the upper flux limit. """ for line in f: line, _, com...
python
def parse_limits_table_file(f): """Parse a space-separated file containing reaction flux limits The first column contains reaction IDs while the second column contains the lower flux limits. The third column is optional and contains the upper flux limit. """ for line in f: line, _, com...
[ "def", "parse_limits_table_file", "(", "f", ")", ":", "for", "line", "in", "f", ":", "line", ",", "_", ",", "comment", "=", "line", ".", "partition", "(", "'#'", ")", "line", "=", "line", ".", "strip", "(", ")", "if", "line", "==", "''", ":", "co...
Parse a space-separated file containing reaction flux limits The first column contains reaction IDs while the second column contains the lower flux limits. The third column is optional and contains the upper flux limit.
[ "Parse", "a", "space", "-", "separated", "file", "containing", "reaction", "flux", "limits" ]
dc427848c4f9d109ca590f0afa024c63b685b3f4
https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/datasource/native.py#L1104-L1131
48,259
zhanglab/psamm
psamm/datasource/native.py
parse_limits_file
def parse_limits_file(path): """Parse a file as a list of reaction flux limits The file format is detected and the file is parsed accordingly. Path can be given as a string or a context. """ context = FilePathContext(path) format = resolve_format(None, context.filepath) if format == 'tsv'...
python
def parse_limits_file(path): """Parse a file as a list of reaction flux limits The file format is detected and the file is parsed accordingly. Path can be given as a string or a context. """ context = FilePathContext(path) format = resolve_format(None, context.filepath) if format == 'tsv'...
[ "def", "parse_limits_file", "(", "path", ")", ":", "context", "=", "FilePathContext", "(", "path", ")", "format", "=", "resolve_format", "(", "None", ",", "context", ".", "filepath", ")", "if", "format", "==", "'tsv'", ":", "logger", ".", "debug", "(", "...
Parse a file as a list of reaction flux limits The file format is detected and the file is parsed accordingly. Path can be given as a string or a context.
[ "Parse", "a", "file", "as", "a", "list", "of", "reaction", "flux", "limits" ]
dc427848c4f9d109ca590f0afa024c63b685b3f4
https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/datasource/native.py#L1143-L1167
48,260
zhanglab/psamm
psamm/datasource/native.py
parse_model_group
def parse_model_group(path, group): """Parse a structured model group as obtained from a YAML file Path can be given as a string or a context. """ context = FilePathContext(path) for reaction_id in group.get('reactions', []): yield reaction_id # Parse subgroups for reaction_id in...
python
def parse_model_group(path, group): """Parse a structured model group as obtained from a YAML file Path can be given as a string or a context. """ context = FilePathContext(path) for reaction_id in group.get('reactions', []): yield reaction_id # Parse subgroups for reaction_id in...
[ "def", "parse_model_group", "(", "path", ",", "group", ")", ":", "context", "=", "FilePathContext", "(", "path", ")", "for", "reaction_id", "in", "group", ".", "get", "(", "'reactions'", ",", "[", "]", ")", ":", "yield", "reaction_id", "# Parse subgroups", ...
Parse a structured model group as obtained from a YAML file Path can be given as a string or a context.
[ "Parse", "a", "structured", "model", "group", "as", "obtained", "from", "a", "YAML", "file" ]
dc427848c4f9d109ca590f0afa024c63b685b3f4
https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/datasource/native.py#L1170-L1184
48,261
zhanglab/psamm
psamm/datasource/native.py
parse_model_group_list
def parse_model_group_list(path, groups): """Parse a structured list of model groups as obtained from a YAML file Yields reaction IDs. Path can be given as a string or a context. """ context = FilePathContext(path) for model_group in groups: if 'include' in model_group: include...
python
def parse_model_group_list(path, groups): """Parse a structured list of model groups as obtained from a YAML file Yields reaction IDs. Path can be given as a string or a context. """ context = FilePathContext(path) for model_group in groups: if 'include' in model_group: include...
[ "def", "parse_model_group_list", "(", "path", ",", "groups", ")", ":", "context", "=", "FilePathContext", "(", "path", ")", "for", "model_group", "in", "groups", ":", "if", "'include'", "in", "model_group", ":", "include_context", "=", "context", ".", "resolve...
Parse a structured list of model groups as obtained from a YAML file Yields reaction IDs. Path can be given as a string or a context.
[ "Parse", "a", "structured", "list", "of", "model", "groups", "as", "obtained", "from", "a", "YAML", "file" ]
dc427848c4f9d109ca590f0afa024c63b685b3f4
https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/datasource/native.py#L1187-L1201
48,262
zhanglab/psamm
psamm/datasource/native.py
_reaction_representer
def _reaction_representer(dumper, data): """Generate a parsable reaction representation to the YAML parser. Check the number of compounds in the reaction, if it is larger than 10, then transform the reaction data into a list of directories with all attributes in the reaction; otherwise, just return the...
python
def _reaction_representer(dumper, data): """Generate a parsable reaction representation to the YAML parser. Check the number of compounds in the reaction, if it is larger than 10, then transform the reaction data into a list of directories with all attributes in the reaction; otherwise, just return the...
[ "def", "_reaction_representer", "(", "dumper", ",", "data", ")", ":", "if", "len", "(", "data", ".", "compounds", ")", ">", "_MAX_REACTION_LENGTH", ":", "def", "dict_make", "(", "compounds", ")", ":", "for", "compound", ",", "value", "in", "compounds", ":"...
Generate a parsable reaction representation to the YAML parser. Check the number of compounds in the reaction, if it is larger than 10, then transform the reaction data into a list of directories with all attributes in the reaction; otherwise, just return the text_type format of the reaction data.
[ "Generate", "a", "parsable", "reaction", "representation", "to", "the", "YAML", "parser", "." ]
dc427848c4f9d109ca590f0afa024c63b685b3f4
https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/datasource/native.py#L1278-L1310
48,263
zhanglab/psamm
psamm/datasource/native.py
ModelReader.reader_from_path
def reader_from_path(cls, path): """Create a model from specified path. Path can be a directory containing a ``model.yaml`` or ``model.yml`` file or it can be a path naming the central model file directly. """ context = FilePathContext(path) try: with open(co...
python
def reader_from_path(cls, path): """Create a model from specified path. Path can be a directory containing a ``model.yaml`` or ``model.yml`` file or it can be a path naming the central model file directly. """ context = FilePathContext(path) try: with open(co...
[ "def", "reader_from_path", "(", "cls", ",", "path", ")", ":", "context", "=", "FilePathContext", "(", "path", ")", "try", ":", "with", "open", "(", "context", ".", "filepath", ",", "'r'", ")", "as", "f", ":", "return", "ModelReader", "(", "f", ",", "...
Create a model from specified path. Path can be a directory containing a ``model.yaml`` or ``model.yml`` file or it can be a path naming the central model file directly.
[ "Create", "a", "model", "from", "specified", "path", "." ]
dc427848c4f9d109ca590f0afa024c63b685b3f4
https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/datasource/native.py#L180-L204
48,264
zhanglab/psamm
psamm/datasource/native.py
ModelReader.parse_compartments
def parse_compartments(self): """Parse compartment information from model. Return tuple of: 1) iterator of :class:`psamm.datasource.entry.CompartmentEntry`; 2) Set of pairs defining the compartment boundaries of the model. """ compartments = OrderedDict() bounda...
python
def parse_compartments(self): """Parse compartment information from model. Return tuple of: 1) iterator of :class:`psamm.datasource.entry.CompartmentEntry`; 2) Set of pairs defining the compartment boundaries of the model. """ compartments = OrderedDict() bounda...
[ "def", "parse_compartments", "(", "self", ")", ":", "compartments", "=", "OrderedDict", "(", ")", "boundaries", "=", "set", "(", ")", "if", "'compartments'", "in", "self", ".", "_model", ":", "boundary_map", "=", "{", "}", "for", "compartment_def", "in", "...
Parse compartment information from model. Return tuple of: 1) iterator of :class:`psamm.datasource.entry.CompartmentEntry`; 2) Set of pairs defining the compartment boundaries of the model.
[ "Parse", "compartment", "information", "from", "model", "." ]
dc427848c4f9d109ca590f0afa024c63b685b3f4
https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/datasource/native.py#L244-L287
48,265
zhanglab/psamm
psamm/datasource/native.py
ModelReader.parse_reactions
def parse_reactions(self): """Yield tuples of reaction ID and reactions defined in the model""" # Parse reactions defined in the main model file if 'reactions' in self._model: for reaction in parse_reaction_list( self._context, self._model['reactions'], ...
python
def parse_reactions(self): """Yield tuples of reaction ID and reactions defined in the model""" # Parse reactions defined in the main model file if 'reactions' in self._model: for reaction in parse_reaction_list( self._context, self._model['reactions'], ...
[ "def", "parse_reactions", "(", "self", ")", ":", "# Parse reactions defined in the main model file", "if", "'reactions'", "in", "self", ".", "_model", ":", "for", "reaction", "in", "parse_reaction_list", "(", "self", ".", "_context", ",", "self", ".", "_model", "[...
Yield tuples of reaction ID and reactions defined in the model
[ "Yield", "tuples", "of", "reaction", "ID", "and", "reactions", "defined", "in", "the", "model" ]
dc427848c4f9d109ca590f0afa024c63b685b3f4
https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/datasource/native.py#L289-L297
48,266
zhanglab/psamm
psamm/datasource/native.py
ModelReader.parse_model
def parse_model(self): """Yield reaction IDs of model reactions""" if self.has_model_definition(): for reaction_id in parse_model_group_list( self._context, self._model['model']): yield reaction_id
python
def parse_model(self): """Yield reaction IDs of model reactions""" if self.has_model_definition(): for reaction_id in parse_model_group_list( self._context, self._model['model']): yield reaction_id
[ "def", "parse_model", "(", "self", ")", ":", "if", "self", ".", "has_model_definition", "(", ")", ":", "for", "reaction_id", "in", "parse_model_group_list", "(", "self", ".", "_context", ",", "self", ".", "_model", "[", "'model'", "]", ")", ":", "yield", ...
Yield reaction IDs of model reactions
[ "Yield", "reaction", "IDs", "of", "model", "reactions" ]
dc427848c4f9d109ca590f0afa024c63b685b3f4
https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/datasource/native.py#L303-L309
48,267
zhanglab/psamm
psamm/datasource/native.py
ModelReader.parse_limits
def parse_limits(self): """Yield tuples of reaction ID, lower, and upper bound flux limits""" if 'limits' in self._model: if not isinstance(self._model['limits'], list): raise ParseError('Expected limits to be a list') for limit in parse_limits_list( ...
python
def parse_limits(self): """Yield tuples of reaction ID, lower, and upper bound flux limits""" if 'limits' in self._model: if not isinstance(self._model['limits'], list): raise ParseError('Expected limits to be a list') for limit in parse_limits_list( ...
[ "def", "parse_limits", "(", "self", ")", ":", "if", "'limits'", "in", "self", ".", "_model", ":", "if", "not", "isinstance", "(", "self", ".", "_model", "[", "'limits'", "]", ",", "list", ")", ":", "raise", "ParseError", "(", "'Expected limits to be a list...
Yield tuples of reaction ID, lower, and upper bound flux limits
[ "Yield", "tuples", "of", "reaction", "ID", "lower", "and", "upper", "bound", "flux", "limits" ]
dc427848c4f9d109ca590f0afa024c63b685b3f4
https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/datasource/native.py#L311-L320
48,268
zhanglab/psamm
psamm/datasource/native.py
ModelReader.parse_exchange
def parse_exchange(self): """Yield tuples of exchange compounds. Each exchange compound is a tuple of compound, reaction ID, lower and upper flux limits. """ if 'media' in self._model: if 'exchange' in self._model: raise ParseError('Both "media" and ...
python
def parse_exchange(self): """Yield tuples of exchange compounds. Each exchange compound is a tuple of compound, reaction ID, lower and upper flux limits. """ if 'media' in self._model: if 'exchange' in self._model: raise ParseError('Both "media" and ...
[ "def", "parse_exchange", "(", "self", ")", ":", "if", "'media'", "in", "self", ".", "_model", ":", "if", "'exchange'", "in", "self", ".", "_model", ":", "raise", "ParseError", "(", "'Both \"media\" and \"exchange\" are specified'", ")", "logger", ".", "warning",...
Yield tuples of exchange compounds. Each exchange compound is a tuple of compound, reaction ID, lower and upper flux limits.
[ "Yield", "tuples", "of", "exchange", "compounds", "." ]
dc427848c4f9d109ca590f0afa024c63b685b3f4
https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/datasource/native.py#L322-L349
48,269
zhanglab/psamm
psamm/datasource/native.py
ModelReader.parse_compounds
def parse_compounds(self): """Yield CompoundEntries for defined compounds""" if 'compounds' in self._model: for compound in parse_compound_list( self._context, self._model['compounds']): yield compound
python
def parse_compounds(self): """Yield CompoundEntries for defined compounds""" if 'compounds' in self._model: for compound in parse_compound_list( self._context, self._model['compounds']): yield compound
[ "def", "parse_compounds", "(", "self", ")", ":", "if", "'compounds'", "in", "self", ".", "_model", ":", "for", "compound", "in", "parse_compound_list", "(", "self", ".", "_context", ",", "self", ".", "_model", "[", "'compounds'", "]", ")", ":", "yield", ...
Yield CompoundEntries for defined compounds
[ "Yield", "CompoundEntries", "for", "defined", "compounds" ]
dc427848c4f9d109ca590f0afa024c63b685b3f4
https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/datasource/native.py#L358-L364
48,270
zhanglab/psamm
psamm/datasource/native.py
ModelWriter.convert_compartment_entry
def convert_compartment_entry(self, compartment, adjacencies): """Convert compartment entry to YAML dict. Args: compartment: :class:`psamm.datasource.entry.CompartmentEntry`. adjacencies: Sequence of IDs or a single ID of adjacent compartments (or None). ...
python
def convert_compartment_entry(self, compartment, adjacencies): """Convert compartment entry to YAML dict. Args: compartment: :class:`psamm.datasource.entry.CompartmentEntry`. adjacencies: Sequence of IDs or a single ID of adjacent compartments (or None). ...
[ "def", "convert_compartment_entry", "(", "self", ",", "compartment", ",", "adjacencies", ")", ":", "d", "=", "OrderedDict", "(", ")", "d", "[", "'id'", "]", "=", "compartment", ".", "id", "if", "adjacencies", "is", "not", "None", ":", "d", "[", "'adjacen...
Convert compartment entry to YAML dict. Args: compartment: :class:`psamm.datasource.entry.CompartmentEntry`. adjacencies: Sequence of IDs or a single ID of adjacent compartments (or None).
[ "Convert", "compartment", "entry", "to", "YAML", "dict", "." ]
dc427848c4f9d109ca590f0afa024c63b685b3f4
https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/datasource/native.py#L1369-L1389
48,271
zhanglab/psamm
psamm/datasource/native.py
ModelWriter.convert_compound_entry
def convert_compound_entry(self, compound): """Convert compound entry to YAML dict.""" d = OrderedDict() d['id'] = compound.id order = { key: i for i, key in enumerate( ['name', 'formula', 'formula_neutral', 'charge', 'kegg', 'cas'])} ...
python
def convert_compound_entry(self, compound): """Convert compound entry to YAML dict.""" d = OrderedDict() d['id'] = compound.id order = { key: i for i, key in enumerate( ['name', 'formula', 'formula_neutral', 'charge', 'kegg', 'cas'])} ...
[ "def", "convert_compound_entry", "(", "self", ",", "compound", ")", ":", "d", "=", "OrderedDict", "(", ")", "d", "[", "'id'", "]", "=", "compound", ".", "id", "order", "=", "{", "key", ":", "i", "for", "i", ",", "key", "in", "enumerate", "(", "[", ...
Convert compound entry to YAML dict.
[ "Convert", "compound", "entry", "to", "YAML", "dict", "." ]
dc427848c4f9d109ca590f0afa024c63b685b3f4
https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/datasource/native.py#L1391-L1407
48,272
zhanglab/psamm
psamm/datasource/native.py
ModelWriter.convert_reaction_entry
def convert_reaction_entry(self, reaction): """Convert reaction entry to YAML dict.""" d = OrderedDict() d['id'] = reaction.id def is_equation_valid(equation): # If the equation is a Reaction object, it must have non-zero # number of compounds. return...
python
def convert_reaction_entry(self, reaction): """Convert reaction entry to YAML dict.""" d = OrderedDict() d['id'] = reaction.id def is_equation_valid(equation): # If the equation is a Reaction object, it must have non-zero # number of compounds. return...
[ "def", "convert_reaction_entry", "(", "self", ",", "reaction", ")", ":", "d", "=", "OrderedDict", "(", ")", "d", "[", "'id'", "]", "=", "reaction", ".", "id", "def", "is_equation_valid", "(", "equation", ")", ":", "# If the equation is a Reaction object, it must...
Convert reaction entry to YAML dict.
[ "Convert", "reaction", "entry", "to", "YAML", "dict", "." ]
dc427848c4f9d109ca590f0afa024c63b685b3f4
https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/datasource/native.py#L1409-L1433
48,273
zhanglab/psamm
psamm/datasource/native.py
ModelWriter._write_entries
def _write_entries(self, stream, entries, converter, properties=None): """Write iterable of entries as YAML object to stream. Args: stream: File-like object. entries: Iterable of entries. converter: Conversion function from entry to YAML object. propertie...
python
def _write_entries(self, stream, entries, converter, properties=None): """Write iterable of entries as YAML object to stream. Args: stream: File-like object. entries: Iterable of entries. converter: Conversion function from entry to YAML object. propertie...
[ "def", "_write_entries", "(", "self", ",", "stream", ",", "entries", ",", "converter", ",", "properties", "=", "None", ")", ":", "def", "iter_entries", "(", ")", ":", "for", "c", "in", "entries", ":", "entry", "=", "converter", "(", "c", ")", "if", "...
Write iterable of entries as YAML object to stream. Args: stream: File-like object. entries: Iterable of entries. converter: Conversion function from entry to YAML object. properties: Set of compartment properties to output (or None to output all)...
[ "Write", "iterable", "of", "entries", "as", "YAML", "object", "to", "stream", "." ]
dc427848c4f9d109ca590f0afa024c63b685b3f4
https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/datasource/native.py#L1435-L1456
48,274
zhanglab/psamm
psamm/datasource/native.py
ModelWriter.write_compartments
def write_compartments(self, stream, compartments, adjacencies, properties=None): """Write iterable of compartments as YAML object to stream. Args: stream: File-like object. compartments: Iterable of compartment entries. adjacencies: Dictio...
python
def write_compartments(self, stream, compartments, adjacencies, properties=None): """Write iterable of compartments as YAML object to stream. Args: stream: File-like object. compartments: Iterable of compartment entries. adjacencies: Dictio...
[ "def", "write_compartments", "(", "self", ",", "stream", ",", "compartments", ",", "adjacencies", ",", "properties", "=", "None", ")", ":", "def", "convert", "(", "entry", ")", ":", "return", "self", ".", "convert_compartment_entry", "(", "entry", ",", "adja...
Write iterable of compartments as YAML object to stream. Args: stream: File-like object. compartments: Iterable of compartment entries. adjacencies: Dictionary mapping IDs to adjacent compartment IDs. properties: Set of compartment properties to output (or None t...
[ "Write", "iterable", "of", "compartments", "as", "YAML", "object", "to", "stream", "." ]
dc427848c4f9d109ca590f0afa024c63b685b3f4
https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/datasource/native.py#L1458-L1473
48,275
zhanglab/psamm
psamm/datasource/native.py
ModelWriter.write_compounds
def write_compounds(self, stream, compounds, properties=None): """Write iterable of compounds as YAML object to stream. Args: stream: File-like object. compounds: Iterable of compound entries. properties: Set of compound properties to output (or None to output ...
python
def write_compounds(self, stream, compounds, properties=None): """Write iterable of compounds as YAML object to stream. Args: stream: File-like object. compounds: Iterable of compound entries. properties: Set of compound properties to output (or None to output ...
[ "def", "write_compounds", "(", "self", ",", "stream", ",", "compounds", ",", "properties", "=", "None", ")", ":", "self", ".", "_write_entries", "(", "stream", ",", "compounds", ",", "self", ".", "convert_compound_entry", ",", "properties", ")" ]
Write iterable of compounds as YAML object to stream. Args: stream: File-like object. compounds: Iterable of compound entries. properties: Set of compound properties to output (or None to output all).
[ "Write", "iterable", "of", "compounds", "as", "YAML", "object", "to", "stream", "." ]
dc427848c4f9d109ca590f0afa024c63b685b3f4
https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/datasource/native.py#L1475-L1485
48,276
zhanglab/psamm
psamm/datasource/native.py
ModelWriter.write_reactions
def write_reactions(self, stream, reactions, properties=None): """Write iterable of reactions as YAML object to stream. Args: stream: File-like object. compounds: Iterable of reaction entries. properties: Set of reaction properties to output (or None to output ...
python
def write_reactions(self, stream, reactions, properties=None): """Write iterable of reactions as YAML object to stream. Args: stream: File-like object. compounds: Iterable of reaction entries. properties: Set of reaction properties to output (or None to output ...
[ "def", "write_reactions", "(", "self", ",", "stream", ",", "reactions", ",", "properties", "=", "None", ")", ":", "self", ".", "_write_entries", "(", "stream", ",", "reactions", ",", "self", ".", "convert_reaction_entry", ",", "properties", ")" ]
Write iterable of reactions as YAML object to stream. Args: stream: File-like object. compounds: Iterable of reaction entries. properties: Set of reaction properties to output (or None to output all).
[ "Write", "iterable", "of", "reactions", "as", "YAML", "object", "to", "stream", "." ]
dc427848c4f9d109ca590f0afa024c63b685b3f4
https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/datasource/native.py#L1487-L1497
48,277
inveniosoftware/invenio-rest
invenio_rest/views.py
create_api_errorhandler
def create_api_errorhandler(**kwargs): r"""Create an API error handler. E.g. register a 404 error: .. code-block:: python app.errorhandler(404)(create_api_errorhandler( status=404, message='Not Found')) :param \*\*kwargs: It contains the ``'status'`` and the ``'message'`` ...
python
def create_api_errorhandler(**kwargs): r"""Create an API error handler. E.g. register a 404 error: .. code-block:: python app.errorhandler(404)(create_api_errorhandler( status=404, message='Not Found')) :param \*\*kwargs: It contains the ``'status'`` and the ``'message'`` ...
[ "def", "create_api_errorhandler", "(", "*", "*", "kwargs", ")", ":", "def", "api_errorhandler", "(", "e", ")", ":", "if", "isinstance", "(", "e", ",", "RESTException", ")", ":", "return", "e", ".", "get_response", "(", ")", "elif", "isinstance", "(", "e"...
r"""Create an API error handler. E.g. register a 404 error: .. code-block:: python app.errorhandler(404)(create_api_errorhandler( status=404, message='Not Found')) :param \*\*kwargs: It contains the ``'status'`` and the ``'message'`` to describe the error.
[ "r", "Create", "an", "API", "error", "handler", "." ]
4271708f0e2877e5100236be9242035b95b5ae6e
https://github.com/inveniosoftware/invenio-rest/blob/4271708f0e2877e5100236be9242035b95b5ae6e/invenio_rest/views.py#L21-L42
48,278
inveniosoftware/invenio-rest
invenio_rest/views.py
ContentNegotiatedMethodView.get_method_serializers
def get_method_serializers(self, http_method): """Get request method serializers + default media type. Grab serializers from ``method_serializers`` if defined, otherwise returns the default serializers. Uses GET serializers for HEAD requests if no HEAD serializers were specified. ...
python
def get_method_serializers(self, http_method): """Get request method serializers + default media type. Grab serializers from ``method_serializers`` if defined, otherwise returns the default serializers. Uses GET serializers for HEAD requests if no HEAD serializers were specified. ...
[ "def", "get_method_serializers", "(", "self", ",", "http_method", ")", ":", "if", "http_method", "==", "'HEAD'", "and", "'HEAD'", "not", "in", "self", ".", "method_serializers", ":", "http_method", "=", "'GET'", "return", "(", "self", ".", "method_serializers", ...
Get request method serializers + default media type. Grab serializers from ``method_serializers`` if defined, otherwise returns the default serializers. Uses GET serializers for HEAD requests if no HEAD serializers were specified. The method also determines the default media type. ...
[ "Get", "request", "method", "serializers", "+", "default", "media", "type", "." ]
4271708f0e2877e5100236be9242035b95b5ae6e
https://github.com/inveniosoftware/invenio-rest/blob/4271708f0e2877e5100236be9242035b95b5ae6e/invenio_rest/views.py#L119-L138
48,279
inveniosoftware/invenio-rest
invenio_rest/views.py
ContentNegotiatedMethodView._match_serializers_by_query_arg
def _match_serializers_by_query_arg(self, serializers): """Match serializer by query arg.""" # if the format query argument is present, match the serializer arg_name = current_app.config.get('REST_MIMETYPE_QUERY_ARG_NAME') if arg_name: arg_value = request.args.get(arg_name, N...
python
def _match_serializers_by_query_arg(self, serializers): """Match serializer by query arg.""" # if the format query argument is present, match the serializer arg_name = current_app.config.get('REST_MIMETYPE_QUERY_ARG_NAME') if arg_name: arg_value = request.args.get(arg_name, N...
[ "def", "_match_serializers_by_query_arg", "(", "self", ",", "serializers", ")", ":", "# if the format query argument is present, match the serializer", "arg_name", "=", "current_app", ".", "config", ".", "get", "(", "'REST_MIMETYPE_QUERY_ARG_NAME'", ")", "if", "arg_name", "...
Match serializer by query arg.
[ "Match", "serializer", "by", "query", "arg", "." ]
4271708f0e2877e5100236be9242035b95b5ae6e
https://github.com/inveniosoftware/invenio-rest/blob/4271708f0e2877e5100236be9242035b95b5ae6e/invenio_rest/views.py#L140-L156
48,280
inveniosoftware/invenio-rest
invenio_rest/views.py
ContentNegotiatedMethodView._match_serializers_by_accept_headers
def _match_serializers_by_accept_headers(self, serializers, default_media_type): """Match serializer by `Accept` headers.""" # Bail out fast if no accept headers were given. if len(request.accept_mimetypes) == 0: return serializers[default...
python
def _match_serializers_by_accept_headers(self, serializers, default_media_type): """Match serializer by `Accept` headers.""" # Bail out fast if no accept headers were given. if len(request.accept_mimetypes) == 0: return serializers[default...
[ "def", "_match_serializers_by_accept_headers", "(", "self", ",", "serializers", ",", "default_media_type", ")", ":", "# Bail out fast if no accept headers were given.", "if", "len", "(", "request", ".", "accept_mimetypes", ")", "==", "0", ":", "return", "serializers", "...
Match serializer by `Accept` headers.
[ "Match", "serializer", "by", "Accept", "headers", "." ]
4271708f0e2877e5100236be9242035b95b5ae6e
https://github.com/inveniosoftware/invenio-rest/blob/4271708f0e2877e5100236be9242035b95b5ae6e/invenio_rest/views.py#L158-L186
48,281
inveniosoftware/invenio-rest
invenio_rest/views.py
ContentNegotiatedMethodView.match_serializers
def match_serializers(self, serializers, default_media_type): """Choose serializer for a given request based on query arg or headers. Checks if query arg `format` (by default) is present and tries to match the serializer based on the arg value, by resolving the mimetype mapped to the ar...
python
def match_serializers(self, serializers, default_media_type): """Choose serializer for a given request based on query arg or headers. Checks if query arg `format` (by default) is present and tries to match the serializer based on the arg value, by resolving the mimetype mapped to the ar...
[ "def", "match_serializers", "(", "self", ",", "serializers", ",", "default_media_type", ")", ":", "return", "self", ".", "_match_serializers_by_query_arg", "(", "serializers", ")", "or", "self", ".", "_match_serializers_by_accept_headers", "(", "serializers", ",", "de...
Choose serializer for a given request based on query arg or headers. Checks if query arg `format` (by default) is present and tries to match the serializer based on the arg value, by resolving the mimetype mapped to the arg value. Otherwise, chooses the serializer by retrieving the best...
[ "Choose", "serializer", "for", "a", "given", "request", "based", "on", "query", "arg", "or", "headers", "." ]
4271708f0e2877e5100236be9242035b95b5ae6e
https://github.com/inveniosoftware/invenio-rest/blob/4271708f0e2877e5100236be9242035b95b5ae6e/invenio_rest/views.py#L188-L204
48,282
inveniosoftware/invenio-rest
invenio_rest/views.py
ContentNegotiatedMethodView.make_response
def make_response(self, *args, **kwargs): """Create a Flask Response. Dispatch the given arguments to the serializer best matching the current request's Accept header. :return: The response created by the serializing function. :rtype: :class:`flask.Response` :raises wer...
python
def make_response(self, *args, **kwargs): """Create a Flask Response. Dispatch the given arguments to the serializer best matching the current request's Accept header. :return: The response created by the serializing function. :rtype: :class:`flask.Response` :raises wer...
[ "def", "make_response", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "serializer", "=", "self", ".", "match_serializers", "(", "*", "self", ".", "get_method_serializers", "(", "request", ".", "method", ")", ")", "if", "serializer", "...
Create a Flask Response. Dispatch the given arguments to the serializer best matching the current request's Accept header. :return: The response created by the serializing function. :rtype: :class:`flask.Response` :raises werkzeug.exceptions.NotAcceptable: If no media type ...
[ "Create", "a", "Flask", "Response", "." ]
4271708f0e2877e5100236be9242035b95b5ae6e
https://github.com/inveniosoftware/invenio-rest/blob/4271708f0e2877e5100236be9242035b95b5ae6e/invenio_rest/views.py#L206-L222
48,283
inveniosoftware/invenio-rest
invenio_rest/views.py
ContentNegotiatedMethodView.dispatch_request
def dispatch_request(self, *args, **kwargs): """Dispatch current request. Dispatch the current request using :class:`flask.views.MethodView` `dispatch_request()` then, if the result is not already a :py:class:`flask.Response`, search for the serializing function which matches th...
python
def dispatch_request(self, *args, **kwargs): """Dispatch current request. Dispatch the current request using :class:`flask.views.MethodView` `dispatch_request()` then, if the result is not already a :py:class:`flask.Response`, search for the serializing function which matches th...
[ "def", "dispatch_request", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "result", "=", "super", "(", "ContentNegotiatedMethodView", ",", "self", ")", ".", "dispatch_request", "(", "*", "args", ",", "*", "*", "kwargs", ")", "if", "i...
Dispatch current request. Dispatch the current request using :class:`flask.views.MethodView` `dispatch_request()` then, if the result is not already a :py:class:`flask.Response`, search for the serializing function which matches the best the current request's Accept header and u...
[ "Dispatch", "current", "request", "." ]
4271708f0e2877e5100236be9242035b95b5ae6e
https://github.com/inveniosoftware/invenio-rest/blob/4271708f0e2877e5100236be9242035b95b5ae6e/invenio_rest/views.py#L224-L248
48,284
inveniosoftware/invenio-rest
invenio_rest/views.py
ContentNegotiatedMethodView.check_etag
def check_etag(self, etag, weak=False): """Validate the given ETag with current request conditions. Compare the given ETag to the ones in the request header If-Match and If-None-Match conditions. The result is unspecified for requests having If-Match and If-None-Match being bot...
python
def check_etag(self, etag, weak=False): """Validate the given ETag with current request conditions. Compare the given ETag to the ones in the request header If-Match and If-None-Match conditions. The result is unspecified for requests having If-Match and If-None-Match being bot...
[ "def", "check_etag", "(", "self", ",", "etag", ",", "weak", "=", "False", ")", ":", "# bool(:py:class:`werkzeug.datastructures.ETags`) is not consistent", "# in Python 3. bool(Etags()) == True even though it is empty.", "if", "len", "(", "request", ".", "if_match", ".", "as...
Validate the given ETag with current request conditions. Compare the given ETag to the ones in the request header If-Match and If-None-Match conditions. The result is unspecified for requests having If-Match and If-None-Match being both set. :param str etag: The ETag of the cu...
[ "Validate", "the", "given", "ETag", "with", "current", "request", "conditions", "." ]
4271708f0e2877e5100236be9242035b95b5ae6e
https://github.com/inveniosoftware/invenio-rest/blob/4271708f0e2877e5100236be9242035b95b5ae6e/invenio_rest/views.py#L250-L285
48,285
inveniosoftware/invenio-rest
invenio_rest/views.py
ContentNegotiatedMethodView.check_if_modified_since
def check_if_modified_since(self, dt, etag=None): """Validate If-Modified-Since with current request conditions.""" dt = dt.replace(microsecond=0) if request.if_modified_since and dt <= request.if_modified_since: raise SameContentException(etag, last_modified=dt)
python
def check_if_modified_since(self, dt, etag=None): """Validate If-Modified-Since with current request conditions.""" dt = dt.replace(microsecond=0) if request.if_modified_since and dt <= request.if_modified_since: raise SameContentException(etag, last_modified=dt)
[ "def", "check_if_modified_since", "(", "self", ",", "dt", ",", "etag", "=", "None", ")", ":", "dt", "=", "dt", ".", "replace", "(", "microsecond", "=", "0", ")", "if", "request", ".", "if_modified_since", "and", "dt", "<=", "request", ".", "if_modified_s...
Validate If-Modified-Since with current request conditions.
[ "Validate", "If", "-", "Modified", "-", "Since", "with", "current", "request", "conditions", "." ]
4271708f0e2877e5100236be9242035b95b5ae6e
https://github.com/inveniosoftware/invenio-rest/blob/4271708f0e2877e5100236be9242035b95b5ae6e/invenio_rest/views.py#L287-L291
48,286
zhanglab/psamm
psamm/importer.py
get_default_compartment
def get_default_compartment(model): """Return what the default compartment should be set to. If some compounds have no compartment, unique compartment name is returned to avoid collisions. """ default_compartment = 'c' default_key = set() for reaction in model.reactions: equation = ...
python
def get_default_compartment(model): """Return what the default compartment should be set to. If some compounds have no compartment, unique compartment name is returned to avoid collisions. """ default_compartment = 'c' default_key = set() for reaction in model.reactions: equation = ...
[ "def", "get_default_compartment", "(", "model", ")", ":", "default_compartment", "=", "'c'", "default_key", "=", "set", "(", ")", "for", "reaction", "in", "model", ".", "reactions", ":", "equation", "=", "reaction", ".", "equation", "if", "equation", "is", "...
Return what the default compartment should be set to. If some compounds have no compartment, unique compartment name is returned to avoid collisions.
[ "Return", "what", "the", "default", "compartment", "should", "be", "set", "to", "." ]
dc427848c4f9d109ca590f0afa024c63b685b3f4
https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/importer.py#L172-L201
48,287
zhanglab/psamm
psamm/importer.py
detect_best_flux_limit
def detect_best_flux_limit(model): """Detect the best default flux limit to use for model output. The default flux limit does not change the model but selecting a good value reduced the amount of output produced and reduces clutter in the output files. """ flux_limit_count = Counter() for ...
python
def detect_best_flux_limit(model): """Detect the best default flux limit to use for model output. The default flux limit does not change the model but selecting a good value reduced the amount of output produced and reduces clutter in the output files. """ flux_limit_count = Counter() for ...
[ "def", "detect_best_flux_limit", "(", "model", ")", ":", "flux_limit_count", "=", "Counter", "(", ")", "for", "reaction", "in", "model", ".", "reactions", ":", "if", "reaction", ".", "id", "not", "in", "model", ".", "limits", ":", "continue", "equation", "...
Detect the best default flux limit to use for model output. The default flux limit does not change the model but selecting a good value reduced the amount of output produced and reduces clutter in the output files.
[ "Detect", "the", "best", "default", "flux", "limit", "to", "use", "for", "model", "output", "." ]
dc427848c4f9d109ca590f0afa024c63b685b3f4
https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/importer.py#L204-L231
48,288
zhanglab/psamm
psamm/importer.py
reactions_to_files
def reactions_to_files(model, dest, writer, split_subsystem): """Turn the reaction subsystems into their own files. If a subsystem has a number of reactions over the threshold, it gets its own YAML file. All other reactions, those that don't have a subsystem or are in a subsystem that falls below the t...
python
def reactions_to_files(model, dest, writer, split_subsystem): """Turn the reaction subsystems into their own files. If a subsystem has a number of reactions over the threshold, it gets its own YAML file. All other reactions, those that don't have a subsystem or are in a subsystem that falls below the t...
[ "def", "reactions_to_files", "(", "model", ",", "dest", ",", "writer", ",", "split_subsystem", ")", ":", "def", "safe_file_name", "(", "origin_name", ")", ":", "safe_name", "=", "re", ".", "sub", "(", "r'\\W+'", ",", "'_'", ",", "origin_name", ",", "flags"...
Turn the reaction subsystems into their own files. If a subsystem has a number of reactions over the threshold, it gets its own YAML file. All other reactions, those that don't have a subsystem or are in a subsystem that falls below the threshold, get added to a common reaction file. Args: ...
[ "Turn", "the", "reaction", "subsystems", "into", "their", "own", "files", "." ]
dc427848c4f9d109ca590f0afa024c63b685b3f4
https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/importer.py#L234-L303
48,289
zhanglab/psamm
psamm/importer.py
_generate_limit_items
def _generate_limit_items(lower, upper): """Yield key, value pairs for limits dictionary. Yield pairs of key, value where key is ``lower``, ``upper`` or ``fixed``. A key, value pair is emitted if the bounds are not None. """ # Use value + 0 to convert any -0.0 to 0.0 which looks better. if lowe...
python
def _generate_limit_items(lower, upper): """Yield key, value pairs for limits dictionary. Yield pairs of key, value where key is ``lower``, ``upper`` or ``fixed``. A key, value pair is emitted if the bounds are not None. """ # Use value + 0 to convert any -0.0 to 0.0 which looks better. if lowe...
[ "def", "_generate_limit_items", "(", "lower", ",", "upper", ")", ":", "# Use value + 0 to convert any -0.0 to 0.0 which looks better.", "if", "lower", "is", "not", "None", "and", "upper", "is", "not", "None", "and", "lower", "==", "upper", ":", "yield", "'fixed'", ...
Yield key, value pairs for limits dictionary. Yield pairs of key, value where key is ``lower``, ``upper`` or ``fixed``. A key, value pair is emitted if the bounds are not None.
[ "Yield", "key", "value", "pairs", "for", "limits", "dictionary", "." ]
dc427848c4f9d109ca590f0afa024c63b685b3f4
https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/importer.py#L311-L324
48,290
zhanglab/psamm
psamm/importer.py
model_exchange
def model_exchange(model): """Return exchange definition as YAML dict.""" # Determine the default flux limits. If the value is already at the # default it does not need to be included in the output. lower_default, upper_default = None, None if model.default_flux_limit is not None: lower_defa...
python
def model_exchange(model): """Return exchange definition as YAML dict.""" # Determine the default flux limits. If the value is already at the # default it does not need to be included in the output. lower_default, upper_default = None, None if model.default_flux_limit is not None: lower_defa...
[ "def", "model_exchange", "(", "model", ")", ":", "# Determine the default flux limits. If the value is already at the", "# default it does not need to be included in the output.", "lower_default", ",", "upper_default", "=", "None", ",", "None", "if", "model", ".", "default_flux_l...
Return exchange definition as YAML dict.
[ "Return", "exchange", "definition", "as", "YAML", "dict", "." ]
dc427848c4f9d109ca590f0afa024c63b685b3f4
https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/importer.py#L327-L349
48,291
zhanglab/psamm
psamm/importer.py
model_reaction_limits
def model_reaction_limits(model): """Yield model reaction limits as YAML dicts.""" for reaction in sorted(model.reactions, key=lambda r: r.id): equation = reaction.properties.get('equation') if equation is None: continue # Determine the default flux limits. If the value is a...
python
def model_reaction_limits(model): """Yield model reaction limits as YAML dicts.""" for reaction in sorted(model.reactions, key=lambda r: r.id): equation = reaction.properties.get('equation') if equation is None: continue # Determine the default flux limits. If the value is a...
[ "def", "model_reaction_limits", "(", "model", ")", ":", "for", "reaction", "in", "sorted", "(", "model", ".", "reactions", ",", "key", "=", "lambda", "r", ":", "r", ".", "id", ")", ":", "equation", "=", "reaction", ".", "properties", ".", "get", "(", ...
Yield model reaction limits as YAML dicts.
[ "Yield", "model", "reaction", "limits", "as", "YAML", "dicts", "." ]
dc427848c4f9d109ca590f0afa024c63b685b3f4
https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/importer.py#L352-L383
48,292
zhanglab/psamm
psamm/importer.py
infer_compartment_entries
def infer_compartment_entries(model): """Infer compartment entries for model based on reaction compounds.""" compartment_ids = set() for reaction in model.reactions: equation = reaction.equation if equation is None: continue for compound, _ in equation.compounds: ...
python
def infer_compartment_entries(model): """Infer compartment entries for model based on reaction compounds.""" compartment_ids = set() for reaction in model.reactions: equation = reaction.equation if equation is None: continue for compound, _ in equation.compounds: ...
[ "def", "infer_compartment_entries", "(", "model", ")", ":", "compartment_ids", "=", "set", "(", ")", "for", "reaction", "in", "model", ".", "reactions", ":", "equation", "=", "reaction", ".", "equation", "if", "equation", "is", "None", ":", "continue", "for"...
Infer compartment entries for model based on reaction compounds.
[ "Infer", "compartment", "entries", "for", "model", "based", "on", "reaction", "compounds", "." ]
dc427848c4f9d109ca590f0afa024c63b685b3f4
https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/importer.py#L386-L407
48,293
zhanglab/psamm
psamm/importer.py
infer_compartment_adjacency
def infer_compartment_adjacency(model): """Infer compartment adjacency for model based on reactions.""" def reaction_compartments(seq): for compound, _ in seq: compartment = compound.compartment if compartment is None: compartment = model.default_compartment ...
python
def infer_compartment_adjacency(model): """Infer compartment adjacency for model based on reactions.""" def reaction_compartments(seq): for compound, _ in seq: compartment = compound.compartment if compartment is None: compartment = model.default_compartment ...
[ "def", "infer_compartment_adjacency", "(", "model", ")", ":", "def", "reaction_compartments", "(", "seq", ")", ":", "for", "compound", ",", "_", "in", "seq", ":", "compartment", "=", "compound", ".", "compartment", "if", "compartment", "is", "None", ":", "co...
Infer compartment adjacency for model based on reactions.
[ "Infer", "compartment", "adjacency", "for", "model", "based", "on", "reactions", "." ]
dc427848c4f9d109ca590f0afa024c63b685b3f4
https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/importer.py#L410-L432
48,294
zhanglab/psamm
psamm/importer.py
count_genes
def count_genes(model): """Count the number of distinct genes in model reactions.""" genes = set() for reaction in model.reactions: if reaction.genes is None: continue if isinstance(reaction.genes, boolean.Expression): genes.update(v.symbol for v in reaction.genes.va...
python
def count_genes(model): """Count the number of distinct genes in model reactions.""" genes = set() for reaction in model.reactions: if reaction.genes is None: continue if isinstance(reaction.genes, boolean.Expression): genes.update(v.symbol for v in reaction.genes.va...
[ "def", "count_genes", "(", "model", ")", ":", "genes", "=", "set", "(", ")", "for", "reaction", "in", "model", ".", "reactions", ":", "if", "reaction", ".", "genes", "is", "None", ":", "continue", "if", "isinstance", "(", "reaction", ".", "genes", ",",...
Count the number of distinct genes in model reactions.
[ "Count", "the", "number", "of", "distinct", "genes", "in", "model", "reactions", "." ]
dc427848c4f9d109ca590f0afa024c63b685b3f4
https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/importer.py#L435-L447
48,295
zhanglab/psamm
psamm/importer.py
Importer._try_parse_formula
def _try_parse_formula(self, compound_id, s): """Try to parse the given compound formula string. Logs a warning if the formula could not be parsed. """ s = s.strip() if s == '': return None try: # Do not return the parsed formula. For now it is b...
python
def _try_parse_formula(self, compound_id, s): """Try to parse the given compound formula string. Logs a warning if the formula could not be parsed. """ s = s.strip() if s == '': return None try: # Do not return the parsed formula. For now it is b...
[ "def", "_try_parse_formula", "(", "self", ",", "compound_id", ",", "s", ")", ":", "s", "=", "s", ".", "strip", "(", ")", "if", "s", "==", "''", ":", "return", "None", "try", ":", "# Do not return the parsed formula. For now it is better to keep", "# the original...
Try to parse the given compound formula string. Logs a warning if the formula could not be parsed.
[ "Try", "to", "parse", "the", "given", "compound", "formula", "string", "." ]
dc427848c4f9d109ca590f0afa024c63b685b3f4
https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/importer.py#L79-L96
48,296
zhanglab/psamm
psamm/importer.py
Importer._try_parse_reaction
def _try_parse_reaction(self, reaction_id, s, parser=parse_reaction, **kwargs): """Try to parse the given reaction equation string. Returns the parsed Reaction object, or raises an error if the reaction could not be parsed. """ try: return...
python
def _try_parse_reaction(self, reaction_id, s, parser=parse_reaction, **kwargs): """Try to parse the given reaction equation string. Returns the parsed Reaction object, or raises an error if the reaction could not be parsed. """ try: return...
[ "def", "_try_parse_reaction", "(", "self", ",", "reaction_id", ",", "s", ",", "parser", "=", "parse_reaction", ",", "*", "*", "kwargs", ")", ":", "try", ":", "return", "parser", "(", "s", ",", "*", "*", "kwargs", ")", "except", "ReactionParseError", "as"...
Try to parse the given reaction equation string. Returns the parsed Reaction object, or raises an error if the reaction could not be parsed.
[ "Try", "to", "parse", "the", "given", "reaction", "equation", "string", "." ]
dc427848c4f9d109ca590f0afa024c63b685b3f4
https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/importer.py#L98-L112
48,297
zhanglab/psamm
psamm/importer.py
Importer._try_parse_gene_association
def _try_parse_gene_association(self, reaction_id, s): """Try to parse the given gene association rule. Logs a warning if the association rule could not be parsed and returns the original string. Otherwise, returns the boolean.Expression object. """ s = s.strip() if s ==...
python
def _try_parse_gene_association(self, reaction_id, s): """Try to parse the given gene association rule. Logs a warning if the association rule could not be parsed and returns the original string. Otherwise, returns the boolean.Expression object. """ s = s.strip() if s ==...
[ "def", "_try_parse_gene_association", "(", "self", ",", "reaction_id", ",", "s", ")", ":", "s", "=", "s", ".", "strip", "(", ")", "if", "s", "==", "''", ":", "return", "None", "try", ":", "return", "boolean", ".", "Expression", "(", "s", ")", "except...
Try to parse the given gene association rule. Logs a warning if the association rule could not be parsed and returns the original string. Otherwise, returns the boolean.Expression object.
[ "Try", "to", "parse", "the", "given", "gene", "association", "rule", "." ]
dc427848c4f9d109ca590f0afa024c63b685b3f4
https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/importer.py#L114-L133
48,298
inveniosoftware/invenio-rest
invenio_rest/decorators.py
require_content_types
def require_content_types(*allowed_content_types): r"""Decorator to test if proper Content-Type is provided. :param \*allowed_content_types: List of allowed content types. :raises invenio_rest.errors.InvalidContentType: It's rised if a content type not allowed is required. """ def decorator...
python
def require_content_types(*allowed_content_types): r"""Decorator to test if proper Content-Type is provided. :param \*allowed_content_types: List of allowed content types. :raises invenio_rest.errors.InvalidContentType: It's rised if a content type not allowed is required. """ def decorator...
[ "def", "require_content_types", "(", "*", "allowed_content_types", ")", ":", "def", "decorator", "(", "f", ")", ":", "@", "wraps", "(", "f", ")", "def", "inner", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "request", ".", "mimetype", "...
r"""Decorator to test if proper Content-Type is provided. :param \*allowed_content_types: List of allowed content types. :raises invenio_rest.errors.InvalidContentType: It's rised if a content type not allowed is required.
[ "r", "Decorator", "to", "test", "if", "proper", "Content", "-", "Type", "is", "provided", "." ]
4271708f0e2877e5100236be9242035b95b5ae6e
https://github.com/inveniosoftware/invenio-rest/blob/4271708f0e2877e5100236be9242035b95b5ae6e/invenio_rest/decorators.py#L20-L34
48,299
merll/docker-fabric
dockerfabric/base.py
DockerConnectionDict.get_connection
def get_connection(self, *args, **kwargs): """ Create a new connection, or return an existing one from the cache. Uses Fabric's current ``env.host_string`` and the URL to the Docker service. :param args: Additional arguments for the client constructor, if a new client has to be instanti...
python
def get_connection(self, *args, **kwargs): """ Create a new connection, or return an existing one from the cache. Uses Fabric's current ``env.host_string`` and the URL to the Docker service. :param args: Additional arguments for the client constructor, if a new client has to be instanti...
[ "def", "get_connection", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "key", "=", "env", ".", "get", "(", "'host_string'", ")", ",", "kwargs", ".", "get", "(", "'base_url'", ",", "env", ".", "get", "(", "'docker_base_url'", ")", ...
Create a new connection, or return an existing one from the cache. Uses Fabric's current ``env.host_string`` and the URL to the Docker service. :param args: Additional arguments for the client constructor, if a new client has to be instantiated. :param kwargs: Additional keyword args for the cl...
[ "Create", "a", "new", "connection", "or", "return", "an", "existing", "one", "from", "the", "cache", ".", "Uses", "Fabric", "s", "current", "env", ".", "host_string", "and", "the", "URL", "to", "the", "Docker", "service", "." ]
785d84e40e17265b667d8b11a6e30d8e6b2bf8d4
https://github.com/merll/docker-fabric/blob/785d84e40e17265b667d8b11a6e30d8e6b2bf8d4/dockerfabric/base.py#L43-L58