straindesign.strainDesignSolutions

Container for strain design solutions (SDSolutions)

Module Contents

class straindesign.strainDesignSolutions.SDSolutions(model, sd, status, sd_setup, *, _lazy_init=None)[source]

Bases: object

Container for strain design solutions

Objects of this class are returned by strain design computations. This class contains the metabolic interventions on the gene, reaction or regulation level alongside with information about the strain design setup, including the model used and the strain design modules. Strain design solutions can be accessed either through the fields or through specific functions that preprocess or reformat strain designs for different purposes.

Instances of this class are not meant to be created by StrainDesign users.

Parameters:
  • model (cobra.Model) – A metabolic model that is an instance of the cobra.Model class.

  • sd (list of dict) – A list of dicts every dict represents an intervention set. Keys in each dict are reaction/gene identifiers and the associated value determines if it is added (1), not added (0) or knocked out (-1). For regulatory interventions, (1) means active regulation and (0) means regulatory intervention not added. These will be translated to True and False.

  • status (str) – Status string of the computation (e.g.: ‘optimal’)

  • sd_setup (dict) –

    A dictionary containing information about the problem setup. This dict can/should contain the keys MODEL_ID, MODULES, MAX_SOLUTIONS, MAX_COST, TIME_LIMIT, SOLVER, KOCOST, KICOST, REGCOST, GKICOST, GKOCOST

    These entries can be set like this: sd_setup[straindesign.MODEL_ID] = model.id

Returns

(SDSolutions): Strain design solutions

__add__(other)[source]

Merge two SDSolutions objects, returning a new object.

__iadd__(other)[source]

In-place merge of two SDSolutions objects (deduplicates at compressed level).

expand_all(n_per_group=None)[source]

Expand all compressed groups.

Parameters:

n_per_group – None means all, int means keep up to n per group.

expand_group(grp_idx)[source]

Expand one compressed group on demand.

Returns list of expanded solution dicts. Also updates reaction_sd, sd_cost, itv_bounds, and group_map in place.

get_gene_reac_sd_assoc(i=None)[source]

Get reaction and gene-based strain design solutions, and show which reaction-based solution corresponds to which gene-based.

Often the association is not 1:1 but n:1.

get_gene_reac_sd_assoc_mark_no_ki(i=None)[source]

Get reaction and gene-based strain design solutions, but also tag knock-ins that were not made with a 0

Often the association is not 1:1 but n:1.

get_gene_sd(i=None)[source]

Get gene-based strain design solutions

get_gene_sd_mark_no_ki(i=None)[source]

Get gene-based strain design solutions, but also tag knock-ins that were not made with a 0

get_group(i)[source]

Get all expanded solution indices that belong to the same compressed group as solution i.

Returns a list of indices into reaction_sd that share the same compressed solution origin. Requires that compute_strain_designs was called with compression enabled.

get_num_groups()[source]

Get the number of distinct compressed solution groups.

get_num_materialized()[source]

Number of currently materialized solutions in reaction_sd.

get_num_sols()[source]

Get number of solutions

get_reaction_sd(i=None)[source]

Get reaction-based strain design solutions

Gene-based intervention sets are translated to the reaction level. This can be helpful to understand the impact of gene interventions. GPR-rules are accounted for automatically.

get_reaction_sd_bnds(i=None)[source]

Get reaction-based strain design solutions represented by upper and lower bounds

Knocked-out reactions will show as upper and lower bounds of zero.

get_reaction_sd_mark_no_ki(i=None)[source]

Get reaction-based strain design solutions, but also tag knock-ins that were not made with a 0

This can be helpful to analyze gene intervention sets in original metabolic models. GPR-rules are accounted for automatically.

get_representative_sd()[source]

Get one representative expanded solution per compressed group.

Returns a list of dicts, one per unique compressed solution.

get_strain_design_costs(i=None)[source]

Get costs of i-th strain design or of all in a list

get_strain_designs(i=None)[source]

Get i-th strain design (intervention set) or all in original format

classmethod load(filename)[source]

Load strain design solutions from a file.

save(filename)[source]

Save strain design solutions to a file.

property is_lazy[source]

True if lazy expansion is active (some groups unexpanded).

straindesign.strainDesignSolutions.get_subset(sd, i)[source]

SDSolutions internal function: getting a subset of solutions

straindesign.strainDesignSolutions.gpr_eval(cj_terms, interv)[source]

SDSolutions internal function: evaluate a GPR term

straindesign.strainDesignSolutions.strip_non_ki(sd)[source]

SDSolutions internal function: removing non-added reactions or genes