Exemplo n.º 1
0
    def toXMLString(self, enzmldoc):
        '''
        Converts EnzymeMLDocument to XML string.
        
        Args:
            EnzymeMLDocument enzmldoc: Previously created instance of an EnzymeML document
        '''
        doc = SBMLDocument()
        doc.setLevelAndVersion(enzmldoc.getLevel(), enzmldoc.getVersion())

        model = doc.createModel()
        model.setName(enzmldoc.getName())
        model.setId(enzmldoc.getName())

        # Add references
        self.__addRefs(model, enzmldoc)

        # Add units
        self.__addUnits(model, enzmldoc)

        # Add Vessel
        self.__addVessel(model, enzmldoc)

        # Add protein
        self.__addProteins(model, enzmldoc)

        # Add reactants
        self.__addReactants(model, enzmldoc)

        # Add reactions
        self.__addReactions(model, enzmldoc, csv=False)

        # Write to EnzymeML
        writer = SBMLWriter()
        return writer.writeToString(doc)
Exemplo n.º 2
0
    def toSBML(self, enzmldoc):
        '''
        Returns libSBML model.
        
        Args:
            EnzymeMLDocument enzmldoc: Previously created instance of an EnzymeML document
        '''

        doc = SBMLDocument()
        doc.setLevelAndVersion(enzmldoc.getLevel(), enzmldoc.getVersion())

        model = doc.createModel()
        model.setName(enzmldoc.getName())
        model.setId(enzmldoc.getName())

        # Add references
        self.__addRefs(model, enzmldoc)

        # Add units
        self.__addUnits(model, enzmldoc)

        # Add Vessel
        self.__addVessel(model, enzmldoc)

        # Add protein
        self.__addProteins(model, enzmldoc)

        # Add reactants
        self.__addReactants(model, enzmldoc)

        # Add reactions
        self.__addReactions(model, enzmldoc, csv=False)

        return doc
Exemplo n.º 3
0
    def toFile(self, enzmldoc, path):
        '''
        Writes EnzymeMLDocument object to an .omex container
        
        Args:
            EnzymeMLDocument enzmldoc: Previously created instance of an EnzymeML document
            String path: EnzymeML file is written to this destination
        '''

        self.path = path + '/' + enzmldoc.getName()

        try:
            os.makedirs(self.path + '/data')
        except FileExistsError:
            pass

        doc = SBMLDocument()
        doc.setLevelAndVersion(enzmldoc.getLevel(), enzmldoc.getVersion())

        model = doc.createModel()
        model.setName(enzmldoc.getName())
        model.setId(enzmldoc.getName())

        # Add references
        self.__addRefs(model, enzmldoc)

        # Add units
        self.__addUnits(model, enzmldoc)

        # Add Vessel
        self.__addVessel(model, enzmldoc)

        # Add protein
        self.__addProteins(model, enzmldoc)

        # Add reactants
        self.__addReactants(model, enzmldoc)

        # Add reactions
        self.__addReactions(model, enzmldoc)

        # Write to EnzymeML
        writer = SBMLWriter()
        writer.writeSBMLToFile(doc, self.path + '/experiment.xml')

        # Write to OMEX
        self.__createArchive(enzmldoc, doc)

        os.remove(self.path + '/experiment.xml')
        os.remove(self.path + '/data/data.csv')
        os.rmdir(self.path + '/data')