API¶
-
class
LibStructural
[source]¶ -
analyzeWithFullyPivotedLU
(self)[source]¶ Uses fully pivoted LU Decomposition for Conservation analysis.This method performs the actual analysis of the stoichiometry matrix loaded either via
LibStructural.loadStoichiometryMatrix
orLibStructural.loadSBMLFromString
.Only after one of the analysis methods below has been called are the structural matrices (L0, K0…) available.
LibStructural.analyzeWithQR
LibStructural.analyzeWithLU
LibStructural.analyzeWithLUandRunTests
LibStructural.analyzeWithFullyPivotedLU
orLibStructural.analyzeWithFullyPivotedLUwithTests
Returns: A string with information about the analysis process
-
analyzeWithFullyPivotedLUwithTests
(self)[source]¶ Uses fully pivoted LU Decomposition for Conservation analysis. This method performs the actual analysis of the stoichiometry matrix loaded either via
LibStructural.loadStoichiometryMatrix
orLibStructural.loadSBMLFromString
.Only after one of the analysis methods below has been called are the structural matrices (L0, K0…) available.
LibStructural.analyzeWithQR
,LibStructural.analyzeWithLU
,``LibStructural.analyzeWithLU``andRunTests,LibStructural.analyzeWithFullyPivotedLU
orLibStructural.analyzeWithFullyPivotedLUwithTests
This method additionally performs the integrated test suite and returns those results.
Returns: A string with information about the analysis process
-
analyzeWithLU
(self)[source]¶ Uses LU Decomposition for Conservation analysis. This method performs the actual analysis of the stoichiometry matrix (loaded either via
LibStructural.loadStoichiometryMatrix
orLibStructural.loadSBMLFromString
.Only after one of the analysis methods below has been called are the structural matrices (L0, K0…) available.
LibStructural.analyzeWithQR
,LibStructural.analyzeWithLU
,LibStructural.analyzeWithLUandRunTests
,LibStructural.analyzeWithFullyPivotedLU
orLibStructural.analyzeWithFullyPivotedLUwithTests
Returns: A string with information about the analysis process
-
analyzeWithLUandRunTests
(self)[source]¶ Uses LU Decomposition for Conservation analysis. This method performs the actual analysis of the stoichiometry matrix loaded either via
LibStructural.loadStoichiometryMatrix
orLibStructural.loadSBMLFromString
.Only after one of the analysis methods below has been called are the structural matrices (L0, K0…) available.
LibStructural.analyzeWithQR
,LibStructural.analyzeWithLU
,LibStructural.analyzeWithLUandRunTests
,LibStructural.analyzeWithFullyPivotedLU
or``LibStructural.analyzeWithFullyPivotedLUwithTests’‘This method additionally performs the integrated test suite and returns those results.
Returns: A string with information about the analysis process
-
analyzeWithQR
(self)[source]¶ Uses QR factorization for structural analysis. This method performs the actual analysis of the stoichiometry matrix loaded either via
LibStructural.loadStoichiometryMatrix
orLibStructural.loadSBMLFromString
.Only after one of the analysis methods below has been called are the structural matrices (L0, K0…) available.
LibStructural.analyzeWithQR
,LibStructural.analyzeWithLU
,LibStructural.analyzeWithLU
,RunTests
,LibStructural.analyzeWithFullyPivotedLU
,LibStructural.analyzeWithFullyPivotedLUwithTests
Remarks: This is the prefered method for structural analysis.
Returns: A string with information about the analysis process
-
getColumnReorderedNrMatrix
(self)[source]¶ Returns: The Nr Matrix repartitioned into NIC (independent columns) and NDC (dependent columns). The Nr matrix contains the independent rows of the stoichiometry matrix
-
getColumnReorderedNrMatrixIds
(self)[source]¶ Returns: The Nr Matrix row and column labels (repartitioned into NIC and NDC).
-
getConditionNumber
(self, matrix)[source]¶ Param: Takes a matrix (numpy) as an argument. Find the condition number of the matrix. Returns: The condition number
-
getConservedLaws
(self)[source]¶ Returns: Algebraic expressions for the conserved cycles. Returns empty if none.
-
getConservedSums
(self)[source]¶ Returns: Total mass for each conserved cycle in the model. The sum is based on the current initial conditions.
-
getEigenValues
(self, matrix)[source]¶ Param: Matrix to find the eigenvalues for. Returns: An array, first column are the real values and second column are imaginary values
-
getEigenVectors
(self, matrix)[source]¶ Param: Matrix to find the eigenvectors for Returns: An array where each columns is an eigenvector
-
getElementaryModesDouble
(self)[source]¶ Returns: An array where each column is an elementary mode (Generated from MetaTool)
-
getElementaryModesMetaToolRxnIds
(self)[source]¶ Returns: An array of reaction Ids corresponding with the columns of getElementaryModesMetaToolRxnIds() matrix.
-
getFullyReorderedN0StoichiometryMatrix
(self)[source]¶ Computes the N0 matrix if possible. The N0 matrix will contain all the dependent rows of the stoichiometry matrix.
Returns: The N0 Matrix.
-
getFullyReorderedNrMatrix
(self)[source]¶ The Nr matrix contains all the linearly independent rows of the stoichiometry matrix.
Returns: The Nr Matrix.
-
getFullyReorderedStoichiometryMatrix
(self)[source]¶ Returns: The fully reordered stoichiometry matrix. Rows and columns are reordered so all indepedent rows of the stoichiometry matrix are brought to the top and left side of the matrix.
-
getFullyReorderedStoichiometryMatrixIds
(self)[source]¶ Returns: The row and column labels for the reordered stoichiometry matrix (row reordered stoichiometry matrix)
-
getGammaMatrix
(self)[source]¶ Returns: Gamma, the conservation law array. Each row represents a single conservation law where the column indicates the participating molecular species. The number of rows is therefore equal to the number of conservation laws. Columns are ordered according to the rows in the reordered stoichiometry matrix, see
LibStructural.getReorderedSpeciesId
andLibStructural.getReorderedStoichiometryMatrix
.
-
getGammaMatrixGJ
(self, matrix)[source]¶ Param: The stoichiometry matrix that will be used to calculate gamma matrix. Returns: Gamma, the conservation law array. Each row represents a single conservation law where the column indicate the participating molecular species. The number of rows is therefore equal to the number of conservation laws. In this case the Gamma Matrix is recalculated for the given stoichiometry matrix. The column label will be the same label as the stoichiometry matrix.
-
getGammaMatrixIds
(self)[source]¶ Returns: The row and column labels for Gamma, the conservation law array.
-
static
getInstance
(self)[source]¶ static method to get an instance of LibStructural (allows use as singleton)
import structural ls = structural.LibStructural.getInstance()
-
getK0Matrix
(self)[source]¶ Returns: The K0 Matrix. K0 is defined such that K0 = -(NIC)-1* NDC, or equivalently, [NDC NIC][I K0]’ = 0 where [NDC NIC] = Nr
-
getKMatrix
(self)[source]¶ Returns: The K matrix (right nullspace of Nr) The K matrix has the structure, [I K0]’
-
getL0Matrix
(self)[source]¶ Returns: The L0 Matrix. L0 is defined such that L0*Nr = N0. L0 forms part of the link matrix, L. N0 is the set of linear dependent rows from the lower portion of the reordered stoichiometry matrix.
-
getLeftNullSpace
(self, matrix)[source]¶ Param: Matrix to find the left nullspace of. Returns: The Left Nullspace of the matrix argument.
-
getLinkMatrix
(self)[source]¶ Returns: L, the Link Matrix, left nullspace (aka nullspace of the transpose Nr). L will have the structure, [I L0]’, such that L*Nr = N
-
getModelName
(self)[source]¶ Returns: The name of the model if SBML model has Name-tag, otherwise it returns the SBML id. If only a stoichiometry matrix was loaded ‘untitled’ will be returned.
-
getN0Matrix
(self)[source]¶ Returns: The N0 Matrix. The N0 matrix is the set of linearly dependent rows of N where L0 Nr = N0.
-
getNrMatrix
(self)[source]¶ Returns: The Nr Matrix. The rows of the Nr matrix will be linearly independent.
-
getRConditionNumber
(self, matrix)[source]¶ Find the condition number of a matrix.
Param: A matrix as an argument. Returns: The condition number
-
getReorderedSpeciesIds
(self)[source]¶ Returns: The reordered list of molecular species (choosing the SBML Id if possible)
-
getReorderedStoichiometryMatrix
(self)[source]¶ Returns: The reordered stoichiometry matrix (row reordered stoichiometry matrix, columns are not reordered!)
-
getReorderedStoichiometryMatrixIds
(self)[source]¶ Returns: The row and column labels for the reordered stoichiometry matrix (row reordered stoichiometry matrix)
-
getRightNullSpace
(self, matrix)[source]¶ Param: Matrix to find the right nullspace of. Returns: The Right Nullspace of the matric argument.
-
getStoichiometryMatrixBoundary
(self)[source]¶ Returns: Unaltered stoichiometry matrix with boundary species included at the end.
-
getStoichiometryMatrixIds
(self)[source]¶ Returns: The row and column labels for the original and unaltered stoichiometry matrix.
-
getTolerance
(self)[source]¶ Returns: The currently used tolerance for deciding whether a small number is considered zero or not. This function returns the tolerance currently used by the library to determine what value is considered as zero. Any value with absolute value smaller than this tolerance is considered zero and will be neglected.
-
isReactionReversible
(self, *args)[source]¶ Param: Reaction index Returns: True if the reaction with given index is reversible Checks whether a given reaction is reversible or not.
-
loadReactionIdsWithValues
(self, id_array, value_array)[source]¶ Param: A vector of reaction ids to load Param: A vector of reaction rates This function should be used whenever labeled matrices are important as these labels will be used in labeling the structural matrices. This function sets the reaction ids. It is also possible to provide reaction rate values. This will be used when calculating the conserved sums.
Remarks: This method should only be called after
LibStructural.loadStoichiometryMatrix
.LibStructural.analyzeWithQR
should be called for the function to take effect.
-
loadSBMLFromFile
(self, SBMLfile)[source]¶ Param: An SBML file name to load Returns: Information about the loaded model Loads SBML model from the specified file.
-
loadSBMLFromString
(self, SBMLstring)[source]¶ Param: SBML string to load Returns: Information about the loaded model Loads SBML model from a string variable.
-
loadSBMLwithTests
(self, *args)[source]¶ Param: A file name to an SBML model to load Returns: Information about the loaded model and results of the internal test suite Loads an SBML model into the library and carries out tests using the internal test suite.
-
loadSpeciesIdsWithValues
(self, id_array, value_array)[source]¶ Param: A vector of species ids to load Param: A vector of initial concentrations Loads species names and initial values. This function should be used whenever labeled matrices are important as these labels will be used in labeling the structural matrices. This function sets the species ids. It is also possible to provide an initial condition for each of the species. This will be used when calculating the conserved sums.
Remarks: This method should only be called after
LibStructural.loadStoichiometryMatrix
.LibStructural.analyzeWithQR
should be called for the function to take effect.
-
loadStoichiometryMatrix
(self, Matrix)[source]¶ Param: 2D array stoichiometry matrix Loads a stoichiometry matrix into the library. To analyze the stoichiometry call one of the following:
LibStructural.analyzeWithQR
,LibStructural.analyzeWithLU
,LibStructural.analyzeWithLUandRunTests
,LibStructural.analyzeWithFullyPivotedLU
,LibStructural.analyzeWithFullyPivotedLUwithTests
,
-
rref
(self, matrix)[source]¶ Computes the reduced row echelon of the given matrix. Tolerance is set to indicate the smallest number consider to be zero.
Param: A matrix (numpy) Param: Optional: tolerance (float), default is 1E-6 Returns: A reduced row echelon form of the matrix
-
runElementaryModeTests
(self)[source]¶ Returns: A valididty test result of elementary modes generated from 31 models.
-
runLibstructTests
(self)[source]¶ Returns: A summary of test results on the integrity of structural methods.
-
saveElementaryModes
(self, csv_format=False)[source]¶ Returns: A directory path for the file generated
-
setTolerance
(self, *args)[source]¶ Param: An integer or a float Sets user specified tolerance. This function sets the tolerance used by the library to determine what value is considered as zero. Any value with absolute value smaller than this tolerance is considered as zero and will be neglected.
-
validateStructuralMatrices
(self)[source]¶ Validates structural matrices. Calling this method will run the internal test suite against the structural matrices. Those tests include:
Test 1 : Gamma*N = 0 (Zero matrix)Test 2 : Rank(N) using SVD (5) is same as m0 (5)Test 3 : Rank(NR) using SVD (5) is same as m0 (5)Test 4 : Rank(NR) using QR (5) is same as m0 (5)Test 5 : L0 obtained with QR matches Q21*inv(Q11)Test 6 : N*K = 0 (Zero matrix)Returns: A tuple of strings indicating whether a particular test passed or failed.
-