示例#1
0
def cellmlFileToAntimony(CellMLFileName):
    """Load a cellml file and return the
    equivalent antimony string:
    
    ant = cellMLToAntimony('mymodel.cellml')
    """
    if antimony.loadCellMLFile(CellMLFileName) == -1:
        raise Exception("Error calling loadCellMLFile")
    antimony.loadCellMLFile(CellMLFileName)
    return antimony.getAntimonyString(None)
示例#2
0
def cellmlStrToSBML(CellMLStr):
    """Convert a cellml string into the
    equivalent SBML string:
    
    sbmlStr = cellMLStrToSBML('mymodel.cellml')
    """
    if antimony.loadCellMLFile(CellMLStr) < 0:
        raise Exception("Error calling cellMLStrToSBML" + antimony.getLastError())
    return antimony.getSBMLString(None)
示例#3
0
def cellmlStrToAntimony(CellMLStr):
    """Convert a cellml string into the
    equivalent antimony string:
    
    ant = cellMLStrToAntimony('mymodel.cellml')
    """
    if antimony.loadCellMLFile(CellMLStr) < 0:
        raise Exception("Error calling cellMLStrToAntimony" + antimony.getLastError())
    return antimony.getAntimonyString(None)
示例#4
0
def cellmlFileToSBML(CellMLFileName):
    """Load a cellml file and return the
    equivalent SBML string:
    
    sbmlStr = cellMLToSBML('mymodel.cellml')
    """

    if antimony.loadCellMLFile(CellMLFileName) < 0:
        raise Exception("Error calling loadCellMLFile" + antimony.getLastError())
    return antimony.getSBMLString(None)
def cellmlToSBML(cellml):
    """ Convert CellML to SBML string.

    :param cellml: CellML string or file
    :type cellml: str | file
    :return: SBML
    :rtype: str
    """
    if os.path.isfile(cellml):
        code = antimony.loadCellMLFile(cellml)
    else:
        code = antimony.loadCellMLString(cellml)
    _checkAntimonyReturnCode(code)
    return antimony.getSBMLString(None)
示例#6
0
def cellmlToSBML(cellml):
    """ Convert CellML to SBML string.

    :param cellml: CellML string or file
    :type cellml: str | file
    :return: SBML
    :rtype: str
    """
    if os.path.isfile(cellml):
        code = antimony.loadCellMLFile(cellml)
    else:
        code = antimony.loadCellMLString(cellml)
    _checkAntimonyReturnCode(code)
    return antimony.getSBMLString(None)
示例#7
0
    def cellmlFileToAntimony(self, sbml_path):
        """ Converts a CellML file to Antimony source.

        :param sbml_path: The path to the CellML file
        :returns: A 2-tuple (module_name, antimony_source)
        """

        import antimony as sb
        # try to load the Antimony code`
        code = sb.loadCellMLFile(sbml_path)

        # if errors, bail
        if self.checkAntimonyReturnCode(code):
            errors = sb.getLastError()
            raise RuntimeError('Errors encountered when trying to load model:\n{}'.format(errors))

        module = sb.getMainModuleName()
        sb_source = sb.getAntimonyString(module)
        return (module, sb_source)
示例#8
0
    def cellmlFileToAntimony(self, sbml_path):
        """ Converts a CellML file to Antimony source.

        :param sbml_path: The path to the CellML file
        :returns: A 2-tuple (module_name, antimony_source)
        """

        import antimony as sb
        # try to load the Antimony code`
        code = sb.loadCellMLFile(sbml_path)

        # if errors, bail
        if self.checkAntimonyReturnCode(code):
            errors = sb.getLastError()
            raise RuntimeError('Errors encountered when trying to load model:\n{}'.format(errors))

        module = sb.getMainModuleName()
        sb_source = sb.getAntimonyString(module)
        return (module, sb_source)