Esempio n. 1
0
    def addSmallMolToXml( self, parsedSmallMol, xmlElement ):
        smallMolElt = XmlObject("small-mol")
        smallMolElt.addAttribute( "name", parsedSmallMol.getName() )

        smallMolElt.attachToParent( xmlElement)

        return smallMolElt
Esempio n. 2
0
    def writeParsedLineAsXmlMol(self, parsedLine, xmlobject):
        parsedComplex = parsedLine.getParsedComponents()[0]
        assert (len(parsedComplex.getMols()) == 1)

        parsedMol = parsedComplex.getMols()[0]

        newMolElement = 0
        if parsedMol.isSmallMol():
            newMolElement = self.addSmallMolToXml(parsedMol, xmlobject)
        else:
            newMolElement = self.addModMolToXml(parsedMol, xmlobject)

        # Now add the mass element to the thing.

        mass = 0.0

        if (parsedLine.hasAssignment("mass")):
            mass = parsedLine.getAssignment("mass")
        elif self.getTranslationLevel == self.STRICT:
            raise Exception()

        weightElmt = XmlObject("weight")
        weightElmt.addAttribute("daltons", mass)

        newMolElement.addSubElement(weightElmt)
Esempio n. 3
0
    def writeParsedLineAsXmlMol(self, parsedLine, xmlobject):
        parsedComplex = parsedLine.getParsedComponents()[0]
        assert( len( parsedComplex.getMols() ) == 1)

        parsedMol = parsedComplex.getMols()[0]

        newMolElement = 0
        if parsedMol.isSmallMol():
            newMolElement = self.addSmallMolToXml( parsedMol, xmlobject )
        else:
            newMolElement = self.addModMolToXml( parsedMol, xmlobject)


        # Now add the mass element to the thing.

        mass = 0.0

        if ( parsedLine.hasAssignment("mass") ):
            mass = parsedLine.getAssignment("mass")
        elif self.getTranslationLevel == self.STRICT:
            raise Exception()

        
        weightElmt = XmlObject("weight")
        weightElmt.addAttribute("daltons", mass)

        newMolElement.addSubElement( weightElmt )
Esempio n. 4
0
    def writeOmniGenLineToParent(self, line, parElmt):
        omniGenElment = XmlObject("omni-gen", parElmt)

        reaction = line.getParsedComponents()[0]

        enablingOmniplex = reaction.getReactants()[0]
        additionalReactant = 0
        if len(reaction.getReactants()) > 1:
            additionalReactant = reaction.getReactants()[1]

        product = reaction.getProducts()[0]
        additionalProduct = 0
        if len(reaction.getProducts()) > 1:
            additionalProduct = reaction.getProducts()[1]

        self.__writeEnablingOmniPlexElementToXml(enablingOmniplex,
                                                 omniGenElment)

        self.__writeModificationExchanges(reaction, omniGenElment)
        self.__writeSmallMolExchange(reaction, omniGenElment)

        rateElmt = XmlObject("rate", omniGenElment)
        rateElmt.addAttribute("value", line.getAssignment("k"))

        return
Esempio n. 5
0
    def __writeSmallMolExchange(self, reaction, parElmt):
        smallMolExchangesElmt = XmlObject("small-mol-exchanges", parElmt)

        reactant_omniplex = reaction.getReactants()[0]
        product_omniplex = reaction.getProducts()[0]

        assert (len(reactant_omniplex.getMols()) == len(
            product_omniplex.getMols()))
        for ndx in range(len(reactant_omniplex.getMols())):
            if reactant_omniplex.getMols()[ndx].getName(
            ) != product_omniplex.getMols()[ndx].getName():
                assert (reactant_omniplex.getMols()[ndx].isSmallMol())

                smallMolExchangeElmt = XmlObject("small-mol-exchage",
                                                 smallMolExchangesElmt)

                smallMolInstRef = XmlObject("small-mol-instance-ref",
                                            smallMolExchangeElmt)
                smallMolRef = XmlObject("small-mol-ref", smallMolExchangeElmt)

                smallMolInstRef.addAttribute(
                    "name",
                    self.getMolName(reactant_omniplex.getMols()[ndx].getName(),
                                    ndx))
                smallMolRef.addAttribute(
                    "name",
                    product_omniplex.getMols()[ndx].getName())

        return
    def writeSpeciesStreamLineToParent( self, line, parentElmt):
        omniSpeciesStreamElmt = XmlObject("omni-species-stream", parentElmt)
        omniSpeciesStreamElmt.addAttribute("name", line.getAssignment("name"))

        self.writeParsedComplexAsPlex( line.getParsedComponents()[0], omniSpeciesStreamElmt)
        
        return
    def writeExplicitSpeciesLineToXml( self, parsedLine, parentObject):
        parsedComplex = parsedLine.getParsedComponents()[0]
        name = parsedLine.getAssignment("name")

        plexSpeciesElmt = XmlObject( "plex-species", parentObject)
        plexSpeciesElmt.addAttribute( "name", name)

        self.writeParsedComplexAsPlex( parsedComplex, plexSpeciesElmt, writeComplexInstanceStates = True)
Esempio n. 8
0
    def writeSpeciesStreamLineToParent(self, line, parentElmt):
        omniSpeciesStreamElmt = XmlObject("omni-species-stream", parentElmt)
        omniSpeciesStreamElmt.addAttribute("name", line.getAssignment("name"))

        self.writeParsedComplexAsPlex(line.getParsedComponents()[0],
                                      omniSpeciesStreamElmt)

        return
    def writeExplicitSpeciesLineToXml(self, parsedLine, parentObject):
        parsedComplex = parsedLine.getParsedComponents()[0]
        name = parsedLine.getAssignment("name")

        plexSpeciesElmt = XmlObject("plex-species", parentObject)
        plexSpeciesElmt.addAttribute("name", name)

        self.writeParsedComplexAsPlex(parsedComplex, plexSpeciesElmt)
    def writeAllostericSitesElementToElement( self, parsedComplex, parentElement):
        allostericSitesElmt = XmlObject("allosteric-sites", parentElement)

        for ndx in range(len(parsedComplex.getMols())):
            mol = parsedComplex.getMols()[ndx]
            if mol.isSmallMol():
                continue

#             [x for x in mol.getBindingSites() \
#                  if x.hasBindingSiteSpecification() and \
#                  x.getBindingSiteSpecification().hasShapeSpecification()  and \
#                  x.getBindingSiteSpecification().getShapeSpecification().isTransformation() ]:
            
            for bndSiteWithTrans in [x for x in mol.getBindingSites() \
                                         if x.hasBindingSiteSpecification() and \
                                         x.getBindingSiteSpecification().hasShapeSpecification()  and \
                                         x.getBindingSiteSpecification().getShapeSpecification().isTransformation() ]:


                transformation = \
                    bndSiteWithTrans.getBindingSiteSpecification().getShapeSpecification().getTransformation()
                
                molElmt = XmlObject("mol-instance-ref", allostericSitesElmt)
                molElmt.addAttribute("name", self.getMolName( mol.getName(), ndx) )

                bindingRefElmt = XmlObject( "binding-site-ref", molElmt)
                bindingRefElmt.addAttribute( "name", bndSiteWithTrans.getName() )
                
                siteShapeRefElmt = XmlObject( "site-shape-ref", bindingRefElmt )
                siteShapeRefElmt.addAttribute( "name", transformation )
Esempio n. 11
0
    def addModifications(self, parentElmt):
        for modification in self.getUniversalModificationList():
            modificationTypeElmt = XmlObject("modification")
            modificationTypeElmt.addAttribute("name", modification)
            modificationTypeElmt.attachToParent(parentElmt)            

            weightElmt = XmlObject("weight-delta")
            weightElmt.attachToParent(modificationTypeElmt)

            if self.representsNullModification(modification):
                weightDelta = 0.0
            else:
                weightDelta = 1.0

            weightElmt.addAttribute("daltons", weightDelta)
Esempio n. 12
0
    def __writeModMolInstanceToInstanceStates(self, parsedMol, molNdx, parentElmt):
        modMolInstanceRefElmt = XmlObject("mod-mol-instance-ref", parentElmt)
        modMolInstanceRefElmt.addAttribute("name", self.getMolName( parsedMol.getName(), molNdx))

        modMapElmt = XmlObject("mod-map", modMolInstanceRefElmt)
        
        for modSite in parsedMol.getModificationSites():
            modSiteRefElmt = XmlObject("mod-site-ref", modMapElmt)
            modSiteRefElmt.addAttribute("name", modSite.getName())

            modRefElmt = XmlObject("mod-ref", modSiteRefElmt)
            modRefElmt.addAttribute("name", modSite.getModificationSiteSpecification().getList()[0])
Esempio n. 13
0
    def __addSpeciesStreams(self, parentObject):

        speciesStreamsElement = XmlObject("species-streams", parentObject)

        if self.speciesStreamSection:
            self.speciesStreamSection.writeSpeciesStreamSection(
                speciesStreamsElement)
Esempio n. 14
0
    def __addReactionGens(self, parentObject):
        reactionGenElmt = XmlObject("reaction-gens", parentObject)

        if self.reactionGensSection:
            self.reactionGensSection.writeReactionGensSection(reactionGenElmt)

        return
Esempio n. 15
0
    def __addMols(self, parentObject):
        molsSection = XmlObject("mols", parentObject)

        if self.molsSection:
            self.molsSection.writeMolsSection(molsSection)

        return
Esempio n. 16
0
    def writeModificationToXml(self, modLine, modsElmt):

        modElmt = XmlObject("modification", modsElmt)
        modElmt.addAttribute("name", modLine.getAssignment("name"))

        weightDeltaElmt = XmlObject("weight-delta", modElmt)
        weightDeltaElmt.addAttribute("daltons", modLine.getAssignment("mass"))

        return
Esempio n. 17
0
    def __addAllostericOmnis(self, parentObject):
        allostericOmnis = XmlObject("allosteric-omnis", parentObject)

        if self.allostericOmnisSection:
            self.allostericOmnisSection.writeAllostericOmnisSection(
                allostericOmnis)

        return
Esempio n. 18
0
    def __addAllostericPlexes(self, parentObject):
        allostericPlexes = XmlObject("allosteric-plexes", parentObject)

        if self.allostericPlexesSection:
            self.allostericPlexesSection.writeAllostericPlexesSection(
                allostericPlexes)

        return
Esempio n. 19
0
    def __addModifications(self, parentObject):
        # Write me!!!
        modificationsSection = XmlObject("modifications", parentObject)

        if self.modificationsSection:
            self.modificationsSection.writeModificationsSections(
                modificationsSection)
        return
Esempio n. 20
0
    def __addExplicitSpecies(self, parentObject):
        explicitSpeciesElmt = XmlObject("explicit-species", parentObject)

        if self.explicitSpeciesSection:
            self.explicitSpeciesSection.writeExplicitSpeciesSection(
                explicitSpeciesElmt)

        return
Esempio n. 21
0
    def writeAllostericPlexLineToXml(self, lineToWrite, xmlobject):
        alloPlexElmt = XmlObject("allosteric-plex", xmlobject)

        self.writeParsedComplexAsPlex(lineToWrite.getParsedComponents()[0],
                                      alloPlexElmt)
        self.writeAllostericSitesElementToElement(
            lineToWrite.getParsedComponents()[0], alloPlexElmt)

        return
Esempio n. 22
0
    def __writeEnablingOmniPlexElementToXml(self, omniplex, omniGenElment):
        enablingOmniplex = XmlObject("enabling-omniplex", omniGenElment)

        self.writeParsedComplexAsPlex(omniplex, enablingOmniplex)

        # We shouldn't always parse this, is this ok?
        self.__writeInstanceStateToXml(omniplex, enablingOmniplex)

        return enablingOmniplex
Esempio n. 23
0
    def __constructXMLRepresentation(self):
        
        rootNode = XmlObject("moleculizer-input")
        modelElmt = XmlObject("model")
        modelElmt.attachToParent(rootNode)

        streamsElmt = XmlObject("streams", rootNode)

        self.__addModifications( modelElmt )

        self.__addMols( modelElmt )
        self.__addAllostericPlexes( modelElmt )
        self.__addAllostericOmnis( modelElmt )
        self.__addReactionGens( modelElmt )
        self.__addExplicitSpecies( modelElmt )
        self.__addExplicitReactions( modelElmt )

        self.__addSpeciesStreams( streamsElmt )

        return rootNode
Esempio n. 24
0
    def addSmallMolToXml(self, parsedSmallMol, xmlElement):
        smallMolElt = XmlObject("small-mol")
        smallMolElt.addAttribute("name", parsedSmallMol.getName())

        smallMolElt.attachToParent(xmlElement)

        return smallMolElt
Esempio n. 25
0
    def writeOmniGenLineToParent(self, line, parElmt):
        omniGenElment = XmlObject("omni-gen", parElmt)

        reaction = line.getParsedComponents()[0]
        
        enablingOmniplex = reaction.getReactants()[0]
        additionalReactant = 0
        if len(reaction.getReactants()) > 1:
            additionalReactant = reaction.getReactants()[1]

        product = reaction.getProducts()[0]
        additionalProduct = 0
        if len(reaction.getProducts()) > 1:
            additionalProduct = reaction.getProducts()[1]

        self.__writeEnablingOmniPlexElementToXml(enablingOmniplex, omniGenElment)

        self.__writeModificationExchanges( reaction, omniGenElment)
        self.__writeSmallMolExchange( reaction, omniGenElment)

        rateElmt = XmlObject("rate", omniGenElment)
        rateElmt.addAttribute("value", line.getAssignment("k"))
        
        return
Esempio n. 26
0
    def writeParsedComplexInstanceStates(self, complex, xmlobject):
        # This is quite inelegant, but I can't obviously think of a
        # better way to do it.

        for mol_ndx, parsed_mol in enumerate(complex.getMols()):
            if not parsed_mol.isModMol():
                continue

            if not parsed_mol.getModificationSiteList():
                continue
            break
        else:
            # If we get 
            return 
        
        instanceStatesElmt = XmlObject("instance-states", xmlobject)
        # For each mol in complex which is a mod map that has modifications specified
        for mol_ndx, parsed_mol in enumerate(complex.getMols()):
            if not parsed_mol.isModMol():
                continue

            if not parsed_mol.getModificationSiteList():
                continue
            
            modMolInstanceRef = XmlObject("mod-mol-instance-ref", instanceStatesElmt)
            modMolInstanceRef.addAttribute( "name", self.getMolName( parsed_mol.getName(), mol_ndx ))

            modMapElmt = XmlObject("mod-map", modMolInstanceRef)

            for modification in parsed_mol.getModificationSites():
                modSiteRefNameElmt = XmlObject("mod-site-ref", modMapElmt)
                modSiteRefNameElmt.addAttribute("name", modification.getName())

                modRefElmt = XmlObject("mod-ref", modSiteRefNameElmt)

                modState = modification.getModificationSiteSpecification().getList()[0]

                modRefElmt.addAttribute("name", modState)

        return 
Esempio n. 27
0
    def __constructXMLRepresentation(self):
        rootNode = XmlObject("moleculizer-input")
        modelElmt = XmlObject("model")
        modelElmt.attachToParent(rootNode)

        self.__addModifications(modelElmt)
        self.__addMols(modelElmt)
        self.__addAllostericPlexes(modelElmt)
        self.__addAllostericOmnis(modelElmt)
        self.__addReactionGens(modelElmt)
        self.__addExplicitSpecies(modelElmt)
        self.__addExplicitReactions(modelElmt)
        self.__addVolume(modelElmt)

        # This adds the streams and events elements.
        if self.streamsAndEventsFile:
            rootNode.addSubFile(self.streamsAndEventsFile)

        return rootNode
Esempio n. 28
0
    def __writeModificationExchanges( self, reaction, parElmt):
        modExchanges = XmlObject("modification-exchanges", parElmt)

        omniplex = reaction.getProducts()[0]

        for ndx in range(len(omniplex.getMols())):
            mol = omniplex.getMols()[ndx]
            if mol.isSmallMol():
                continue

            for mod_site in mol.getModificationSites():
                modExchange = XmlObject("modification-exchange", modExchanges)
                modMolInstance = XmlObject("mod-mol-instance-ref", modExchange)

                modMolInstance.addAttribute("name", self.getMolName( mol.getName(), ndx))
                
                modSiteRefElmt = XmlObject("mod-site-ref", modMolInstance)
                modSiteRefElmt.addAttribute("name", mod_site.getName())

                installedModRefElmt = XmlObject("installed-mod-ref", modExchange)
                installedModRefElmt.addAttribute("name", mod_site.getModificationSiteSpecification().getList()[0])
                    
        return 
Esempio n. 29
0
    def __writeInstanceStateToXml(self, omniplex, enablingOmniplexElmt):
        written_instance_states = False
        instStatesElmt = 0

        for ndx in range(len(omniplex.getMols())):
            mol = omniplex.getMols()[ndx]

            if mol.isSmallMol():
                continue

            for modSite in mol.getModificationSites():
                if modSite.hasModificationSiteSpecification(
                ) and modSite.getModificationSiteSpecification().isList():
                    if not written_instance_states:
                        instStatesElmt = XmlObject("instance-states",
                                                   enablingOmniplexElmt)
                        written_instance_states = True
                self.__writeModMolInstanceToInstanceStates(
                    mol, ndx, instStatesElmt)
Esempio n. 30
0
    def writeUnboundStates(self, complex, patternMatchingSitesSpec, xmlobject):
        unboundPatterns = [x for x in patternMatchingSitesSpec if x[2] == "-"]

        unboundSectionElmt = XmlObject("unbound-sites", xmlobject)

        for pattern in unboundPatterns:
            mol_ndx, site_ndx = pattern[0], pattern[1]
            instanceRef = XmlObject("instance-ref", unboundSectionElmt)
            instanceRef.addAttribute("name", \
                                     self.getMolName(complex.getMols()[mol_ndx].getName(), \
                                                     mol_ndx))

            siteRef = XmlObject("site-ref", instanceRef)
            siteRef.addAttribute("name", pattern[1])        
        return 
Esempio n. 31
0
    def __constructXMLRepresentation(self):
        rootNode = XmlObject("moleculizer-input")
        modelElmt = XmlObject("model")
        modelElmt.attachToParent(rootNode)

        self.__addModifications( modelElmt )
        self.__addMols( modelElmt )
        self.__addAllostericPlexes( modelElmt )
        self.__addAllostericOmnis( modelElmt )
        self.__addReactionGens( modelElmt )
        self.__addExplicitSpecies( modelElmt )
        self.__addExplicitReactions( modelElmt )
        self.__addVolume( modelElmt )

        # This adds the streams and events elements.
        if self.streamsAndEventsFile:
            rootNode.addSubFile(self.streamsAndEventsFile)

        return rootNode
Esempio n. 32
0
    def __writeSmallMolExchange(self, reaction, parElmt):
        smallMolExchangesElmt = XmlObject("small-mol-exchanges", parElmt)

        reactant_omniplex = reaction.getReactants()[0]
        product_omniplex = reaction.getProducts()[0]

        assert(len(reactant_omniplex.getMols()) == len(product_omniplex.getMols()))
        for ndx in range(len(reactant_omniplex.getMols())):
            if reactant_omniplex.getMols()[ndx].getName() != product_omniplex.getMols()[ndx].getName():
                assert( reactant_omniplex.getMols()[ndx].isSmallMol() )

                smallMolExchangeElmt = XmlObject("small-mol-exchage", smallMolExchangesElmt)

                smallMolInstRef = XmlObject("small-mol-instance-ref", smallMolExchangeElmt)
                smallMolRef = XmlObject("small-mol-ref", smallMolExchangeElmt)

                smallMolInstRef.addAttribute("name", self.getMolName(reactant_omniplex.getMols()[ndx].getName(), ndx))
                smallMolRef.addAttribute("name", product_omniplex.getMols()[ndx].getName() )
    
        return
Esempio n. 33
0
    def __constructXMLRepresentation(self):

        rootNode = XmlObject("moleculizer-input")
        modelElmt = XmlObject("model")
        modelElmt.attachToParent(rootNode)

        streamsElmt = XmlObject("streams", rootNode)

        self.__addModifications(modelElmt)

        self.__addMols(modelElmt)
        self.__addAllostericPlexes(modelElmt)
        self.__addAllostericOmnis(modelElmt)
        self.__addReactionGens(modelElmt)
        self.__addExplicitSpecies(modelElmt)
        self.__addExplicitReactions(modelElmt)

        self.__addSpeciesStreams(streamsElmt)

        return rootNode
Esempio n. 34
0
    def __writeModificationExchanges(self, reaction, parElmt):
        modExchanges = XmlObject("modification-exchanges", parElmt)

        omniplex = reaction.getProducts()[0]

        for ndx in range(len(omniplex.getMols())):
            mol = omniplex.getMols()[ndx]
            if mol.isSmallMol():
                continue

            for mod_site in mol.getModificationSites():
                modExchange = XmlObject("modification-exchange", modExchanges)
                modMolInstance = XmlObject("mod-mol-instance-ref", modExchange)

                modMolInstance.addAttribute(
                    "name", self.getMolName(mol.getName(), ndx))

                modSiteRefElmt = XmlObject("mod-site-ref", modMolInstance)
                modSiteRefElmt.addAttribute("name", mod_site.getName())

                installedModRefElmt = XmlObject("installed-mod-ref",
                                                modExchange)
                installedModRefElmt.addAttribute(
                    "name",
                    mod_site.getModificationSiteSpecification().getList()[0])

        return
Esempio n. 35
0
    def addAllostericOmnis(self, allostericOmnisElement):
        # pdb.set_trace()
        for bindingWithAllostery in self.allosteryMapping.keys():
            owningMolName, allostericBindingSiteName = bindingWithAllostery
            complexAllosteryPairs = [
                (key, self.allosteryMapping[bindingWithAllostery][key])
                for key in self.allosteryMapping[bindingWithAllostery].keys()
            ]
            for complex_allostery_pair in complexAllosteryPairs:
                complex, allostericName = complex_allostery_pair
                if allostericName == "default":
                    continue

                allostericOmniElmt = XmlObject("allosteric-omni")
                allostericOmnisElement.addSubElement(allostericOmniElmt)

                # Now prepare the four sub-elements
                plexElmt = XmlObject("plex")
                instanceStatesElmt = XmlObject("instance-states")
                unboundSitesElmt = XmlObject("unbound-sites")
                boundSitesElmt = XmlObject("bound-sites")
                allostericStatesElmt = XmlObject("allosteric-sites")

                # First we construct the molRefToInstanceDict
                molRefToInstanceDict = {}
                tmpMolInstanceInt = {}

                molArray = complex.split(".")

                for molNdx in xrange(len(molArray)):
                    mol = molArray[molNdx]
                    parenNdx = mol.find("(")
                    molType = mol[:parenNdx]

                    if molType not in tmpMolInstanceInt:
                        tmpMolInstanceInt[molType] = 1
                        molInstance = "the-" + molType
                    else:
                        molInstance = molType + "-" + str(tmpMolInstanceInt[molType])
                        tmpMolInstanceInt[molType] = tmpMolInstanceInt[molType] + 1

                    molRefToInstanceDict[molInstance] = molType
                    molArray[molNdx] = molInstance + mol[parenNdx:]

                # So now we calculate -- the plex.
                bindingDict = {}
                genericBoundSitesArray = []
                unboundSitesArray = []
                modificationSitesArray = []
                for molSpec in molArray:
                    # Process the molNames
                    molInstance = util.getMolNameFromFullMolSpec(molSpec)
                    molInstanceElmt = XmlObject("mol-instance")
                    molInstanceElmt.addAttribute("name", molInstance)
                    molRefElmt = XmlObject("mol-ref")
                    molRefElmt.addAttribute("name", molRefToInstanceDict[molInstance])
                    molRefElmt.attachToParent(molInstanceElmt).attachToParent(plexElmt)

                    # Collect the bindings
                    bindingSites = util.getBindingSites(molSpec)

                    explicitlyBoundBindingSites = [
                        x.split("!") for x in bindingSites if ("!" in x and x[-1] != "!" and x[-1] != "+")
                    ]
                    boundBindingSites = [
                        x.split("!") for x in bindingSites if ("!" in x and x[-1] != "!" and x[-1] == "+")
                    ]
                    unboundBindingSites = [x for x in bindingSites if "!" not in x]

                    modificationSites = [x.split("~") for x in util.getModificationList(molSpec)]

                    for halfBinding in explicitlyBoundBindingSites:
                        bindingSite, bindingNdx = halfBinding[0], int(halfBinding[1])
                        if not bindingNdx in bindingDict:
                            bindingDict[bindingNdx] = []
                        bindingDict[bindingNdx].append((molInstance, bindingSite))

                    # Collect the unbound binding sites.
                    for unboundBindingSite in unboundBindingSites:
                        unboundSitesArray.append((molInstance, unboundBindingSite))

                    for boundSite in boundBindingSites:
                        genericBoundSitesArray.append((molInstance, boundSite[0]))

                    for modificationSite in modificationSites:
                        modificationSitesArray.append((molInstance, modificationSite[0], modificationSite[1]))

                # Do the bindings
                listOfBindings = [bindingDict[key] for key in bindingDict.keys()]

                for binding in listOfBindings:
                    try:
                        assert len(binding) == 2
                    except:
                        pdb.set_trace()
                        a = 1
                for binding in listOfBindings:
                    bindingElmt = XmlObject("binding")
                    bindingElmt.attachToParent(plexElmt)
                    for halfBinding in binding:
                        molInstance, bindingRef = halfBinding
                        molInstanceRefElmt = XmlObject("mol-instance-ref")
                        molInstanceRefElmt.addAttribute("name", molInstance)
                        bindingSiteRefElmt = XmlObject("binding-site-ref")
                        bindingSiteRefElmt.addAttribute("name", bindingRef)
                        bindingSiteRefElmt.attachToParent(molInstanceRefElmt).attachToParent(bindingElmt)

                # Now we add in the modificationSitesArray
                for modMolName in set([x[0] for x in modificationSitesArray]):
                    modMolModifications = [x for x in modificationSitesArray if x[0] == modMolName]
                    modMolInstanceRefElmt = XmlObject("mod-mol-instance-ref")
                    modMolInstanceRefElmt.attachToParent(instanceStatesElmt)
                    modMolInstanceRefElmt.addAttribute("name", modMolName)
                    modMapElmt = XmlObject("mod-map")
                    modMapElmt.attachToParent(modMolInstanceRefElmt)
                    for modification in modMolModifications:
                        modSiteRefElmt = XmlObject("mod-site-ref")
                        modSiteRefElmt.addAttribute("name", modification[1])
                        modRefElmt = XmlObject("mod-ref")
                        modRefElmt.addAttribute("name", modification[2])
                        modRefElmt.attachToParent(modSiteRefElmt).attachToParent(modMapElmt)

                # Now we add in the unboundSitesArray
                for molWithUnboundBindings in set([x[0] for x in unboundSitesArray]):
                    unboundSites = [x for x in unboundSitesArray if x[0] == molWithUnboundBindings]
                    for site in unboundSites:
                        instanceRefElmt = XmlObject("instance-ref")
                        instanceRefElmt.addAttribute("name", molWithUnboundBindings)
                        siteRefElmt = XmlObject("site-ref")
                        siteRefElmt.addAttribute("name", site[1])
                        siteRefElmt.attachToParent(instanceRefElmt).attachToParent(unboundSitesElmt)

                # Now we add in the boundSitesArray
                for molWithGenericBoundBindings in set([x[0] for x in genericBoundSitesArray]):
                    genericBoundSites = [x for x in genericBoundSitesArray if x[0] == molWithGenericBoundBindings]
                    for site in genericBoundSites:
                        instanceRefElmt = XmlObject("instance-ref")
                        instanceRefElmt.addAttribute("name", molWithGenericBoundBindings)
                        siteRefElmt = XmlObject("site-ref")
                        siteRefElmt.addAttribute("name", site[1])
                        siteRefElmt.attachToParent(instanceRefElmt).attachToParent(boundSitesElmt)

                molInstanceRefElmt = XmlObject("mol-instance-ref")
                molInstanceRefElmt.addAttribute("name", "the-" + owningMolName)
                bindingSiteRefElmt = XmlObject("binding-site-ref")
                bindingSiteRefElmt.addAttribute("name", allostericBindingSiteName)
                siteShapeRefElmt = XmlObject("site-shape-ref")
                siteShapeRefElmt.addAttribute("name", allostericName)
                siteShapeRefElmt.attachToParent(bindingSiteRefElmt).attachToParent(molInstanceRefElmt).attachToParent(
                    allostericStatesElmt
                )

                ## End of function
                plexElmt.attachToParent(allostericOmniElmt)
                if instanceStatesElmt.getNumberOfChildren() > 0:
                    instanceStatesElmt.attachToParent(allostericOmniElmt)
                if unboundSitesElmt.getNumberOfChildren() > 0:
                    unboundSitesElmt.attachToParent(allostericOmniElmt)
                if boundSitesElmt.getNumberOfChildren():
                    boundSitesElmt.attachToParent(allostericOmniElmt)
                allostericStatesElmt.attachToParent(allostericOmniElmt)
Esempio n. 36
0
 def __addAllostericPlexes(self, parentObject):
     allostericPlexesElmt = XmlObject("allosteric-plexes")
     allostericPlexesElmt.attachToParent(parentObject)
Esempio n. 37
0
    def addBindingSiteElmtToModMolElmt(self, bindingName, moleculizerMol, xmlObject):

        newBindingElmt = XmlObject("binding-site")
        newBindingElmt.addAttribute("name", bindingName)
        
        defaultShape = XmlObject("default-shape-ref")
        defaultShape.addAttribute("name", "default")
        defaultShape.attachToParent(newBindingElmt)

        for shapeName in moleculizerMol.bindingSites[bindingName]:
            siteShapeElmt = XmlObject("site-shape")
            siteShapeElmt.addAttribute("name", shapeName)
            siteShapeElmt.attachToParent(newBindingElmt)

        xmlObject.addSubElement(newBindingElmt)
        return
Esempio n. 38
0
    def writeExplicitSpecies(self, parentElmt):

        for ss in self.seedSpeciesInModel:
            plexSpeciesElmt = XmlObject("plex-species")
            plexSpeciesElmt.attachToParent(parentElmt)
            
            speciesDefinition, number = ss

            # Inputs to the species numbers are given in micromolar...
            # The inputs we have been given are in the form: Dig1_tot_conc=Dig1_num*1e6/(Cell_volume*Avogadros_number)
            # So to get num we multiply by (Cell_v * Avog) / 1e6.
            number = number * (6.0221415e23 * 40e-15) / 1e6
            plexSpeciesElmt.addAttribute("name", speciesDefinition.constructEntireComplexInstanceName())

            plexElmt = XmlObject("plex")
            plexElmt.attachToParent(plexSpeciesElmt)

            populationElmt = XmlObject("population")
            populationElmt.attachToParent(plexSpeciesElmt)
            populationElmt.addAttribute("count", int(number))

            # Make this a method of class bndSpeciesDefinition.
            for molNdx in speciesDefinition.moleculeRefsInComplex:
                molReferenceName = speciesDefinition.moleculeRefsInComplex[molNdx]
                molInstanceName = speciesDefinition.moleculeInstancesInComplex[molNdx]
                
                molInstanceElmt = XmlObject("mol-instance")
                molInstanceElmt.addAttribute("name", molInstanceName)
                molReferenceElmt = XmlObject("mol-ref")
                molReferenceElmt.addAttribute("name", molReferenceName)
                molReferenceElmt.attachToParent(molInstanceElmt).attachToParent(plexElmt)

            for bindingNdx in speciesDefinition.bindings:
                bindingElmt = XmlObject("binding")
                bindingElmt.attachToParent(plexElmt)

                for hb in speciesDefinition.bindings[bindingNdx]:
                    molInstanceRefElmt = XmlObject("mol-instance-ref")
                    molInstanceRefElmt.addAttribute("name", speciesDefinition.moleculeInstancesInComplex[hb[0]])
                    bindingSiteRefElmt = XmlObject("binding-site-ref")
                    bindingSiteRefElmt.addAttribute("name", hb[1])
                    bindingSiteRefElmt.attachToParent(molInstanceRefElmt).attachToParent(bindingElmt)
Esempio n. 39
0
 def __addVolume(self, parentObject):
     ## So far, there is a parameter "Cell_volume" that does this.
     volumeElement = XmlObject("volume")
     volumeElement.addAttribute("liters", self.parameterEE.getVariableValue("Cell_volume"))
     parentObject.addSubElement(volumeElement)
    def addModifications(self, parentElmt):
        for modification in self.getUniversalModificationList():
            modificationTypeElmt = XmlObject("modification")
            modificationTypeElmt.addAttribute("name", modification)
            modificationTypeElmt.attachToParent(parentElmt)

            weightElmt = XmlObject("weight-delta")
            weightElmt.attachToParent(modificationTypeElmt)

            if self.representsNullModification(modification):
                weightDelta = 0.0
            else:
                weightDelta = 1.0

            weightElmt.addAttribute("daltons", weightDelta)
Esempio n. 41
0
 def __addReactionGens(self, parentObject):
     rxnGenElmt = XmlObject("reaction-gens")
     rxnGenElmt.attachToParent(parentObject)
     self.reactionRules.writeReactionGensElement(rxnGenElmt)
Esempio n. 42
0
 def __addAllostericOmnis(self, parentObject):
     allostericOmnisElmt = XmlObject("allosteric-omnis")
     allostericOmnisElmt.attachToParent(parentObject)
     self.reactionRules.addAllostericOmnis(allostericOmnisElmt)
Esempio n. 43
0
    def writeAllostericSitesElementToElement(self, parsedComplex,
                                             parentElement):
        allostericSitesElmt = XmlObject("allosteric-sites", parentElement)

        for ndx in range(len(parsedComplex.getMols())):
            mol = parsedComplex.getMols()[ndx]
            if mol.isSmallMol():
                continue


#             [x for x in mol.getBindingSites() \
#                  if x.hasBindingSiteSpecification() and \
#                  x.getBindingSiteSpecification().hasShapeSpecification()  and \
#                  x.getBindingSiteSpecification().getShapeSpecification().isTransformation() ]:

            for bndSiteWithTrans in [x for x in mol.getBindingSites() \
                                         if x.hasBindingSiteSpecification() and \
                                         x.getBindingSiteSpecification().hasShapeSpecification()  and \
                                         x.getBindingSiteSpecification().getShapeSpecification().isTransformation() ]:

                try:
                    transformation = bndSiteWithTrans.getBindingSiteSpecification(
                    ).getShapeSpecification().getTransformation()
                except:
                    pdb.set_trace()
                    a = 10
                    raise e

                molElmt = XmlObject("mol-instance-ref", allostericSitesElmt)
                molElmt.addAttribute("name",
                                     self.getMolName(mol.getName(), ndx))

                bindingRefElmt = XmlObject("binding-site-ref", molElmt)
                bindingRefElmt.addAttribute("name", bndSiteWithTrans.getName())

                siteShapeRefElmt = XmlObject("site-shape-ref", bindingRefElmt)
                siteShapeRefElmt.addAttribute("name", transformation)
Esempio n. 44
0
    def writeParsedComplexAsPlex( self, complex, xmlobject):
        plexElmt = XmlObject( "plex", xmlobject)

        for ndx in range(len(complex.getMols())):
            parsedMol = complex.getMols()[ndx]

            molInst = XmlObject("mol-instance", plexElmt)
            molInst.addAttribute( "name", self.getMolName( parsedMol.getName(), ndx ))
            
            molTypeElmt = XmlObject("mol-ref", molInst)
            molTypeElmt.addAttribute( "name", parsedMol.getName() )

        for bindingID in complex.getBindings().keys():
            # Find the two bindings with that 
            newBindingElmt = XmlObject("binding", plexElmt)

            try:
                molNdx1, molNdx2 = complex.getBindings()[bindingID]
            except ValueError:
                pdb.set_trace()
                raise Exception("Error unpacking bindings '%s' associated with complex '%s' -- Binding ID only has one value." % (repr(complex.getBindings()[bindingID]), complex.getOriginalLine(), bindingID))
            
            parsedMol1 = complex.getMols()[molNdx1]
            parsedMol2 = complex.getMols()[molNdx2]
            bindingSite1 = ""
            bindingSite2 = ""

            if parsedMol1.isModMol():
                for bindingSite in parsedMol1.getBindingSiteList():
                    parsedBindingSite = parsedMol1.getBindingSiteWithName( bindingSite )
                    if parsedBindingSite.hasBindingToken(bindingID):
                        bindingSite1 = parsedBindingSite.getName()
                        break
                else:
                    print "Error, binding site 1 not found"
                    raise Exception()
            else:
                bindingSite1 = parsedMol1.getName()
         
            if parsedMol2.isModMol():
                for bindingSite in parsedMol2.getBindingSiteList():
                    bindingSite = parsedMol2.getBindingSiteWithName( bindingSite )
                    if bindingSite.hasBindingToken( bindingID ):
                        bindingSite2 = bindingSite.getName()
                        break
                else:
                    print "Error, binding site 2 not found"
                    raise Exception()
            else:
                bindingSite2 = parsedMol2.getName()
            
            molInstance1 = XmlObject("mol-instance-ref", newBindingElmt)
            molInstance1.addAttribute( "name", self.getMolName(parsedMol1.getName(), molNdx1))
            
            bindingSiteRef1 = XmlObject("binding-site-ref", molInstance1)
            bindingSiteRef1.addAttribute("name", bindingSite1)


            molInstance2 = XmlObject("mol-instance-ref", newBindingElmt)
            molInstance2.addAttribute( "name", self.getMolName(parsedMol2.getName(), molNdx2))
            
            bindingSiteRef2 = XmlObject("binding-site-ref", molInstance2)
            bindingSiteRef2.addAttribute("name", bindingSite2)

        return plexElmt
Esempio n. 45
0
    def writeDimerGenLineToParent(self, line, reactionGens):
        dimerGen = XmlObject("dimerization-gen", reactionGens)

        parsedRxn = line.getParsedComponents()[0]
        theReactants = parsedRxn.getReactants()
        theProducts = parsedRxn.getProducts()

        reactant1 = theReactants[0].getMols()[0]
        reactant2 = theReactants[1].getMols()[0]

        molSpec1 = XmlObject("mol-ref", dimerGen)
        molSpec2 = XmlObject("mol-ref", dimerGen)

        molSpec1.addAttribute("name", reactant1.getName())
        molSpec2.addAttribute("name", reactant2.getName())

        siteRef1 = XmlObject("site-ref", molSpec1)
        siteRef2 = XmlObject("site-ref", molSpec2)

        self.__addSiteNameToElement(reactant1, siteRef1)
        self.__addSiteNameToElement(reactant2, siteRef2)

        defaultOnElmt = XmlObject("default-on-rate", dimerGen)
        defaultOffElmt = XmlObject("default-off-rate", dimerGen)

        defaultOnElmt.addAttribute("value", line.getAssignment("kon"))
        defaultOffElmt.addAttribute("value", line.getAssignment("koff"))

        if len(line.getParsedComponents()) == 3:
            return

        # Now add the allosteric on- and off- rates.
        allosteryComponents = line.getParsedComponents()[3:]

        allostery_index = 3
        while (len(allosteryComponents) > 0):
            # This is used in a hacky way to find the correct parameter

            alloRatesElmt = XmlObject("allo-rates", dimerGen)

            alloReactants = allosteryComponents[0].getReactants()

            siteShapeRef1 = XmlObject("site-shape-ref", alloRatesElmt)
            siteShapeRef2 = XmlObject("site-shape-ref", alloRatesElmt)
            onRate = XmlObject("on-rate", alloRatesElmt)
            offRate = XmlObject("off-rate", alloRatesElmt)

            if alloReactants[0].getMols()[0].isModMol():
                if alloReactants[0].getMols()[0].getBindingSites(
                )[0].hasBindingSiteSpecification():
                    siteShapeRef1.addAttribute(
                        "name", alloReactants[0].getMols()
                        [0].getBindingSites()[0].getBindingSiteSpecification(
                        ).getShapeSpecification().getShapeList()[0])
                else:
                    siteShapeRef1.addAttribute("name", "default")

            else:
                siteShapeRef1.addAttribute("name", "default")

            if alloReactants[1].getMols()[0].isModMol():
                if alloReactants[1].getMols()[0].getBindingSites(
                )[0].hasBindingSiteSpecification():
                    siteShapeRef2.addAttribute(
                        "name", alloReactants[1].getMols()
                        [0].getBindingSites()[0].getBindingSiteSpecification(
                        ).getShapeSpecification().getShapeList()[0])
                else:
                    siteShapeRef2.addAttribute("name", "default")
            else:
                siteShapeRef2.addAttribute("name", "default")

            onRate.addAttribute("value",
                                line.getAssignment("kon", allostery_index))
            offRate.addAttribute("value",
                                 line.getAssignment("koff", allostery_index))

            allosteryComponents = allosteryComponents[3:]
            allostery_index += 3

        return
Esempio n. 46
0
 def __addExplicitSpecies(self, parentObject):
     explicitSpeciesElmt = XmlObject("explicit-species")
     explicitSpeciesElmt.attachToParent(parentObject)
     self.seedSpecies.writeExplicitSpecies(explicitSpeciesElmt)
Esempio n. 47
0
    def writeParsedComplexAsPlex( self, complex, xmlobject, writeComplexInstanceStates = False, writeBoundUnboundStates = False):

        #
        if writeBoundUnboundStates:
            # This should be a list of things like (2, 1, +) = the
            # first binding on the second mol must be bound.
            patternMatchingSitesSpec = complex.externalizePatternMatchingSites()
        
        plexElmt = XmlObject( "plex", xmlobject)

        for ndx in range(len(complex.getMols())):
            parsedMol = complex.getMols()[ndx]

            molInst = XmlObject("mol-instance", plexElmt)
            molInst.addAttribute( "name", self.getMolName( parsedMol.getName(), ndx ))
            
            molTypeElmt = XmlObject("mol-ref", molInst)
            molTypeElmt.addAttribute( "name", parsedMol.getName() )

        for bindingID in complex.getBindings().keys():
            # Find the two bindings with that 
            newBindingElmt = XmlObject("binding", plexElmt)

            try:
                molNdx1, molNdx2 = complex.getBindings()[bindingID]
            except ValueError:
                raise Exception("Error unpacking bindings '%s' associated with complex '%s' -- Binding ID only has one value." % (repr(complex.getBindings()[bindingID]), complex.getOriginalLine(), bindingID))
            
            parsedMol1 = complex.getMols()[molNdx1]
            parsedMol2 = complex.getMols()[molNdx2]
            bindingSite1 = ""
            bindingSite2 = ""

            if parsedMol1.isModMol():
                for bindingSite in parsedMol1.getBindingSiteList():
                    parsedBindingSite = parsedMol1.getBindingSiteWithName( bindingSite )
                    if parsedBindingSite.hasBindingToken(bindingID):
                        bindingSite1 = parsedBindingSite.getName()
                        break
                else:
                    print "Error, binding site 1 not found"
                    raise Exception()
            else:
                bindingSite1 = parsedMol1.getName()
         
            if parsedMol2.isModMol():
                for bindingSite in parsedMol2.getBindingSiteList():
                    bindingSite = parsedMol2.getBindingSiteWithName( bindingSite )
                    if bindingSite.hasBindingToken( bindingID ):
                        bindingSite2 = bindingSite.getName()
                        break
                else:
                    print "Error, binding site 2 not found"
                    raise Exception()
            else:
                bindingSite2 = parsedMol2.getName()
            
            molInstance1 = XmlObject("mol-instance-ref", newBindingElmt)
            molInstance1.addAttribute( "name", self.getMolName(parsedMol1.getName(), molNdx1))
            
            bindingSiteRef1 = XmlObject("binding-site-ref", molInstance1)
            bindingSiteRef1.addAttribute("name", bindingSite1)


            molInstance2 = XmlObject("mol-instance-ref", newBindingElmt)
            molInstance2.addAttribute( "name", self.getMolName(parsedMol2.getName(), molNdx2))
            
            bindingSiteRef2 = XmlObject("binding-site-ref", molInstance2)
            bindingSiteRef2.addAttribute("name", bindingSite2)

        #pdb.set_trace()
        if writeComplexInstanceStates:
            self.writeParsedComplexInstanceStates(complex, xmlobject)

        if writeBoundUnboundStates:
            self.writeBoundUnboundStates(complex, patternMatchingSitesSpec, xmlobject)

        return plexElmt
Esempio n. 48
0
 def __addMols(self, parentObject):
     molsElmt = XmlObject("mols")
     molsElmt.attachToParent(parentObject)
     self.moleculeDictionary.addMols(molsElmt)
Esempio n. 49
0
    def addModMolToXml( self, parsedMol, xmlObject):
        modMolElmt = XmlObject( "mod-mol")
        modMolElmt.attachToParent(xmlObject)
        modMolElmt.addAttribute( "name",  parsedMol.getName() )

        for bindingSiteName in parsedMol.getBindingSiteList():

            bindingSiteElmt = XmlObject("binding-site")
            bindingSiteElmt.attachToParent( modMolElmt)
            bindingSiteElmt.addAttribute("name", bindingSiteName)
            
            parsedBindingSite = parsedMol.getBindingSiteWithName( bindingSiteName )

            if( parsedBindingSite.hasBindingSiteSpecification() and parsedBindingSite.getBindingSiteSpecification().hasShapeSpecification()):

                bindingShapeNames = parsedBindingSite.getBindingSiteSpecification().getShapeSpecification().getShapeList()

                assert( len(bindingShapeNames) > 0 )
                
                defaultShapeElmt = XmlObject("default-shape-ref")
                defaultShapeElmt.addAttribute("name", bindingShapeNames[0] )
                defaultShapeElmt.attachToParent( bindingSiteElmt )

                for shape_name in bindingShapeNames:
                    newShapeElmt = XmlObject("site-shape")
                    newShapeElmt.addAttribute("name", shape_name)
                    newShapeElmt.attachToParent( bindingSiteElmt )
            else:
                defaultShapeElmt = XmlObject( "default-shape-ref" )
                defaultShapeElmt.addAttribute( "name", "default")
                defaultShapeElmt.attachToParent( bindingSiteElmt )
                
                shapeElmt = XmlObject("site-shape")
                shapeElmt.addAttribute("name", "default")
                shapeElmt.attachToParent( bindingSiteElmt )
                    

        for modSiteName in parsedMol.getModificationSiteList():
            modSiteElmt = XmlObject("mod-site", modMolElmt)
            modSiteElmt.addAttribute("name", modSiteName)

            parsedModificationSite = parsedMol.getModificationSiteWithName( modSiteName )
            if not parsedModificationSite.hasModificationSiteSpecification():
                defaultModElmt = XmlObject("default-mod-ref", modSiteElmt)
                defaultModElmt.addAttribute("name", "none")
            else:
                modValueArray = parsedModificationSite.getModificationSiteSpecification().getList()
                try:
                    assert( len(modValueArray) > 1)
                except:
                    print "Error, in sectionmols::addModMolToXml for mol with line '%s'.  Mod Value Array '%s' should have more than one component..." % ( parsedMol.getOriginalLine(), str(modValueArray) )
                    
                defaultModification = modValueArray[0]

                defaultModElmt = XmlObject("default-mod-ref", modSiteElmt)
                defaultModElmt.addAttribute("name", defaultModification )
                
        return modMolElmt
Esempio n. 50
0
    def addModMolToXml(self, parsedMol, xmlObject):
        modMolElmt = XmlObject("mod-mol")
        modMolElmt.attachToParent(xmlObject)
        modMolElmt.addAttribute("name", parsedMol.getName())

        for bindingSiteName in parsedMol.getBindingSiteList():

            bindingSiteElmt = XmlObject("binding-site")
            bindingSiteElmt.attachToParent(modMolElmt)
            bindingSiteElmt.addAttribute("name", bindingSiteName)

            parsedBindingSite = parsedMol.getBindingSiteWithName(
                bindingSiteName)

            if (parsedBindingSite.hasBindingSiteSpecification()
                    and parsedBindingSite.getBindingSiteSpecification(
                    ).hasShapeSpecification()):

                bindingShapeNames = parsedBindingSite.getBindingSiteSpecification(
                ).getShapeSpecification().getShapeList()

                assert (len(bindingShapeNames) > 0)

                defaultShapeElmt = XmlObject("default-shape-ref")
                defaultShapeElmt.addAttribute("name", bindingShapeNames[0])
                defaultShapeElmt.attachToParent(bindingSiteElmt)

                for shape_name in bindingShapeNames:
                    newShapeElmt = XmlObject("site-shape")
                    newShapeElmt.addAttribute("name", shape_name)
                    newShapeElmt.attachToParent(bindingSiteElmt)
            else:
                defaultShapeElmt = XmlObject("default-shape-ref")
                defaultShapeElmt.addAttribute("name", "default")
                defaultShapeElmt.attachToParent(bindingSiteElmt)

                shapeElmt = XmlObject("site-shape")
                shapeElmt.addAttribute("name", "default")
                shapeElmt.attachToParent(bindingSiteElmt)

        for modSiteName in parsedMol.getModificationSiteList():
            modSiteElmt = XmlObject("mod-site", modMolElmt)
            modSiteElmt.addAttribute("name", modSiteName)

            parsedModificationSite = parsedMol.getModificationSiteWithName(
                modSiteName)
            if not parsedModificationSite.hasModificationSiteSpecification():
                defaultModElmt = XmlObject("default-mod-ref", modSiteElmt)
                defaultModElmt.addAttribute("name", "none")
            else:
                modValueArray = parsedModificationSite.getModificationSiteSpecification(
                ).getList()
                try:
                    assert (len(modValueArray) > 1)
                except:
                    print "Error, in sectionmols::addModMolToXml for mol with line '%s'.  Mod Value Array '%s' should have more than one component..." % (
                        parsedMol.getOriginalLine(), str(modValueArray))

                defaultModification = modValueArray[0]

                defaultModElmt = XmlObject("default-mod-ref", modSiteElmt)
                defaultModElmt.addAttribute("name", defaultModification)

        return modMolElmt
Esempio n. 51
0
    def addModMolElmtToMolsElmt(self, xmlObject, moleculizerMolObject):
        assert(isinstance(xmlObject, XmlObject))
        assert(isinstance(moleculizerMolObject, MoleculizerMol))

        newModMol = XmlObject("mod-mol")
        newModMol.addAttribute("name", moleculizerMolObject.getName())

        weightElement = XmlObject("weight")

        # Obviously this is one of the big deficiencies of this thing.  What shall
        # we set the (mandatory) weights to?  For now, let's just put in something
        # arbitratry.  But this is a big issue that ought to be fixed as soon as all
        # the basic facilities of the code have been built in.

        if moleculizerMolObject.getName() == "Pheromone":
            weightElement.addAttribute("daltons", 10.0)
        else:
            weightElement.addAttribute("daltons", 100.0)            

        newModMol.addSubElement(weightElement)

        for binding in moleculizerMolObject.bindingSites:
            self.addBindingSiteElmtToModMolElmt(binding, moleculizerMolObject, newModMol)

        for modification in moleculizerMolObject.modificationSites:
            modSite, defaultModState = modification
            modSiteElmt = XmlObject("mod-site")
            modSiteElmt.addAttribute("name", modSite)
            defModRefElmt = XmlObject("default-mod-ref")
            defModRefElmt.addAttribute("name", defaultModState)
            defModRefElmt.attachToParent(modSiteElmt).attachToParent(newModMol)

        xmlObject.addSubElement(newModMol)
        
        return
Esempio n. 52
0
    def __writeModMolInstanceToInstanceStates(self, parsedMol, molNdx,
                                              parentElmt):
        modMolInstanceRefElmt = XmlObject("mod-mol-instance-ref", parentElmt)
        modMolInstanceRefElmt.addAttribute(
            "name", self.getMolName(parsedMol.getName(), molNdx))

        modMapElmt = XmlObject("mod-map", modMolInstanceRefElmt)

        for modSite in parsedMol.getModificationSites():
            modSiteRefElmt = XmlObject("mod-site-ref", modMapElmt)
            modSiteRefElmt.addAttribute("name", modSite.getName())

            modRefElmt = XmlObject("mod-ref", modSiteRefElmt)
            modRefElmt.addAttribute(
                "name",
                modSite.getModificationSiteSpecification().getList()[0])
    def addModMolElmtToMolsElmt(self, xmlObject, moleculizerMolObject):
        assert (isinstance(xmlObject, XmlObject))
        assert (isinstance(moleculizerMolObject, MoleculizerMol))

        newModMol = XmlObject("mod-mol")
        newModMol.addAttribute("name", moleculizerMolObject.getName())

        weightElement = XmlObject("weight")

        # Obviously this is one of the big deficiencies of this thing.  What shall
        # we set the (mandatory) weights to?  For now, let's just put in something
        # arbitratry.  But this is a big issue that ought to be fixed as soon as all
        # the basic facilities of the code have been built in.

        if moleculizerMolObject.getName() == "Pheromone":
            weightElement.addAttribute("daltons", 10.0)
        else:
            weightElement.addAttribute("daltons", 100.0)

        newModMol.addSubElement(weightElement)

        for binding in moleculizerMolObject.bindingSites:
            self.addBindingSiteElmtToModMolElmt(binding, moleculizerMolObject,
                                                newModMol)

        for modification in moleculizerMolObject.modificationSites:
            modSite, defaultModState = modification
            modSiteElmt = XmlObject("mod-site")
            modSiteElmt.addAttribute("name", modSite)
            defModRefElmt = XmlObject("default-mod-ref")
            defModRefElmt.addAttribute("name", defaultModState)
            defModRefElmt.attachToParent(modSiteElmt).attachToParent(newModMol)

        xmlObject.addSubElement(newModMol)

        return
Esempio n. 54
0
 def __addModifications(self, parentObject):
     modificationListElmt = XmlObject("modifications")
     modificationListElmt.attachToParent(parentObject)
     self.moleculeDictionary.addModifications(modificationListElmt)
Esempio n. 55
0
    def writeDimerGenLineToParent( self, line, reactionGens):
        dimerGen = XmlObject("dimerization-gen", reactionGens)

        parsedRxn = line.getParsedComponents()[0]
        theReactants = parsedRxn.getReactants()
        theProducts = parsedRxn.getProducts()

        reactant1 = theReactants[0].getMols()[0]
        reactant2 = theReactants[1].getMols()[0]

        molSpec1 = XmlObject("mol-ref", dimerGen)
        molSpec2 = XmlObject("mol-ref", dimerGen)
        
        molSpec1.addAttribute("name", reactant1.getName() )
        molSpec2.addAttribute("name", reactant2.getName() )

        siteRef1 = XmlObject("site-ref", molSpec1)
        siteRef2 = XmlObject("site-ref", molSpec2)

        self.__addSiteNameToElement( reactant1, siteRef1)
        self.__addSiteNameToElement( reactant2, siteRef2)

        defaultOnElmt = XmlObject("default-on-rate", dimerGen)
        defaultOffElmt = XmlObject("default-off-rate", dimerGen)

        defaultOnElmt.addAttribute("value", line.getAssignment("kon"))
        defaultOffElmt.addAttribute("value", line.getAssignment("koff"))



        if len( line.getParsedComponents())  == 3:
            return

        # Now add the allosteric on- and off- rates.
        allosteryComponents = line.getParsedComponents()[3:]
        
        allostery_index = 3
        while (len(allosteryComponents) > 0):
            # This is used in a hacky way to find the correct parameter

            alloRatesElmt = XmlObject("allo-rates", dimerGen)

            alloReactants = allosteryComponents[0].getReactants()

            siteShapeRef1 = XmlObject("site-shape-ref", alloRatesElmt)
            siteShapeRef2 = XmlObject("site-shape-ref", alloRatesElmt)
            onRate = XmlObject("on-rate", alloRatesElmt)
            offRate = XmlObject("off-rate", alloRatesElmt)

            if alloReactants[0].getMols()[0].isModMol():
                if alloReactants[0].getMols()[0].getBindingSites()[0].hasBindingSiteSpecification():
                    siteShapeRef1.addAttribute("name", alloReactants[0].getMols()[0].getBindingSites()[0].getBindingSiteSpecification().getShapeSpecification().getShapeList()[0])
                else:
                    siteShapeRef1.addAttribute("name", "default")

            else:
                siteShapeRef1.addAttribute("name", "default")

            if alloReactants[1].getMols()[0].isModMol():
                if alloReactants[1].getMols()[0].getBindingSites()[0].hasBindingSiteSpecification():
                    siteShapeRef2.addAttribute("name", alloReactants[1].getMols()[0].getBindingSites()[0].getBindingSiteSpecification().getShapeSpecification().getShapeList()[0])
                else:
                    siteShapeRef2.addAttribute("name", "default")
            else:
                siteShapeRef2.addAttribute("name", "default")

            onRate.addAttribute("value", line.getAssignment( "kon", allostery_index) )
            offRate.addAttribute("value", line.getAssignment( "koff", allostery_index) )
                                       
            allosteryComponents = allosteryComponents[3:]
            allostery_index += 3

        return
    def addBindingSiteElmtToModMolElmt(self, bindingName, moleculizerMol,
                                       xmlObject):

        newBindingElmt = XmlObject("binding-site")
        newBindingElmt.addAttribute("name", bindingName)

        defaultShape = XmlObject("default-shape-ref")
        defaultShape.addAttribute("name", "default")
        defaultShape.attachToParent(newBindingElmt)

        for shapeName in moleculizerMol.bindingSites[bindingName]:
            siteShapeElmt = XmlObject("site-shape")
            siteShapeElmt.addAttribute("name", shapeName)
            siteShapeElmt.attachToParent(newBindingElmt)

        xmlObject.addSubElement(newBindingElmt)
        return
Esempio n. 57
0
 def __addExplicitReactions(self, modelElmt):
     explicitReactionsElmt = XmlObject("explicit-reactions", modelElmt)
     return