StrainDesign class

class gsmodutils.project.design.StrainDesign(did, name, description, project, parent=None, reactions=None, metabolites=None, genes=None, removed_metabolites=None, removed_reactions=None, removed_genes=None, base_model=None, conditions=None, is_pydesign=False, design_func=None)[source]

Bases: object

add_to_model(model, copy=False, add_missing=True)[source]

Add this design to a given cobra model :param model: :param copy: :param add_missing: add missing metabolites to the model :return:

as_pathway_model()[source]

Loads a cobra model with just the reactions present in this design Can be useful for the cobra.Model methods

# TODO: add full metabolite info from parent model (optional, as it will be slower) :return: mdl instance of cobra.Model

check_parents(p_stack=None)[source]

Tests to see if their is a loop in parental inheritance

static compile_pydesign(pyfile)[source]

Compile a python file and load any gsmodutil design names :param pyfile: :return:

design_schema = {'description': 'JSON representation of gsmodutils designs. Largely based on COBRApy JSON schema', 'properties': {'removed_reactions': {'type': 'array'}, 'genes': {'items': {'properties': {'annotation': {'type': 'object'}, 'id': {'type': 'string'}, 'name': {'type': 'string'}, 'notes': {'type': 'object'}}, 'required': ['id', 'name'], 'type': 'object'}, 'type': 'array'}, 'conditions': {'type': ['string', 'null']}, 'metabolites': {'items': {'properties': {'_bound': {'default': 0, 'type': 'number'}, '_constraint_sense': {'default': 'E', 'pattern': 'E|L|G', 'type': 'string'}, 'id': {'type': 'string'}, 'name': {'item': {'type': 'string'}, 'type': ['string', 'array']}, 'charge': {'type': ['integer', 'null']}, 'annotation': {'type': 'object'}, 'formula': {'type': ['string', 'null']}, 'notes': {'type': 'object'}, 'compartment': {'pattern': '[a-z]{1,2}', 'type': ['string', 'null']}}, 'required': ['id', 'name', 'compartment'], 'type': 'object'}, 'type': 'array'}, 'id': {'type': 'string'}, 'reactions': {'items': {'properties': {'variable_kind': {'default': 'continuous', 'pattern': 'integer|continuous', 'type': 'string'}, 'lower_bound': {'type': 'number'}, 'metabolites': {'patternProperties': {'.*': {'type': 'number'}}, 'type': 'object'}, 'id': {'type': 'string'}, 'name': {'type': 'string'}, 'objective_coefficient': {'default': 0, 'type': 'number'}, 'upper_bound': {'type': 'number'}, 'annotation': {'type': 'object'}, 'gene_reaction_rule': {'type': 'string'}, 'subsystem': {'type': 'string'}, 'notes': {'type': 'object'}}, 'required': ['id', 'name', 'metabolites', 'lower_bound', 'upper_bound', 'gene_reaction_rule'], 'type': 'object'}, 'type': 'array'}, 'name': {'type': 'string'}, 'removed_metabolites': {'type': 'array'}, 'removed_genes': {'type': 'array'}, 'parent': {'type': ['string', 'null']}, 'description': {'type': 'string'}}, 'required': ['id', 'name', 'description', 'reactions', 'metabolites', 'genes'], 'type': 'object'}
classmethod from_dict(did, design, project)[source]
Parameters:
  • did – unique design identifier
  • design – design dict
  • project – GSMProject instance
Returns:

classmethod from_json(did, file_path, project)[source]

Load from a json file :param did unique design identifier :param file_path: file location of design :param project: GSMProject project instance :return:

classmethod from_pydesign(project, did, func_name, compiled_code)[source]

Load a pydesign function as a proper design

genes

Recursively builds set of genes inherited from parents

genes_dataframe()[source]

Return a dataframe of the reactions involved in the design :return:

info
load()[source]

Returns a cobra model containing the parent model with the design applied :return:

metabolites

Recursively builds set of metabolites inherited from parents

metabolites_dataframe()[source]

Return a dataframe of the reactions involved in the design :return:

reactions

Recursively builds set of reactions inherited from parents

reactions_dataframe()[source]

Return a dataframe of the reactions involved in the design :return:

removed_genes

Recursively builds set of removed genes inherited from parents

removed_metabolites

Recursively builds set of removed metabolites inherited from parents

removed_reactions

Recursively builds set of removed reactions inherited from parents

to_dict()[source]

Converts to design dict (compatible with model diffs) :return:

to_json(file_path, overwrite=False)[source]

Write to a given file

static validate_dict(design_dict, throw_exceptions=True)[source]

Check required fields are present :param design_dict: :param throw_exceptions: Throw json schema exceptions. If false, returns bool on any exception :return: