Reconstruction Methods
Corda Algorithm
- class troppo.methods.reconstruction.corda.CORDA(S, lb, ub, properties)[source]
Bases:
ContextSpecificModelReconstructionAlgorithmCORDA algorithm
Parameters
- Sarray
Stoichiometric matrix
- lbarray
Lower bounds
- ubarray
Upper bounds
- propertiesCORDAProperties
Properties object
Attributes
- corso_fbaCORSOModel
CORSO FBA model
- block_reactions_from_idxs(rxcat: ndarray)[source]
Block reactions from a list of indices
Parameters
- rxcat: np.ndarray
Array of reaction indices
- check_if_blocked(rx: int) bool[source]
Check if a reaction is blocked
Parameters
- rx: int
Reaction index
Returns
- bool
True if the reaction is blocked, False otherwise
- do_function_for_reactions_on_both_models(reaction: int, mfunction, corsofunction)[source]
Perform a function on both models
Parameters
- reaction: int
Reaction index
- mfunction: function
Function to perform on the CBModel
- corsofunction: function
Function to perform on the CORSOModel
- find_dependent_reactions(rx: int, constraint: int, constrainby: str, costfx, costbase: ndarray, ntimes: int, eps: float) tuple[source]
Find dependent reactions for a given reaction
Parameters
- rx: int
Reaction index
- constraint: int
Value of the constraint
- constrainby: str
either ‘val’ (constrain fluxes by value) or ‘perc’ (constraint by percentage)
- costfx: function
Cost function
- costbase: np.ndarray
Cost base
- ntimes: int
Number of CORSO FBA simulations performed per dependency assessment
- eps: float
Epsilon value
Returns
- tuple
Dependent reactions and reactions to delete
- find_reaction_limits(rx: int) tuple[source]
Find the minimum and maximum flux for a given reaction
Parameters
- rx: int
Reaction index
Returns
- tuple
Minimum and maximum flux
- properties_class
alias of
CORDAProperties
- run() ndarray[source]
Set up of the variables to be used and calls the run_corda method.
Returns
- array
Returns an Array of reaction categories
- run_corda(rx_cat: ndarray, constraint: int, constrainby: str, nl: int, ntimes: int, om: float = 10000.0, pr_to_np: float = 2, threads: int = 1) ndarray[source]
Run the CORDA algorithm
Parameters
- rx_cat: np.ndarray
Array of reaction categories
- constraint: int
Value of the constraint
- constrainby: str
either ‘val’ (constrain fluxes by value) or ‘perc’ (constraint by percentage)
- nl: int
Number of loops to perform
- ntimes: int
Number of CORSO FBA simulations performed per dependency assessment
- om: float
Cost assigned to reactions when calculating dependencies
- pr_to_np: float
Threshold to include NP reactions if PR reactions depend on them
- threads: int
Number of threads to use
Returns
- np.ndarray
Returns an Array of reaction categories
- class troppo.methods.reconstruction.corda.CORDAProperties(high_conf_rx: list, medium_conf_rx: list, neg_conf_rx: list, pr_to_np: Optional[float] = None, constraint: Optional[int] = None, constrainby: Optional[str] = None, om: Optional[float] = None, ntimes: Optional[int] = None, nl: Optional[int] = None, solver: Optional[str] = None, threads: Optional[int] = None)[source]
Bases:
PropertiesReconstructionProperties reconstruction using CORDA
Parameters
- high_conf_rxlist
High confidence reactions
- medium_conf_rxlist
Medium confidence reactions
- neg_conf_rxlist
Negative confidence reactions
- pr_to_npfloat
Threshold to include NP reactions if PR reactions depend on them
- constraintint
Value of the constraint
- constrainbystr
either ‘val’ (constrain fluxes by value) or ‘perc’ (constraint by percentage)
- omfloat
cost assigned to reactions when calculating dependencies
- ntimesint
Number of CORSO FBA simulations performed per dependency assessment
- nlint or float
Number of loops to perform
- solverstr
Solver to use for optimization
- threadsint
Number of threads to use
- CONSTRAINBY_PERC = 'perc'
- CONSTRAINBY_VAL = 'val'
- static from_integrated_scores(scores: tuple, **kwargs) CORDAProperties[source]
Create a CORDAProperties object from integrated scores
Parameters
- scores: tuple
Tuple of high, medium and negative confidence scores
- kwargs: dict
Additional arguments to pass to the constructor
Returns
CORDAProperties
FastCORE Algorithm
- class troppo.methods.reconstruction.fastcore.FASTcore(S: ndarray, lb: ndarray, ub: ndarray, properties: FastcoreProperties)[source]
Bases:
ContextSpecificModelReconstructionAlgorithmFASTcore algorithm for context-specific model reconstruction.
Parameters
- S: numpy.ndarray
Stoichiometric matrix
- lb: numpy.ndarray
Lower bounds
- ub: numpy.ndarray
Upper bounds
- properties: FastcoreProperties
Properties for the algorithm
- LP3(J: ndarray, basis=None) dict[source]
LP3 problem.
Parameters
- J: numpy.ndarray
Indices of the reactions to be considered
- basis: None
Not used
Returns
- dict
Dictionary with the solution of the LP3 problem
- LP7(J, basis=None)[source]
LP7 problem.
Parameters
- J: numpy.ndarray
Indices of the reactions to be considered
- basis: None
Not used
Returns
- dict
Dictionary with the solution of the LP3 problem
- LP9(K, P)[source]
LP9 problem.
Parameters
- K: numpy.ndarray
Indices of the reactions to be considered
- P: numpy.ndarray
Indices of the reactions to be considered
Returns
- dict
Dictionary with the solution of the LP3 problem
- fastcore() list[source]
Fastcore algorithm.
Returns
- list
List with the reaction IDs of the reactions in the resulting model
- findSparseMode(J: ndarray, P: ndarray, singleton: bool, basis=None) ndarray[source]
Find sparse mode.
Parameters
- J: numpy.ndarray or tuple
Indices of the reactions to be considered
- P: numpy.ndarray
Indices of the reactions to be considered
- singleton: bool
If True, the algorithm will consider only one reaction at a time
- basis
List of basis vectors
Returns
numpy.ndarray
- preprocessing() -> (<class 'numpy.ndarray'>, <class 'numpy.ndarray'>, <class 'numpy.ndarray'>, <class 'numpy.ndarray'>)[source]
Preprocessing of the model.
Returns
np.ndarray, np.ndarray, np.ndarray, np.ndarray
- properties_class
alias of
FastcoreProperties
- reverse_irreversible_reactions_in_reverse_direction(irrev_reverse_idx: ndarray)[source]
Identifies the irreversible reactions in the reverse direction and returns the S matrix with the signals for the metabolites reversed, a vector with the upper bounds as reversed form the lower bounds and a vector with the lower bounds as the reverse of the upper ones.
Parameters
- irrev_reverse_idx: numpy.ndarray
Indices of the irreversible reactions in the reverse direction
Returns
- S: numpy.ndarray
Modified stoichiometric matrix
- ub: numpy.ndarray
Modified upper bounds
- lb: numpy.ndarray
Modified lower bounds
- class troppo.methods.reconstruction.fastcore.FastcoreProperties(core: list, flux_threshold: float = 0.0001, solver: Optional[str] = None)[source]
Bases:
PropertiesReconstructionProperties for FASTcore algorithm.
Parameters
- core: list
List of reactions that are considered core, as determined by the integrated scores
- flux_threshold: float
Flux threshold for the algorithm
- solver: str
Solver to be used
- static from_integrated_scores(scores: list, **kwargs) FastcoreProperties[source]
Creates a FastcoreProperties object from integrated scores.
Parameters
- scores: list
Integrated scores
- kwargs: dict
Additional arguments
Returns
- FastcoreProperties
FastcoreProperties object
GIMME Algorithm
- class troppo.methods.reconstruction.gimme.GIMME(S: list, lb: list, ub: list, properties: GIMMEProperties)[source]
Bases:
ContextSpecificModelReconstructionAlgorithmGIMME algorithm
Parameters
- S: list or ndarray
Stoichiometric matrix
- lb: list or ndarray
Lower bounds
- ub: list or ndarray
Upper bounds
- properties: GIMMEProperties
GIMME properties
Attributes
- S: ndarray
Stoichiometric matrix
- lb: ndarray
Lower bounds
- ub: ndarray
Upper bounds
- properties: GIMMEProperties
GIMME properties
- sol: GIMMESolution
GIMME solution
- gm: GIMMEModel
GIMME model
- properties_class
alias of
GIMMEProperties
- class troppo.methods.reconstruction.gimme.GIMMEModel(cbmodel: ConstraintBasedModel, solver: Optional[str] = None)[source]
Bases:
ConstraintBasedModelA GIMME model is a model that is used to reconstruct a context-specific model using the GIMME algorithm.
Parameters:
- cbmodel: ConstraintBasedModel
The template model that is used to reconstruct the context-specific model.
- solver: str or None
The solver that is used to solve the optimization problem.
Attributes:
- cbmodel: ConstraintBasedModel
The template model that is used to reconstruct the context-specific model.
- mapping: dict
A dictionary that maps the reactions of the template model to the reactions of the GIMME model.
- optimize_gimme(exp_vector: list, objectives: list, obj_frac: list = 0.9, flux_thres: Optional[float] = None)[source]
Optimize the GIMME model.
Parameters
- exp_vector: list
A list of expression values for each reaction in the GIMME model.
- objectives: list or tuple
A list of dictionaries that define the objectives of the GIMME model.
- obj_frac: list or tuple or float
A list of fractions that define the lower bounds of the objectives. If a float is given, the same fraction is used for all objectives.
- flux_thres: float
A threshold that defines the minimum flux that is allowed for each reaction in the GIMME model.
Returns
- GIMMESolution:
The solution of the GIMME model.
- class troppo.methods.reconstruction.gimme.GIMMEProperties(exp_vector: list, objectives: list, obj_frac: list = 0.9, preprocess: bool = False, flux_threshold: Optional[float] = None, solver: Optional[str] = None, reaction_ids: Optional[list] = None, metabolite_ids: Optional[list] = None)[source]
Bases:
PropertiesReconstructionProperties for GIMME
Parameters:
- exp_vector: list or ndarray
Expression vector
- objectives: list or tuple
List of objective vectors
- obj_frac: list or tuple or float
Fraction of the objective vector to be used
- preprocess: bool
Preprocess the model
- flux_threshold: float
Flux threshold
- solver: str
Solver to be used
- reaction_ids: list
List of reaction ids
- metabolite_ids: list
List of metabolite ids
- class troppo.methods.reconstruction.gimme.GIMMESolution(sol, exp_vector, var_names, mapping=None)[source]
Bases:
SolutionA GIMME solution is a solution of a GIMME model.
Parameters:
- sol: Solution
The solution of the GIMME model.
- exp_vector: list or ndarray
Expression vector
- var_names: list
List of variable names
- mapping: dict
A dictionary that maps the reactions of the template model to the reactions of the GIMME model.
iMAT Algorithm
- class troppo.methods.reconstruction.imat.IMAT(S: ndarray, lb: ndarray, ub: ndarray, properties: IMATProperties)[source]
Bases:
ContextSpecificModelReconstructionAlgorithmIMAT algorithm
Parameters
- Sndarray
The stoichiometric matrix
- lbndarray
The lower bounds
- ubndarray
The upper bounds
- propertiesIMATProperties
The IMAT properties
Attributes
- solLinearSystemOptimizer
The solution
- generate_imat_problem(S, lb, ub, high_idx, low_idx, epsilon)[source]
Generate the IMAT problem
Parameters
- S: ndarray
The stoichiometric matrix
- lb: ndarray
The lower bounds
- ub: ndarray
The upper bounds
- high_idx: ndarray
The high index
- low_idx: ndarray
The low index
- epsilon: float or int
The epsilon value
Returns
- lso: LinearSystemOptimizer
The linear system optimizer
- lsystem: GenericLinearSystem
The linear system
- properties_class
alias of
IMATProperties
- class troppo.methods.reconstruction.imat.IMATProperties(exp_vector: ndarray, exp_thresholds: tuple, core: Optional[ndarray] = None, tolerance: float = 1e-08, epsilon: int = 1)[source]
Bases:
PropertiesReconstructionProperties for IMAT algorithm
Parameters
- exp_vectornp.ndarray or list
The vector of expression values
- exp_thresholdstuple
The thresholds for the expression values
- corelist, optional
The core reactions, by default None
- tolerancefloat, optional
The tolerance, by default 1e-8
- epsilonfloat, optional
The epsilon, by default 1
- static from_integrated_scores(scores: list, **kwargs) IMATProperties[source]
Create IMAT properties from integrated scores
Parameters
- scores: list
The list of integrated scores
- kwargs: dict
Additional arguments
Returns
IMATProperties: The IMAT properties
SwiftCore Algorithm
- class troppo.methods.reconstruction.swiftcore.SWIFTCORE(S: ndarray, lb: ndarray, ub: ndarray, properties: SwiftcoreProperties)[source]
Bases:
ContextSpecificModelReconstructionAlgorithmSWIFTCORE algorithm
Parameters
- S: np.ndarray
Stoichiometric matrix
- lb: np.ndarray
Lower bounds
- ub: np.ndarray
Upper bounds
- properties: SwiftcoreProperties
The properties of the algorithm
- properties_class
alias of
SwiftcoreProperties
- class troppo.methods.reconstruction.swiftcore.SwiftcoreProperties(core: list, weights: list, flux_threshold: int = 0.0001, solver: Optional[str] = None)[source]
Bases:
PropertiesReconstruction
- troppo.methods.reconstruction.swiftcore.find_core(S: ndarray, lb: ndarray, ub: ndarray, blocked: ndarray, weights: ndarray, solver: str) Solution[source]
Find the core of the given model
Parameters
- S: np.ndarray
Stoichiometric matrix
- lb: np.ndarray
Lower bounds
- ub: np.ndarray
Upper bounds
- blocked: np.ndarray
Blocked reactions
- weights: np.ndarray
Weights
- solver: str
The solver to use
Returns
Solution : The solution of the optimization problem
(t)INIT Algorithm
- class troppo.methods.reconstruction.tINIT.tINIT(S: ndarray, lb: ndarray, ub: ndarray, properties: tINITProperties)[source]
Bases:
ContextSpecificModelReconstructionAlgorithmThe tINIT algorithm.
Parameters
- Snp.ndarray
The stoichiometric matrix.
- lbnp.ndarray
The lower bounds for the reactions.
- ubnp.ndarray
The upper bounds for the reactions.
- propertiestINITProperties
The properties for the algorithm.
- properties_class
alias of
tINITProperties
- class troppo.methods.reconstruction.tINIT.tINITProperties(reactions_scores: list, present_metabolites: Optional[list] = None, essential_reactions: Optional[list] = None, production_weight: float = 0.5, allow_excretion: bool = False, no_reverse_loops: bool = False, solver: Optional[str] = None)[source]
Bases:
PropertiesReconstructionProperties for the tINIT algorithm.
Parameters
- reactions_scoreslist
The scores for each reaction.
- present_metaboliteslist, default=[]
The metabolites that are present in the model.
- essential_reactionslist, default=[]
The reactions that are essential in the model.
- production_weightfloat, default=0.5
The weight of the production reactions.
- allow_excretionbool, default=False
Whether to allow excretion.
- no_reverse_loopsbool, default=False
Whether to allow reverse loops.
- solverstr, default=None
The solver to be used.
- static from_integrated_scores(scores: list, **kwargs: dict) tINITProperties[source]
Creates the properties object from integrated scores.
Parameters
- scores: list
The integrated scores for each reaction.
- kwargs: dict
The other properties.
Returns
- tINITProperties
The properties object.