tellurium.utils package¶
Submodules¶
tellurium.utils.matrix module¶
Helpers for matrix operations.
- tellurium.utils.matrix.nullspace(A, atol=1e-13, rtol=0)[source]¶
Compute an approximate basis for the nullspace of A.
The algorithm used by this function is based on the singular value decomposition of A.
Parameters¶
- Andarray
A should be at most 2-D. A 1-D array with length k will be treated as a 2-D with shape (1, k)
- atolfloat
The absolute tolerance for a zero singular value. Singular values smaller than atol are considered to be zero.
- rtolfloat
The relative tolerance. Singular values less than rtol*smax are considered to be zero, where smax is the largest singular value.
If both atol and rtol are positive, the combined tolerance is the maximum of the two; that is:
tol = max(atol, rtol * smax)
Singular values smaller than tol are considered to be zero.
Return value¶
- nsndarray
If A is an array with shape (m, k), then ns will be an array with shape (k, n), where n is the estimated dimension of the nullspace of A. The columns of ns are a basis for the nullspace; each element in numpy.dot(A, ns) will be approximately zero.
- tellurium.utils.matrix.rank(A, atol=1e-13, rtol=0)[source]¶
Estimate the rank (i.e. the dimension of the columnspace) of a matrix.
The algorithm used by this function is based on the singular value decomposition of A.
Parameters¶
- Andarray
A should be at most 2-D. A 1-D array with length n will be treated as a 2-D with shape (1, n)
- atolfloat
The absolute tolerance for a zero singular value. Singular values smaller than atol are considered to be zero.
- rtolfloat
The relative tolerance. Singular values less than rtol*smax are considered to be zero, where smax is the largest singular value.
If both atol and rtol are positive, the combined tolerance is the maximum of the two; that is:
tol = max(atol, rtol * smax)
Singular values smaller than tol are considered to be zero.
Return value¶
- rint
The estimated rank of the matrix.
See also¶
- numpy.linalg.matrix_rank
matrix_rank is basically the same as this function, but it does not provide the option of the absolute tolerance.
tellurium.utils.misc module¶
- tellurium.utils.misc.deprecated(func)[source]¶
This is a decorator which can be used to mark functions as deprecated. It will result in a warning being emitted when the function is used.
- tellurium.utils.misc.getODEsFromModel(roadrunnerModel)[source]¶
Given a roadrunner instance this function returns a string of rules and ODEs
>>> r = te.loada ('S1 -> S2; k1*S1; k1=1') >>> te.getODEsFromModel (r)
- tellurium.utils.misc.getODEsFromSBMLFile(fileName)[source]¶
Given a SBML file name, this function returns the model as a string of rules and ODEs
>>> te.getODEsFromSBMLFile ('mymodel.xml')
- tellurium.utils.misc.getODEsFromSBMLString(sbmlStr)[source]¶
Given a SBML string this fucntion returns the model as a string of rules and ODEs
>>> te.getODEsFromSBMLString (sbmlStr)
- tellurium.utils.misc.listFiles(wildcardstr)[source]¶
List the files names in the current directory using the wildcard argument
eg te.listFiles (’*.xml’) :param wildcardstr: WIld card using during the file search :returns: list of file names that match the wildcard
- tellurium.utils.misc.readFromFile(filePath)[source]¶
Load a file and return contents as a string.
see also:
saveToFile()
- Parameters:
filePath – file path to read from
- Returns:
string representation of the contents of the file
- tellurium.utils.misc.runTool(toolFileName)[source]¶
Call an external application called toolFileName. Note that .exe extension may be omitted for windows applications.
Include any arguments in arguments parameter.
Example: returnString = te.runTool ([‘myplugin’, ‘arg1’, ‘arg2’])
If the external tool writes to stdout, this will be captured and returned.
- Parameters:
toolFileName – argument to external tool
- Returns:
String return by external tool, if any.
- tellurium.utils.misc.saveToFile(filePath, str)[source]¶
Save string to file.
see also:
readFromFile()
- Parameters:
filePath – file path to save to
str – string to save
tellurium.utils.omex module¶
COMBINE Archive helper functions and classes based on libcombine.
Here common operations with COMBINE archives are implemented, like extracting archives, creating archives from entries or directories, adding metadata, listing content of archives.
When working with COMBINE archives these wrapper functions should be used.
- class tellurium.utils.omex.Creator(givenName, familyName, organization, email)[source]¶
Bases:
object
Helper class to store the creator information.
- class tellurium.utils.omex.Entry(location, format=None, formatKey=None, master=False, description=None, creators=None)[source]¶
Bases:
object
Helper class to store content to create an OmexEntry.
- tellurium.utils.omex.addEntriesToCombineArchive(omexPath, entries, workingDir)[source]¶
Adds entries to
- Parameters:
omexPath –
entries – iteratable of Entry
workingDir – locations are relative to working dir
- Returns:
- tellurium.utils.omex.combineArchiveFromDirectory(directory, omexPath, creators=None, creators_for_all=False)[source]¶
Creates a COMBINE archive from a given folder.
The file types are inferred, in case of existing manifest or metadata information this should be reused.
For all SED-ML files in the directory the master attribute is set to True.
- Parameters:
directory –
omexPath –
:param :return:
- tellurium.utils.omex.combineArchiveFromEntries(omexPath, entries, workingDir)[source]¶
Creates combine archive from given entries.
Overwrites existing combine archive at omexPath.
- Parameters:
entries –
workingDir –
- Returns:
- tellurium.utils.omex.extractCombineArchive(omexPath, directory, method='zip')[source]¶
Extracts combine archive at given path to directory.
The zip method extracts all entries in the zip, the omex method only extracts the entries listed in the manifest. In some archives not all content is listed in the manifest.
- Parameters:
omexPath –
directory –
method – method to extract content, either ‘zip’ or ‘omex’
- Returns:
- tellurium.utils.omex.getLocationsByFormat(omexPath, formatKey=None, method='omex')[source]¶
Returns locations to files with given format in the archive.
Uses the libcombine KnownFormats for formatKey, e.g., ‘sed-ml’ or ‘sbml’. Files which have a master=True have higher priority and are listed first.
- Parameters:
omexPath –
formatKey –
method –
- Returns: