def writeMod2SBML(self, mod, filename=None, directory=None, iValues=True, getdocument=False, getstrbuf=False): """ Writes a PySCeS model object to an SBML file. - *filename*: writes <filename>.xml or <model_name>.xml if None - *directory*: (optional) an output directory - *iValues*: if True then the models initial values are used (or the current values if False). - *getdocument*: if True an SBML document object is returned instead of writing to disk or - *getstrbuf*: if True a StringIO buffer is returned instead of writing to disk """ self.core = NewCore(mod, iValues=iValues) ## assert os.sys.platform != 'win32', '\nSBML translation currently only supported on Linux (Mac?)' assert self.core != None, "\nPlease set a PySCeS model or Core2 object" self.core2sbml = CoreToSBML(self.core) self.core2sbml.level = self.sbml_level self.core2sbml.version = self.sbml_version assert self.core2sbml.SBML != None, "\nProblems loading SBML/Python interface" self.__buildSbmlComponents__() if filename == None: filename = self.core.name if filename[-4:] != '.xml': filename += '.xml' if getdocument: return self.core2sbml.getSBMLdocument() elif getstrbuf: return self.core2sbml.getSBMLFileAsStrBuf() else: self.core2sbml.writeSBML2file(filename, directory)
def writeCore2SBML(self, filename=None, directory=None, getdocument=False): """ Writes Core2 object to an SBML file. - *filename*: writes <filename>.xml or <model_name>.xml if None - *directory*: (optional) an output directory - *getdocument*: if True an SBML document object is returned instead of writing to disk or """ assert self.core != None, "\nPlease set a PySCeS model or Core2 object" ## print 'Using existing self.core' self.core2sbml = CoreToSBML(self.core) self.core2sbml.level = self.sbml_level self.core2sbml.version = self.sbml_version assert self.core2sbml.SBML != None, "\nProblems loading SBML/Python interface" self.__buildSbmlComponents__() if filename == None: filename = self.core.name if filename[-4:] != '.xml': filename += '.xml' if not getdocument: self.core2sbml.writeSBML2file(filename, directory) else: return self.core2sbml.getSBMLdocument()