Esempio n. 1
0
    def getXSDataRaddoseInput(self, _xsDataBeam, _xsDataSample, _inumOperators,
                              _iNumberOfImages):

        xsDataRaddoseInput = XSDataRaddoseInput()

        # Beam
        xsDataRaddoseInput.setBeamSize(_xsDataBeam.getSize())
        xsDataRaddoseInput.setBeamFlux(_xsDataBeam.getFlux())
        xsDataRaddoseInput.setBeamWavelength(_xsDataBeam.getWavelength())

        xsDataRaddoseInput.setBeamExposureTime(_xsDataBeam.getExposureTime())
        xsDataRaddoseInput.setNumberOfImages(XSDataInteger(_iNumberOfImages))
        xsDataRaddoseInput.setCrystalCell(_xsDataSample.getCrystal().getCell())

        xsDataRaddoseInput.setCrystalSize(_xsDataSample.getSize())

        xsDataComposition = _xsDataSample.getChemicalComposition()

        xsDataSolvent = xsDataComposition.getSolvent()
        if (xsDataSolvent is not None):
            xsDataRaddoseInput.setCrystalSATM(xsDataSolvent.getAtoms())

        xsDataStructure = xsDataComposition.getStructure()
        if (xsDataStructure is not None):
            xsDataChains = xsDataStructure.getChain()

            totalNRESInStructure = 0
            totalNDNAInStructure = 0
            totalNRNAInStructure = 0
            totalPATM = XSDataAtomicComposition()

            for chain in xsDataChains:
                # heavy atoms of each chain to be added in the PATM
                xsDataAtomicCompositionHeavyAtoms = chain.getHeavyAtoms()
                if (xsDataAtomicCompositionHeavyAtoms is not None):
                    iterator = 1
                    while iterator <= chain.getNumberOfCopies().getValue():
                        totalPATM = self.mergeAtomicComposition(
                            totalPATM, xsDataAtomicCompositionHeavyAtoms)
                        iterator = iterator + 1

                type = chain.getType().getValue()
                numberOfMonomers = chain.getNumberOfMonomers().getValue(
                ) * chain.getNumberOfCopies().getValue()

                if (type == "protein"):
                    totalNRESInStructure = totalNRESInStructure + numberOfMonomers
                elif (type == "dna"):
                    totalNDNAInStructure = totalNDNAInStructure + numberOfMonomers
                elif (type == "rna"):
                    totalNRNAInStructure = totalNRNAInStructure + numberOfMonomers

            xsDataLigands = xsDataStructure.getLigand()
            for ligand in xsDataLigands:

                # Light atoms to be added to the NRES
                nres = ligand.getNumberOfLightAtoms().getValue(
                ) * ligand.getNumberOfCopies().getValue() / 7.85
                totalNRESInStructure = totalNRESInStructure + nres

                # Heavy atoms to be added to the PATM
                if (ligand.getHeavyAtoms() is not None):
                    iterator = 1
                    while iterator <= ligand.getNumberOfCopies().getValue():
                        totalPATM = self.mergeAtomicComposition(
                            totalPATM, ligand.getHeavyAtoms())
                        iterator = iterator + 1

            if (totalNRESInStructure != 0):
                xsDataRaddoseInput.setCrystalNRES(
                    XSDataInteger(int(round(totalNRESInStructure))))
            if (totalNDNAInStructure != 0):
                xsDataRaddoseInput.setCrystalNDNA(
                    XSDataInteger(int(totalNDNAInStructure)))
            if (totalNRNAInStructure != 0):
                xsDataRaddoseInput.setCrystalNRNA(
                    XSDataInteger(int(totalNRNAInStructure)))
            if (len(totalPATM.getAtom()) != 0):
                xsDataRaddoseInput.setCrystalPATM(totalPATM)

            xsDataNumberNumStructInAU = xsDataStructure.getNumberOfCopiesInAsymmetricUnit(
            )
            xsDataNumberNumStructInUC = int(
                xsDataNumberNumStructInAU.getValue() * _inumOperators)
            xsDataRaddoseInput.setCrystalNMON(
                XSDataInteger(xsDataNumberNumStructInUC))

        return xsDataRaddoseInput
    def getXSDataRaddoseInput(self, _xsDataBeam, _xsDataSample, _inumOperators):



        xsDataRaddoseInput = XSDataRaddoseInput()

        # Beam        
        xsDataRaddoseInput.setBeamSize(_xsDataBeam.getSize())
        xsDataRaddoseInput.setBeamFlux(_xsDataBeam.getFlux())
        xsDataRaddoseInput.setBeamWavelength(_xsDataBeam.getWavelength())

        xsDataRaddoseInput.setBeamExposureTime(XSDataTime(1.0))
        xsDataRaddoseInput.setNumberOfImages(XSDataInteger(1))
        xsDataRaddoseInput.setCrystalCell(_xsDataSample.getCrystal().getCell())

        xsDataRaddoseInput.setCrystalSize(_xsDataSample.getSize())

        xsDataComposition = _xsDataSample.getChemicalComposition()

        xsDataSolvent = xsDataComposition.getSolvent()
        if(xsDataSolvent is not None):
            xsDataRaddoseInput.setCrystalSATM(xsDataSolvent.getAtoms())

        xsDataStructure = xsDataComposition.getStructure()
        if(xsDataStructure is not None):
            xsDataChains = xsDataStructure.getChain()

            totalNRESInStructure = 0
            totalNDNAInStructure = 0
            totalNRNAInStructure = 0
            totalPATM = XSDataAtomicComposition()

            for chain in xsDataChains:
                # heavy atoms of each chain to be added in the PATM
                xsDataAtomicCompositionHeavyAtoms = chain.getHeavyAtoms()
                if (xsDataAtomicCompositionHeavyAtoms is not None):
                    iterator = 1
                    while iterator <= chain.getNumberOfCopies().getValue():
                        totalPATM = self.mergeAtomicComposition(totalPATM, xsDataAtomicCompositionHeavyAtoms)
                        iterator = iterator + 1

                type = chain.getType().getValue()
                numberOfMonomers = chain.getNumberOfMonomers().getValue() * chain.getNumberOfCopies().getValue()

                if (type == "protein"):
                    totalNRESInStructure = totalNRESInStructure + numberOfMonomers
                elif(type == "dna"):
                    totalNDNAInStructure = totalNDNAInStructure + numberOfMonomers
                elif(type == "rna"):
                    totalNRNAInStructure = totalNRNAInStructure + numberOfMonomers

            xsDataLigands = xsDataStructure.getLigand()
            for ligand in xsDataLigands:

                # Light atoms to be added to the NRES
                nres = ligand.getNumberOfLightAtoms().getValue() * ligand.getNumberOfCopies().getValue() / 7.85
                totalNRESInStructure = totalNRESInStructure + nres

                # Heavy atoms to be added to the PATM
                if (ligand.getHeavyAtoms() is not None):
                    iterator = 1
                    while iterator <= ligand.getNumberOfCopies().getValue():
                        totalPATM = self.mergeAtomicComposition(totalPATM, ligand.getHeavyAtoms())
                        iterator = iterator + 1

            if(totalNRESInStructure != 0):
                xsDataRaddoseInput.setCrystalNRES(XSDataInteger(int(round(totalNRESInStructure))))
            if(totalNDNAInStructure != 0):
                xsDataRaddoseInput.setCrystalNDNA(XSDataInteger(int(totalNDNAInStructure)))
            if(totalNRNAInStructure != 0):
                xsDataRaddoseInput.setCrystalNRNA(XSDataInteger(int(totalNRNAInStructure)))
            if(len(totalPATM.getAtom()) != 0):
                xsDataRaddoseInput.setCrystalPATM(totalPATM)

            xsDataNumberNumStructInAU = xsDataStructure.getNumberOfCopiesInAsymmetricUnit()
            xsDataNumberNumStructInUC = int(xsDataNumberNumStructInAU.getValue() * _inumOperators)
            xsDataRaddoseInput.setCrystalNMON(XSDataInteger(xsDataNumberNumStructInUC))

        return xsDataRaddoseInput
    def testSetDataModelInput(self):
        # Crystal
        from XSDataRaddosev10 import XSDataRaddoseInput
        xsDataRaddoseInput = XSDataRaddoseInput()

        from XSDataCommon import XSDataString
        from XSDataCommon import XSDataDouble
        from XSDataCommon import XSDataAngle
        from XSDataCommon import XSDataLength
        from XSDataCommon import XSDataSize
        from XSDataCommon import XSDataInteger
        from XSDataRaddosev10 import XSDataCell
        from XSDataRaddosev10 import XSDataAtom
        from XSDataRaddosev10 import XSDataAtomicComposition

        xsDataAtomSulfur = XSDataAtom()
        xsDataAtomSulfur.setNumberOf(XSDataDouble(4))
        xsDataAtomSulfur.setSymbol(XSDataString("S"))
        xsDataAtomSelenium = XSDataAtom()
        xsDataAtomSelenium.setNumberOf(XSDataDouble(4))
        xsDataAtomSelenium.setSymbol(XSDataString("Se"))

        xsDataAtomicComposition = XSDataAtomicComposition()
        xsDataAtomicComposition.addAtom(xsDataAtomSulfur)
        xsDataAtomicComposition.addAtom(xsDataAtomSelenium)
        xsDataRaddoseInput.setCrystalPATM(xsDataAtomicComposition)
        xsDataRaddoseInput.setCrystalNRES(XSDataInteger(295))
        xsDataRaddoseInput.setCrystalNMON(XSDataInteger(8))
        xsDataCell = XSDataCell(angle_alpha=XSDataAngle(90.0),
                                angle_beta=XSDataAngle(90.0),
                                angle_gamma=XSDataAngle(90.0),
                                length_a=XSDataLength(78.9),
                                length_b=XSDataLength(95.162),
                                length_c=XSDataLength(104.087))

        xsDataSizeCrystal = XSDataSize(XSDataLength(0.1), XSDataLength(0.1),
                                       XSDataLength(0.1))

        xsDataRaddoseInput.setCrystalCell(xsDataCell)
        xsDataRaddoseInput.setCrystalSize(xsDataSizeCrystal)

        # Beam
        from XSDataCommon import XSDataFlux
        from XSDataCommon import XSDataWavelength
        from XSDataCommon import XSDataTime

        xsDataSize = XSDataSize(x=XSDataLength(0.1), y=XSDataLength(0.1))

        xsDataRaddoseInput.setBeamSize(xsDataSize)
        xsDataRaddoseInput.setBeamFlux(XSDataFlux(1e+12))
        xsDataRaddoseInput.setBeamWavelength(XSDataWavelength(2.41))
        xsDataRaddoseInput.setBeamExposureTime(XSDataTime(1))

        xsDataRaddoseInput.setNumberOfImages(XSDataInteger(1))

        xsDataRaddoseInput.exportToFile(self.strObtainedInputFile)

        strExpectedInput = self.readAndParseFile(self.strReferenceInputFile)
        strObtainedInput = self.readAndParseFile(self.strObtainedInputFile)

        xsDataRaddoseInputExpected = XSDataRaddoseInput.parseString(
            strExpectedInput)
        xsDataRaddoseInputObtained = XSDataRaddoseInput.parseString(
            strObtainedInput)

        EDAssert.equal(xsDataRaddoseInputExpected.marshal(),
                       xsDataRaddoseInputObtained.marshal())
    def testSetDataModelInput(self):
        # Crystal         
        from XSDataRaddosev10 import XSDataRaddoseInput
        xsDataRaddoseInput = XSDataRaddoseInput()

        from XSDataCommon import XSDataString
        from XSDataCommon import XSDataFloat
        from XSDataCommon import XSDataAngle
        from XSDataCommon import XSDataLength
        from XSDataCommon import XSDataSize
        from XSDataCommon import XSDataInteger
        from XSDataRaddosev10 import XSDataCell
        from XSDataRaddosev10 import XSDataAtom
        from XSDataRaddosev10 import XSDataAtomicComposition

        xsDataAtomSulfur = XSDataAtom()
        xsDataAtomSulfur.setNumberOf(XSDataFloat(4))
        xsDataAtomSulfur.setSymbol(XSDataString("S"))
        xsDataAtomSelenium = XSDataAtom()
        xsDataAtomSelenium.setNumberOf(XSDataFloat(4))
        xsDataAtomSelenium.setSymbol(XSDataString("Se"))

        xsDataAtomicComposition = XSDataAtomicComposition()
        xsDataAtomicComposition.addAtom(xsDataAtomSulfur)
        xsDataAtomicComposition.addAtom(xsDataAtomSelenium)
        xsDataRaddoseInput.setCrystalPATM(xsDataAtomicComposition)
        xsDataRaddoseInput.setCrystalNRES(XSDataInteger(295))
        xsDataRaddoseInput.setCrystalNMON(XSDataInteger(8))
        xsDataCell = XSDataCell(angle_alpha = XSDataAngle(90.0),
                                angle_beta =  XSDataAngle(90.0),
                                angle_gamma =  XSDataAngle(90.0),
                                length_a = XSDataLength(78.9),
                                length_b = XSDataLength(95.162),
                                length_c = XSDataLength(104.087))

        xsDataSizeCrystal = XSDataSize(XSDataLength(0.1),
                                        XSDataLength(0.1),
                                        XSDataLength(0.1))

        xsDataRaddoseInput.setCrystalCell(xsDataCell)
        xsDataRaddoseInput.setCrystalSize(xsDataSizeCrystal)

        # Beam
        from XSDataCommon import XSDataFlux
        from XSDataCommon import XSDataWavelength
        from XSDataCommon import XSDataTime

        xsDataSize = XSDataSize(x = XSDataLength(0.1),
                                y = XSDataLength(0.1))

        xsDataRaddoseInput.setBeamSize(xsDataSize)
        xsDataRaddoseInput.setBeamFlux(XSDataFlux(1e+12))
        xsDataRaddoseInput.setBeamWavelength(XSDataWavelength(2.41))
        xsDataRaddoseInput.setBeamExposureTime(XSDataTime(1))

        xsDataRaddoseInput.setNumberOfImages(XSDataInteger(1))

        xsDataRaddoseInput.exportToFile(self.strObtainedInputFile)

        strExpectedInput = self.readAndParseFile (self.strReferenceInputFile)
        strObtainedInput = self.readAndParseFile (self.strObtainedInputFile)

        xsDataRaddoseInputExpected = XSDataRaddoseInput.parseString(strExpectedInput)
        xsDataRaddoseInputObtained = XSDataRaddoseInput.parseString(strObtainedInput)

        EDAssert.equal(xsDataRaddoseInputExpected.marshal(), xsDataRaddoseInputObtained.marshal())