repository_name stringlengths 5 67 | func_path_in_repository stringlengths 4 234 | func_name stringlengths 0 314 | whole_func_string stringlengths 52 3.87M | language stringclasses 6
values | func_code_string stringlengths 52 3.87M | func_code_tokens listlengths 15 672k | func_documentation_string stringlengths 1 47.2k | func_documentation_tokens listlengths 1 3.92k | split_name stringclasses 1
value | func_code_url stringlengths 85 339 |
|---|---|---|---|---|---|---|---|---|---|---|
opencobra/memote | memote/support/annotation.py | generate_component_annotation_miriam_match | def generate_component_annotation_miriam_match(elements, component, db):
"""
Tabulate which MIRIAM databases the element's annotation match.
If the relevant MIRIAM identifier is not in an element's annotation it is
ignored.
Parameters
----------
elements : list
Elements of a model,... | python | def generate_component_annotation_miriam_match(elements, component, db):
"""
Tabulate which MIRIAM databases the element's annotation match.
If the relevant MIRIAM identifier is not in an element's annotation it is
ignored.
Parameters
----------
elements : list
Elements of a model,... | [
"def",
"generate_component_annotation_miriam_match",
"(",
"elements",
",",
"component",
",",
"db",
")",
":",
"def",
"is_faulty",
"(",
"annotation",
",",
"key",
",",
"pattern",
")",
":",
"# Ignore missing annotation for this database.",
"if",
"key",
"not",
"in",
"ann... | Tabulate which MIRIAM databases the element's annotation match.
If the relevant MIRIAM identifier is not in an element's annotation it is
ignored.
Parameters
----------
elements : list
Elements of a model, either metabolites or reactions.
component : {"metabolites", "reactions"}
... | [
"Tabulate",
"which",
"MIRIAM",
"databases",
"the",
"element",
"s",
"annotation",
"match",
"."
] | train | https://github.com/opencobra/memote/blob/276630fcd4449fb7b914186edfd38c239e7052df/memote/support/annotation.py#L167-L206 |
opencobra/memote | memote/support/annotation.py | generate_component_id_namespace_overview | def generate_component_id_namespace_overview(model, components):
"""
Tabulate which MIRIAM databases the component's identifier matches.
Parameters
----------
model : cobra.Model
A cobrapy metabolic model.
components : {"metabolites", "reactions", "genes"}
A string denoting `cob... | python | def generate_component_id_namespace_overview(model, components):
"""
Tabulate which MIRIAM databases the component's identifier matches.
Parameters
----------
model : cobra.Model
A cobrapy metabolic model.
components : {"metabolites", "reactions", "genes"}
A string denoting `cob... | [
"def",
"generate_component_id_namespace_overview",
"(",
"model",
",",
"components",
")",
":",
"patterns",
"=",
"{",
"\"metabolites\"",
":",
"METABOLITE_ANNOTATIONS",
",",
"\"reactions\"",
":",
"REACTION_ANNOTATIONS",
",",
"\"genes\"",
":",
"GENE_PRODUCT_ANNOTATIONS",
"}",... | Tabulate which MIRIAM databases the component's identifier matches.
Parameters
----------
model : cobra.Model
A cobrapy metabolic model.
components : {"metabolites", "reactions", "genes"}
A string denoting `cobra.Model` components.
Returns
-------
pandas.DataFrame
T... | [
"Tabulate",
"which",
"MIRIAM",
"databases",
"the",
"component",
"s",
"identifier",
"matches",
"."
] | train | https://github.com/opencobra/memote/blob/276630fcd4449fb7b914186edfd38c239e7052df/memote/support/annotation.py#L209-L257 |
opencobra/memote | memote/support/essentiality.py | confusion_matrix | def confusion_matrix(predicted_essential, expected_essential,
predicted_nonessential, expected_nonessential):
"""
Compute a representation of the confusion matrix.
Parameters
----------
predicted_essential : set
expected_essential : set
predicted_nonessential : set
... | python | def confusion_matrix(predicted_essential, expected_essential,
predicted_nonessential, expected_nonessential):
"""
Compute a representation of the confusion matrix.
Parameters
----------
predicted_essential : set
expected_essential : set
predicted_nonessential : set
... | [
"def",
"confusion_matrix",
"(",
"predicted_essential",
",",
"expected_essential",
",",
"predicted_nonessential",
",",
"expected_nonessential",
")",
":",
"true_positive",
"=",
"predicted_essential",
"&",
"expected_essential",
"tp",
"=",
"len",
"(",
"true_positive",
")",
... | Compute a representation of the confusion matrix.
Parameters
----------
predicted_essential : set
expected_essential : set
predicted_nonessential : set
expected_nonessential : set
Returns
-------
dict
Confusion matrix as different keys of a dictionary. The abbreviated
... | [
"Compute",
"a",
"representation",
"of",
"the",
"confusion",
"matrix",
"."
] | train | https://github.com/opencobra/memote/blob/276630fcd4449fb7b914186edfd38c239e7052df/memote/support/essentiality.py#L29-L100 |
opencobra/memote | memote/suite/api.py | validate_model | def validate_model(path):
"""
Validate a model structurally and optionally store results as JSON.
Parameters
----------
path :
Path to model file.
Returns
-------
tuple
cobra.Model
The metabolic model under investigation.
tuple
A tuple re... | python | def validate_model(path):
"""
Validate a model structurally and optionally store results as JSON.
Parameters
----------
path :
Path to model file.
Returns
-------
tuple
cobra.Model
The metabolic model under investigation.
tuple
A tuple re... | [
"def",
"validate_model",
"(",
"path",
")",
":",
"notifications",
"=",
"{",
"\"warnings\"",
":",
"[",
"]",
",",
"\"errors\"",
":",
"[",
"]",
"}",
"model",
",",
"sbml_ver",
"=",
"val",
".",
"load_cobra_model",
"(",
"path",
",",
"notifications",
")",
"retur... | Validate a model structurally and optionally store results as JSON.
Parameters
----------
path :
Path to model file.
Returns
-------
tuple
cobra.Model
The metabolic model under investigation.
tuple
A tuple reporting on the SBML level, version, an... | [
"Validate",
"a",
"model",
"structurally",
"and",
"optionally",
"store",
"results",
"as",
"JSON",
"."
] | train | https://github.com/opencobra/memote/blob/276630fcd4449fb7b914186edfd38c239e7052df/memote/suite/api.py#L41-L64 |
opencobra/memote | memote/suite/api.py | snapshot_report | def snapshot_report(result, config=None, html=True):
"""
Generate a snapshot report from a result set and configuration.
Parameters
----------
result : memote.MemoteResult
Nested dictionary structure as returned from the test suite.
config : dict, optional
The final test report ... | python | def snapshot_report(result, config=None, html=True):
"""
Generate a snapshot report from a result set and configuration.
Parameters
----------
result : memote.MemoteResult
Nested dictionary structure as returned from the test suite.
config : dict, optional
The final test report ... | [
"def",
"snapshot_report",
"(",
"result",
",",
"config",
"=",
"None",
",",
"html",
"=",
"True",
")",
":",
"if",
"config",
"is",
"None",
":",
"config",
"=",
"ReportConfiguration",
".",
"load",
"(",
")",
"report",
"=",
"SnapshotReport",
"(",
"result",
"=",
... | Generate a snapshot report from a result set and configuration.
Parameters
----------
result : memote.MemoteResult
Nested dictionary structure as returned from the test suite.
config : dict, optional
The final test report configuration (default None).
html : bool, optional
W... | [
"Generate",
"a",
"snapshot",
"report",
"from",
"a",
"result",
"set",
"and",
"configuration",
"."
] | train | https://github.com/opencobra/memote/blob/276630fcd4449fb7b914186edfd38c239e7052df/memote/suite/api.py#L112-L132 |
opencobra/memote | memote/suite/api.py | history_report | def history_report(history, config=None, html=True):
"""
Test a model and save a history report.
Parameters
----------
history : memote.HistoryManager
The manager grants access to previous results.
config : dict, optional
The final test report configuration.
html : bool, opt... | python | def history_report(history, config=None, html=True):
"""
Test a model and save a history report.
Parameters
----------
history : memote.HistoryManager
The manager grants access to previous results.
config : dict, optional
The final test report configuration.
html : bool, opt... | [
"def",
"history_report",
"(",
"history",
",",
"config",
"=",
"None",
",",
"html",
"=",
"True",
")",
":",
"if",
"config",
"is",
"None",
":",
"config",
"=",
"ReportConfiguration",
".",
"load",
"(",
")",
"report",
"=",
"HistoryReport",
"(",
"history",
"=",
... | Test a model and save a history report.
Parameters
----------
history : memote.HistoryManager
The manager grants access to previous results.
config : dict, optional
The final test report configuration.
html : bool, optional
Whether to render the report as full HTML or JSON (... | [
"Test",
"a",
"model",
"and",
"save",
"a",
"history",
"report",
"."
] | train | https://github.com/opencobra/memote/blob/276630fcd4449fb7b914186edfd38c239e7052df/memote/suite/api.py#L135-L155 |
opencobra/memote | memote/suite/api.py | diff_report | def diff_report(diff_results, config=None, html=True):
"""
Generate a diff report from a result set and configuration.
Parameters
----------
diff_results : iterable of memote.MemoteResult
Nested dictionary structure as returned from the test suite.
config : dict, optional
The fi... | python | def diff_report(diff_results, config=None, html=True):
"""
Generate a diff report from a result set and configuration.
Parameters
----------
diff_results : iterable of memote.MemoteResult
Nested dictionary structure as returned from the test suite.
config : dict, optional
The fi... | [
"def",
"diff_report",
"(",
"diff_results",
",",
"config",
"=",
"None",
",",
"html",
"=",
"True",
")",
":",
"if",
"config",
"is",
"None",
":",
"config",
"=",
"ReportConfiguration",
".",
"load",
"(",
")",
"report",
"=",
"DiffReport",
"(",
"diff_results",
"... | Generate a diff report from a result set and configuration.
Parameters
----------
diff_results : iterable of memote.MemoteResult
Nested dictionary structure as returned from the test suite.
config : dict, optional
The final test report configuration (default None).
html : bool, opti... | [
"Generate",
"a",
"diff",
"report",
"from",
"a",
"result",
"set",
"and",
"configuration",
"."
] | train | https://github.com/opencobra/memote/blob/276630fcd4449fb7b914186edfd38c239e7052df/memote/suite/api.py#L158-L178 |
opencobra/memote | memote/suite/api.py | validation_report | def validation_report(path, notifications, filename):
"""
Generate a validation report from a notification object.
Parameters
----------
path : string
Path to model file.
notifications : dict
A simple dictionary structure containing a list of errors and warnings.
"""
en... | python | def validation_report(path, notifications, filename):
"""
Generate a validation report from a notification object.
Parameters
----------
path : string
Path to model file.
notifications : dict
A simple dictionary structure containing a list of errors and warnings.
"""
en... | [
"def",
"validation_report",
"(",
"path",
",",
"notifications",
",",
"filename",
")",
":",
"env",
"=",
"Environment",
"(",
"loader",
"=",
"PackageLoader",
"(",
"'memote.suite'",
",",
"'templates'",
")",
",",
"autoescape",
"=",
"select_autoescape",
"(",
"[",
"'h... | Generate a validation report from a notification object.
Parameters
----------
path : string
Path to model file.
notifications : dict
A simple dictionary structure containing a list of errors and warnings. | [
"Generate",
"a",
"validation",
"report",
"from",
"a",
"notification",
"object",
"."
] | train | https://github.com/opencobra/memote/blob/276630fcd4449fb7b914186edfd38c239e7052df/memote/suite/api.py#L181-L200 |
opencobra/memote | memote/suite/reporting/config.py | ReportConfiguration.load | def load(cls, filename=None):
"""Load a test report configuration."""
if filename is None:
LOGGER.debug("Loading default configuration.")
with open_text(templates, "test_config.yml",
encoding="utf-8") as file_handle:
content = yaml.load(... | python | def load(cls, filename=None):
"""Load a test report configuration."""
if filename is None:
LOGGER.debug("Loading default configuration.")
with open_text(templates, "test_config.yml",
encoding="utf-8") as file_handle:
content = yaml.load(... | [
"def",
"load",
"(",
"cls",
",",
"filename",
"=",
"None",
")",
":",
"if",
"filename",
"is",
"None",
":",
"LOGGER",
".",
"debug",
"(",
"\"Loading default configuration.\"",
")",
"with",
"open_text",
"(",
"templates",
",",
"\"test_config.yml\"",
",",
"encoding",
... | Load a test report configuration. | [
"Load",
"a",
"test",
"report",
"configuration",
"."
] | train | https://github.com/opencobra/memote/blob/276630fcd4449fb7b914186edfd38c239e7052df/memote/suite/reporting/config.py#L52-L70 |
opencobra/memote | memote/support/gpr_helpers.py | find_top_level_complex | def find_top_level_complex(gpr):
"""
Find unique elements of both branches of the top level logical AND.
Parameters
----------
gpr : str
The gene-protein-reaction association as a string.
Returns
-------
int
The size of the symmetric difference between the set of elemen... | python | def find_top_level_complex(gpr):
"""
Find unique elements of both branches of the top level logical AND.
Parameters
----------
gpr : str
The gene-protein-reaction association as a string.
Returns
-------
int
The size of the symmetric difference between the set of elemen... | [
"def",
"find_top_level_complex",
"(",
"gpr",
")",
":",
"logger",
".",
"debug",
"(",
"\"%r\"",
",",
"gpr",
")",
"conform",
"=",
"logical_and",
".",
"sub",
"(",
"\"and\"",
",",
"gpr",
")",
"conform",
"=",
"logical_or",
".",
"sub",
"(",
"\"or\"",
",",
"co... | Find unique elements of both branches of the top level logical AND.
Parameters
----------
gpr : str
The gene-protein-reaction association as a string.
Returns
-------
int
The size of the symmetric difference between the set of elements to
the left of the top level logic... | [
"Find",
"unique",
"elements",
"of",
"both",
"branches",
"of",
"the",
"top",
"level",
"logical",
"AND",
"."
] | train | https://github.com/opencobra/memote/blob/276630fcd4449fb7b914186edfd38c239e7052df/memote/support/gpr_helpers.py#L107-L130 |
opencobra/memote | memote/support/gpr_helpers.py | GPRVisitor.visit_BoolOp | def visit_BoolOp(self, node):
"""Set up recording of elements with this hook."""
if self._is_top and isinstance(node.op, ast.And):
self._is_top = False
self._current = self.left
self.visit(node.values[0])
self._current = self.right
for successo... | python | def visit_BoolOp(self, node):
"""Set up recording of elements with this hook."""
if self._is_top and isinstance(node.op, ast.And):
self._is_top = False
self._current = self.left
self.visit(node.values[0])
self._current = self.right
for successo... | [
"def",
"visit_BoolOp",
"(",
"self",
",",
"node",
")",
":",
"if",
"self",
".",
"_is_top",
"and",
"isinstance",
"(",
"node",
".",
"op",
",",
"ast",
".",
"And",
")",
":",
"self",
".",
"_is_top",
"=",
"False",
"self",
".",
"_current",
"=",
"self",
".",... | Set up recording of elements with this hook. | [
"Set",
"up",
"recording",
"of",
"elements",
"with",
"this",
"hook",
"."
] | train | https://github.com/opencobra/memote/blob/276630fcd4449fb7b914186edfd38c239e7052df/memote/support/gpr_helpers.py#L90-L100 |
opencobra/memote | memote/support/basic.py | find_nonzero_constrained_reactions | def find_nonzero_constrained_reactions(model):
"""Return list of reactions with non-zero, non-maximal bounds."""
lower_bound, upper_bound = helpers.find_bounds(model)
return [rxn for rxn in model.reactions if
0 > rxn.lower_bound > lower_bound or
0 < rxn.upper_bound < upper_bound] | python | def find_nonzero_constrained_reactions(model):
"""Return list of reactions with non-zero, non-maximal bounds."""
lower_bound, upper_bound = helpers.find_bounds(model)
return [rxn for rxn in model.reactions if
0 > rxn.lower_bound > lower_bound or
0 < rxn.upper_bound < upper_bound] | [
"def",
"find_nonzero_constrained_reactions",
"(",
"model",
")",
":",
"lower_bound",
",",
"upper_bound",
"=",
"helpers",
".",
"find_bounds",
"(",
"model",
")",
"return",
"[",
"rxn",
"for",
"rxn",
"in",
"model",
".",
"reactions",
"if",
"0",
">",
"rxn",
".",
... | Return list of reactions with non-zero, non-maximal bounds. | [
"Return",
"list",
"of",
"reactions",
"with",
"non",
"-",
"zero",
"non",
"-",
"maximal",
"bounds",
"."
] | train | https://github.com/opencobra/memote/blob/276630fcd4449fb7b914186edfd38c239e7052df/memote/support/basic.py#L53-L58 |
opencobra/memote | memote/support/basic.py | find_zero_constrained_reactions | def find_zero_constrained_reactions(model):
"""Return list of reactions that are constrained to zero flux."""
return [rxn for rxn in model.reactions if
rxn.lower_bound == 0 and
rxn.upper_bound == 0] | python | def find_zero_constrained_reactions(model):
"""Return list of reactions that are constrained to zero flux."""
return [rxn for rxn in model.reactions if
rxn.lower_bound == 0 and
rxn.upper_bound == 0] | [
"def",
"find_zero_constrained_reactions",
"(",
"model",
")",
":",
"return",
"[",
"rxn",
"for",
"rxn",
"in",
"model",
".",
"reactions",
"if",
"rxn",
".",
"lower_bound",
"==",
"0",
"and",
"rxn",
".",
"upper_bound",
"==",
"0",
"]"
] | Return list of reactions that are constrained to zero flux. | [
"Return",
"list",
"of",
"reactions",
"that",
"are",
"constrained",
"to",
"zero",
"flux",
"."
] | train | https://github.com/opencobra/memote/blob/276630fcd4449fb7b914186edfd38c239e7052df/memote/support/basic.py#L61-L65 |
opencobra/memote | memote/support/basic.py | find_unconstrained_reactions | def find_unconstrained_reactions(model):
"""Return list of reactions that are not constrained at all."""
lower_bound, upper_bound = helpers.find_bounds(model)
return [rxn for rxn in model.reactions if
rxn.lower_bound <= lower_bound and
rxn.upper_bound >= upper_bound] | python | def find_unconstrained_reactions(model):
"""Return list of reactions that are not constrained at all."""
lower_bound, upper_bound = helpers.find_bounds(model)
return [rxn for rxn in model.reactions if
rxn.lower_bound <= lower_bound and
rxn.upper_bound >= upper_bound] | [
"def",
"find_unconstrained_reactions",
"(",
"model",
")",
":",
"lower_bound",
",",
"upper_bound",
"=",
"helpers",
".",
"find_bounds",
"(",
"model",
")",
"return",
"[",
"rxn",
"for",
"rxn",
"in",
"model",
".",
"reactions",
"if",
"rxn",
".",
"lower_bound",
"<=... | Return list of reactions that are not constrained at all. | [
"Return",
"list",
"of",
"reactions",
"that",
"are",
"not",
"constrained",
"at",
"all",
"."
] | train | https://github.com/opencobra/memote/blob/276630fcd4449fb7b914186edfd38c239e7052df/memote/support/basic.py#L73-L78 |
opencobra/memote | memote/support/basic.py | find_ngam | def find_ngam(model):
u"""
Return all potential non growth-associated maintenance reactions.
From the list of all reactions that convert ATP to ADP select the reactions
that match a defined reaction string and whose metabolites are situated
within the main model compartment. The main model compartm... | python | def find_ngam(model):
u"""
Return all potential non growth-associated maintenance reactions.
From the list of all reactions that convert ATP to ADP select the reactions
that match a defined reaction string and whose metabolites are situated
within the main model compartment. The main model compartm... | [
"def",
"find_ngam",
"(",
"model",
")",
":",
"atp_adp_conv_rxns",
"=",
"helpers",
".",
"find_converting_reactions",
"(",
"model",
",",
"(",
"\"MNXM3\"",
",",
"\"MNXM7\"",
")",
")",
"id_of_main_compartment",
"=",
"helpers",
".",
"find_compartment_id_in_model",
"(",
... | u"""
Return all potential non growth-associated maintenance reactions.
From the list of all reactions that convert ATP to ADP select the reactions
that match a defined reaction string and whose metabolites are situated
within the main model compartment. The main model compartment is the
cytosol, an... | [
"u",
"Return",
"all",
"potential",
"non",
"growth",
"-",
"associated",
"maintenance",
"reactions",
"."
] | train | https://github.com/opencobra/memote/blob/276630fcd4449fb7b914186edfd38c239e7052df/memote/support/basic.py#L81-L148 |
opencobra/memote | memote/support/basic.py | calculate_metabolic_coverage | def calculate_metabolic_coverage(model):
u"""
Return the ratio of reactions and genes included in the model.
Determine whether the amount of reactions and genes in model not equal to
zero, then return the ratio.
Parameters
----------
model : cobra.Model
The metabolic model under in... | python | def calculate_metabolic_coverage(model):
u"""
Return the ratio of reactions and genes included in the model.
Determine whether the amount of reactions and genes in model not equal to
zero, then return the ratio.
Parameters
----------
model : cobra.Model
The metabolic model under in... | [
"def",
"calculate_metabolic_coverage",
"(",
"model",
")",
":",
"if",
"len",
"(",
"model",
".",
"reactions",
")",
"==",
"0",
"or",
"len",
"(",
"model",
".",
"genes",
")",
"==",
"0",
":",
"raise",
"ValueError",
"(",
"\"The model contains no reactions or genes.\"... | u"""
Return the ratio of reactions and genes included in the model.
Determine whether the amount of reactions and genes in model not equal to
zero, then return the ratio.
Parameters
----------
model : cobra.Model
The metabolic model under investigation.
Returns
-------
flo... | [
"u",
"Return",
"the",
"ratio",
"of",
"reactions",
"and",
"genes",
"included",
"in",
"the",
"model",
"."
] | train | https://github.com/opencobra/memote/blob/276630fcd4449fb7b914186edfd38c239e7052df/memote/support/basic.py#L151-L192 |
opencobra/memote | memote/support/basic.py | find_protein_complexes | def find_protein_complexes(model):
"""
Find reactions that are catalyzed by at least a heterodimer.
Parameters
----------
model : cobra.Model
The metabolic model under investigation.
Returns
-------
list
Reactions whose gene-protein-reaction association contains at leas... | python | def find_protein_complexes(model):
"""
Find reactions that are catalyzed by at least a heterodimer.
Parameters
----------
model : cobra.Model
The metabolic model under investigation.
Returns
-------
list
Reactions whose gene-protein-reaction association contains at leas... | [
"def",
"find_protein_complexes",
"(",
"model",
")",
":",
"complexes",
"=",
"[",
"]",
"for",
"rxn",
"in",
"model",
".",
"reactions",
":",
"if",
"not",
"rxn",
".",
"gene_reaction_rule",
":",
"continue",
"size",
"=",
"find_top_level_complex",
"(",
"rxn",
".",
... | Find reactions that are catalyzed by at least a heterodimer.
Parameters
----------
model : cobra.Model
The metabolic model under investigation.
Returns
-------
list
Reactions whose gene-protein-reaction association contains at least one
logical AND combining different g... | [
"Find",
"reactions",
"that",
"are",
"catalyzed",
"by",
"at",
"least",
"a",
"heterodimer",
"."
] | train | https://github.com/opencobra/memote/blob/276630fcd4449fb7b914186edfd38c239e7052df/memote/support/basic.py#L195-L218 |
opencobra/memote | memote/support/basic.py | is_constrained_reaction | def is_constrained_reaction(model, rxn):
"""Return whether a reaction has fixed constraints."""
lower_bound, upper_bound = helpers.find_bounds(model)
if rxn.reversibility:
return rxn.lower_bound > lower_bound or rxn.upper_bound < upper_bound
else:
return rxn.lower_bound > 0 or rxn.upper_... | python | def is_constrained_reaction(model, rxn):
"""Return whether a reaction has fixed constraints."""
lower_bound, upper_bound = helpers.find_bounds(model)
if rxn.reversibility:
return rxn.lower_bound > lower_bound or rxn.upper_bound < upper_bound
else:
return rxn.lower_bound > 0 or rxn.upper_... | [
"def",
"is_constrained_reaction",
"(",
"model",
",",
"rxn",
")",
":",
"lower_bound",
",",
"upper_bound",
"=",
"helpers",
".",
"find_bounds",
"(",
"model",
")",
"if",
"rxn",
".",
"reversibility",
":",
"return",
"rxn",
".",
"lower_bound",
">",
"lower_bound",
"... | Return whether a reaction has fixed constraints. | [
"Return",
"whether",
"a",
"reaction",
"has",
"fixed",
"constraints",
"."
] | train | https://github.com/opencobra/memote/blob/276630fcd4449fb7b914186edfd38c239e7052df/memote/support/basic.py#L236-L242 |
opencobra/memote | memote/support/basic.py | find_oxygen_reactions | def find_oxygen_reactions(model):
"""Return list of oxygen-producing/-consuming reactions."""
o2_in_model = helpers.find_met_in_model(model, "MNXM4")
return set([rxn for met in model.metabolites for
rxn in met.reactions if met.formula == "O2" or
met in o2_in_model]) | python | def find_oxygen_reactions(model):
"""Return list of oxygen-producing/-consuming reactions."""
o2_in_model = helpers.find_met_in_model(model, "MNXM4")
return set([rxn for met in model.metabolites for
rxn in met.reactions if met.formula == "O2" or
met in o2_in_model]) | [
"def",
"find_oxygen_reactions",
"(",
"model",
")",
":",
"o2_in_model",
"=",
"helpers",
".",
"find_met_in_model",
"(",
"model",
",",
"\"MNXM4\"",
")",
"return",
"set",
"(",
"[",
"rxn",
"for",
"met",
"in",
"model",
".",
"metabolites",
"for",
"rxn",
"in",
"me... | Return list of oxygen-producing/-consuming reactions. | [
"Return",
"list",
"of",
"oxygen",
"-",
"producing",
"/",
"-",
"consuming",
"reactions",
"."
] | train | https://github.com/opencobra/memote/blob/276630fcd4449fb7b914186edfd38c239e7052df/memote/support/basic.py#L245-L250 |
opencobra/memote | memote/support/basic.py | find_unique_metabolites | def find_unique_metabolites(model):
"""Return set of metabolite IDs without duplicates from compartments."""
unique = set()
for met in model.metabolites:
is_missing = True
for comp in model.compartments:
if met.id.endswith("_{}".format(comp)):
unique.add(met.id[:-... | python | def find_unique_metabolites(model):
"""Return set of metabolite IDs without duplicates from compartments."""
unique = set()
for met in model.metabolites:
is_missing = True
for comp in model.compartments:
if met.id.endswith("_{}".format(comp)):
unique.add(met.id[:-... | [
"def",
"find_unique_metabolites",
"(",
"model",
")",
":",
"unique",
"=",
"set",
"(",
")",
"for",
"met",
"in",
"model",
".",
"metabolites",
":",
"is_missing",
"=",
"True",
"for",
"comp",
"in",
"model",
".",
"compartments",
":",
"if",
"met",
".",
"id",
"... | Return set of metabolite IDs without duplicates from compartments. | [
"Return",
"set",
"of",
"metabolite",
"IDs",
"without",
"duplicates",
"from",
"compartments",
"."
] | train | https://github.com/opencobra/memote/blob/276630fcd4449fb7b914186edfd38c239e7052df/memote/support/basic.py#L253-L265 |
opencobra/memote | memote/support/basic.py | find_duplicate_metabolites_in_compartments | def find_duplicate_metabolites_in_compartments(model):
"""
Return list of metabolites with duplicates in the same compartment.
This function identifies duplicate metabolites in each compartment by
determining if any two metabolites have identical InChI-key annotations.
For instance, this function w... | python | def find_duplicate_metabolites_in_compartments(model):
"""
Return list of metabolites with duplicates in the same compartment.
This function identifies duplicate metabolites in each compartment by
determining if any two metabolites have identical InChI-key annotations.
For instance, this function w... | [
"def",
"find_duplicate_metabolites_in_compartments",
"(",
"model",
")",
":",
"unique_identifiers",
"=",
"[",
"\"inchikey\"",
",",
"\"inchi\"",
"]",
"duplicates",
"=",
"[",
"]",
"for",
"met_1",
",",
"met_2",
"in",
"combinations",
"(",
"model",
".",
"metabolites",
... | Return list of metabolites with duplicates in the same compartment.
This function identifies duplicate metabolites in each compartment by
determining if any two metabolites have identical InChI-key annotations.
For instance, this function would find compounds with IDs ATP1 and ATP2 in
the cytosolic com... | [
"Return",
"list",
"of",
"metabolites",
"with",
"duplicates",
"in",
"the",
"same",
"compartment",
"."
] | train | https://github.com/opencobra/memote/blob/276630fcd4449fb7b914186edfd38c239e7052df/memote/support/basic.py#L269-L298 |
opencobra/memote | memote/support/basic.py | find_reactions_with_partially_identical_annotations | def find_reactions_with_partially_identical_annotations(model):
"""
Return duplicate reactions based on identical annotation.
Identify duplicate reactions globally by checking if any two metabolic
reactions have the same entries in their annotation attributes. This can be
useful to identify one 'ty... | python | def find_reactions_with_partially_identical_annotations(model):
"""
Return duplicate reactions based on identical annotation.
Identify duplicate reactions globally by checking if any two metabolic
reactions have the same entries in their annotation attributes. This can be
useful to identify one 'ty... | [
"def",
"find_reactions_with_partially_identical_annotations",
"(",
"model",
")",
":",
"duplicates",
"=",
"{",
"}",
"rxn_db_identifiers",
"=",
"[",
"\"metanetx.reaction\"",
",",
"\"kegg.reaction\"",
",",
"\"brenda\"",
",",
"\"rhea\"",
",",
"\"biocyc\"",
",",
"\"bigg.reac... | Return duplicate reactions based on identical annotation.
Identify duplicate reactions globally by checking if any two metabolic
reactions have the same entries in their annotation attributes. This can be
useful to identify one 'type' of reactions that occurs in several
compartments, to curate merged m... | [
"Return",
"duplicate",
"reactions",
"based",
"on",
"identical",
"annotation",
"."
] | train | https://github.com/opencobra/memote/blob/276630fcd4449fb7b914186edfd38c239e7052df/memote/support/basic.py#L301-L356 |
opencobra/memote | memote/support/basic.py | map_metabolites_to_structures | def map_metabolites_to_structures(metabolites, compartments):
"""
Map metabolites from the identifier namespace to structural space.
Metabolites who lack structural annotation (InChI or InChIKey) are ignored.
Parameters
----------
metabolites : iterable
The cobra.Metabolites to map.
... | python | def map_metabolites_to_structures(metabolites, compartments):
"""
Map metabolites from the identifier namespace to structural space.
Metabolites who lack structural annotation (InChI or InChIKey) are ignored.
Parameters
----------
metabolites : iterable
The cobra.Metabolites to map.
... | [
"def",
"map_metabolites_to_structures",
"(",
"metabolites",
",",
"compartments",
")",
":",
"# TODO (Moritz Beber): Consider SMILES?",
"unique_identifiers",
"=",
"[",
"\"inchikey\"",
",",
"\"inchi\"",
"]",
"met2mol",
"=",
"{",
"}",
"molecules",
"=",
"{",
"c",
":",
"[... | Map metabolites from the identifier namespace to structural space.
Metabolites who lack structural annotation (InChI or InChIKey) are ignored.
Parameters
----------
metabolites : iterable
The cobra.Metabolites to map.
compartments : iterable
The different compartments to consider. ... | [
"Map",
"metabolites",
"from",
"the",
"identifier",
"namespace",
"to",
"structural",
"space",
"."
] | train | https://github.com/opencobra/memote/blob/276630fcd4449fb7b914186edfd38c239e7052df/memote/support/basic.py#L359-L407 |
opencobra/memote | memote/support/basic.py | find_duplicate_reactions | def find_duplicate_reactions(model):
"""
Return a list with pairs of reactions that are functionally identical.
Identify duplicate reactions globally by checking if any
two reactions have the same metabolites, same directionality and are in
the same compartment.
This can be useful to curate me... | python | def find_duplicate_reactions(model):
"""
Return a list with pairs of reactions that are functionally identical.
Identify duplicate reactions globally by checking if any
two reactions have the same metabolites, same directionality and are in
the same compartment.
This can be useful to curate me... | [
"def",
"find_duplicate_reactions",
"(",
"model",
")",
":",
"met2mol",
"=",
"map_metabolites_to_structures",
"(",
"model",
".",
"metabolites",
",",
"model",
".",
"compartments",
")",
"# Build a list associating reactions with their stoichiometry in molecular",
"# structure space... | Return a list with pairs of reactions that are functionally identical.
Identify duplicate reactions globally by checking if any
two reactions have the same metabolites, same directionality and are in
the same compartment.
This can be useful to curate merged models or to clean-up bulk model
modific... | [
"Return",
"a",
"list",
"with",
"pairs",
"of",
"reactions",
"that",
"are",
"functionally",
"identical",
"."
] | train | https://github.com/opencobra/memote/blob/276630fcd4449fb7b914186edfd38c239e7052df/memote/support/basic.py#L410-L479 |
opencobra/memote | memote/support/basic.py | find_reactions_with_identical_genes | def find_reactions_with_identical_genes(model):
"""
Return reactions that have identical genes.
Identify duplicate reactions globally by checking if any
two reactions have the same genes.
This can be useful to curate merged models or to clean-up bulk model
modifications, but also to identify pr... | python | def find_reactions_with_identical_genes(model):
"""
Return reactions that have identical genes.
Identify duplicate reactions globally by checking if any
two reactions have the same genes.
This can be useful to curate merged models or to clean-up bulk model
modifications, but also to identify pr... | [
"def",
"find_reactions_with_identical_genes",
"(",
"model",
")",
":",
"duplicates",
"=",
"dict",
"(",
")",
"for",
"rxn_a",
",",
"rxn_b",
"in",
"combinations",
"(",
"model",
".",
"reactions",
",",
"2",
")",
":",
"if",
"not",
"(",
"rxn_a",
".",
"genes",
"a... | Return reactions that have identical genes.
Identify duplicate reactions globally by checking if any
two reactions have the same genes.
This can be useful to curate merged models or to clean-up bulk model
modifications, but also to identify promiscuous enzymes.
The heuristic compares reactions in a... | [
"Return",
"reactions",
"that",
"have",
"identical",
"genes",
"."
] | train | https://github.com/opencobra/memote/blob/276630fcd4449fb7b914186edfd38c239e7052df/memote/support/basic.py#L482-L526 |
opencobra/memote | memote/support/basic.py | find_medium_metabolites | def find_medium_metabolites(model):
"""Return the list of metabolites ingested/excreted by the model."""
return [met.id for rxn in model.medium
for met in model.reactions.get_by_id(rxn).metabolites] | python | def find_medium_metabolites(model):
"""Return the list of metabolites ingested/excreted by the model."""
return [met.id for rxn in model.medium
for met in model.reactions.get_by_id(rxn).metabolites] | [
"def",
"find_medium_metabolites",
"(",
"model",
")",
":",
"return",
"[",
"met",
".",
"id",
"for",
"rxn",
"in",
"model",
".",
"medium",
"for",
"met",
"in",
"model",
".",
"reactions",
".",
"get_by_id",
"(",
"rxn",
")",
".",
"metabolites",
"]"
] | Return the list of metabolites ingested/excreted by the model. | [
"Return",
"the",
"list",
"of",
"metabolites",
"ingested",
"/",
"excreted",
"by",
"the",
"model",
"."
] | train | https://github.com/opencobra/memote/blob/276630fcd4449fb7b914186edfd38c239e7052df/memote/support/basic.py#L535-L538 |
opencobra/memote | memote/support/basic.py | find_external_metabolites | def find_external_metabolites(model):
"""Return all metabolites in the external compartment."""
ex_comp = find_external_compartment(model)
return [met for met in model.metabolites if met.compartment == ex_comp] | python | def find_external_metabolites(model):
"""Return all metabolites in the external compartment."""
ex_comp = find_external_compartment(model)
return [met for met in model.metabolites if met.compartment == ex_comp] | [
"def",
"find_external_metabolites",
"(",
"model",
")",
":",
"ex_comp",
"=",
"find_external_compartment",
"(",
"model",
")",
"return",
"[",
"met",
"for",
"met",
"in",
"model",
".",
"metabolites",
"if",
"met",
".",
"compartment",
"==",
"ex_comp",
"]"
] | Return all metabolites in the external compartment. | [
"Return",
"all",
"metabolites",
"in",
"the",
"external",
"compartment",
"."
] | train | https://github.com/opencobra/memote/blob/276630fcd4449fb7b914186edfd38c239e7052df/memote/support/basic.py#L541-L544 |
opencobra/memote | memote/suite/results/result_manager.py | ResultManager.store | def store(self, result, filename, pretty=True):
"""
Write a result to the given file.
Parameters
----------
result : memote.MemoteResult
The dictionary structure of results.
filename : str or pathlib.Path
Store results directly to the given filena... | python | def store(self, result, filename, pretty=True):
"""
Write a result to the given file.
Parameters
----------
result : memote.MemoteResult
The dictionary structure of results.
filename : str or pathlib.Path
Store results directly to the given filena... | [
"def",
"store",
"(",
"self",
",",
"result",
",",
"filename",
",",
"pretty",
"=",
"True",
")",
":",
"LOGGER",
".",
"info",
"(",
"\"Storing result in '%s'.\"",
",",
"filename",
")",
"if",
"filename",
".",
"endswith",
"(",
"\".gz\"",
")",
":",
"with",
"gzip... | Write a result to the given file.
Parameters
----------
result : memote.MemoteResult
The dictionary structure of results.
filename : str or pathlib.Path
Store results directly to the given filename.
pretty : bool, optional
Whether (default) or... | [
"Write",
"a",
"result",
"to",
"the",
"given",
"file",
"."
] | train | https://github.com/opencobra/memote/blob/276630fcd4449fb7b914186edfd38c239e7052df/memote/suite/results/result_manager.py#L42-L64 |
opencobra/memote | memote/suite/results/result_manager.py | ResultManager.load | def load(self, filename):
"""Load a result from the given JSON file."""
LOGGER.info("Loading result from '%s'.", filename)
if filename.endswith(".gz"):
with gzip.open(filename, "rb") as file_handle:
result = MemoteResult(
json.loads(file_handle.rea... | python | def load(self, filename):
"""Load a result from the given JSON file."""
LOGGER.info("Loading result from '%s'.", filename)
if filename.endswith(".gz"):
with gzip.open(filename, "rb") as file_handle:
result = MemoteResult(
json.loads(file_handle.rea... | [
"def",
"load",
"(",
"self",
",",
"filename",
")",
":",
"LOGGER",
".",
"info",
"(",
"\"Loading result from '%s'.\"",
",",
"filename",
")",
"if",
"filename",
".",
"endswith",
"(",
"\".gz\"",
")",
":",
"with",
"gzip",
".",
"open",
"(",
"filename",
",",
"\"r... | Load a result from the given JSON file. | [
"Load",
"a",
"result",
"from",
"the",
"given",
"JSON",
"file",
"."
] | train | https://github.com/opencobra/memote/blob/276630fcd4449fb7b914186edfd38c239e7052df/memote/suite/results/result_manager.py#L66-L80 |
opencobra/memote | memote/support/validation.py | load_cobra_model | def load_cobra_model(path, notifications):
"""Load a COBRA model with meta information from an SBML document."""
doc = libsbml.readSBML(path)
fbc = doc.getPlugin("fbc")
sbml_ver = doc.getLevel(), doc.getVersion(), fbc if fbc is None else \
fbc.getVersion()
with catch_warnings(record=True) as... | python | def load_cobra_model(path, notifications):
"""Load a COBRA model with meta information from an SBML document."""
doc = libsbml.readSBML(path)
fbc = doc.getPlugin("fbc")
sbml_ver = doc.getLevel(), doc.getVersion(), fbc if fbc is None else \
fbc.getVersion()
with catch_warnings(record=True) as... | [
"def",
"load_cobra_model",
"(",
"path",
",",
"notifications",
")",
":",
"doc",
"=",
"libsbml",
".",
"readSBML",
"(",
"path",
")",
"fbc",
"=",
"doc",
".",
"getPlugin",
"(",
"\"fbc\"",
")",
"sbml_ver",
"=",
"doc",
".",
"getLevel",
"(",
")",
",",
"doc",
... | Load a COBRA model with meta information from an SBML document. | [
"Load",
"a",
"COBRA",
"model",
"with",
"meta",
"information",
"from",
"an",
"SBML",
"document",
"."
] | train | https://github.com/opencobra/memote/blob/276630fcd4449fb7b914186edfd38c239e7052df/memote/support/validation.py#L30-L49 |
opencobra/memote | memote/support/validation.py | format_failure | def format_failure(failure):
"""Format how an error or warning should be displayed."""
return "Line {}, Column {} - #{}: {} - Category: {}, Severity: {}".format(
failure.getLine(),
failure.getColumn(),
failure.getErrorId(),
failure.getMessage(),
failure.getCategoryAsStrin... | python | def format_failure(failure):
"""Format how an error or warning should be displayed."""
return "Line {}, Column {} - #{}: {} - Category: {}, Severity: {}".format(
failure.getLine(),
failure.getColumn(),
failure.getErrorId(),
failure.getMessage(),
failure.getCategoryAsStrin... | [
"def",
"format_failure",
"(",
"failure",
")",
":",
"return",
"\"Line {}, Column {} - #{}: {} - Category: {}, Severity: {}\"",
".",
"format",
"(",
"failure",
".",
"getLine",
"(",
")",
",",
"failure",
".",
"getColumn",
"(",
")",
",",
"failure",
".",
"getErrorId",
"(... | Format how an error or warning should be displayed. | [
"Format",
"how",
"an",
"error",
"or",
"warning",
"should",
"be",
"displayed",
"."
] | train | https://github.com/opencobra/memote/blob/276630fcd4449fb7b914186edfd38c239e7052df/memote/support/validation.py#L52-L61 |
opencobra/memote | memote/support/validation.py | run_sbml_validation | def run_sbml_validation(document, notifications):
"""Report errors and warnings found in an SBML document."""
validator = libsbml.SBMLValidator()
validator.validate(document)
for i in range(document.getNumErrors()):
notifications['errors'].append(format_failure(document.getError(i)))
for i i... | python | def run_sbml_validation(document, notifications):
"""Report errors and warnings found in an SBML document."""
validator = libsbml.SBMLValidator()
validator.validate(document)
for i in range(document.getNumErrors()):
notifications['errors'].append(format_failure(document.getError(i)))
for i i... | [
"def",
"run_sbml_validation",
"(",
"document",
",",
"notifications",
")",
":",
"validator",
"=",
"libsbml",
".",
"SBMLValidator",
"(",
")",
"validator",
".",
"validate",
"(",
"document",
")",
"for",
"i",
"in",
"range",
"(",
"document",
".",
"getNumErrors",
"... | Report errors and warnings found in an SBML document. | [
"Report",
"errors",
"and",
"warnings",
"found",
"in",
"an",
"SBML",
"document",
"."
] | train | https://github.com/opencobra/memote/blob/276630fcd4449fb7b914186edfd38c239e7052df/memote/support/validation.py#L64-L75 |
opencobra/memote | memote/suite/results/sql_result_manager.py | SQLResultManager.store | def store(self, result, commit=None, **kwargs):
"""
Store a result in a JSON file attaching git meta information.
Parameters
----------
result : memote.MemoteResult
The dictionary structure of results.
commit : str, optional
Unique hexsha of the d... | python | def store(self, result, commit=None, **kwargs):
"""
Store a result in a JSON file attaching git meta information.
Parameters
----------
result : memote.MemoteResult
The dictionary structure of results.
commit : str, optional
Unique hexsha of the d... | [
"def",
"store",
"(",
"self",
",",
"result",
",",
"commit",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"git_info",
"=",
"self",
".",
"record_git_info",
"(",
"commit",
")",
"try",
":",
"row",
"=",
"self",
".",
"session",
".",
"query",
"(",
"Resu... | Store a result in a JSON file attaching git meta information.
Parameters
----------
result : memote.MemoteResult
The dictionary structure of results.
commit : str, optional
Unique hexsha of the desired commit.
kwargs :
Passed to parent functio... | [
"Store",
"a",
"result",
"in",
"a",
"JSON",
"file",
"attaching",
"git",
"meta",
"information",
"."
] | train | https://github.com/opencobra/memote/blob/276630fcd4449fb7b914186edfd38c239e7052df/memote/suite/results/sql_result_manager.py#L58-L87 |
opencobra/memote | memote/suite/results/sql_result_manager.py | SQLResultManager.load | def load(self, commit=None):
"""Load a result from the database."""
git_info = self.record_git_info(commit)
LOGGER.info("Loading result from '%s'.", git_info.hexsha)
result = MemoteResult(
self.session.query(Result.memote_result).
filter_by(hexsha=git_info.hexsha)... | python | def load(self, commit=None):
"""Load a result from the database."""
git_info = self.record_git_info(commit)
LOGGER.info("Loading result from '%s'.", git_info.hexsha)
result = MemoteResult(
self.session.query(Result.memote_result).
filter_by(hexsha=git_info.hexsha)... | [
"def",
"load",
"(",
"self",
",",
"commit",
"=",
"None",
")",
":",
"git_info",
"=",
"self",
".",
"record_git_info",
"(",
"commit",
")",
"LOGGER",
".",
"info",
"(",
"\"Loading result from '%s'.\"",
",",
"git_info",
".",
"hexsha",
")",
"result",
"=",
"MemoteR... | Load a result from the database. | [
"Load",
"a",
"result",
"from",
"the",
"database",
"."
] | train | https://github.com/opencobra/memote/blob/276630fcd4449fb7b914186edfd38c239e7052df/memote/suite/results/sql_result_manager.py#L89-L100 |
opencobra/memote | memote/suite/reporting/history.py | HistoryReport.collect_history | def collect_history(self):
"""Build the structure of results in terms of a commit history."""
def format_data(data):
"""Format result data according to the user-defined type."""
# TODO Remove this failsafe once proper error handling is in place.
if type == "percent" o... | python | def collect_history(self):
"""Build the structure of results in terms of a commit history."""
def format_data(data):
"""Format result data according to the user-defined type."""
# TODO Remove this failsafe once proper error handling is in place.
if type == "percent" o... | [
"def",
"collect_history",
"(",
"self",
")",
":",
"def",
"format_data",
"(",
"data",
")",
":",
"\"\"\"Format result data according to the user-defined type.\"\"\"",
"# TODO Remove this failsafe once proper error handling is in place.",
"if",
"type",
"==",
"\"percent\"",
"or",
"d... | Build the structure of results in terms of a commit history. | [
"Build",
"the",
"structure",
"of",
"results",
"in",
"terms",
"of",
"a",
"commit",
"history",
"."
] | train | https://github.com/opencobra/memote/blob/276630fcd4449fb7b914186edfd38c239e7052df/memote/suite/reporting/history.py#L61-L126 |
opencobra/memote | memote/suite/reporting/diff.py | DiffReport.format_and_score_diff_data | def format_and_score_diff_data(self, diff_results):
"""Reformat the api results to work with the front-end."""
base = dict()
meta = base.setdefault('meta', dict())
tests = base.setdefault('tests', dict())
score = base.setdefault('score', dict())
for model_filename, result... | python | def format_and_score_diff_data(self, diff_results):
"""Reformat the api results to work with the front-end."""
base = dict()
meta = base.setdefault('meta', dict())
tests = base.setdefault('tests', dict())
score = base.setdefault('score', dict())
for model_filename, result... | [
"def",
"format_and_score_diff_data",
"(",
"self",
",",
"diff_results",
")",
":",
"base",
"=",
"dict",
"(",
")",
"meta",
"=",
"base",
".",
"setdefault",
"(",
"'meta'",
",",
"dict",
"(",
")",
")",
"tests",
"=",
"base",
".",
"setdefault",
"(",
"'tests'",
... | Reformat the api results to work with the front-end. | [
"Reformat",
"the",
"api",
"results",
"to",
"work",
"with",
"the",
"front",
"-",
"end",
"."
] | train | https://github.com/opencobra/memote/blob/276630fcd4449fb7b914186edfd38c239e7052df/memote/suite/reporting/diff.py#L48-L97 |
opencobra/memote | scripts/annotate_mnx_shortlists.py | generate_shortlist | def generate_shortlist(mnx_db, shortlist):
"""
Create a condensed cross-references format from data in long form.
Both data frames must contain a column 'MNX_ID' and the dump is assumed
to also have a column 'XREF'.
Parameters
----------
mnx_db : pandas.DataFrame
The entire MetaNet... | python | def generate_shortlist(mnx_db, shortlist):
"""
Create a condensed cross-references format from data in long form.
Both data frames must contain a column 'MNX_ID' and the dump is assumed
to also have a column 'XREF'.
Parameters
----------
mnx_db : pandas.DataFrame
The entire MetaNet... | [
"def",
"generate_shortlist",
"(",
"mnx_db",
",",
"shortlist",
")",
":",
"# Reduce the whole database to targets of interest.",
"xref",
"=",
"mnx_db",
".",
"loc",
"[",
"mnx_db",
"[",
"\"MNX_ID\"",
"]",
".",
"isin",
"(",
"shortlist",
"[",
"\"MNX_ID\"",
"]",
")",
"... | Create a condensed cross-references format from data in long form.
Both data frames must contain a column 'MNX_ID' and the dump is assumed
to also have a column 'XREF'.
Parameters
----------
mnx_db : pandas.DataFrame
The entire MetaNetX dump as a data frame.
shortlist : pandas.DataFram... | [
"Create",
"a",
"condensed",
"cross",
"-",
"references",
"format",
"from",
"data",
"in",
"long",
"form",
"."
] | train | https://github.com/opencobra/memote/blob/276630fcd4449fb7b914186edfd38c239e7052df/scripts/annotate_mnx_shortlists.py#L50-L96 |
opencobra/memote | scripts/annotate_mnx_shortlists.py | generate | def generate(mnx_dump):
"""
Annotate a shortlist of metabolites with cross-references using MetaNetX.
MNX_DUMP : The chemicals dump from MetaNetX usually called 'chem_xref.tsv'.
Will be downloaded if it doesn't exist.
"""
LOGGER.info("Read shortlist.")
targets = pd.read_table(join(dirn... | python | def generate(mnx_dump):
"""
Annotate a shortlist of metabolites with cross-references using MetaNetX.
MNX_DUMP : The chemicals dump from MetaNetX usually called 'chem_xref.tsv'.
Will be downloaded if it doesn't exist.
"""
LOGGER.info("Read shortlist.")
targets = pd.read_table(join(dirn... | [
"def",
"generate",
"(",
"mnx_dump",
")",
":",
"LOGGER",
".",
"info",
"(",
"\"Read shortlist.\"",
")",
"targets",
"=",
"pd",
".",
"read_table",
"(",
"join",
"(",
"dirname",
"(",
"__file__",
")",
",",
"\"shortlist.tsv\"",
")",
")",
"if",
"not",
"exists",
"... | Annotate a shortlist of metabolites with cross-references using MetaNetX.
MNX_DUMP : The chemicals dump from MetaNetX usually called 'chem_xref.tsv'.
Will be downloaded if it doesn't exist. | [
"Annotate",
"a",
"shortlist",
"of",
"metabolites",
"with",
"cross",
"-",
"references",
"using",
"MetaNetX",
"."
] | train | https://github.com/opencobra/memote/blob/276630fcd4449fb7b914186edfd38c239e7052df/scripts/annotate_mnx_shortlists.py#L105-L133 |
opencobra/memote | memote/experimental/essentiality.py | EssentialityExperiment.validate | def validate(self, model, checks=[]):
"""Use a defined schema to validate the medium table format."""
custom = [
check_partial(gene_id_check, frozenset(g.id for g in model.genes))
]
super(EssentialityExperiment, self).validate(
model=model, checks=checks + custom) | python | def validate(self, model, checks=[]):
"""Use a defined schema to validate the medium table format."""
custom = [
check_partial(gene_id_check, frozenset(g.id for g in model.genes))
]
super(EssentialityExperiment, self).validate(
model=model, checks=checks + custom) | [
"def",
"validate",
"(",
"self",
",",
"model",
",",
"checks",
"=",
"[",
"]",
")",
":",
"custom",
"=",
"[",
"check_partial",
"(",
"gene_id_check",
",",
"frozenset",
"(",
"g",
".",
"id",
"for",
"g",
"in",
"model",
".",
"genes",
")",
")",
"]",
"super",... | Use a defined schema to validate the medium table format. | [
"Use",
"a",
"defined",
"schema",
"to",
"validate",
"the",
"medium",
"table",
"format",
"."
] | train | https://github.com/opencobra/memote/blob/276630fcd4449fb7b914186edfd38c239e7052df/memote/experimental/essentiality.py#L70-L76 |
opencobra/memote | memote/experimental/essentiality.py | EssentialityExperiment.evaluate | def evaluate(self, model):
"""Use the defined parameters to predict single gene essentiality."""
with model:
if self.medium is not None:
self.medium.apply(model)
if self.objective is not None:
model.objective = self.objective
model.add_... | python | def evaluate(self, model):
"""Use the defined parameters to predict single gene essentiality."""
with model:
if self.medium is not None:
self.medium.apply(model)
if self.objective is not None:
model.objective = self.objective
model.add_... | [
"def",
"evaluate",
"(",
"self",
",",
"model",
")",
":",
"with",
"model",
":",
"if",
"self",
".",
"medium",
"is",
"not",
"None",
":",
"self",
".",
"medium",
".",
"apply",
"(",
"model",
")",
"if",
"self",
".",
"objective",
"is",
"not",
"None",
":",
... | Use the defined parameters to predict single gene essentiality. | [
"Use",
"the",
"defined",
"parameters",
"to",
"predict",
"single",
"gene",
"essentiality",
"."
] | train | https://github.com/opencobra/memote/blob/276630fcd4449fb7b914186edfd38c239e7052df/memote/experimental/essentiality.py#L78-L93 |
opencobra/memote | memote/utils.py | register_with | def register_with(registry):
"""
Register a passed in object.
Intended to be used as a decorator on model building functions with a
``dict`` as a registry.
Examples
--------
.. code-block:: python
REGISTRY = dict()
@register_with(REGISTRY)
def build_empty(base):
... | python | def register_with(registry):
"""
Register a passed in object.
Intended to be used as a decorator on model building functions with a
``dict`` as a registry.
Examples
--------
.. code-block:: python
REGISTRY = dict()
@register_with(REGISTRY)
def build_empty(base):
... | [
"def",
"register_with",
"(",
"registry",
")",
":",
"def",
"decorator",
"(",
"func",
")",
":",
"registry",
"[",
"func",
".",
"__name__",
"]",
"=",
"func",
"return",
"func",
"return",
"decorator"
] | Register a passed in object.
Intended to be used as a decorator on model building functions with a
``dict`` as a registry.
Examples
--------
.. code-block:: python
REGISTRY = dict()
@register_with(REGISTRY)
def build_empty(base):
return base | [
"Register",
"a",
"passed",
"in",
"object",
"."
] | train | https://github.com/opencobra/memote/blob/276630fcd4449fb7b914186edfd38c239e7052df/memote/utils.py#L48-L68 |
opencobra/memote | memote/utils.py | annotate | def annotate(title, format_type, message=None, data=None, metric=1.0):
"""
Annotate a test case with info that should be displayed in the reports.
Parameters
----------
title : str
A human-readable descriptive title of the test case.
format_type : str
A string that determines ho... | python | def annotate(title, format_type, message=None, data=None, metric=1.0):
"""
Annotate a test case with info that should be displayed in the reports.
Parameters
----------
title : str
A human-readable descriptive title of the test case.
format_type : str
A string that determines ho... | [
"def",
"annotate",
"(",
"title",
",",
"format_type",
",",
"message",
"=",
"None",
",",
"data",
"=",
"None",
",",
"metric",
"=",
"1.0",
")",
":",
"if",
"format_type",
"not",
"in",
"TYPES",
":",
"raise",
"ValueError",
"(",
"\"Invalid type. Expected one of: {}.... | Annotate a test case with info that should be displayed in the reports.
Parameters
----------
title : str
A human-readable descriptive title of the test case.
format_type : str
A string that determines how the result data is formatted in the
report. It is expected not to be None... | [
"Annotate",
"a",
"test",
"case",
"with",
"info",
"that",
"should",
"be",
"displayed",
"in",
"the",
"reports",
"."
] | train | https://github.com/opencobra/memote/blob/276630fcd4449fb7b914186edfd38c239e7052df/memote/utils.py#L71-L130 |
opencobra/memote | memote/utils.py | truncate | def truncate(sequence):
"""
Create a potentially shortened text display of a list.
Parameters
----------
sequence : list
An indexable sequence of elements.
Returns
-------
str
The list as a formatted string.
"""
if len(sequence) > LIST_SLICE:
return ", ... | python | def truncate(sequence):
"""
Create a potentially shortened text display of a list.
Parameters
----------
sequence : list
An indexable sequence of elements.
Returns
-------
str
The list as a formatted string.
"""
if len(sequence) > LIST_SLICE:
return ", ... | [
"def",
"truncate",
"(",
"sequence",
")",
":",
"if",
"len",
"(",
"sequence",
")",
">",
"LIST_SLICE",
":",
"return",
"\", \"",
".",
"join",
"(",
"sequence",
"[",
":",
"LIST_SLICE",
"]",
"+",
"[",
"\"...\"",
"]",
")",
"else",
":",
"return",
"\", \"",
".... | Create a potentially shortened text display of a list.
Parameters
----------
sequence : list
An indexable sequence of elements.
Returns
-------
str
The list as a formatted string. | [
"Create",
"a",
"potentially",
"shortened",
"text",
"display",
"of",
"a",
"list",
"."
] | train | https://github.com/opencobra/memote/blob/276630fcd4449fb7b914186edfd38c239e7052df/memote/utils.py#L152-L170 |
opencobra/memote | memote/utils.py | log_json_incompatible_types | def log_json_incompatible_types(obj):
"""
Log types that are not JSON compatible.
Explore a nested dictionary structure and log types that are not JSON
compatible.
Parameters
----------
obj : dict
A potentially nested dictionary.
"""
keys_to_explore = list(obj)
while l... | python | def log_json_incompatible_types(obj):
"""
Log types that are not JSON compatible.
Explore a nested dictionary structure and log types that are not JSON
compatible.
Parameters
----------
obj : dict
A potentially nested dictionary.
"""
keys_to_explore = list(obj)
while l... | [
"def",
"log_json_incompatible_types",
"(",
"obj",
")",
":",
"keys_to_explore",
"=",
"list",
"(",
"obj",
")",
"while",
"len",
"(",
"keys_to_explore",
")",
">",
"0",
":",
"key",
"=",
"keys_to_explore",
".",
"pop",
"(",
")",
"if",
"not",
"isinstance",
"(",
... | Log types that are not JSON compatible.
Explore a nested dictionary structure and log types that are not JSON
compatible.
Parameters
----------
obj : dict
A potentially nested dictionary. | [
"Log",
"types",
"that",
"are",
"not",
"JSON",
"compatible",
"."
] | train | https://github.com/opencobra/memote/blob/276630fcd4449fb7b914186edfd38c239e7052df/memote/utils.py#L173-L198 |
opencobra/memote | memote/utils.py | jsonify | def jsonify(obj, pretty=False):
"""
Turn a nested object into a (compressed) JSON string.
Parameters
----------
obj : dict
Any kind of dictionary structure.
pretty : bool, optional
Whether to format the resulting JSON in a more legible way (
default False).
"""
... | python | def jsonify(obj, pretty=False):
"""
Turn a nested object into a (compressed) JSON string.
Parameters
----------
obj : dict
Any kind of dictionary structure.
pretty : bool, optional
Whether to format the resulting JSON in a more legible way (
default False).
"""
... | [
"def",
"jsonify",
"(",
"obj",
",",
"pretty",
"=",
"False",
")",
":",
"if",
"pretty",
":",
"params",
"=",
"dict",
"(",
"sort_keys",
"=",
"True",
",",
"indent",
"=",
"2",
",",
"allow_nan",
"=",
"False",
",",
"separators",
"=",
"(",
"\",\"",
",",
"\":... | Turn a nested object into a (compressed) JSON string.
Parameters
----------
obj : dict
Any kind of dictionary structure.
pretty : bool, optional
Whether to format the resulting JSON in a more legible way (
default False). | [
"Turn",
"a",
"nested",
"object",
"into",
"a",
"(",
"compressed",
")",
"JSON",
"string",
"."
] | train | https://github.com/opencobra/memote/blob/276630fcd4449fb7b914186edfd38c239e7052df/memote/utils.py#L225-L251 |
opencobra/memote | memote/utils.py | flatten | def flatten(list_of_lists):
"""Flatten a list of lists but maintain strings and ints as entries."""
flat_list = []
for sublist in list_of_lists:
if isinstance(sublist, string_types) or isinstance(sublist, int):
flat_list.append(sublist)
elif sublist is None:
continue
... | python | def flatten(list_of_lists):
"""Flatten a list of lists but maintain strings and ints as entries."""
flat_list = []
for sublist in list_of_lists:
if isinstance(sublist, string_types) or isinstance(sublist, int):
flat_list.append(sublist)
elif sublist is None:
continue
... | [
"def",
"flatten",
"(",
"list_of_lists",
")",
":",
"flat_list",
"=",
"[",
"]",
"for",
"sublist",
"in",
"list_of_lists",
":",
"if",
"isinstance",
"(",
"sublist",
",",
"string_types",
")",
"or",
"isinstance",
"(",
"sublist",
",",
"int",
")",
":",
"flat_list",... | Flatten a list of lists but maintain strings and ints as entries. | [
"Flatten",
"a",
"list",
"of",
"lists",
"but",
"maintain",
"strings",
"and",
"ints",
"as",
"entries",
"."
] | train | https://github.com/opencobra/memote/blob/276630fcd4449fb7b914186edfd38c239e7052df/memote/utils.py#L254-L266 |
opencobra/memote | memote/utils.py | stdout_notifications | def stdout_notifications(notifications):
"""
Print each entry of errors and warnings to stdout.
Parameters
----------
notifications: dict
A simple dictionary structure containing a list of errors and warnings.
"""
for error in notifications["errors"]:
LOGGER.error(error)
... | python | def stdout_notifications(notifications):
"""
Print each entry of errors and warnings to stdout.
Parameters
----------
notifications: dict
A simple dictionary structure containing a list of errors and warnings.
"""
for error in notifications["errors"]:
LOGGER.error(error)
... | [
"def",
"stdout_notifications",
"(",
"notifications",
")",
":",
"for",
"error",
"in",
"notifications",
"[",
"\"errors\"",
"]",
":",
"LOGGER",
".",
"error",
"(",
"error",
")",
"for",
"warn",
"in",
"notifications",
"[",
"\"warnings\"",
"]",
":",
"LOGGER",
".",
... | Print each entry of errors and warnings to stdout.
Parameters
----------
notifications: dict
A simple dictionary structure containing a list of errors and warnings. | [
"Print",
"each",
"entry",
"of",
"errors",
"and",
"warnings",
"to",
"stdout",
"."
] | train | https://github.com/opencobra/memote/blob/276630fcd4449fb7b914186edfd38c239e7052df/memote/utils.py#L289-L302 |
opencobra/memote | memote/experimental/experimental_base.py | ExperimentalBase.load | def load(self, dtype_conversion=None):
"""
Load the data table and corresponding validation schema.
Parameters
----------
dtype_conversion : dict
Column names as keys and corresponding type for loading the data.
Please take a look at the `pandas documenta... | python | def load(self, dtype_conversion=None):
"""
Load the data table and corresponding validation schema.
Parameters
----------
dtype_conversion : dict
Column names as keys and corresponding type for loading the data.
Please take a look at the `pandas documenta... | [
"def",
"load",
"(",
"self",
",",
"dtype_conversion",
"=",
"None",
")",
":",
"self",
".",
"data",
"=",
"read_tabular",
"(",
"self",
".",
"filename",
",",
"dtype_conversion",
")",
"with",
"open_text",
"(",
"memote",
".",
"experimental",
".",
"schemata",
",",... | Load the data table and corresponding validation schema.
Parameters
----------
dtype_conversion : dict
Column names as keys and corresponding type for loading the data.
Please take a look at the `pandas documentation
<https://pandas.pydata.org/pandas-docs/sta... | [
"Load",
"the",
"data",
"table",
"and",
"corresponding",
"validation",
"schema",
"."
] | train | https://github.com/opencobra/memote/blob/276630fcd4449fb7b914186edfd38c239e7052df/memote/experimental/experimental_base.py#L72-L88 |
opencobra/memote | memote/experimental/experimental_base.py | ExperimentalBase.validate | def validate(self, model, checks=[]):
"""Use a defined schema to validate the given table."""
records = self.data.to_dict("records")
self.evaluate_report(
validate(records, headers=list(records[0]),
preset='table', schema=self.schema,
order_f... | python | def validate(self, model, checks=[]):
"""Use a defined schema to validate the given table."""
records = self.data.to_dict("records")
self.evaluate_report(
validate(records, headers=list(records[0]),
preset='table', schema=self.schema,
order_f... | [
"def",
"validate",
"(",
"self",
",",
"model",
",",
"checks",
"=",
"[",
"]",
")",
":",
"records",
"=",
"self",
".",
"data",
".",
"to_dict",
"(",
"\"records\"",
")",
"self",
".",
"evaluate_report",
"(",
"validate",
"(",
"records",
",",
"headers",
"=",
... | Use a defined schema to validate the given table. | [
"Use",
"a",
"defined",
"schema",
"to",
"validate",
"the",
"given",
"table",
"."
] | train | https://github.com/opencobra/memote/blob/276630fcd4449fb7b914186edfd38c239e7052df/memote/experimental/experimental_base.py#L90-L96 |
opencobra/memote | memote/experimental/experimental_base.py | ExperimentalBase.evaluate_report | def evaluate_report(report):
"""Iterate over validation errors."""
if report["valid"]:
return
for warn in report["warnings"]:
LOGGER.warning(warn)
# We only ever test one table at a time.
for err in report["tables"][0]["errors"]:
LOGGER.error(e... | python | def evaluate_report(report):
"""Iterate over validation errors."""
if report["valid"]:
return
for warn in report["warnings"]:
LOGGER.warning(warn)
# We only ever test one table at a time.
for err in report["tables"][0]["errors"]:
LOGGER.error(e... | [
"def",
"evaluate_report",
"(",
"report",
")",
":",
"if",
"report",
"[",
"\"valid\"",
"]",
":",
"return",
"for",
"warn",
"in",
"report",
"[",
"\"warnings\"",
"]",
":",
"LOGGER",
".",
"warning",
"(",
"warn",
")",
"# We only ever test one table at a time.",
"for"... | Iterate over validation errors. | [
"Iterate",
"over",
"validation",
"errors",
"."
] | train | https://github.com/opencobra/memote/blob/276630fcd4449fb7b914186edfd38c239e7052df/memote/experimental/experimental_base.py#L99-L108 |
opencobra/memote | memote/support/consistency_helpers.py | add_reaction_constraints | def add_reaction_constraints(model, reactions, Constraint):
"""
Add the stoichiometric coefficients as constraints.
Parameters
----------
model : optlang.Model
The transposed stoichiometric matrix representation.
reactions : iterable
Container of `cobra.Reaction` instances.
... | python | def add_reaction_constraints(model, reactions, Constraint):
"""
Add the stoichiometric coefficients as constraints.
Parameters
----------
model : optlang.Model
The transposed stoichiometric matrix representation.
reactions : iterable
Container of `cobra.Reaction` instances.
... | [
"def",
"add_reaction_constraints",
"(",
"model",
",",
"reactions",
",",
"Constraint",
")",
":",
"constraints",
"=",
"[",
"]",
"for",
"rxn",
"in",
"reactions",
":",
"expression",
"=",
"add",
"(",
"[",
"c",
"*",
"model",
".",
"variables",
"[",
"m",
".",
... | Add the stoichiometric coefficients as constraints.
Parameters
----------
model : optlang.Model
The transposed stoichiometric matrix representation.
reactions : iterable
Container of `cobra.Reaction` instances.
Constraint : optlang.Constraint
The constraint class for the spe... | [
"Add",
"the",
"stoichiometric",
"coefficients",
"as",
"constraints",
"."
] | train | https://github.com/opencobra/memote/blob/276630fcd4449fb7b914186edfd38c239e7052df/memote/support/consistency_helpers.py#L43-L62 |
opencobra/memote | memote/support/consistency_helpers.py | stoichiometry_matrix | def stoichiometry_matrix(metabolites, reactions):
"""
Return the stoichiometry matrix representation of a set of reactions.
The reactions and metabolites order is respected. All metabolites are
expected to be contained and complete in terms of the reactions.
Parameters
----------
reactions... | python | def stoichiometry_matrix(metabolites, reactions):
"""
Return the stoichiometry matrix representation of a set of reactions.
The reactions and metabolites order is respected. All metabolites are
expected to be contained and complete in terms of the reactions.
Parameters
----------
reactions... | [
"def",
"stoichiometry_matrix",
"(",
"metabolites",
",",
"reactions",
")",
":",
"matrix",
"=",
"np",
".",
"zeros",
"(",
"(",
"len",
"(",
"metabolites",
")",
",",
"len",
"(",
"reactions",
")",
")",
")",
"met_index",
"=",
"dict",
"(",
"(",
"met",
",",
"... | Return the stoichiometry matrix representation of a set of reactions.
The reactions and metabolites order is respected. All metabolites are
expected to be contained and complete in terms of the reactions.
Parameters
----------
reactions : iterable
A somehow ordered list of unique reactions... | [
"Return",
"the",
"stoichiometry",
"matrix",
"representation",
"of",
"a",
"set",
"of",
"reactions",
"."
] | train | https://github.com/opencobra/memote/blob/276630fcd4449fb7b914186edfd38c239e7052df/memote/support/consistency_helpers.py#L65-L97 |
opencobra/memote | memote/support/consistency_helpers.py | rank | def rank(matrix, atol=1e-13, rtol=0):
"""
Estimate the rank, i.e., the dimension of the column space, of a matrix.
The algorithm used by this function is based on the singular value
decomposition of `stoichiometry_matrix`.
Parameters
----------
matrix : ndarray
The matrix should be... | python | def rank(matrix, atol=1e-13, rtol=0):
"""
Estimate the rank, i.e., the dimension of the column space, of a matrix.
The algorithm used by this function is based on the singular value
decomposition of `stoichiometry_matrix`.
Parameters
----------
matrix : ndarray
The matrix should be... | [
"def",
"rank",
"(",
"matrix",
",",
"atol",
"=",
"1e-13",
",",
"rtol",
"=",
"0",
")",
":",
"matrix",
"=",
"np",
".",
"atleast_2d",
"(",
"matrix",
")",
"sigma",
"=",
"svd",
"(",
"matrix",
",",
"compute_uv",
"=",
"False",
")",
"tol",
"=",
"max",
"("... | Estimate the rank, i.e., the dimension of the column space, of a matrix.
The algorithm used by this function is based on the singular value
decomposition of `stoichiometry_matrix`.
Parameters
----------
matrix : ndarray
The matrix should be at most 2-D. A 1-D array with length k
w... | [
"Estimate",
"the",
"rank",
"i",
".",
"e",
".",
"the",
"dimension",
"of",
"the",
"column",
"space",
"of",
"a",
"matrix",
"."
] | train | https://github.com/opencobra/memote/blob/276630fcd4449fb7b914186edfd38c239e7052df/memote/support/consistency_helpers.py#L100-L144 |
opencobra/memote | memote/support/consistency_helpers.py | nullspace | def nullspace(matrix, atol=1e-13, rtol=0.0): # noqa: D402
"""
Compute an approximate basis for the null space (kernel) of a matrix.
The algorithm used by this function is based on the singular value
decomposition of the given matrix.
Parameters
----------
matrix : ndarray
The matr... | python | def nullspace(matrix, atol=1e-13, rtol=0.0): # noqa: D402
"""
Compute an approximate basis for the null space (kernel) of a matrix.
The algorithm used by this function is based on the singular value
decomposition of the given matrix.
Parameters
----------
matrix : ndarray
The matr... | [
"def",
"nullspace",
"(",
"matrix",
",",
"atol",
"=",
"1e-13",
",",
"rtol",
"=",
"0.0",
")",
":",
"# noqa: D402",
"matrix",
"=",
"np",
".",
"atleast_2d",
"(",
"matrix",
")",
"_",
",",
"sigma",
",",
"vh",
"=",
"svd",
"(",
"matrix",
")",
"tol",
"=",
... | Compute an approximate basis for the null space (kernel) of a matrix.
The algorithm used by this function is based on the singular value
decomposition of the given matrix.
Parameters
----------
matrix : ndarray
The matrix should be at most 2-D. A 1-D array with length k
will be tr... | [
"Compute",
"an",
"approximate",
"basis",
"for",
"the",
"null",
"space",
"(",
"kernel",
")",
"of",
"a",
"matrix",
"."
] | train | https://github.com/opencobra/memote/blob/276630fcd4449fb7b914186edfd38c239e7052df/memote/support/consistency_helpers.py#L147-L193 |
opencobra/memote | memote/support/consistency_helpers.py | get_interface | def get_interface(model):
"""
Return the interface specific classes.
Parameters
----------
model : cobra.Model
The metabolic model under investigation.
"""
return (
model.solver.interface.Model,
model.solver.interface.Constraint,
model.solver.interface.Varia... | python | def get_interface(model):
"""
Return the interface specific classes.
Parameters
----------
model : cobra.Model
The metabolic model under investigation.
"""
return (
model.solver.interface.Model,
model.solver.interface.Constraint,
model.solver.interface.Varia... | [
"def",
"get_interface",
"(",
"model",
")",
":",
"return",
"(",
"model",
".",
"solver",
".",
"interface",
".",
"Model",
",",
"model",
".",
"solver",
".",
"interface",
".",
"Constraint",
",",
"model",
".",
"solver",
".",
"interface",
".",
"Variable",
",",
... | Return the interface specific classes.
Parameters
----------
model : cobra.Model
The metabolic model under investigation. | [
"Return",
"the",
"interface",
"specific",
"classes",
"."
] | train | https://github.com/opencobra/memote/blob/276630fcd4449fb7b914186edfd38c239e7052df/memote/support/consistency_helpers.py#L197-L212 |
opencobra/memote | memote/support/consistency_helpers.py | get_internals | def get_internals(model):
"""
Return non-boundary reactions and their metabolites.
Boundary reactions are unbalanced by their nature. They are excluded here
and only the metabolites of the others are considered.
Parameters
----------
model : cobra.Model
The metabolic model under in... | python | def get_internals(model):
"""
Return non-boundary reactions and their metabolites.
Boundary reactions are unbalanced by their nature. They are excluded here
and only the metabolites of the others are considered.
Parameters
----------
model : cobra.Model
The metabolic model under in... | [
"def",
"get_internals",
"(",
"model",
")",
":",
"biomass",
"=",
"set",
"(",
"find_biomass_reaction",
"(",
"model",
")",
")",
"if",
"len",
"(",
"biomass",
")",
"==",
"0",
":",
"LOGGER",
".",
"warning",
"(",
"\"No biomass reaction detected. Consistency test result... | Return non-boundary reactions and their metabolites.
Boundary reactions are unbalanced by their nature. They are excluded here
and only the metabolites of the others are considered.
Parameters
----------
model : cobra.Model
The metabolic model under investigation. | [
"Return",
"non",
"-",
"boundary",
"reactions",
"and",
"their",
"metabolites",
"."
] | train | https://github.com/opencobra/memote/blob/276630fcd4449fb7b914186edfd38c239e7052df/memote/support/consistency_helpers.py#L216-L233 |
opencobra/memote | memote/support/consistency_helpers.py | create_milp_problem | def create_milp_problem(kernel, metabolites, Model, Variable, Constraint,
Objective):
"""
Create the MILP as defined by equation (13) in [1]_.
Parameters
----------
kernel : numpy.array
A 2-dimensional array that represents the left nullspace of the
stoichiom... | python | def create_milp_problem(kernel, metabolites, Model, Variable, Constraint,
Objective):
"""
Create the MILP as defined by equation (13) in [1]_.
Parameters
----------
kernel : numpy.array
A 2-dimensional array that represents the left nullspace of the
stoichiom... | [
"def",
"create_milp_problem",
"(",
"kernel",
",",
"metabolites",
",",
"Model",
",",
"Variable",
",",
"Constraint",
",",
"Objective",
")",
":",
"assert",
"len",
"(",
"metabolites",
")",
"==",
"kernel",
".",
"shape",
"[",
"0",
"]",
",",
"\"metabolite vector an... | Create the MILP as defined by equation (13) in [1]_.
Parameters
----------
kernel : numpy.array
A 2-dimensional array that represents the left nullspace of the
stoichiometric matrix which is the nullspace of the transpose of the
stoichiometric matrix.
metabolites : iterable
... | [
"Create",
"the",
"MILP",
"as",
"defined",
"by",
"equation",
"(",
"13",
")",
"in",
"[",
"1",
"]",
"_",
"."
] | train | https://github.com/opencobra/memote/blob/276630fcd4449fb7b914186edfd38c239e7052df/memote/support/consistency_helpers.py#L236-L295 |
opencobra/memote | memote/support/consistency_helpers.py | add_cut | def add_cut(problem, indicators, bound, Constraint):
"""
Add an integer cut to the problem.
Ensure that the same solution involving these indicator variables cannot be
found by enforcing their sum to be less than before.
Parameters
----------
problem : optlang.Model
Specific optlan... | python | def add_cut(problem, indicators, bound, Constraint):
"""
Add an integer cut to the problem.
Ensure that the same solution involving these indicator variables cannot be
found by enforcing their sum to be less than before.
Parameters
----------
problem : optlang.Model
Specific optlan... | [
"def",
"add_cut",
"(",
"problem",
",",
"indicators",
",",
"bound",
",",
"Constraint",
")",
":",
"cut",
"=",
"Constraint",
"(",
"sympy",
".",
"Add",
"(",
"*",
"indicators",
")",
",",
"ub",
"=",
"bound",
")",
"problem",
".",
"add",
"(",
"cut",
")",
"... | Add an integer cut to the problem.
Ensure that the same solution involving these indicator variables cannot be
found by enforcing their sum to be less than before.
Parameters
----------
problem : optlang.Model
Specific optlang interface Model instance.
indicators : iterable
Bin... | [
"Add",
"an",
"integer",
"cut",
"to",
"the",
"problem",
"."
] | train | https://github.com/opencobra/memote/blob/276630fcd4449fb7b914186edfd38c239e7052df/memote/support/consistency_helpers.py#L298-L327 |
opencobra/memote | memote/support/consistency_helpers.py | is_mass_balanced | def is_mass_balanced(reaction):
"""Confirm that a reaction is mass balanced."""
balance = defaultdict(int)
for metabolite, coefficient in iteritems(reaction.metabolites):
if metabolite.elements is None or len(metabolite.elements) == 0:
return False
for element, amount in iteritem... | python | def is_mass_balanced(reaction):
"""Confirm that a reaction is mass balanced."""
balance = defaultdict(int)
for metabolite, coefficient in iteritems(reaction.metabolites):
if metabolite.elements is None or len(metabolite.elements) == 0:
return False
for element, amount in iteritem... | [
"def",
"is_mass_balanced",
"(",
"reaction",
")",
":",
"balance",
"=",
"defaultdict",
"(",
"int",
")",
"for",
"metabolite",
",",
"coefficient",
"in",
"iteritems",
"(",
"reaction",
".",
"metabolites",
")",
":",
"if",
"metabolite",
".",
"elements",
"is",
"None"... | Confirm that a reaction is mass balanced. | [
"Confirm",
"that",
"a",
"reaction",
"is",
"mass",
"balanced",
"."
] | train | https://github.com/opencobra/memote/blob/276630fcd4449fb7b914186edfd38c239e7052df/memote/support/consistency_helpers.py#L330-L338 |
opencobra/memote | memote/support/consistency_helpers.py | is_charge_balanced | def is_charge_balanced(reaction):
"""Confirm that a reaction is charge balanced."""
charge = 0
for metabolite, coefficient in iteritems(reaction.metabolites):
if metabolite.charge is None:
return False
charge += coefficient * metabolite.charge
return charge == 0 | python | def is_charge_balanced(reaction):
"""Confirm that a reaction is charge balanced."""
charge = 0
for metabolite, coefficient in iteritems(reaction.metabolites):
if metabolite.charge is None:
return False
charge += coefficient * metabolite.charge
return charge == 0 | [
"def",
"is_charge_balanced",
"(",
"reaction",
")",
":",
"charge",
"=",
"0",
"for",
"metabolite",
",",
"coefficient",
"in",
"iteritems",
"(",
"reaction",
".",
"metabolites",
")",
":",
"if",
"metabolite",
".",
"charge",
"is",
"None",
":",
"return",
"False",
... | Confirm that a reaction is charge balanced. | [
"Confirm",
"that",
"a",
"reaction",
"is",
"charge",
"balanced",
"."
] | train | https://github.com/opencobra/memote/blob/276630fcd4449fb7b914186edfd38c239e7052df/memote/support/consistency_helpers.py#L341-L348 |
opencobra/memote | memote/experimental/checks.py | check_partial | def check_partial(func, *args, **kwargs):
"""Create a partial to be used by goodtables."""
new_func = partial(func, *args, **kwargs)
new_func.check = func.check
return new_func | python | def check_partial(func, *args, **kwargs):
"""Create a partial to be used by goodtables."""
new_func = partial(func, *args, **kwargs)
new_func.check = func.check
return new_func | [
"def",
"check_partial",
"(",
"func",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"new_func",
"=",
"partial",
"(",
"func",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"new_func",
".",
"check",
"=",
"func",
".",
"check",
"return",
"new_f... | Create a partial to be used by goodtables. | [
"Create",
"a",
"partial",
"to",
"be",
"used",
"by",
"goodtables",
"."
] | train | https://github.com/opencobra/memote/blob/276630fcd4449fb7b914186edfd38c239e7052df/memote/experimental/checks.py#L27-L31 |
opencobra/memote | memote/experimental/checks.py | gene_id_check | def gene_id_check(genes, errors, columns, row_number):
"""
Validate gene identifiers against a known set.
Parameters
----------
genes : set
The known set of gene identifiers.
errors :
Passed by goodtables.
columns :
Passed by goodtables.
row_number :
Pass... | python | def gene_id_check(genes, errors, columns, row_number):
"""
Validate gene identifiers against a known set.
Parameters
----------
genes : set
The known set of gene identifiers.
errors :
Passed by goodtables.
columns :
Passed by goodtables.
row_number :
Pass... | [
"def",
"gene_id_check",
"(",
"genes",
",",
"errors",
",",
"columns",
",",
"row_number",
")",
":",
"message",
"=",
"(",
"\"Gene '{value}' in column {col} and row {row} does not \"",
"\"appear in the metabolic model.\"",
")",
"for",
"column",
"in",
"columns",
":",
"if",
... | Validate gene identifiers against a known set.
Parameters
----------
genes : set
The known set of gene identifiers.
errors :
Passed by goodtables.
columns :
Passed by goodtables.
row_number :
Passed by goodtables. | [
"Validate",
"gene",
"identifiers",
"against",
"a",
"known",
"set",
"."
] | train | https://github.com/opencobra/memote/blob/276630fcd4449fb7b914186edfd38c239e7052df/memote/experimental/checks.py#L35-L64 |
opencobra/memote | memote/experimental/checks.py | reaction_id_check | def reaction_id_check(reactions, errors, columns, row_number):
"""
Validate reactions identifiers against a known set.
Parameters
----------
reactions : set
The known set of reaction identifiers.
errors :
Passed by goodtables.
columns :
Passed by goodtables.
row_... | python | def reaction_id_check(reactions, errors, columns, row_number):
"""
Validate reactions identifiers against a known set.
Parameters
----------
reactions : set
The known set of reaction identifiers.
errors :
Passed by goodtables.
columns :
Passed by goodtables.
row_... | [
"def",
"reaction_id_check",
"(",
"reactions",
",",
"errors",
",",
"columns",
",",
"row_number",
")",
":",
"message",
"=",
"(",
"\"Reaction '{value}' in column {col} and row {row} does not \"",
"\"appear in the metabolic model.\"",
")",
"for",
"column",
"in",
"columns",
":... | Validate reactions identifiers against a known set.
Parameters
----------
reactions : set
The known set of reaction identifiers.
errors :
Passed by goodtables.
columns :
Passed by goodtables.
row_number :
Passed by goodtables. | [
"Validate",
"reactions",
"identifiers",
"against",
"a",
"known",
"set",
"."
] | train | https://github.com/opencobra/memote/blob/276630fcd4449fb7b914186edfd38c239e7052df/memote/experimental/checks.py#L68-L97 |
opencobra/memote | memote/experimental/checks.py | metabolite_id_check | def metabolite_id_check(metabolites, errors, columns, row_number):
"""
Validate metabolite identifiers against a known set.
Parameters
----------
metabolites : set
The known set of metabolite identifiers.
errors :
Passed by goodtables.
columns :
Passed by goodtables.... | python | def metabolite_id_check(metabolites, errors, columns, row_number):
"""
Validate metabolite identifiers against a known set.
Parameters
----------
metabolites : set
The known set of metabolite identifiers.
errors :
Passed by goodtables.
columns :
Passed by goodtables.... | [
"def",
"metabolite_id_check",
"(",
"metabolites",
",",
"errors",
",",
"columns",
",",
"row_number",
")",
":",
"message",
"=",
"(",
"\"Metabolite '{value}' in column {col} and row {row} does not \"",
"\"appear in the metabolic model.\"",
")",
"for",
"column",
"in",
"columns"... | Validate metabolite identifiers against a known set.
Parameters
----------
metabolites : set
The known set of metabolite identifiers.
errors :
Passed by goodtables.
columns :
Passed by goodtables.
row_number :
Passed by goodtables. | [
"Validate",
"metabolite",
"identifiers",
"against",
"a",
"known",
"set",
"."
] | train | https://github.com/opencobra/memote/blob/276630fcd4449fb7b914186edfd38c239e7052df/memote/experimental/checks.py#L101-L131 |
opencobra/memote | memote/suite/cli/runner.py | run | def run(model, collect, filename, location, ignore_git, pytest_args, exclusive,
skip, solver, experimental, custom_tests, deployment,
skip_unchanged):
"""
Run the test suite on a single model and collect results.
MODEL: Path to model file. Can also be supplied via the environment variable
... | python | def run(model, collect, filename, location, ignore_git, pytest_args, exclusive,
skip, solver, experimental, custom_tests, deployment,
skip_unchanged):
"""
Run the test suite on a single model and collect results.
MODEL: Path to model file. Can also be supplied via the environment variable
... | [
"def",
"run",
"(",
"model",
",",
"collect",
",",
"filename",
",",
"location",
",",
"ignore_git",
",",
"pytest_args",
",",
"exclusive",
",",
"skip",
",",
"solver",
",",
"experimental",
",",
"custom_tests",
",",
"deployment",
",",
"skip_unchanged",
")",
":",
... | Run the test suite on a single model and collect results.
MODEL: Path to model file. Can also be supplied via the environment variable
MEMOTE_MODEL or configured in 'setup.cfg' or 'memote.ini'. | [
"Run",
"the",
"test",
"suite",
"on",
"a",
"single",
"model",
"and",
"collect",
"results",
"."
] | train | https://github.com/opencobra/memote/blob/276630fcd4449fb7b914186edfd38c239e7052df/memote/suite/cli/runner.py#L133-L222 |
opencobra/memote | memote/suite/cli/runner.py | new | def new(directory, replay):
"""
Create a suitable model repository structure from a template.
By using a cookiecutter template, memote will ask you a couple of questions
and set up a new directory structure that will make your life easier. The
new directory will be placed in the current directory o... | python | def new(directory, replay):
"""
Create a suitable model repository structure from a template.
By using a cookiecutter template, memote will ask you a couple of questions
and set up a new directory structure that will make your life easier. The
new directory will be placed in the current directory o... | [
"def",
"new",
"(",
"directory",
",",
"replay",
")",
":",
"callbacks",
".",
"git_installed",
"(",
")",
"if",
"directory",
"is",
"None",
":",
"directory",
"=",
"os",
".",
"getcwd",
"(",
")",
"cookiecutter",
"(",
"\"gh:opencobra/cookiecutter-memote\"",
",",
"ou... | Create a suitable model repository structure from a template.
By using a cookiecutter template, memote will ask you a couple of questions
and set up a new directory structure that will make your life easier. The
new directory will be placed in the current directory or respect the given
--directory opti... | [
"Create",
"a",
"suitable",
"model",
"repository",
"structure",
"from",
"a",
"template",
"."
] | train | https://github.com/opencobra/memote/blob/276630fcd4449fb7b914186edfd38c239e7052df/memote/suite/cli/runner.py#L236-L250 |
opencobra/memote | memote/suite/cli/runner.py | history | def history(model, message, rewrite, solver, location, pytest_args, deployment,
commits, skip, exclusive, experimental=None): # noqa: D301
"""
Re-compute test results for the git branch history.
MODEL is the path to the model file.
MESSAGE is a commit message in case results were modified... | python | def history(model, message, rewrite, solver, location, pytest_args, deployment,
commits, skip, exclusive, experimental=None): # noqa: D301
"""
Re-compute test results for the git branch history.
MODEL is the path to the model file.
MESSAGE is a commit message in case results were modified... | [
"def",
"history",
"(",
"model",
",",
"message",
",",
"rewrite",
",",
"solver",
",",
"location",
",",
"pytest_args",
",",
"deployment",
",",
"commits",
",",
"skip",
",",
"exclusive",
",",
"experimental",
"=",
"None",
")",
":",
"# noqa: D301",
"# callbacks.val... | Re-compute test results for the git branch history.
MODEL is the path to the model file.
MESSAGE is a commit message in case results were modified or added.
[COMMIT] ... It is possible to list out individual commits that should be
re-computed or supply a range <oldest commit>..<newest commit>, for ex... | [
"Re",
"-",
"compute",
"test",
"results",
"for",
"the",
"git",
"branch",
"history",
"."
] | train | https://github.com/opencobra/memote/blob/276630fcd4449fb7b914186edfd38c239e7052df/memote/suite/cli/runner.py#L307-L429 |
opencobra/memote | memote/suite/cli/runner.py | online | def online(note, github_repository, github_username):
"""Upload the repository to GitHub and enable testing on Travis CI."""
callbacks.git_installed()
try:
repo = git.Repo()
except git.InvalidGitRepositoryError:
LOGGER.critical(
"'memote online' requires a git repository in o... | python | def online(note, github_repository, github_username):
"""Upload the repository to GitHub and enable testing on Travis CI."""
callbacks.git_installed()
try:
repo = git.Repo()
except git.InvalidGitRepositoryError:
LOGGER.critical(
"'memote online' requires a git repository in o... | [
"def",
"online",
"(",
"note",
",",
"github_repository",
",",
"github_username",
")",
":",
"callbacks",
".",
"git_installed",
"(",
")",
"try",
":",
"repo",
"=",
"git",
".",
"Repo",
"(",
")",
"except",
"git",
".",
"InvalidGitRepositoryError",
":",
"LOGGER",
... | Upload the repository to GitHub and enable testing on Travis CI. | [
"Upload",
"the",
"repository",
"to",
"GitHub",
"and",
"enable",
"testing",
"on",
"Travis",
"CI",
"."
] | train | https://github.com/opencobra/memote/blob/276630fcd4449fb7b914186edfd38c239e7052df/memote/suite/cli/runner.py#L737-L780 |
opencobra/memote | scripts/update_mock_repo.py | update_mock_repo | def update_mock_repo():
"""
Clone and gzip the memote-mock-repo used for CLI and integration tests.
The repo is hosted at
'https://github.com/ChristianLieven/memote-mock-repo.git' and maintained
separately from
"""
target_file = os.path.abspath(
join("tests", "data", "memote-mock-r... | python | def update_mock_repo():
"""
Clone and gzip the memote-mock-repo used for CLI and integration tests.
The repo is hosted at
'https://github.com/ChristianLieven/memote-mock-repo.git' and maintained
separately from
"""
target_file = os.path.abspath(
join("tests", "data", "memote-mock-r... | [
"def",
"update_mock_repo",
"(",
")",
":",
"target_file",
"=",
"os",
".",
"path",
".",
"abspath",
"(",
"join",
"(",
"\"tests\"",
",",
"\"data\"",
",",
"\"memote-mock-repo.tar.gz\"",
")",
")",
"temp_dir",
"=",
"mkdtemp",
"(",
"prefix",
"=",
"'tmp_mock'",
")",
... | Clone and gzip the memote-mock-repo used for CLI and integration tests.
The repo is hosted at
'https://github.com/ChristianLieven/memote-mock-repo.git' and maintained
separately from | [
"Clone",
"and",
"gzip",
"the",
"memote",
"-",
"mock",
"-",
"repo",
"used",
"for",
"CLI",
"and",
"integration",
"tests",
"."
] | train | https://github.com/opencobra/memote/blob/276630fcd4449fb7b914186edfd38c239e7052df/scripts/update_mock_repo.py#L39-L86 |
opencobra/memote | memote/support/biomass.py | sum_biomass_weight | def sum_biomass_weight(reaction):
"""
Compute the sum of all reaction compounds.
This function expects all metabolites of the biomass reaction to have
formula information assigned.
Parameters
----------
reaction : cobra.core.reaction.Reaction
The biomass reaction of the model under... | python | def sum_biomass_weight(reaction):
"""
Compute the sum of all reaction compounds.
This function expects all metabolites of the biomass reaction to have
formula information assigned.
Parameters
----------
reaction : cobra.core.reaction.Reaction
The biomass reaction of the model under... | [
"def",
"sum_biomass_weight",
"(",
"reaction",
")",
":",
"return",
"sum",
"(",
"-",
"coef",
"*",
"met",
".",
"formula_weight",
"for",
"(",
"met",
",",
"coef",
")",
"in",
"iteritems",
"(",
"reaction",
".",
"metabolites",
")",
")",
"/",
"1000.0"
] | Compute the sum of all reaction compounds.
This function expects all metabolites of the biomass reaction to have
formula information assigned.
Parameters
----------
reaction : cobra.core.reaction.Reaction
The biomass reaction of the model under investigation.
Returns
-------
f... | [
"Compute",
"the",
"sum",
"of",
"all",
"reaction",
"compounds",
"."
] | train | https://github.com/opencobra/memote/blob/276630fcd4449fb7b914186edfd38c239e7052df/memote/support/biomass.py#L69-L88 |
opencobra/memote | memote/support/biomass.py | find_biomass_precursors | def find_biomass_precursors(model, reaction):
"""
Return a list of all biomass precursors excluding ATP and H2O.
Parameters
----------
reaction : cobra.core.reaction.Reaction
The biomass reaction of the model under investigation.
model : cobra.Model
The metabolic model under inv... | python | def find_biomass_precursors(model, reaction):
"""
Return a list of all biomass precursors excluding ATP and H2O.
Parameters
----------
reaction : cobra.core.reaction.Reaction
The biomass reaction of the model under investigation.
model : cobra.Model
The metabolic model under inv... | [
"def",
"find_biomass_precursors",
"(",
"model",
",",
"reaction",
")",
":",
"id_of_main_compartment",
"=",
"helpers",
".",
"find_compartment_id_in_model",
"(",
"model",
",",
"'c'",
")",
"gam_reactants",
"=",
"set",
"(",
")",
"try",
":",
"gam_reactants",
".",
"upd... | Return a list of all biomass precursors excluding ATP and H2O.
Parameters
----------
reaction : cobra.core.reaction.Reaction
The biomass reaction of the model under investigation.
model : cobra.Model
The metabolic model under investigation.
Returns
-------
list
Meta... | [
"Return",
"a",
"list",
"of",
"all",
"biomass",
"precursors",
"excluding",
"ATP",
"and",
"H2O",
"."
] | train | https://github.com/opencobra/memote/blob/276630fcd4449fb7b914186edfd38c239e7052df/memote/support/biomass.py#L91-L126 |
opencobra/memote | memote/support/biomass.py | find_blocked_biomass_precursors | def find_blocked_biomass_precursors(reaction, model):
"""
Return a list of all biomass precursors that cannot be produced.
Parameters
----------
reaction : cobra.core.reaction.Reaction
The biomass reaction of the model under investigation.
model : cobra.Model
The metabolic model... | python | def find_blocked_biomass_precursors(reaction, model):
"""
Return a list of all biomass precursors that cannot be produced.
Parameters
----------
reaction : cobra.core.reaction.Reaction
The biomass reaction of the model under investigation.
model : cobra.Model
The metabolic model... | [
"def",
"find_blocked_biomass_precursors",
"(",
"reaction",
",",
"model",
")",
":",
"LOGGER",
".",
"debug",
"(",
"\"Finding blocked biomass precursors\"",
")",
"precursors",
"=",
"find_biomass_precursors",
"(",
"model",
",",
"reaction",
")",
"blocked_precursors",
"=",
... | Return a list of all biomass precursors that cannot be produced.
Parameters
----------
reaction : cobra.core.reaction.Reaction
The biomass reaction of the model under investigation.
model : cobra.Model
The metabolic model under investigation.
Returns
-------
list
Me... | [
"Return",
"a",
"list",
"of",
"all",
"biomass",
"precursors",
"that",
"cannot",
"be",
"produced",
"."
] | train | https://github.com/opencobra/memote/blob/276630fcd4449fb7b914186edfd38c239e7052df/memote/support/biomass.py#L129-L163 |
opencobra/memote | memote/support/biomass.py | gam_in_biomass | def gam_in_biomass(model, reaction):
"""
Return boolean if biomass reaction includes growth-associated maintenance.
Parameters
----------
model : cobra.Model
The metabolic model under investigation.
reaction : cobra.core.reaction.Reaction
The biomass reaction of the model under ... | python | def gam_in_biomass(model, reaction):
"""
Return boolean if biomass reaction includes growth-associated maintenance.
Parameters
----------
model : cobra.Model
The metabolic model under investigation.
reaction : cobra.core.reaction.Reaction
The biomass reaction of the model under ... | [
"def",
"gam_in_biomass",
"(",
"model",
",",
"reaction",
")",
":",
"id_of_main_compartment",
"=",
"helpers",
".",
"find_compartment_id_in_model",
"(",
"model",
",",
"'c'",
")",
"try",
":",
"left",
"=",
"{",
"helpers",
".",
"find_met_in_model",
"(",
"model",
","... | Return boolean if biomass reaction includes growth-associated maintenance.
Parameters
----------
model : cobra.Model
The metabolic model under investigation.
reaction : cobra.core.reaction.Reaction
The biomass reaction of the model under investigation.
Returns
-------
boole... | [
"Return",
"boolean",
"if",
"biomass",
"reaction",
"includes",
"growth",
"-",
"associated",
"maintenance",
"."
] | train | https://github.com/opencobra/memote/blob/276630fcd4449fb7b914186edfd38c239e7052df/memote/support/biomass.py#L166-L206 |
opencobra/memote | memote/support/biomass.py | find_direct_metabolites | def find_direct_metabolites(model, reaction, tolerance=1E-06):
"""
Return list of possible direct biomass precursor metabolites.
The term direct metabolites describes metabolites that are involved only
in either transport and/or boundary reactions, AND the biomass reaction(s),
but not in any purely... | python | def find_direct_metabolites(model, reaction, tolerance=1E-06):
"""
Return list of possible direct biomass precursor metabolites.
The term direct metabolites describes metabolites that are involved only
in either transport and/or boundary reactions, AND the biomass reaction(s),
but not in any purely... | [
"def",
"find_direct_metabolites",
"(",
"model",
",",
"reaction",
",",
"tolerance",
"=",
"1E-06",
")",
":",
"biomass_rxns",
"=",
"set",
"(",
"helpers",
".",
"find_biomass_reaction",
"(",
"model",
")",
")",
"tra_bou_bio_rxns",
"=",
"helpers",
".",
"find_interchang... | Return list of possible direct biomass precursor metabolites.
The term direct metabolites describes metabolites that are involved only
in either transport and/or boundary reactions, AND the biomass reaction(s),
but not in any purely metabolic reactions.
Parameters
----------
model : cobra.Mode... | [
"Return",
"list",
"of",
"possible",
"direct",
"biomass",
"precursor",
"metabolites",
"."
] | train | https://github.com/opencobra/memote/blob/276630fcd4449fb7b914186edfd38c239e7052df/memote/support/biomass.py#L209-L272 |
opencobra/memote | memote/support/biomass.py | detect_false_positive_direct_metabolites | def detect_false_positive_direct_metabolites(
candidates, biomass_reactions, cytosol, extra, reaction_fluxes,
metabolite_fluxes):
"""
Weed out false positive direct metabolites.
False positives exists in the extracellular
compartment with flux from the cytosolic compartment and are part... | python | def detect_false_positive_direct_metabolites(
candidates, biomass_reactions, cytosol, extra, reaction_fluxes,
metabolite_fluxes):
"""
Weed out false positive direct metabolites.
False positives exists in the extracellular
compartment with flux from the cytosolic compartment and are part... | [
"def",
"detect_false_positive_direct_metabolites",
"(",
"candidates",
",",
"biomass_reactions",
",",
"cytosol",
",",
"extra",
",",
"reaction_fluxes",
",",
"metabolite_fluxes",
")",
":",
"for",
"met",
"in",
"candidates",
":",
"is_internal",
"=",
"met",
".",
"compartm... | Weed out false positive direct metabolites.
False positives exists in the extracellular
compartment with flux from the cytosolic compartment and are part of the
biomass reaction(s). It sums fluxes positively or negatively depending
on if direct metabolites in the extracellular compartment are defined a... | [
"Weed",
"out",
"false",
"positive",
"direct",
"metabolites",
"."
] | train | https://github.com/opencobra/memote/blob/276630fcd4449fb7b914186edfd38c239e7052df/memote/support/biomass.py#L275-L334 |
opencobra/memote | memote/support/biomass.py | bundle_biomass_components | def bundle_biomass_components(model, reaction):
"""
Return bundle biomass component reactions if it is not one lumped reaction.
There are two basic ways of specifying the biomass composition. The most
common is a single lumped reaction containing all biomass precursors.
Alternatively, the biomass e... | python | def bundle_biomass_components(model, reaction):
"""
Return bundle biomass component reactions if it is not one lumped reaction.
There are two basic ways of specifying the biomass composition. The most
common is a single lumped reaction containing all biomass precursors.
Alternatively, the biomass e... | [
"def",
"bundle_biomass_components",
"(",
"model",
",",
"reaction",
")",
":",
"if",
"len",
"(",
"reaction",
".",
"metabolites",
")",
">=",
"16",
":",
"return",
"[",
"reaction",
"]",
"id_of_main_compartment",
"=",
"helpers",
".",
"find_compartment_id_in_model",
"(... | Return bundle biomass component reactions if it is not one lumped reaction.
There are two basic ways of specifying the biomass composition. The most
common is a single lumped reaction containing all biomass precursors.
Alternatively, the biomass equation can be split into several reactions
each focusin... | [
"Return",
"bundle",
"biomass",
"component",
"reactions",
"if",
"it",
"is",
"not",
"one",
"lumped",
"reaction",
"."
] | train | https://github.com/opencobra/memote/blob/276630fcd4449fb7b914186edfd38c239e7052df/memote/support/biomass.py#L337-L408 |
opencobra/memote | memote/support/biomass.py | essential_precursors_not_in_biomass | def essential_precursors_not_in_biomass(model, reaction):
u"""
Return a list of essential precursors missing from the biomass reaction.
There are universal components of life that make up the biomass of all
known organisms. These include all proteinogenic amino acids, deoxy- and
ribonucleotides, wa... | python | def essential_precursors_not_in_biomass(model, reaction):
u"""
Return a list of essential precursors missing from the biomass reaction.
There are universal components of life that make up the biomass of all
known organisms. These include all proteinogenic amino acids, deoxy- and
ribonucleotides, wa... | [
"def",
"essential_precursors_not_in_biomass",
"(",
"model",
",",
"reaction",
")",
":",
"main_comp",
"=",
"helpers",
".",
"find_compartment_id_in_model",
"(",
"model",
",",
"'c'",
")",
"biomass_eq",
"=",
"bundle_biomass_components",
"(",
"model",
",",
"reaction",
")"... | u"""
Return a list of essential precursors missing from the biomass reaction.
There are universal components of life that make up the biomass of all
known organisms. These include all proteinogenic amino acids, deoxy- and
ribonucleotides, water and a range of metabolic cofactors.
Parameters
--... | [
"u",
"Return",
"a",
"list",
"of",
"essential",
"precursors",
"missing",
"from",
"the",
"biomass",
"reaction",
"."
] | train | https://github.com/opencobra/memote/blob/276630fcd4449fb7b914186edfd38c239e7052df/memote/support/biomass.py#L411-L477 |
opencobra/memote | memote/suite/cli/callbacks.py | validate_experimental | def validate_experimental(context, param, value):
"""Load and validate an experimental data configuration."""
if value is None:
return
config = ExperimentConfiguration(value)
config.validate()
return config | python | def validate_experimental(context, param, value):
"""Load and validate an experimental data configuration."""
if value is None:
return
config = ExperimentConfiguration(value)
config.validate()
return config | [
"def",
"validate_experimental",
"(",
"context",
",",
"param",
",",
"value",
")",
":",
"if",
"value",
"is",
"None",
":",
"return",
"config",
"=",
"ExperimentConfiguration",
"(",
"value",
")",
"config",
".",
"validate",
"(",
")",
"return",
"config"
] | Load and validate an experimental data configuration. | [
"Load",
"and",
"validate",
"an",
"experimental",
"data",
"configuration",
"."
] | train | https://github.com/opencobra/memote/blob/276630fcd4449fb7b914186edfd38c239e7052df/memote/suite/cli/callbacks.py#L44-L50 |
opencobra/memote | memote/suite/cli/callbacks.py | probe_git | def probe_git():
"""Return a git repository instance if it exists."""
try:
repo = git.Repo()
except git.InvalidGitRepositoryError:
LOGGER.warning(
"We highly recommend keeping your model in a git repository."
" It allows you to track changes and to easily collaborate ... | python | def probe_git():
"""Return a git repository instance if it exists."""
try:
repo = git.Repo()
except git.InvalidGitRepositoryError:
LOGGER.warning(
"We highly recommend keeping your model in a git repository."
" It allows you to track changes and to easily collaborate ... | [
"def",
"probe_git",
"(",
")",
":",
"try",
":",
"repo",
"=",
"git",
".",
"Repo",
"(",
")",
"except",
"git",
".",
"InvalidGitRepositoryError",
":",
"LOGGER",
".",
"warning",
"(",
"\"We highly recommend keeping your model in a git repository.\"",
"\" It allows you to tra... | Return a git repository instance if it exists. | [
"Return",
"a",
"git",
"repository",
"instance",
"if",
"it",
"exists",
"."
] | train | https://github.com/opencobra/memote/blob/276630fcd4449fb7b914186edfd38c239e7052df/memote/suite/cli/callbacks.py#L79-L94 |
opencobra/memote | memote/suite/cli/callbacks.py | git_installed | def git_installed():
"""Interrupt execution of memote if `git` has not been installed."""
LOGGER.info("Checking `git` installation.")
try:
check_output(['git', '--version'])
except CalledProcessError as e:
LOGGER.critical(
"The execution of memote was interrupted since no ins... | python | def git_installed():
"""Interrupt execution of memote if `git` has not been installed."""
LOGGER.info("Checking `git` installation.")
try:
check_output(['git', '--version'])
except CalledProcessError as e:
LOGGER.critical(
"The execution of memote was interrupted since no ins... | [
"def",
"git_installed",
"(",
")",
":",
"LOGGER",
".",
"info",
"(",
"\"Checking `git` installation.\"",
")",
"try",
":",
"check_output",
"(",
"[",
"'git'",
",",
"'--version'",
"]",
")",
"except",
"CalledProcessError",
"as",
"e",
":",
"LOGGER",
".",
"critical",
... | Interrupt execution of memote if `git` has not been installed. | [
"Interrupt",
"execution",
"of",
"memote",
"if",
"git",
"has",
"not",
"been",
"installed",
"."
] | train | https://github.com/opencobra/memote/blob/276630fcd4449fb7b914186edfd38c239e7052df/memote/suite/cli/callbacks.py#L103-L115 |
opencobra/memote | memote/suite/results/repo_result_manager.py | RepoResultManager.record_git_info | def record_git_info(self, commit=None):
"""
Record git meta information.
Parameters
----------
commit : str, optional
Unique hexsha of the desired commit.
Returns
-------
GitInfo
Git commit meta information.
"""
i... | python | def record_git_info(self, commit=None):
"""
Record git meta information.
Parameters
----------
commit : str, optional
Unique hexsha of the desired commit.
Returns
-------
GitInfo
Git commit meta information.
"""
i... | [
"def",
"record_git_info",
"(",
"self",
",",
"commit",
"=",
"None",
")",
":",
"if",
"commit",
"is",
"None",
":",
"commit",
"=",
"self",
".",
"_repo",
".",
"head",
".",
"commit",
"else",
":",
"commit",
"=",
"self",
".",
"_repo",
".",
"commit",
"(",
"... | Record git meta information.
Parameters
----------
commit : str, optional
Unique hexsha of the desired commit.
Returns
-------
GitInfo
Git commit meta information. | [
"Record",
"git",
"meta",
"information",
"."
] | train | https://github.com/opencobra/memote/blob/276630fcd4449fb7b914186edfd38c239e7052df/memote/suite/results/repo_result_manager.py#L61-L85 |
opencobra/memote | memote/suite/results/repo_result_manager.py | RepoResultManager.add_git | def add_git(meta, git_info):
"""Enrich the result meta information with commit data."""
meta["hexsha"] = git_info.hexsha
meta["author"] = git_info.author
meta["email"] = git_info.email
meta["authored_on"] = git_info.authored_on.isoformat(" ") | python | def add_git(meta, git_info):
"""Enrich the result meta information with commit data."""
meta["hexsha"] = git_info.hexsha
meta["author"] = git_info.author
meta["email"] = git_info.email
meta["authored_on"] = git_info.authored_on.isoformat(" ") | [
"def",
"add_git",
"(",
"meta",
",",
"git_info",
")",
":",
"meta",
"[",
"\"hexsha\"",
"]",
"=",
"git_info",
".",
"hexsha",
"meta",
"[",
"\"author\"",
"]",
"=",
"git_info",
".",
"author",
"meta",
"[",
"\"email\"",
"]",
"=",
"git_info",
".",
"email",
"met... | Enrich the result meta information with commit data. | [
"Enrich",
"the",
"result",
"meta",
"information",
"with",
"commit",
"data",
"."
] | train | https://github.com/opencobra/memote/blob/276630fcd4449fb7b914186edfd38c239e7052df/memote/suite/results/repo_result_manager.py#L106-L111 |
opencobra/memote | memote/suite/results/repo_result_manager.py | RepoResultManager.store | def store(self, result, commit=None, **kwargs):
"""
Store a result in a JSON file attaching git meta information.
Parameters
----------
result : memote.MemoteResult
The dictionary structure of results.
commit : str, optional
Unique hexsha of the d... | python | def store(self, result, commit=None, **kwargs):
"""
Store a result in a JSON file attaching git meta information.
Parameters
----------
result : memote.MemoteResult
The dictionary structure of results.
commit : str, optional
Unique hexsha of the d... | [
"def",
"store",
"(",
"self",
",",
"result",
",",
"commit",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"git_info",
"=",
"self",
".",
"record_git_info",
"(",
"commit",
")",
"self",
".",
"add_git",
"(",
"result",
".",
"meta",
",",
"git_info",
")",
... | Store a result in a JSON file attaching git meta information.
Parameters
----------
result : memote.MemoteResult
The dictionary structure of results.
commit : str, optional
Unique hexsha of the desired commit.
kwargs :
Passed to parent functio... | [
"Store",
"a",
"result",
"in",
"a",
"JSON",
"file",
"attaching",
"git",
"meta",
"information",
"."
] | train | https://github.com/opencobra/memote/blob/276630fcd4449fb7b914186edfd38c239e7052df/memote/suite/results/repo_result_manager.py#L113-L131 |
opencobra/memote | memote/suite/results/repo_result_manager.py | RepoResultManager.load | def load(self, commit=None):
"""Load a result from the storage directory."""
git_info = self.record_git_info(commit)
LOGGER.debug("Loading the result for commit '%s'.", git_info.hexsha)
filename = self.get_filename(git_info)
LOGGER.debug("Loading the result '%s'.", filename)
... | python | def load(self, commit=None):
"""Load a result from the storage directory."""
git_info = self.record_git_info(commit)
LOGGER.debug("Loading the result for commit '%s'.", git_info.hexsha)
filename = self.get_filename(git_info)
LOGGER.debug("Loading the result '%s'.", filename)
... | [
"def",
"load",
"(",
"self",
",",
"commit",
"=",
"None",
")",
":",
"git_info",
"=",
"self",
".",
"record_git_info",
"(",
"commit",
")",
"LOGGER",
".",
"debug",
"(",
"\"Loading the result for commit '%s'.\"",
",",
"git_info",
".",
"hexsha",
")",
"filename",
"=... | Load a result from the storage directory. | [
"Load",
"a",
"result",
"from",
"the",
"storage",
"directory",
"."
] | train | https://github.com/opencobra/memote/blob/276630fcd4449fb7b914186edfd38c239e7052df/memote/suite/results/repo_result_manager.py#L133-L141 |
opencobra/memote | memote/jinja2_extension.py | MemoteExtension.normalize | def normalize(filename):
"""Return an absolute path of the given file name."""
# Default value means we do not resolve a model file.
if filename == "default":
return filename
filename = expanduser(filename)
if isabs(filename):
return filename
else:... | python | def normalize(filename):
"""Return an absolute path of the given file name."""
# Default value means we do not resolve a model file.
if filename == "default":
return filename
filename = expanduser(filename)
if isabs(filename):
return filename
else:... | [
"def",
"normalize",
"(",
"filename",
")",
":",
"# Default value means we do not resolve a model file.",
"if",
"filename",
"==",
"\"default\"",
":",
"return",
"filename",
"filename",
"=",
"expanduser",
"(",
"filename",
")",
"if",
"isabs",
"(",
"filename",
")",
":",
... | Return an absolute path of the given file name. | [
"Return",
"an",
"absolute",
"path",
"of",
"the",
"given",
"file",
"name",
"."
] | train | https://github.com/opencobra/memote/blob/276630fcd4449fb7b914186edfd38c239e7052df/memote/jinja2_extension.py#L42-L51 |
opencobra/memote | memote/experimental/growth.py | GrowthExperiment.load | def load(self, dtype_conversion=None):
"""
Load the data table and corresponding validation schema.
Parameters
----------
dtype_conversion : dict
Column names as keys and corresponding type for loading the data.
Please take a look at the `pandas documenta... | python | def load(self, dtype_conversion=None):
"""
Load the data table and corresponding validation schema.
Parameters
----------
dtype_conversion : dict
Column names as keys and corresponding type for loading the data.
Please take a look at the `pandas documenta... | [
"def",
"load",
"(",
"self",
",",
"dtype_conversion",
"=",
"None",
")",
":",
"if",
"dtype_conversion",
"is",
"None",
":",
"dtype_conversion",
"=",
"{",
"\"growth\"",
":",
"str",
"}",
"super",
"(",
"GrowthExperiment",
",",
"self",
")",
".",
"load",
"(",
"d... | Load the data table and corresponding validation schema.
Parameters
----------
dtype_conversion : dict
Column names as keys and corresponding type for loading the data.
Please take a look at the `pandas documentation
<https://pandas.pydata.org/pandas-docs/sta... | [
"Load",
"the",
"data",
"table",
"and",
"corresponding",
"validation",
"schema",
"."
] | train | https://github.com/opencobra/memote/blob/276630fcd4449fb7b914186edfd38c239e7052df/memote/experimental/growth.py#L49-L65 |
opencobra/memote | memote/experimental/growth.py | GrowthExperiment.evaluate | def evaluate(self, model, threshold=0.1):
"""Evaluate in silico growth rates."""
with model:
if self.medium is not None:
self.medium.apply(model)
if self.objective is not None:
model.objective = self.objective
model.add_cons_vars(self.c... | python | def evaluate(self, model, threshold=0.1):
"""Evaluate in silico growth rates."""
with model:
if self.medium is not None:
self.medium.apply(model)
if self.objective is not None:
model.objective = self.objective
model.add_cons_vars(self.c... | [
"def",
"evaluate",
"(",
"self",
",",
"model",
",",
"threshold",
"=",
"0.1",
")",
":",
"with",
"model",
":",
"if",
"self",
".",
"medium",
"is",
"not",
"None",
":",
"self",
".",
"medium",
".",
"apply",
"(",
"model",
")",
"if",
"self",
".",
"objective... | Evaluate in silico growth rates. | [
"Evaluate",
"in",
"silico",
"growth",
"rates",
"."
] | train | https://github.com/opencobra/memote/blob/276630fcd4449fb7b914186edfd38c239e7052df/memote/experimental/growth.py#L67-L88 |
opencobra/memote | memote/suite/results/models.py | BJSON.process_bind_param | def process_bind_param(self, value, dialect):
"""Convert the value to a JSON encoded string before storing it."""
try:
with BytesIO() as stream:
with GzipFile(fileobj=stream, mode="wb") as file_handle:
file_handle.write(
jsonify(val... | python | def process_bind_param(self, value, dialect):
"""Convert the value to a JSON encoded string before storing it."""
try:
with BytesIO() as stream:
with GzipFile(fileobj=stream, mode="wb") as file_handle:
file_handle.write(
jsonify(val... | [
"def",
"process_bind_param",
"(",
"self",
",",
"value",
",",
"dialect",
")",
":",
"try",
":",
"with",
"BytesIO",
"(",
")",
"as",
"stream",
":",
"with",
"GzipFile",
"(",
"fileobj",
"=",
"stream",
",",
"mode",
"=",
"\"wb\"",
")",
"as",
"file_handle",
":"... | Convert the value to a JSON encoded string before storing it. | [
"Convert",
"the",
"value",
"to",
"a",
"JSON",
"encoded",
"string",
"before",
"storing",
"it",
"."
] | train | https://github.com/opencobra/memote/blob/276630fcd4449fb7b914186edfd38c239e7052df/memote/suite/results/models.py#L70-L82 |
opencobra/memote | memote/suite/results/models.py | BJSON.process_result_value | def process_result_value(self, value, dialect):
"""Convert a JSON encoded string to a dictionary structure."""
if value is not None:
with BytesIO(value) as stream:
with GzipFile(fileobj=stream, mode="rb") as file_handle:
value = json.loads(file_handle.read... | python | def process_result_value(self, value, dialect):
"""Convert a JSON encoded string to a dictionary structure."""
if value is not None:
with BytesIO(value) as stream:
with GzipFile(fileobj=stream, mode="rb") as file_handle:
value = json.loads(file_handle.read... | [
"def",
"process_result_value",
"(",
"self",
",",
"value",
",",
"dialect",
")",
":",
"if",
"value",
"is",
"not",
"None",
":",
"with",
"BytesIO",
"(",
"value",
")",
"as",
"stream",
":",
"with",
"GzipFile",
"(",
"fileobj",
"=",
"stream",
",",
"mode",
"=",... | Convert a JSON encoded string to a dictionary structure. | [
"Convert",
"a",
"JSON",
"encoded",
"string",
"to",
"a",
"dictionary",
"structure",
"."
] | train | https://github.com/opencobra/memote/blob/276630fcd4449fb7b914186edfd38c239e7052df/memote/suite/results/models.py#L84-L90 |
pawamoy/django-zxcvbn-password | src/zxcvbn_password/widgets.py | PasswordStrengthInput.render | def render(self, name, value, attrs=None, **kwargs):
"""Widget render method."""
min_score = zxcvbn_min_score()
message_title = _('Warning')
message_body = _(
'This password would take '
'<em class="password_strength_time"></em> to crack.')
strength_marku... | python | def render(self, name, value, attrs=None, **kwargs):
"""Widget render method."""
min_score = zxcvbn_min_score()
message_title = _('Warning')
message_body = _(
'This password would take '
'<em class="password_strength_time"></em> to crack.')
strength_marku... | [
"def",
"render",
"(",
"self",
",",
"name",
",",
"value",
",",
"attrs",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"min_score",
"=",
"zxcvbn_min_score",
"(",
")",
"message_title",
"=",
"_",
"(",
"'Warning'",
")",
"message_body",
"=",
"_",
"(",
"'... | Widget render method. | [
"Widget",
"render",
"method",
"."
] | train | https://github.com/pawamoy/django-zxcvbn-password/blob/7c6d37099da0f130d6ab88a0f941b6de476a0f86/src/zxcvbn_password/widgets.py#L17-L60 |
pawamoy/django-zxcvbn-password | src/zxcvbn_password/widgets.py | PasswordConfirmationInput.render | def render(self, name, value, attrs=None, **kwargs):
"""Widget render method."""
if self.confirm_with:
self.attrs['data-confirm-with'] = 'id_%s' % self.confirm_with
confirmation_markup = """
<div style="margin-top: 10px;" class="hidden password_strength_info">
<p... | python | def render(self, name, value, attrs=None, **kwargs):
"""Widget render method."""
if self.confirm_with:
self.attrs['data-confirm-with'] = 'id_%s' % self.confirm_with
confirmation_markup = """
<div style="margin-top: 10px;" class="hidden password_strength_info">
<p... | [
"def",
"render",
"(",
"self",
",",
"name",
",",
"value",
",",
"attrs",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"self",
".",
"confirm_with",
":",
"self",
".",
"attrs",
"[",
"'data-confirm-with'",
"]",
"=",
"'id_%s'",
"%",
"self",
".",
... | Widget render method. | [
"Widget",
"render",
"method",
"."
] | train | https://github.com/pawamoy/django-zxcvbn-password/blob/7c6d37099da0f130d6ab88a0f941b6de476a0f86/src/zxcvbn_password/widgets.py#L79-L101 |
pawamoy/django-zxcvbn-password | src/zxcvbn_password/validators.py | ZXCVBNValidator.validate | def validate(self, password, user=None):
"""Validate method, run zxcvbn and check score."""
user_inputs = []
if user is not None:
for attribute in self.user_attributes:
if hasattr(user, attribute):
user_inputs.append(getattr(user, attribute))
... | python | def validate(self, password, user=None):
"""Validate method, run zxcvbn and check score."""
user_inputs = []
if user is not None:
for attribute in self.user_attributes:
if hasattr(user, attribute):
user_inputs.append(getattr(user, attribute))
... | [
"def",
"validate",
"(",
"self",
",",
"password",
",",
"user",
"=",
"None",
")",
":",
"user_inputs",
"=",
"[",
"]",
"if",
"user",
"is",
"not",
"None",
":",
"for",
"attribute",
"in",
"self",
".",
"user_attributes",
":",
"if",
"hasattr",
"(",
"user",
",... | Validate method, run zxcvbn and check score. | [
"Validate",
"method",
"run",
"zxcvbn",
"and",
"check",
"score",
"."
] | train | https://github.com/pawamoy/django-zxcvbn-password/blob/7c6d37099da0f130d6ab88a0f941b6de476a0f86/src/zxcvbn_password/validators.py#L42-L54 |
rossant/ipymd | ipymd/formats/atlas.py | _get_html_contents | def _get_html_contents(html):
"""Process a HTML block and detects whether it is a code block,
a math block, or a regular HTML block."""
parser = MyHTMLParser()
parser.feed(html)
if parser.is_code:
return ('code', parser.data.strip())
elif parser.is_math:
return ('math', parser.da... | python | def _get_html_contents(html):
"""Process a HTML block and detects whether it is a code block,
a math block, or a regular HTML block."""
parser = MyHTMLParser()
parser.feed(html)
if parser.is_code:
return ('code', parser.data.strip())
elif parser.is_math:
return ('math', parser.da... | [
"def",
"_get_html_contents",
"(",
"html",
")",
":",
"parser",
"=",
"MyHTMLParser",
"(",
")",
"parser",
".",
"feed",
"(",
"html",
")",
"if",
"parser",
".",
"is_code",
":",
"return",
"(",
"'code'",
",",
"parser",
".",
"data",
".",
"strip",
"(",
")",
")... | Process a HTML block and detects whether it is a code block,
a math block, or a regular HTML block. | [
"Process",
"a",
"HTML",
"block",
"and",
"detects",
"whether",
"it",
"is",
"a",
"code",
"block",
"a",
"math",
"block",
"or",
"a",
"regular",
"HTML",
"block",
"."
] | train | https://github.com/rossant/ipymd/blob/d87c9ebc59d67fe78b0139ee00e0e5307682e303/ipymd/formats/atlas.py#L47-L57 |
rossant/ipymd | ipymd/core/format_manager.py | _is_path | def _is_path(s):
"""Return whether an object is a path."""
if isinstance(s, string_types):
try:
return op.exists(s)
except (OSError, ValueError):
return False
else:
return False | python | def _is_path(s):
"""Return whether an object is a path."""
if isinstance(s, string_types):
try:
return op.exists(s)
except (OSError, ValueError):
return False
else:
return False | [
"def",
"_is_path",
"(",
"s",
")",
":",
"if",
"isinstance",
"(",
"s",
",",
"string_types",
")",
":",
"try",
":",
"return",
"op",
".",
"exists",
"(",
"s",
")",
"except",
"(",
"OSError",
",",
"ValueError",
")",
":",
"return",
"False",
"else",
":",
"re... | Return whether an object is a path. | [
"Return",
"whether",
"an",
"object",
"is",
"a",
"path",
"."
] | train | https://github.com/rossant/ipymd/blob/d87c9ebc59d67fe78b0139ee00e0e5307682e303/ipymd/core/format_manager.py#L38-L46 |
rossant/ipymd | ipymd/core/format_manager.py | FormatManager.format_manager | def format_manager(cls):
"""Return the instance singleton, creating if necessary
"""
if cls._instance is None:
# Discover the formats and register them with a new singleton.
cls._instance = cls().register_entrypoints()
return cls._instance | python | def format_manager(cls):
"""Return the instance singleton, creating if necessary
"""
if cls._instance is None:
# Discover the formats and register them with a new singleton.
cls._instance = cls().register_entrypoints()
return cls._instance | [
"def",
"format_manager",
"(",
"cls",
")",
":",
"if",
"cls",
".",
"_instance",
"is",
"None",
":",
"# Discover the formats and register them with a new singleton.",
"cls",
".",
"_instance",
"=",
"cls",
"(",
")",
".",
"register_entrypoints",
"(",
")",
"return",
"cls"... | Return the instance singleton, creating if necessary | [
"Return",
"the",
"instance",
"singleton",
"creating",
"if",
"necessary"
] | train | https://github.com/rossant/ipymd/blob/d87c9ebc59d67fe78b0139ee00e0e5307682e303/ipymd/core/format_manager.py#L79-L85 |
rossant/ipymd | ipymd/core/format_manager.py | FormatManager.register_entrypoints | def register_entrypoints(self):
"""Look through the `setup_tools` `entry_points` and load all of
the formats.
"""
for spec in iter_entry_points(self.entry_point_group):
format_properties = {"name": spec.name}
try:
format_properties.update(spec.l... | python | def register_entrypoints(self):
"""Look through the `setup_tools` `entry_points` and load all of
the formats.
"""
for spec in iter_entry_points(self.entry_point_group):
format_properties = {"name": spec.name}
try:
format_properties.update(spec.l... | [
"def",
"register_entrypoints",
"(",
"self",
")",
":",
"for",
"spec",
"in",
"iter_entry_points",
"(",
"self",
".",
"entry_point_group",
")",
":",
"format_properties",
"=",
"{",
"\"name\"",
":",
"spec",
".",
"name",
"}",
"try",
":",
"format_properties",
".",
"... | Look through the `setup_tools` `entry_points` and load all of
the formats. | [
"Look",
"through",
"the",
"setup_tools",
"entry_points",
"and",
"load",
"all",
"of",
"the",
"formats",
"."
] | train | https://github.com/rossant/ipymd/blob/d87c9ebc59d67fe78b0139ee00e0e5307682e303/ipymd/core/format_manager.py#L87-L103 |
rossant/ipymd | ipymd/core/format_manager.py | FormatManager.format_from_extension | def format_from_extension(self, extension):
"""Find a format from its extension."""
formats = [name
for name, format in self._formats.items()
if format.get('file_extension', None) == extension]
if len(formats) == 0:
return None
elif len(f... | python | def format_from_extension(self, extension):
"""Find a format from its extension."""
formats = [name
for name, format in self._formats.items()
if format.get('file_extension', None) == extension]
if len(formats) == 0:
return None
elif len(f... | [
"def",
"format_from_extension",
"(",
"self",
",",
"extension",
")",
":",
"formats",
"=",
"[",
"name",
"for",
"name",
",",
"format",
"in",
"self",
".",
"_formats",
".",
"items",
"(",
")",
"if",
"format",
".",
"get",
"(",
"'file_extension'",
",",
"None",
... | Find a format from its extension. | [
"Find",
"a",
"format",
"from",
"its",
"extension",
"."
] | train | https://github.com/rossant/ipymd/blob/d87c9ebc59d67fe78b0139ee00e0e5307682e303/ipymd/core/format_manager.py#L148-L160 |
rossant/ipymd | ipymd/core/format_manager.py | FormatManager.load | def load(self, file, name=None):
"""Load a file. The format name can be specified explicitly or
inferred from the file extension."""
if name is None:
name = self.format_from_extension(op.splitext(file)[1])
file_format = self.file_type(name)
if file_format == 'text':
... | python | def load(self, file, name=None):
"""Load a file. The format name can be specified explicitly or
inferred from the file extension."""
if name is None:
name = self.format_from_extension(op.splitext(file)[1])
file_format = self.file_type(name)
if file_format == 'text':
... | [
"def",
"load",
"(",
"self",
",",
"file",
",",
"name",
"=",
"None",
")",
":",
"if",
"name",
"is",
"None",
":",
"name",
"=",
"self",
".",
"format_from_extension",
"(",
"op",
".",
"splitext",
"(",
"file",
")",
"[",
"1",
"]",
")",
"file_format",
"=",
... | Load a file. The format name can be specified explicitly or
inferred from the file extension. | [
"Load",
"a",
"file",
".",
"The",
"format",
"name",
"can",
"be",
"specified",
"explicitly",
"or",
"inferred",
"from",
"the",
"file",
"extension",
"."
] | train | https://github.com/rossant/ipymd/blob/d87c9ebc59d67fe78b0139ee00e0e5307682e303/ipymd/core/format_manager.py#L166-L181 |
rossant/ipymd | ipymd/core/format_manager.py | FormatManager.save | def save(self, file, contents, name=None, overwrite=False):
"""Save contents into a file. The format name can be specified
explicitly or inferred from the file extension."""
if name is None:
name = self.format_from_extension(op.splitext(file)[1])
file_format = self.file_type(... | python | def save(self, file, contents, name=None, overwrite=False):
"""Save contents into a file. The format name can be specified
explicitly or inferred from the file extension."""
if name is None:
name = self.format_from_extension(op.splitext(file)[1])
file_format = self.file_type(... | [
"def",
"save",
"(",
"self",
",",
"file",
",",
"contents",
",",
"name",
"=",
"None",
",",
"overwrite",
"=",
"False",
")",
":",
"if",
"name",
"is",
"None",
":",
"name",
"=",
"self",
".",
"format_from_extension",
"(",
"op",
".",
"splitext",
"(",
"file",... | Save contents into a file. The format name can be specified
explicitly or inferred from the file extension. | [
"Save",
"contents",
"into",
"a",
"file",
".",
"The",
"format",
"name",
"can",
"be",
"specified",
"explicitly",
"or",
"inferred",
"from",
"the",
"file",
"extension",
"."
] | train | https://github.com/rossant/ipymd/blob/d87c9ebc59d67fe78b0139ee00e0e5307682e303/ipymd/core/format_manager.py#L183-L201 |
rossant/ipymd | ipymd/core/format_manager.py | FormatManager.create_reader | def create_reader(self, name, *args, **kwargs):
"""Create a new reader instance for a given format."""
self._check_format(name)
return self._formats[name]['reader'](*args, **kwargs) | python | def create_reader(self, name, *args, **kwargs):
"""Create a new reader instance for a given format."""
self._check_format(name)
return self._formats[name]['reader'](*args, **kwargs) | [
"def",
"create_reader",
"(",
"self",
",",
"name",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"_check_format",
"(",
"name",
")",
"return",
"self",
".",
"_formats",
"[",
"name",
"]",
"[",
"'reader'",
"]",
"(",
"*",
"args",
",",... | Create a new reader instance for a given format. | [
"Create",
"a",
"new",
"reader",
"instance",
"for",
"a",
"given",
"format",
"."
] | train | https://github.com/rossant/ipymd/blob/d87c9ebc59d67fe78b0139ee00e0e5307682e303/ipymd/core/format_manager.py#L203-L206 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.