Exemplo n.º 1
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
Exemplo n.º 2
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
Exemplo n.º 3
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
Exemplo n.º 4
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
Exemplo n.º 5
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)
Exemplo n.º 6
0
    def addSmallMolToXml(self, parsedSmallMol, xmlElement):
        smallMolElt = XmlObject("small-mol")
        smallMolElt.addAttribute("name", parsedSmallMol.getName())

        smallMolElt.attachToParent(xmlElement)

        return smallMolElt
Exemplo n.º 7
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])
Exemplo n.º 8
0
    def __addSpeciesStreams(self, parentObject):

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

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

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

        return
Exemplo n.º 10
0
    def __addMols(self, parentObject):
        molsSection = XmlObject("mols", parentObject)

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

        return
Exemplo n.º 11
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)
Exemplo n.º 12
0
    def __addExplicitSpecies(self, parentObject):
        explicitSpeciesElmt = XmlObject("explicit-species", parentObject)

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

        return
Exemplo n.º 13
0
    def __addAllostericOmnis(self, parentObject):
        allostericOmnis = XmlObject("allosteric-omnis", parentObject)

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

        return
Exemplo n.º 14
0
    def __addAllostericPlexes(self, parentObject):
        allostericPlexes = XmlObject("allosteric-plexes", parentObject)

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

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

        if self.modificationsSection:
            self.modificationsSection.writeModificationsSections(
                modificationsSection)
        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)
Exemplo n.º 17
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
Exemplo n.º 18
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
Exemplo n.º 19
0
    def writeAllostericPlexLineToXml(self, lineToWrite, xmlobject):
        alloPlexElmt = XmlObject("allosteric-plex", xmlobject)

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

        return
Exemplo n.º 20
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
Exemplo n.º 21
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
Exemplo n.º 22
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
Exemplo n.º 23
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)
Exemplo n.º 24
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
Exemplo n.º 25
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)
Exemplo n.º 26
0
    def getXml(self):

        # Special Case where the line does not represent any
        # displayable text.
        if self._display_xml == False:
            return ''

        xmlObject = XmlObject(self._text)
        if self._paragraph_type in CENTERED:
            xmlObject.center()

        if self._paragraph_type in UPPER:
            xmlObject.upper()

        if self._paragraph_type in PAGE_BREAK_BEFORE:
            if self._previous_paragraph_type not in PAGE_BREAK_AFTER:
                xmlObject.pre_page_break()

            xmlObject.set_pre_buffer(ONE_THIRD_PAGE)
            xmlObject.set_post_buffer(STANDARD_BUFFER)

        if self._paragraph_type in PAGE_BREAK_AFTER:
            xmlObject.post_page_break()

        if self._paragraph_type in BUFFER_SPACES:
            previous_buffer = BUFFER_SPACES.get(self._previous_paragraph_type,
                                                0)
            def_pre_buffer = BUFFER_SPACES[self._paragraph_type]
            print(previous_buffer)
            print(def_pre_buffer)
            pre_buffer = max(def_pre_buffer - previous_buffer, 0)
            print(pre_buffer)
            xmlObject.set_pre_buffer(pre_buffer)

            xmlObject.set_post_buffer(def_pre_buffer)

        if self._paragraph_type in HIDE_TITLE:
            xmlObject.remove_text()

        if self._paragraph_type in INDENT:
            xmlObject.indent()

        output = xmlObject.getXml()
        return output
Exemplo n.º 27
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)
Exemplo n.º 28
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
Exemplo n.º 29
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
Exemplo n.º 30
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