_id stringlengths 2 7 | title stringlengths 1 88 | partition stringclasses 3
values | text stringlengths 75 19.8k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q2400 | get_smallest_compound_id | train | def get_smallest_compound_id(compounds_identifiers):
"""
Return the smallest KEGG compound identifier from a list.
KEGG identifiers may map to compounds, drugs or glycans prefixed
respectively with "C", "D", and "G" followed by at least 5 digits. We
choose the lowest KEGG identifier with the assump... | python | {
"resource": ""
} |
q2401 | map_metabolite2kegg | train | def map_metabolite2kegg(metabolite):
"""
Return a KEGG compound identifier for the metabolite if it exists.
First see if there is an unambiguous mapping to a single KEGG compound ID
provided with the model. If not, check if there is any KEGG compound ID in
a list of mappings. KEGG IDs may map to co... | python | {
"resource": ""
} |
q2402 | translate_reaction | train | def translate_reaction(reaction, metabolite_mapping):
"""
Return a mapping from KEGG compound identifiers to coefficients.
Parameters
----------
reaction : cobra.Reaction
The reaction whose metabolites are to be translated.
metabolite_mapping : dict
An existing mapping from cobr... | python | {
"resource": ""
} |
q2403 | find_thermodynamic_reversibility_index | train | def find_thermodynamic_reversibility_index(reactions):
u"""
Return the reversibility index of the given reactions.
To determine the reversibility index, we calculate
the reversibility index ln_gamma (see [1]_ section 3.5) of each reaction
using the eQuilibrator API [2]_.
Parameters
-------... | python | {
"resource": ""
} |
q2404 | check_stoichiometric_consistency | train | def check_stoichiometric_consistency(model):
"""
Verify the consistency of the model's stoichiometry.
Parameters
----------
model : cobra.Model
The metabolic model under investigation.
Notes
-----
See [1]_ section 3.1 for a complete description of the algorithm.
.. [1] Gev... | python | {
"resource": ""
} |
q2405 | find_unconserved_metabolites | train | def find_unconserved_metabolites(model):
"""
Detect unconserved metabolites.
Parameters
----------
model : cobra.Model
The metabolic model under investigation.
Notes
-----
See [1]_ section 3.2 for a complete description of the algorithm.
.. [1] Gevorgyan, A., M. G Poolman... | python | {
"resource": ""
} |
q2406 | find_inconsistent_min_stoichiometry | train | def find_inconsistent_min_stoichiometry(model, atol=1e-13):
"""
Detect inconsistent minimal net stoichiometries.
Parameters
----------
model : cobra.Model
The metabolic model under investigation.
atol : float, optional
Values below the absolute tolerance are treated as zero. Exp... | python | {
"resource": ""
} |
q2407 | detect_energy_generating_cycles | train | def detect_energy_generating_cycles(model, metabolite_id):
u"""
Detect erroneous energy-generating cycles for a a single metabolite.
The function will first build a dissipation reaction corresponding to the
input metabolite. This reaction is then set as the objective for
optimization, after closing... | python | {
"resource": ""
} |
q2408 | find_orphans | train | def find_orphans(model):
"""
Return metabolites that are only consumed in reactions.
Metabolites that are involved in an exchange reaction are never
considered to be orphaned.
Parameters
----------
model : cobra.Model
The metabolic model under investigation.
"""
exchange =... | python | {
"resource": ""
} |
q2409 | find_metabolites_not_produced_with_open_bounds | train | def find_metabolites_not_produced_with_open_bounds(model):
"""
Return metabolites that cannot be produced with open exchange reactions.
A perfect model should be able to produce each and every metabolite when
all medium components are available.
Parameters
----------
model : cobra.Model
... | python | {
"resource": ""
} |
q2410 | find_metabolites_not_consumed_with_open_bounds | train | def find_metabolites_not_consumed_with_open_bounds(model):
"""
Return metabolites that cannot be consumed with open boundary reactions.
When all metabolites can be secreted, it should be possible for each and
every metabolite to be consumed in some form.
Parameters
----------
model : cobra... | python | {
"resource": ""
} |
q2411 | find_reactions_with_unbounded_flux_default_condition | train | def find_reactions_with_unbounded_flux_default_condition(model):
"""
Return list of reactions whose flux is unbounded in the default condition.
Parameters
----------
model : cobra.Model
The metabolic model under investigation.
Returns
-------
tuple
list
A li... | python | {
"resource": ""
} |
q2412 | read_tabular | train | def read_tabular(filename, dtype_conversion=None):
"""
Read a tabular data file which can be CSV, TSV, XLS or XLSX.
Parameters
----------
filename : str or pathlib.Path
The full file path. May be a compressed file.
dtype_conversion : dict
Column names as keys and corresponding t... | python | {
"resource": ""
} |
q2413 | snapshot | train | def snapshot(model, filename, pytest_args, exclusive, skip, solver,
experimental, custom_tests, custom_config):
"""
Take a snapshot of a model's state and generate a report.
MODEL: Path to model file. Can also be supplied via the environment variable
MEMOTE_MODEL or configured in 'setup.cf... | python | {
"resource": ""
} |
q2414 | history | train | def history(location, model, filename, deployment, custom_config):
"""Generate a report over a model's git commit history."""
callbacks.git_installed()
LOGGER.info("Initialising history report generation.")
if location is None:
raise click.BadParameter("No 'location' given or configured.")
t... | python | {
"resource": ""
} |
q2415 | diff | train | def diff(models, filename, pytest_args, exclusive, skip, solver,
experimental, custom_tests, custom_config):
"""
Take a snapshot of all the supplied models and generate a diff report.
MODELS: List of paths to two or more model files.
"""
if not any(a.startswith("--tb") for a in pytest_args... | python | {
"resource": ""
} |
q2416 | HistoryManager.build_branch_structure | train | def build_branch_structure(self, model, skip):
"""Inspect and record the repo's branches and their history."""
self._history = dict()
self._history["commits"] = commits = dict()
self._history["branches"] = branches = dict()
for branch in self._repo.refs:
LOGGER.debug(... | python | {
"resource": ""
} |
q2417 | HistoryManager.load_history | train | def load_history(self, model, skip={"gh-pages"}):
"""
Load the entire results history into memory.
Could be a bad idea in a far future.
"""
if self._history is None:
self.build_branch_structure(model, skip)
self._results = dict()
all_commits = list(s... | python | {
"resource": ""
} |
q2418 | HistoryManager.get_result | train | def get_result(self, commit, default=MemoteResult()):
"""Return an individual result from the history if it exists."""
assert self._results is not None, \
"Please call the method `load_history` first."
return self._results.get(commit, default) | python | {
"resource": ""
} |
q2419 | absolute_extreme_coefficient_ratio | train | def absolute_extreme_coefficient_ratio(model):
"""
Return the maximum and minimum absolute, non-zero coefficients.
Parameters
----------
model : cobra.Model
The metabolic model under investigation.
"""
s_matrix, _, _ = con_helpers.stoichiometry_matrix(
model.metabolites, mo... | python | {
"resource": ""
} |
q2420 | number_independent_conservation_relations | train | def number_independent_conservation_relations(model):
"""
Return the number of conserved metabolite pools.
This number is given by the left null space of the stoichiometric matrix.
Parameters
----------
model : cobra.Model
The metabolic model under investigation.
"""
s_matrix,... | python | {
"resource": ""
} |
q2421 | matrix_rank | train | def matrix_rank(model):
"""
Return the rank of the model's stoichiometric matrix.
Parameters
----------
model : cobra.Model
The metabolic model under investigation.
"""
s_matrix, _, _ = con_helpers.stoichiometry_matrix(
model.metabolites, model.reactions
)
return co... | python | {
"resource": ""
} |
q2422 | degrees_of_freedom | train | def degrees_of_freedom(model):
"""
Return the degrees of freedom, i.e., number of "free variables".
Parameters
----------
model : cobra.Model
The metabolic model under investigation.
Notes
-----
This specifically refers to the dimensionality of the (right) null space
of the... | python | {
"resource": ""
} |
q2423 | ExperimentConfiguration.load | train | def load(self, model):
"""
Load all information from an experimental configuration file.
Parameters
----------
model : cobra.Model
The metabolic model under investigation.
"""
self.load_medium(model)
self.load_essentiality(model)
self... | python | {
"resource": ""
} |
q2424 | ExperimentConfiguration.validate | train | def validate(self):
"""Validate the configuration file."""
validator = Draft4Validator(self.SCHEMA)
if not validator.is_valid(self.config):
for err in validator.iter_errors(self.config):
LOGGER.error(str(err.message))
validator.validate(self.config) | python | {
"resource": ""
} |
q2425 | ExperimentConfiguration.load_medium | train | def load_medium(self, model):
"""Load and validate all media."""
media = self.config.get("medium")
if media is None:
return
definitions = media.get("definitions")
if definitions is None or len(definitions) == 0:
return
path = self.get_path(media, j... | python | {
"resource": ""
} |
q2426 | ExperimentConfiguration.get_path | train | def get_path(self, obj, default):
"""Return a relative or absolute path to experimental data."""
path = obj.get("path")
if path is None:
path = join(self._base, default)
if not isabs(path):
path = join(self._base, path)
return path | python | {
"resource": ""
} |
q2427 | find_components_without_annotation | train | def find_components_without_annotation(model, components):
"""
Find model components with empty annotation attributes.
Parameters
----------
model : cobra.Model
A cobrapy metabolic model.
components : {"metabolites", "reactions", "genes"}
A string denoting `cobra.Model` componen... | python | {
"resource": ""
} |
q2428 | generate_component_annotation_miriam_match | train | 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 | {
"resource": ""
} |
q2429 | generate_component_id_namespace_overview | train | 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 | {
"resource": ""
} |
q2430 | confusion_matrix | train | 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 | {
"resource": ""
} |
q2431 | validate_model | train | 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 | {
"resource": ""
} |
q2432 | snapshot_report | train | 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 | {
"resource": ""
} |
q2433 | history_report | train | 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 | {
"resource": ""
} |
q2434 | diff_report | train | 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 | {
"resource": ""
} |
q2435 | validation_report | train | 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 | {
"resource": ""
} |
q2436 | ReportConfiguration.load | train | 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 | {
"resource": ""
} |
q2437 | find_top_level_complex | train | 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 | {
"resource": ""
} |
q2438 | GPRVisitor.visit_BoolOp | train | 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 | {
"resource": ""
} |
q2439 | find_nonzero_constrained_reactions | train | 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 | {
"resource": ""
} |
q2440 | find_zero_constrained_reactions | train | 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 | {
"resource": ""
} |
q2441 | find_unconstrained_reactions | train | 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 | {
"resource": ""
} |
q2442 | find_ngam | train | 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 | {
"resource": ""
} |
q2443 | calculate_metabolic_coverage | train | 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 | {
"resource": ""
} |
q2444 | find_protein_complexes | train | 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 | {
"resource": ""
} |
q2445 | is_constrained_reaction | train | 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 | {
"resource": ""
} |
q2446 | find_unique_metabolites | train | 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 | {
"resource": ""
} |
q2447 | find_duplicate_metabolites_in_compartments | train | 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 | {
"resource": ""
} |
q2448 | find_reactions_with_partially_identical_annotations | train | 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 | {
"resource": ""
} |
q2449 | map_metabolites_to_structures | train | 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 | {
"resource": ""
} |
q2450 | find_duplicate_reactions | train | 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 | {
"resource": ""
} |
q2451 | find_reactions_with_identical_genes | train | 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 | {
"resource": ""
} |
q2452 | find_external_metabolites | train | 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 | {
"resource": ""
} |
q2453 | ResultManager.store | train | 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 | {
"resource": ""
} |
q2454 | ResultManager.load | train | 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 | {
"resource": ""
} |
q2455 | load_cobra_model | train | 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 | {
"resource": ""
} |
q2456 | format_failure | train | 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 | {
"resource": ""
} |
q2457 | run_sbml_validation | train | 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 | {
"resource": ""
} |
q2458 | SQLResultManager.load | train | 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 | {
"resource": ""
} |
q2459 | HistoryReport.collect_history | train | 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 | {
"resource": ""
} |
q2460 | DiffReport.format_and_score_diff_data | train | 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 | {
"resource": ""
} |
q2461 | generate_shortlist | train | 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 | {
"resource": ""
} |
q2462 | generate | train | 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 | {
"resource": ""
} |
q2463 | EssentialityExperiment.evaluate | train | 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 | {
"resource": ""
} |
q2464 | register_with | train | 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 | {
"resource": ""
} |
q2465 | annotate | train | 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 | {
"resource": ""
} |
q2466 | truncate | train | 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 | {
"resource": ""
} |
q2467 | log_json_incompatible_types | train | 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 | {
"resource": ""
} |
q2468 | flatten | train | 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 | {
"resource": ""
} |
q2469 | stdout_notifications | train | 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 | {
"resource": ""
} |
q2470 | ExperimentalBase.validate | train | 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 | {
"resource": ""
} |
q2471 | ExperimentalBase.evaluate_report | train | 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 | {
"resource": ""
} |
q2472 | add_reaction_constraints | train | 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 | {
"resource": ""
} |
q2473 | stoichiometry_matrix | train | 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 | {
"resource": ""
} |
q2474 | rank | train | 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 | {
"resource": ""
} |
q2475 | get_interface | train | 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 | {
"resource": ""
} |
q2476 | get_internals | train | 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 | {
"resource": ""
} |
q2477 | add_cut | train | 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 | {
"resource": ""
} |
q2478 | is_mass_balanced | train | 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 | {
"resource": ""
} |
q2479 | is_charge_balanced | train | 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 | {
"resource": ""
} |
q2480 | check_partial | train | 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 | {
"resource": ""
} |
q2481 | gene_id_check | train | 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 | {
"resource": ""
} |
q2482 | reaction_id_check | train | 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 | {
"resource": ""
} |
q2483 | metabolite_id_check | train | 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 | {
"resource": ""
} |
q2484 | run | train | 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 | {
"resource": ""
} |
q2485 | new | train | 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 | {
"resource": ""
} |
q2486 | online | train | 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 | {
"resource": ""
} |
q2487 | update_mock_repo | train | 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 | {
"resource": ""
} |
q2488 | sum_biomass_weight | train | 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 | {
"resource": ""
} |
q2489 | find_biomass_precursors | train | 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 | {
"resource": ""
} |
q2490 | find_blocked_biomass_precursors | train | 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 | {
"resource": ""
} |
q2491 | gam_in_biomass | train | 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 | {
"resource": ""
} |
q2492 | find_direct_metabolites | train | 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 | {
"resource": ""
} |
q2493 | detect_false_positive_direct_metabolites | train | 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 | {
"resource": ""
} |
q2494 | bundle_biomass_components | train | 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 | {
"resource": ""
} |
q2495 | essential_precursors_not_in_biomass | train | 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 | {
"resource": ""
} |
q2496 | validate_experimental | train | 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 | {
"resource": ""
} |
q2497 | probe_git | train | 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 | {
"resource": ""
} |
q2498 | git_installed | train | 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 | {
"resource": ""
} |
q2499 | RepoResultManager.record_git_info | train | 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 | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.