tellurium.teconverters package

Submodules

tellurium.teconverters.antimony_regex module

tellurium.teconverters.antimony_regex.getFunctionSBORegex()[source]

Return the regex string for a function SBO term. Matches whole line.

tellurium.teconverters.antimony_regex.getFunctionStartRegex()[source]

Return the regex string for Antimony model start. Matches whole line.

tellurium.teconverters.antimony_regex.getModelEndRegex()[source]

Return the regex string for Antimony model end. Matches whole line.

tellurium.teconverters.antimony_regex.getModelStartRegex()[source]

Return the regex string for Antimony model start. Matches whole line.

tellurium.teconverters.antimony_regex.getSBORegex()[source]

Return the regex string for an SBO term. Matches whole line.

tellurium.teconverters.antimony_sbo module

Helpers to work with SBO terms in antimony.

exception tellurium.teconverters.antimony_sbo.SBOError[source]

Bases: RuntimeError

class tellurium.teconverters.antimony_sbo.antimonySBOConverter(doc)[source]

Bases: object

convert(antimony_str)[source]

Add SBO terms to the Antimony string corresponding to this SBML document.

Parameters:

antimony_str – Antimony string. Should represent the same SBML this object was initialized with.

Returns:

The Antimony string with the SBO terms added.

createSBOTermStringForElt(elt)[source]
classmethod fromSBMLFile(sbml_file)[source]

Construct from SBML file.

classmethod fromSBMLString(sbml_str)[source]

Construct from SBML string.

getAllSBOTerms()[source]

Get a list of all SBO terms base on the SBML passed to the constructor.

getCompartmentSBOTerms()[source]
getParameterSBOTerms()[source]
getReactionSBOTerms()[source]
getSBOTermForElt(elt)[source]
getSpeciesSBOTerms()[source]
hasSBOTerm(elt)[source]
class tellurium.teconverters.antimony_sbo.antimonySBOParser(antimony_str)[source]

Bases: object

addSBOsToSBML(sbml_str)[source]

Add SBO terms to an SBML string. Must have called elideSBOTerms first to populate self.sbo_map.

elideSBOTerms()[source]

Remove SBO terms from self.antimony_str. Remove SBO terms for functions. See https://github.com/sys-bio/tellurium/issues/340.

Returns:

Antimony string without SBO terms.

tellurium.teconverters.antimony_sbo.filterIfEmpty(l)[source]

If l is one line (comment), filter.

tellurium.teconverters.convert_antimony module

class tellurium.teconverters.convert_antimony.antimonyConverter[source]

Bases: object

antimonyToSBML(sb_str, SBO=False)[source]

Converts an Antimony string to raw SBML.

Parameters:

sb_str – The raw Antimony string

Returns:

A 2-tuple (module_name, raw_sbml)

cellmlFileToAntimony(sbml_path)[source]

Converts a CellML file to Antimony source.

Parameters:

sbml_path – The path to the CellML file

Returns:

A 2-tuple (module_name, antimony_source)

checkAntimonyReturnCode(code)[source]

Negative return code (usu. -1) from Antimony signifies error

sbmlFileToAntimony(sbml_path, addSBO=False)[source]

Converts a SBML file to Antimony source.

Parameters:

sbml_path – The path to the SBML file

Returns:

A 2-tuple (module_name, antimony_source)

sbmlToAntimony(sbml, addSBO=False)[source]

Converts a raw SBML string to Antimony source.

Parameters:

sbml – The raw SBML string

Returns:

A 2-tuple (module_name, antimony_source)

tryAddSBOTerms(antimony_str, sbml_file=None, sbml_str=None)[source]

Attempt to add SBO terms to the Antimony model. You must supply one of either sbml_file or sbml_str, not both. This method will return the original Antimony string if SBO terms cannot be added.

tellurium.teconverters.convert_omex module

Class for working with omex files.

class tellurium.teconverters.convert_omex.Omex(description='', creator=None)[source]

Bases: object

Wrapper for Combine archives.

addSbmlAsset(asset)[source]
addSedmlAsset(asset)[source]
executeOmex()[source]

Executes this Omex instance.

Returns:

exportToCombine(outfile)[source]

Export Omex instance as combine archive.

Parameters:

outfile – A path to the output file

getSbmlAssets()[source]
getSedmlAssets()[source]
writeFiles(dir)[source]
class tellurium.teconverters.convert_omex.OmexAsset[source]

Bases: object

getContent()[source]
getFileName()[source]
getLocation()[source]
getMaster()[source]
class tellurium.teconverters.convert_omex.OmexFormatDetector(omex)[source]

Bases: object

isSBMLEntry(entry)[source]

Return true if this entry is SBML.

isSEDMLEntry(entry)[source]
class tellurium.teconverters.convert_omex.SbmlAsset(location, content, master=False)[source]

Bases: OmexAsset

getModuleName()[source]
class tellurium.teconverters.convert_omex.SedmlAsset(location, content, master=False)[source]

Bases: OmexAsset

class tellurium.teconverters.convert_omex.inlineOmexImporter(omex)[source]

Bases: object

BioModHackRemoveDuplicates()[source]

A hack to remove duplicates (urn/url) in BioModels archives.

containsSBMLOnly()[source]

Return true if this is a SBML-only archive (no SED-ML).

fixExt(path)[source]

Ensures all extensions are .xml.

fixSep(path)[source]

Converts Windows-style separators to Unix separators.

formatPhrasedmlResource(path)[source]

Normalizes path, strips xml extension, and normalizes fs separator.

classmethod fromFile(path)[source]

Initialize from a combine archive.

Parameters:

path – The path to the omex file

getEntries()[source]
isInRootDir(path)[source]

Returns true if path specififies a root location like ./file.ext.

makeFooter(entry, type)[source]

Makes a header for an entry.

Parameters:
  • entry – Entry in Combine archive (class CaContent)

  • type – Can be ‘sbml’ or ‘sedml’

makeHeader(entry, type)[source]

Makes a header for an entry.

Parameters:
  • entry – Entry in Combine archive (class CaContent)

  • type – Can be ‘sbml’ or ‘sedml’

makeSBMLResourceMap(relative_to=None)[source]
normalizePath(path)[source]
numEntries()[source]
numSBMLEntries()[source]
toInlineOmex(detailedErrors=True)[source]

Converts a COMBINE archive into an inline phrasedml / antimony string.

Returns:

A string with the inline phrasedml / antimony source

tellurium.teconverters.convert_omex.readCreator(file=None)[source]

tellurium.teconverters.convert_phrasedml module

class tellurium.teconverters.convert_phrasedml.phrasedmlImporter(sbml_map={})[source]

Bases: object

fixModelRefs(phrasedml_str)[source]

Changes all references of type myModel.xml to myModel.

formatResource(filename)[source]

Normalizes and also strips xml extension.

classmethod fromContent(sedml_str, sbml_map={})[source]
isInRootDir(file)[source]
removeFileExt(filename)[source]
toPhrasedml()[source]

tellurium.teconverters.inline_omex module

Working with inline omex. This is used in the notebook to provide functionality to the cells.

class tellurium.teconverters.inline_omex.inlineOmex(sources)[source]

Bases: object

executeOmex()[source]

Executes the archive.

exportToCombine(outpath)[source]

Exports the archive to file.

classmethod fromString(omex_str, comp=False)[source]

Given mixed Antimony/PhraSEDML, separates out the constituent parts. Assumes that Antimony and PhraSEDML are not mixed on the same line.

Parameters:

instr – The input string containing mixed Antimony/PhraSEDML

Returns:

2-tuple containing a list of Antimony parts and a list of PhraSEDML parts as strings

tellurium.teconverters.inline_omex.parseMagicArgs(line)[source]
tellurium.teconverters.inline_omex.saveInlineOMEX(omex_str, out_path)[source]

Saves an inline omex string to a file.

Parameters:
  • omex_str (str) – The inline omex string

  • out_path (str) – Path to the output file

Module contents