Пример #1
0
    def updateChemicalComposition(self, _xsDataChemicalComposition):
        """
        """
        xsDataChemicalComposition = _xsDataChemicalComposition

        for chain in xsDataChemicalComposition.getStructure().getChain():
            if(chain.getType().getValue() == "protein"):
                bSulfurExists = False
                xsDataAtomicCompositionHeavyAtoms = chain.getHeavyAtoms()
                if(xsDataAtomicCompositionHeavyAtoms is None):
                    xsDataAtomicCompositionHeavyAtoms = XSDataAtomicComposition()
                else:
                    for heavyAtom in xsDataAtomicCompositionHeavyAtoms.getAtom():
                        if(heavyAtom.getSymbol().getValue() == "S" or heavyAtom.getSymbol().getValue() == "s"):
                            bSulfurExists = True

                # all protein chains should contain sulfur atom as a percentage of the number
                # of amino acids. Add them if the user did not input them.
                if(bSulfurExists == False):
                    iNumberOfSulfurAtom = int(round(chain.getNumberOfMonomers().getValue() * 0.05))
                    xsDataSulfurAtom = XSDataAtom()
                    xsDataSulfurAtom.setSymbol(XSDataString("S"))
                    xsDataSulfurAtom.setNumberOf(XSDataFloat(iNumberOfSulfurAtom))
                    xsDataAtomicCompositionHeavyAtoms.addAtom(xsDataSulfurAtom)
                    chain.setHeavyAtoms(xsDataAtomicCompositionHeavyAtoms)

        return xsDataChemicalComposition
    def getDefaultChemicalComposition(self, _xsDataSample, _inumOperators):
        """
        """
        xsDataCell = _xsDataSample.getCrystal().getCell()
        a = xsDataCell.getLength_a().getValue()
        b = xsDataCell.getLength_b().getValue()
        c = xsDataCell.getLength_c().getValue()
        alpha = math.radians(xsDataCell.getAngle_alpha().getValue())
        beta = math.radians(xsDataCell.getAngle_beta().getValue())
        gamma = math.radians(xsDataCell.getAngle_gamma().getValue())

        fUnitCellVolume = (
            a
            * b
            * c
            * (
                math.sqrt(
                    1
                    - math.cos(alpha) * math.cos(alpha)
                    - math.cos(beta) * math.cos(beta)
                    - math.cos(gamma) * math.cos(gamma)
                    + 2 * math.cos(alpha) * math.cos(beta) * math.cos(gamma)
                )
            )
        )
        fPolymerVolume = fUnitCellVolume * (1 - self.fAverageCrystalSolventContent)
        fNumberOfMonomersPerUnitCell = fPolymerVolume / self.fAverageAminoAcidVolume
        fNumberOfMonomersPerAsymmetricUnit = fNumberOfMonomersPerUnitCell / _inumOperators
        iNumberOfSulfurAtom = int(round(fNumberOfMonomersPerAsymmetricUnit * self.fAverageSulfurContentPerAminoacid))

        xsDataAtom = XSDataAtom()
        xsDataAtom.setSymbol(XSDataString("S"))
        xsDataAtom.setNumberOf(XSDataDouble(iNumberOfSulfurAtom))
        xsDataAtomicComposition = XSDataAtomicComposition()
        xsDataAtomicComposition.addAtom(xsDataAtom)

        xsDataChain = XSDataChain()
        xsDataChain.setType(XSDataString("protein"))
        xsDataChain.setNumberOfMonomers(XSDataDouble(round(fNumberOfMonomersPerAsymmetricUnit)))
        xsDataChain.setNumberOfCopies(XSDataDouble(1))
        xsDataChain.setHeavyAtoms(xsDataAtomicComposition)

        xsDataStructure = XSDataStructure()
        xsDataStructure.addChain(xsDataChain)
        xsDataStructure.setNumberOfCopiesInAsymmetricUnit(XSDataDouble(1))

        xsDataAtomSolvent = XSDataAtom()
        xsDataAtomSolvent.setSymbol(XSDataString("S"))
        xsDataAtomSolvent.setConcentration(XSDataDouble(self.fAverageSulfurConcentration))
        xsDataAtomicCompositionSolvent = XSDataAtomicComposition()
        xsDataAtomicCompositionSolvent.addAtom(xsDataAtomSolvent)
        xsDataSolvent = XSDataSolvent()
        xsDataSolvent.setAtoms(xsDataAtomicCompositionSolvent)

        xsDataChemicalCompositionMM = XSDataChemicalCompositionMM()
        xsDataChemicalCompositionMM.setSolvent(xsDataSolvent)
        xsDataChemicalCompositionMM.setStructure(xsDataStructure)

        return xsDataChemicalCompositionMM
    def testUpdateChemicalCompositionWithNativeSulfurAtom(self):
        """
        """
        from XSDataCommon import XSDataAngle
        from XSDataCommon import XSDataString
        from XSDataCommon import XSDataInteger
        from XSDataCommon import XSDataString
        from XSDataCommon import XSDataFloat
        from XSDataMXv1 import XSDataStructure
        from XSDataMXv1 import XSDataChain
        from XSDataMXv1 import XSDataAtom
        from XSDataMXv1 import XSDataLigand
        from XSDataMXv1 import XSDataSampleCrystalMM
        from XSDataMXv1 import XSDataChemicalCompositionMM
        from XSDataMXv1 import XSDataAtomicComposition
        from XSDataMXv1 import XSDataSolvent
        from XSDataMXv1 import XSDataCell
        from XSDataMXv1 import XSDataSpaceGroup


        edPluginStrategy = self.createPlugin()
        xsPluginItemGood01 = self.getPluginConfiguration(os.path.join(self.strDataPath, "XSConfiguration_ESRF.xml"))
        edPluginStrategy.setConfiguration(xsPluginItemGood01)
        edPluginStrategy.configure()

        xsDataSampleCrystalMM = XSDataSampleCrystalMM()
        xsDataStructure = XSDataStructure()
        xsDataComposition = XSDataChemicalCompositionMM()
        xsDataChain = XSDataChain()
        xsDataChain.setType(XSDataString("protein"))
        xsDataChain.setNumberOfCopies(XSDataFloat(2))
        xsDataChain.setNumberOfMonomers(XSDataFloat(60))
        xsDataStructure.addChain(xsDataChain)
        xsDataComposition.setStructure(xsDataStructure)
        updatedChemicalComposition = edPluginStrategy.updateChemicalComposition(xsDataComposition)
        EDAssert.equal(3, updatedChemicalComposition.getStructure().getChain()[0].getHeavyAtoms().getAtom()[0].getNumberOf().getValue())
        EDAssert.equal("S", updatedChemicalComposition.getStructure().getChain()[0].getHeavyAtoms().getAtom()[0].getSymbol().getValue())

        xsDataSampleCrystalMM = XSDataSampleCrystalMM()
        xsDataStructure = XSDataStructure()
        xsDataComposition = XSDataChemicalCompositionMM()
        xsDataChain = XSDataChain()
        xsDataChain.setType(XSDataString("protein"))
        xsDataChain.setNumberOfCopies(XSDataFloat(2))
        xsDataChain.setNumberOfMonomers(XSDataFloat(60))
        xsDataAtom1 = XSDataAtom()
        xsDataAtom1.setSymbol(XSDataString("Se"))
        xsDataAtom1.setNumberOf(XSDataFloat(4))
        xsDataAtomicComposition = XSDataAtomicComposition()
        xsDataAtomicComposition.addAtom(xsDataAtom1)
        xsDataChain.setHeavyAtoms(xsDataAtomicComposition)
        xsDataStructure.addChain(xsDataChain)
        xsDataComposition.setStructure(xsDataStructure)
        updatedChemicalComposition = edPluginStrategy.updateChemicalComposition(xsDataComposition)
        heavyAtoms = updatedChemicalComposition.getStructure().getChain()[0].getHeavyAtoms().getAtom()
        for heavyAtom in heavyAtoms:
            EDVerbose.unitTest(heavyAtom.getSymbol().getValue() + " : " + str(heavyAtom.getNumberOf().getValue()))
            if(heavyAtom.getSymbol().getValue() == "S"):
                EDAssert.equal(3, heavyAtom.getNumberOf().getValue())
    def testUpdateChemicalCompositionWithNativeSulfurAtom(self):

        edPluginStrategy = self.createPlugin()
        xsPluginItemGood01 = self.getPluginConfiguration(os.path.join(self.strDataPath, "XSConfiguration_ESRF.xml"))
        edPluginStrategy.setConfiguration(xsPluginItemGood01)
        edPluginStrategy.configure()

        xsDataStructure = XSDataStructure()
        xsDataComposition = XSDataChemicalCompositionMM()
        xsDataChain = XSDataChain()
        xsDataChain.setType(XSDataString("protein"))
        xsDataChain.setNumberOfCopies(XSDataDouble(2))
        xsDataChain.setNumberOfMonomers(XSDataDouble(60))
        xsDataStructure.addChain(xsDataChain)
        xsDataComposition.setStructure(xsDataStructure)
        updatedChemicalComposition = edPluginStrategy.updateChemicalComposition(xsDataComposition)
        EDAssert.equal(
            3,
            updatedChemicalComposition.getStructure()
            .getChain()[0]
            .getHeavyAtoms()
            .getAtom()[0]
            .getNumberOf()
            .getValue(),
        )
        EDAssert.equal(
            "S",
            updatedChemicalComposition.getStructure().getChain()[0].getHeavyAtoms().getAtom()[0].getSymbol().getValue(),
        )

        xsDataStructure = XSDataStructure()
        xsDataComposition = XSDataChemicalCompositionMM()
        xsDataChain = XSDataChain()
        xsDataChain.setType(XSDataString("protein"))
        xsDataChain.setNumberOfCopies(XSDataDouble(2))
        xsDataChain.setNumberOfMonomers(XSDataDouble(60))
        xsDataAtom1 = XSDataAtom()
        xsDataAtom1.setSymbol(XSDataString("Se"))
        xsDataAtom1.setNumberOf(XSDataDouble(4))
        xsDataAtomicComposition = XSDataAtomicComposition()
        xsDataAtomicComposition.addAtom(xsDataAtom1)
        xsDataChain.setHeavyAtoms(xsDataAtomicComposition)
        xsDataStructure.addChain(xsDataChain)
        xsDataComposition.setStructure(xsDataStructure)
        updatedChemicalComposition = edPluginStrategy.updateChemicalComposition(xsDataComposition)
        heavyAtoms = updatedChemicalComposition.getStructure().getChain()[0].getHeavyAtoms().getAtom()
        for heavyAtom in heavyAtoms:
            EDVerbose.unitTest(heavyAtom.getSymbol().getValue() + " : " + str(heavyAtom.getNumberOf().getValue()))
            if heavyAtom.getSymbol().getValue() == "S":
                EDAssert.equal(3, heavyAtom.getNumberOf().getValue())
    def testUpdateChemicalCompositionWithNativeSulfurAtom(self):

        edPluginStrategy = self.createPlugin()
        strPathToTestConfigFile = os.path.join(self.getPluginTestsDataHome(), "XSConfiguration_ESRF.xml")
        edConfiguration = EDConfiguration(strPathToTestConfigFile)
        dictItem = edConfiguration.get(edPluginStrategy.getPluginName())
        edPluginStrategy.setConfig(dictItem)
        edPluginStrategy.configure()

        xsDataStructure = XSDataStructure()
        xsDataComposition = XSDataChemicalCompositionMM()
        xsDataChain = XSDataChain()
        xsDataChain.setType(XSDataString("protein"))
        xsDataChain.setNumberOfCopies(XSDataDouble(2))
        xsDataChain.setNumberOfMonomers(XSDataDouble(60))
        xsDataStructure.addChain(xsDataChain)
        xsDataComposition.setStructure(xsDataStructure)
        updatedChemicalComposition = edPluginStrategy.updateChemicalComposition(xsDataComposition)
        EDAssert.equal(3, updatedChemicalComposition.getStructure().getChain()[0].getHeavyAtoms().getAtom()[0].getNumberOf().getValue())
        EDAssert.equal("S", updatedChemicalComposition.getStructure().getChain()[0].getHeavyAtoms().getAtom()[0].getSymbol().getValue())

        xsDataStructure = XSDataStructure()
        xsDataComposition = XSDataChemicalCompositionMM()
        xsDataChain = XSDataChain()
        xsDataChain.setType(XSDataString("protein"))
        xsDataChain.setNumberOfCopies(XSDataDouble(2))
        xsDataChain.setNumberOfMonomers(XSDataDouble(60))
        xsDataAtom1 = XSDataAtom()
        xsDataAtom1.setSymbol(XSDataString("Se"))
        xsDataAtom1.setNumberOf(XSDataDouble(4))
        xsDataAtomicComposition = XSDataAtomicComposition()
        xsDataAtomicComposition.addAtom(xsDataAtom1)
        xsDataChain.setHeavyAtoms(xsDataAtomicComposition)
        xsDataStructure.addChain(xsDataChain)
        xsDataComposition.setStructure(xsDataStructure)
        updatedChemicalComposition = edPluginStrategy.updateChemicalComposition(xsDataComposition)
        heavyAtoms = updatedChemicalComposition.getStructure().getChain()[0].getHeavyAtoms().getAtom()
        for heavyAtom in heavyAtoms:
            self.unitTest(heavyAtom.getSymbol().getValue() + " : " + str(heavyAtom.getNumberOf().getValue()))
            if(heavyAtom.getSymbol().getValue() == "S"):
                EDAssert.equal(3, heavyAtom.getNumberOf().getValue())
Пример #6
0
    def updateChemicalComposition(self, _xsDataChemicalComposition):
        """
        """
        xsDataChemicalComposition = _xsDataChemicalComposition

        for chain in xsDataChemicalComposition.getStructure().getChain():
            if (chain.getType().getValue() == "protein"):
                bSulfurExists = False
                xsDataAtomicCompositionHeavyAtoms = chain.getHeavyAtoms()
                if (xsDataAtomicCompositionHeavyAtoms is None):
                    xsDataAtomicCompositionHeavyAtoms = XSDataAtomicComposition(
                    )
                else:
                    for heavyAtom in xsDataAtomicCompositionHeavyAtoms.getAtom(
                    ):
                        if (heavyAtom.getSymbol().getValue() == "S"
                                or heavyAtom.getSymbol().getValue() == "s"):
                            bSulfurExists = True

                # all protein chains should contain sulfur atom as a percentage of the number
                # of amino acids. Add them if the user did not input them.
                if (bSulfurExists == False):
                    iNumberOfSulfurAtom = int(
                        round(chain.getNumberOfMonomers().getValue() * 0.05))
                    xsDataSulfurAtom = XSDataAtom()
                    xsDataSulfurAtom.setSymbol(XSDataString("S"))
                    xsDataSulfurAtom.setNumberOf(
                        XSDataFloat(iNumberOfSulfurAtom))
                    xsDataAtomicCompositionHeavyAtoms.addAtom(xsDataSulfurAtom)
                    chain.setHeavyAtoms(xsDataAtomicCompositionHeavyAtoms)

        return xsDataChemicalComposition
    def testUpdateChemicalCompositionWithNativeSulfurAtom(self):
        from XSDataCommon import XSDataAngle
        from XSDataCommon import XSDataString
        from XSDataCommon import XSDataInteger
        from XSDataCommon import XSDataString
        from XSDataCommon import XSDataFloat
        from XSDataMXv1 import XSDataStructure
        from XSDataMXv1 import XSDataChain
        from XSDataMXv1 import XSDataAtom
        from XSDataMXv1 import XSDataLigand
        from XSDataMXv1 import XSDataSampleCrystalMM
        from XSDataMXv1 import XSDataChemicalCompositionMM
        from XSDataMXv1 import XSDataAtomicComposition
        from XSDataMXv1 import XSDataSolvent
        from XSDataMXv1 import XSDataCell
        from XSDataMXv1 import XSDataSpaceGroup


        edPluginStrategy = self.createPlugin()
        xsPluginItemGood01 = self.getPluginConfiguration(os.path.join(self.strDataPath, "XSConfiguration_ESRF.xml"))
        edPluginStrategy.setConfiguration(xsPluginItemGood01)
        edPluginStrategy.configure()

        xsDataStructure = XSDataStructure()
        xsDataComposition = XSDataChemicalCompositionMM()
        xsDataChain = XSDataChain()
        xsDataChain.setType(XSDataString("protein"))
        xsDataChain.setNumberOfCopies(XSDataFloat(2))
        xsDataChain.setNumberOfMonomers(XSDataFloat(60))
        xsDataStructure.addChain(xsDataChain)
        xsDataComposition.setStructure(xsDataStructure)
        updatedChemicalComposition = edPluginStrategy.updateChemicalComposition(xsDataComposition)
        EDAssert.equal(3, updatedChemicalComposition.getStructure().getChain()[0].getHeavyAtoms().getAtom()[0].getNumberOf().getValue())
        EDAssert.equal("S", updatedChemicalComposition.getStructure().getChain()[0].getHeavyAtoms().getAtom()[0].getSymbol().getValue())

        xsDataStructure = XSDataStructure()
        xsDataComposition = XSDataChemicalCompositionMM()
        xsDataChain = XSDataChain()
        xsDataChain.setType(XSDataString("protein"))
        xsDataChain.setNumberOfCopies(XSDataFloat(2))
        xsDataChain.setNumberOfMonomers(XSDataFloat(60))
        xsDataAtom1 = XSDataAtom()
        xsDataAtom1.setSymbol(XSDataString("Se"))
        xsDataAtom1.setNumberOf(XSDataFloat(4))
        xsDataAtomicComposition = XSDataAtomicComposition()
        xsDataAtomicComposition.addAtom(xsDataAtom1)
        xsDataChain.setHeavyAtoms(xsDataAtomicComposition)
        xsDataStructure.addChain(xsDataChain)
        xsDataComposition.setStructure(xsDataStructure)
        updatedChemicalComposition = edPluginStrategy.updateChemicalComposition(xsDataComposition)
        heavyAtoms = updatedChemicalComposition.getStructure().getChain()[0].getHeavyAtoms().getAtom()
        for heavyAtom in heavyAtoms:
            EDVerbose.unitTest(heavyAtom.getSymbol().getValue() + " : " + str(heavyAtom.getNumberOf().getValue()))
            if(heavyAtom.getSymbol().getValue() == "S"):
                EDAssert.equal(3, heavyAtom.getNumberOf().getValue())
    def testUpdateChemicalCompositionWithNativeSulfurAtom(self):

        edPluginStrategy = self.createPlugin()
        strPathToTestConfigFile = os.path.join(self.getPluginTestsDataHome(),
                                               "XSConfiguration_ESRF.xml")
        edConfiguration = EDConfiguration(strPathToTestConfigFile)
        dictItem = edConfiguration.get(edPluginStrategy.getPluginName())
        edPluginStrategy.setConfig(dictItem)
        edPluginStrategy.configure()

        xsDataStructure = XSDataStructure()
        xsDataComposition = XSDataChemicalCompositionMM()
        xsDataChain = XSDataChain()
        xsDataChain.setType(XSDataString("protein"))
        xsDataChain.setNumberOfCopies(XSDataDouble(2))
        xsDataChain.setNumberOfMonomers(XSDataDouble(60))
        xsDataStructure.addChain(xsDataChain)
        xsDataComposition.setStructure(xsDataStructure)
        updatedChemicalComposition = edPluginStrategy.updateChemicalComposition(
            xsDataComposition)
        EDAssert.equal(
            3,
            updatedChemicalComposition.getStructure().getChain()
            [0].getHeavyAtoms().getAtom()[0].getNumberOf().getValue())
        EDAssert.equal(
            "S",
            updatedChemicalComposition.getStructure().getChain()
            [0].getHeavyAtoms().getAtom()[0].getSymbol().getValue())

        xsDataStructure = XSDataStructure()
        xsDataComposition = XSDataChemicalCompositionMM()
        xsDataChain = XSDataChain()
        xsDataChain.setType(XSDataString("protein"))
        xsDataChain.setNumberOfCopies(XSDataDouble(2))
        xsDataChain.setNumberOfMonomers(XSDataDouble(60))
        xsDataAtom1 = XSDataAtom()
        xsDataAtom1.setSymbol(XSDataString("Se"))
        xsDataAtom1.setNumberOf(XSDataDouble(4))
        xsDataAtomicComposition = XSDataAtomicComposition()
        xsDataAtomicComposition.addAtom(xsDataAtom1)
        xsDataChain.setHeavyAtoms(xsDataAtomicComposition)
        xsDataStructure.addChain(xsDataChain)
        xsDataComposition.setStructure(xsDataStructure)
        updatedChemicalComposition = edPluginStrategy.updateChemicalComposition(
            xsDataComposition)
        heavyAtoms = updatedChemicalComposition.getStructure().getChain(
        )[0].getHeavyAtoms().getAtom()
        for heavyAtom in heavyAtoms:
            self.unitTest(heavyAtom.getSymbol().getValue() + " : " +
                          str(heavyAtom.getNumberOf().getValue()))
            if (heavyAtom.getSymbol().getValue() == "S"):
                EDAssert.equal(3, heavyAtom.getNumberOf().getValue())
Пример #9
0
    def getDefaultChemicalComposition(self, _xsDataSample, _inumOperators):
        """
        """
        xsDataCell = _xsDataSample.getCrystal().getCell()
        a = xsDataCell.getLength_a().getValue()
        b = xsDataCell.getLength_b().getValue()
        c = xsDataCell.getLength_c().getValue()
        alpha = math.radians(xsDataCell.getAngle_alpha().getValue())
        beta = math.radians(xsDataCell.getAngle_beta().getValue())
        gamma = math.radians(xsDataCell.getAngle_gamma().getValue())

        fUnitCellVolume = a * b * c * (
            math.sqrt(1 - math.cos(alpha) * math.cos(alpha) - math.cos(beta) *
                      math.cos(beta) - math.cos(gamma) * math.cos(gamma) +
                      2 * math.cos(alpha) * math.cos(beta) * math.cos(gamma)))
        fPolymerVolume = fUnitCellVolume * (
            1 - self.__fAverageCrystalSolventContent)
        fNumberOfMonomersPerUnitCell = fPolymerVolume / self.__fAverageAminoAcidVolume
        fNumberOfMonomersPerAsymmetricUnit = fNumberOfMonomersPerUnitCell / _inumOperators
        iNumberOfSulfurAtom = int(
            round(fNumberOfMonomersPerAsymmetricUnit *
                  self.__fAverageSulfurContentPerAminoacid))

        xsDataAtom = XSDataAtom()
        xsDataAtom.setSymbol(XSDataString("S"))
        xsDataAtom.setNumberOf(XSDataFloat(iNumberOfSulfurAtom))
        xsDataAtomicComposition = XSDataAtomicComposition()
        xsDataAtomicComposition.addAtom(xsDataAtom)

        xsDataChain = XSDataChain()
        xsDataChain.setType(XSDataString("protein"))
        xsDataChain.setNumberOfMonomers(
            XSDataFloat(round(fNumberOfMonomersPerAsymmetricUnit)))
        xsDataChain.setNumberOfCopies(XSDataFloat(1))
        xsDataChain.setHeavyAtoms(xsDataAtomicComposition)

        xsDataStructure = XSDataStructure()
        xsDataStructure.addChain(xsDataChain)
        xsDataStructure.setNumberOfCopiesInAsymmetricUnit(XSDataFloat(1))

        xsDataAtomSolvent = XSDataAtom()
        xsDataAtomSolvent.setSymbol(XSDataString("S"))
        xsDataAtomSolvent.setConcentration(
            XSDataFloat(self.__fAverageSulfurConcentration))
        xsDataAtomicCompositionSolvent = XSDataAtomicComposition()
        xsDataAtomicCompositionSolvent.addAtom(xsDataAtomSolvent)
        xsDataSolvent = XSDataSolvent()
        xsDataSolvent.setAtoms(xsDataAtomicCompositionSolvent)

        xsDataChemicalCompositionMM = XSDataChemicalCompositionMM()
        xsDataChemicalCompositionMM.setSolvent(xsDataSolvent)
        xsDataChemicalCompositionMM.setStructure(xsDataStructure)

        return xsDataChemicalCompositionMM
    def testSetDataModelInput(self):
        edPluginStrategy = self.createPlugin()
        strPathToTestConfigFile = os.path.join(self.getPluginTestsDataHome(),
                                               "XSConfiguration_ESRF.xml")
        edConfiguration = EDConfiguration(strPathToTestConfigFile)
        dictItem = edConfiguration.get(edPluginStrategy.getPluginName())
        edPluginStrategy.setConfig(dictItem)
        edPluginStrategy.configure()

        xsDataStrategy = XSDataInputStrategy()

        # Beam

        xsExperimentalCondition = XSDataExperimentalCondition()

        xsBeam = XSDataBeam()
        xsBeam.setFlux(XSDataFlux(1e+12))
        xsBeam.setWavelength(XSDataWavelength(2.41))
        xsBeam.setSize(XSDataSize(x=XSDataLength(0.1), y=XSDataLength(0.1)))
        xsBeam.setExposureTime(XSDataTime(1))

        xsExperimentalCondition.setBeam(xsBeam)

        # Detector and Exposure Time

        xsDataDetector = XSDataDetector()
        xsDataDetector.setType(XSDataString("q210-2x"))
        xsExperimentalCondition.setDetector(xsDataDetector)

        xsDataGoniostat = XSDataGoniostat()
        xsDataGoniostat.setRotationAxis(XSDataString("phi"))
        xsExperimentalCondition.setGoniostat(xsDataGoniostat)

        xsDataStrategy.setExperimentalCondition(xsExperimentalCondition)

        # Best Files
        bestFileContentDat = EDUtilsFile.readFile(
            os.path.join(self.strDataPath, "bestfile.dat"))
        xsDataStrategy.setBestFileContentDat(XSDataString(bestFileContentDat))
        bestFileContentPar = EDUtilsFile.readFile(
            os.path.join(self.strDataPath, "bestfile.par"))
        xsDataStrategy.setBestFileContentPar(XSDataString(bestFileContentPar))
        bestFileContentHKL = EDUtilsFile.readFile(
            os.path.join(self.strDataPath, "bestfile1.hkl"))
        xsDataStrategy.addBestFileContentHKL(XSDataString(bestFileContentHKL))

        # Crystal

        xsDataSampleCrystalMM = XSDataSampleCrystalMM()
        xsDataStructure = XSDataStructure()
        xsDataComposition = XSDataChemicalCompositionMM()

        xsDataChain = XSDataChain()
        xsDataChain.setType(XSDataString("protein"))
        xsDataChain.setNumberOfCopies(XSDataDouble(2))
        xsDataAtomicComposition = XSDataAtomicComposition()
        xsDataAtom1 = XSDataAtom()
        xsDataAtom1.setSymbol(XSDataString("Se"))
        xsDataAtom1.setNumberOf(XSDataDouble(4))
        xsDataAtomicComposition.addAtom(xsDataAtom1)

        xsDataChain.setHeavyAtoms(xsDataAtomicComposition)
        xsDataChain.setNumberOfMonomers(XSDataDouble(100))
        xsDataStructure.addChain(xsDataChain)

        xsDataChain2 = XSDataChain()
        xsDataChain2.setType(XSDataString("rna"))
        xsDataChain2.setNumberOfCopies(XSDataDouble(1))
        xsDataChain2.setNumberOfMonomers(XSDataDouble(60))
        xsDataStructure.addChain(xsDataChain2)

        xsDataLigand = XSDataLigand()
        xsDataLigand.setNumberOfCopies(XSDataDouble(2))
        xsDataLigand.setNumberOfLightAtoms(XSDataDouble(42))
        xsDataAtomicComposition = XSDataAtomicComposition()
        xsDataAtom2 = XSDataAtom()
        xsDataAtom2.setSymbol(XSDataString("Fe"))
        xsDataAtom2.setNumberOf(XSDataDouble(1))
        xsDataAtomicComposition.addAtom(xsDataAtom2)
        xsDataLigand.setHeavyAtoms(xsDataAtomicComposition)
        xsDataStructure.addLigand(xsDataLigand)
        xsDataStructure.setNumberOfCopiesInAsymmetricUnit(XSDataDouble(0.25))

        xsDataSolvent = XSDataSolvent()
        xsDataAtomicComposition = XSDataAtomicComposition()

        xsDataAtom3 = XSDataAtom()
        xsDataAtom3.setSymbol(XSDataString("Na"))
        xsDataAtom3.setConcentration(XSDataDouble(1000))
        xsDataAtom4 = XSDataAtom()
        xsDataAtom4.setSymbol(XSDataString("Cl"))
        xsDataAtom4.setConcentration(XSDataDouble(1000))

        xsDataAtomicComposition.addAtom(xsDataAtom3)
        xsDataAtomicComposition.addAtom(xsDataAtom4)
        xsDataSolvent.setAtoms(xsDataAtomicComposition)

        xsDataComposition.setStructure(xsDataStructure)
        xsDataComposition.setSolvent(xsDataSolvent)
        xsDataSampleCrystalMM.setChemicalComposition(xsDataComposition)

        xsDataSampleCrystalMM.setSize(
            XSDataSize(XSDataLength(0.1), XSDataLength(0.1),
                       XSDataLength(0.1)))

        xsDataCrystal = XSDataCrystal()
        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))
        xsDataCrystal.setCell(xsDataCell)

        xsDataSpaceGroup = XSDataSpaceGroup()
        xsDataSpaceGroup.setITNumber(XSDataInteger(16))
        xsDataCrystal.setSpaceGroup(xsDataSpaceGroup)

        xsDataSampleCrystalMM.setSusceptibility(XSDataDouble(1.5))

        xsDataStrategy.setCrystalRefined(xsDataCrystal)

        xsDataStrategy.setSample(xsDataSampleCrystalMM)

        xsDataStrategy.exportToFile(self.strObtainedInputFile)

        pyStrExpectedInput = self.readAndParseFile(self.strReferenceInputFile)
        pyStrObtainedInput = self.readAndParseFile(self.strObtainedInputFile)

        xsDataInputExpected = XSDataInputStrategy.parseString(
            pyStrExpectedInput)
        xsDataInputObtained = XSDataInputStrategy.parseString(
            pyStrObtainedInput)

        EDAssert.equal(xsDataInputExpected.marshal(),
                       xsDataInputObtained.marshal())
    def testSetDataModelInput(self):
        edPluginStrategy = self.createPlugin()
        strPathToTestConfigFile = os.path.join(self.getPluginTestsDataHome(), "XSConfiguration_ESRF.xml")
        edConfiguration = EDConfiguration(strPathToTestConfigFile)
        dictItem = edConfiguration.get(edPluginStrategy.getPluginName())
        edPluginStrategy.setConfig(dictItem)
        edPluginStrategy.configure()

        xsDataStrategy = XSDataInputStrategy()

        # Beam

        xsExperimentalCondition = XSDataExperimentalCondition()

        xsBeam = XSDataBeam()
        xsBeam.setFlux(XSDataFlux(1e+12))
        xsBeam.setWavelength(XSDataWavelength(2.41))
        xsBeam.setSize(XSDataSize(x=XSDataLength(0.1), y=XSDataLength(0.1)))
        xsBeam.setExposureTime(XSDataTime(1))

        xsExperimentalCondition.setBeam(xsBeam)

        # Detector and Exposure Time

        xsDataDetector = XSDataDetector()
        xsDataDetector.setType(XSDataString("q210-2x"))
        xsExperimentalCondition.setDetector(xsDataDetector)

        xsDataGoniostat = XSDataGoniostat()
        xsDataGoniostat.setRotationAxis(XSDataString("phi"))
        xsExperimentalCondition.setGoniostat(xsDataGoniostat)

        xsDataStrategy.setExperimentalCondition(xsExperimentalCondition)


        # Best Files
        bestFileContentDat = EDUtilsFile.readFile(os.path.join(self.strDataPath, "bestfile.dat"))
        xsDataStrategy.setBestFileContentDat(XSDataString(bestFileContentDat))
        bestFileContentPar = EDUtilsFile.readFile(os.path.join(self.strDataPath, "bestfile.par"))
        xsDataStrategy.setBestFileContentPar(XSDataString(bestFileContentPar))
        bestFileContentHKL = EDUtilsFile.readFile(os.path.join(self.strDataPath, "bestfile1.hkl"))
        xsDataStrategy.addBestFileContentHKL(XSDataString(bestFileContentHKL))

        # Crystal

        xsDataSampleCrystalMM = XSDataSampleCrystalMM()
        xsDataStructure = XSDataStructure()
        xsDataComposition = XSDataChemicalCompositionMM()

        xsDataChain = XSDataChain()
        xsDataChain.setType(XSDataString("protein"))
        xsDataChain.setNumberOfCopies(XSDataDouble(2))
        xsDataAtomicComposition = XSDataAtomicComposition()
        xsDataAtom1 = XSDataAtom()
        xsDataAtom1.setSymbol(XSDataString("Se"))
        xsDataAtom1.setNumberOf(XSDataDouble(4))
        xsDataAtomicComposition.addAtom(xsDataAtom1)

        xsDataChain.setHeavyAtoms(xsDataAtomicComposition)
        xsDataChain.setNumberOfMonomers(XSDataDouble(100))
        xsDataStructure.addChain(xsDataChain)

        xsDataChain2 = XSDataChain()
        xsDataChain2.setType(XSDataString("rna"))
        xsDataChain2.setNumberOfCopies(XSDataDouble(1))
        xsDataChain2.setNumberOfMonomers(XSDataDouble(60))
        xsDataStructure.addChain(xsDataChain2)

        xsDataLigand = XSDataLigand()
        xsDataLigand.setNumberOfCopies(XSDataDouble(2))
        xsDataLigand.setNumberOfLightAtoms(XSDataDouble(42))
        xsDataAtomicComposition = XSDataAtomicComposition()
        xsDataAtom2 = XSDataAtom()
        xsDataAtom2.setSymbol(XSDataString("Fe"))
        xsDataAtom2.setNumberOf(XSDataDouble(1))
        xsDataAtomicComposition.addAtom(xsDataAtom2)
        xsDataLigand.setHeavyAtoms(xsDataAtomicComposition)
        xsDataStructure.addLigand(xsDataLigand)
        xsDataStructure.setNumberOfCopiesInAsymmetricUnit(XSDataDouble(0.25))

        xsDataSolvent = XSDataSolvent()
        xsDataAtomicComposition = XSDataAtomicComposition()

        xsDataAtom3 = XSDataAtom()
        xsDataAtom3.setSymbol(XSDataString("Na"))
        xsDataAtom3.setConcentration(XSDataDouble(1000))
        xsDataAtom4 = XSDataAtom()
        xsDataAtom4.setSymbol(XSDataString("Cl"))
        xsDataAtom4.setConcentration(XSDataDouble(1000))

        xsDataAtomicComposition.addAtom(xsDataAtom3)
        xsDataAtomicComposition.addAtom(xsDataAtom4)
        xsDataSolvent.setAtoms(xsDataAtomicComposition)

        xsDataComposition.setStructure(xsDataStructure)
        xsDataComposition.setSolvent(xsDataSolvent)
        xsDataSampleCrystalMM.setChemicalComposition(xsDataComposition)

        xsDataSampleCrystalMM.setSize(XSDataSize(XSDataLength(0.1), XSDataLength(0.1), XSDataLength(0.1)))

        xsDataCrystal = XSDataCrystal()
        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))
        xsDataCrystal.setCell(xsDataCell)

        xsDataSpaceGroup = XSDataSpaceGroup()
        xsDataSpaceGroup.setITNumber(XSDataInteger(16))
        xsDataCrystal.setSpaceGroup(xsDataSpaceGroup)

        xsDataSampleCrystalMM.setSusceptibility(XSDataDouble(1.5))

        xsDataStrategy.setCrystalRefined(xsDataCrystal)

        xsDataStrategy.setSample(xsDataSampleCrystalMM)

        xsDataStrategy.exportToFile(self.strObtainedInputFile)

        pyStrExpectedInput = self.readAndParseFile (self.strReferenceInputFile)
        pyStrObtainedInput = self.readAndParseFile (self.strObtainedInputFile)

        xsDataInputExpected = XSDataInputStrategy.parseString(pyStrExpectedInput)
        xsDataInputObtained = XSDataInputStrategy.parseString(pyStrObtainedInput)

        EDAssert.equal(xsDataInputExpected.marshal(), xsDataInputObtained.marshal())
    def testSetDataModelInput(self):
        from XSDataCCP4iv1_1 import XSDataInputCCP4i
        xsDataInputCCP4i = XSDataInputCCP4i()

        # Beam
        from XSDataCommon import XSDataFlux
        from XSDataCommon import XSDataSize
        from XSDataCommon import XSDataLength
        from XSDataCommon import XSDataFloat

        from XSDataMXv1 import XSDataBeam
        from XSDataMXv1 import XSDataExperimentalCondition

        xsExperimentalCondition = XSDataExperimentalCondition()

        xsBeam = XSDataBeam()
        xsBeam.setFlux(XSDataFlux(1e+12))
        xsBeam.setSize(XSDataSize(XSDataLength(0.1), XSDataLength(0.1)))
        xsBeam.setMinExposureTimePerImage(XSDataFloat(0.1))
        xsExperimentalCondition.setBeam(xsBeam)

        # Goniostat
        from XSDataCommon import XSDataSpeed
        from XSDataCommon import XSDataAngle

        from XSDataMXv1 import XSDataGoniostat

        xsDataGoniostat = XSDataGoniostat()
        xsDataGoniostat.setMaxOscillationSpeed(XSDataSpeed(0.2))
        xsDataGoniostat.setMinOscillationWidth(XSDataAngle(0.1))
        xsExperimentalCondition.setGoniostat(xsDataGoniostat)
        xsDataInputCCP4i.setExperimentalCondition(xsExperimentalCondition)

        # Sample
        from XSDataCommon import XSDataString
        from XSDataCommon import XSDataFloat
        from XSDataCommon import XSDataString

        from XSDataMXv1 import XSDataStructure
        from XSDataMXv1 import XSDataChain
        from XSDataMXv1 import XSDataAtom
        from XSDataMXv1 import XSDataLigand
        from XSDataMXv1 import XSDataSampleCrystalMM
        from XSDataMXv1 import XSDataChemicalCompositionMM
        from XSDataMXv1 import XSDataAtomicComposition
        from XSDataMXv1 import XSDataSolvent

        xsDataSampleCrystalMM = XSDataSampleCrystalMM()
        xsDataStructure = XSDataStructure()
        xsDataComposition = XSDataChemicalCompositionMM()

        xsDataChain = XSDataChain()
        xsDataChain.setType(XSDataString("protein"))
        xsDataChain.setNumberOfCopies(XSDataFloat(2))
        xsDataAtomicComposition = XSDataAtomicComposition()
        xsDataAtom1 = XSDataAtom()
        xsDataAtom1.setSymbol(XSDataString("Se"))
        xsDataAtom1.setNumberOf(XSDataFloat(4))
        xsDataAtomicComposition.addAtom(xsDataAtom1)

        xsDataChain.setHeavyAtoms(xsDataAtomicComposition)
        xsDataChain.setNumberOfMonomers(XSDataFloat(100))
        xsDataStructure.addChain(xsDataChain)

        xsDataChain2 = XSDataChain()
        xsDataChain2.setType(XSDataString("rna"))
        xsDataChain2.setNumberOfCopies(XSDataFloat(1))
        xsDataChain2.setNumberOfMonomers(XSDataFloat(60))
        xsDataStructure.addChain(xsDataChain2)

        xsDataLigand = XSDataLigand()
        xsDataLigand.setNumberOfCopies(XSDataFloat(2))
        xsDataLigand.setNumberOfLightAtoms(XSDataFloat(42))
        xsDataAtomicComposition = XSDataAtomicComposition()
        xsDataAtom2 = XSDataAtom()
        xsDataAtom2.setSymbol(XSDataString("Fe"))
        xsDataAtom2.setNumberOf(XSDataFloat(1))
        xsDataAtomicComposition.addAtom(xsDataAtom2)
        xsDataLigand.setHeavyAtoms(xsDataAtomicComposition)
        xsDataStructure.addLigand(xsDataLigand)
        xsDataStructure.setNumberOfCopiesInAsymmetricUnit(XSDataFloat(0.25))

        xsDataSolvent = XSDataSolvent()
        xsDataAtomicComposition = XSDataAtomicComposition()

        xsDataAtom3 = XSDataAtom()
        xsDataAtom3.setSymbol(XSDataString("Na"))
        xsDataAtom3.setConcentration(XSDataFloat(1000))
        xsDataAtom4 = XSDataAtom()
        xsDataAtom4.setSymbol(XSDataString("Cl"))
        xsDataAtom4.setConcentration(XSDataFloat(1000))

        xsDataAtomicComposition.addAtom(xsDataAtom3)
        xsDataAtomicComposition.addAtom(xsDataAtom4)
        xsDataSolvent.setAtoms(xsDataAtomicComposition)

        xsDataComposition.setStructure(xsDataStructure)
        xsDataComposition.setSolvent(xsDataSolvent)
        xsDataSampleCrystalMM.setChemicalComposition(xsDataComposition)

        xsDataSampleCrystalMM.setSize(XSDataSize(XSDataLength(0.2), XSDataLength(0.2), XSDataLength(0.2)))
        xsDataSampleCrystalMM.setSusceptibility(XSDataFloat(1.5))
        xsDataSampleCrystalMM.setShape(XSDataFloat(2))

        xsDataInputCCP4i.setSample(xsDataSampleCrystalMM)

        from XSDataMXv1 import XSDataDiffractionPlan

        xsDataDiffractionPlan = XSDataDiffractionPlan()

        xsDataDiffractionPlan.setAimedCompleteness(XSDataFloat(95.5))
        xsDataDiffractionPlan.setAimedIOverSigmaAtHighestResolution(XSDataFloat(2.5))
        xsDataDiffractionPlan.setAimedMultiplicity(XSDataFloat(95.5))
        xsDataDiffractionPlan.setAimedResolution(XSDataFloat(3))
        xsDataDiffractionPlan.setComplexity(XSDataString("full"))
        xsDataDiffractionPlan.setForcedSpaceGroup(XSDataString("P222"))
        xsDataDiffractionPlan.setMaxExposureTimePerDataCollection(XSDataFloat(10000))

        xsDataInputCCP4i.setDiffractionPlan(xsDataDiffractionPlan)

        from XSDataCommon import XSDataFile

        listInputDataFile = []
        xsDataFile = XSDataFile(XSDataString(self.strXSDataGenerateTemplateFile))
        listInputDataFile.append(xsDataFile)
        xsDataInputCCP4i.setDataFile(listInputDataFile)
    def testGetXSDataRaddoseInput(self):
        """
        """
        from XSDataCommon import XSDataLength
        from XSDataCommon import XSDataWavelength
        from XSDataCommon import XSDataFlux
        from XSDataCommon import XSDataSize
        from XSDataCommon import XSDataDouble
        from XSDataCommon import XSDataString
        from XSDataCommon import XSDataAngle
        from XSDataCommon import XSDataTime
        from XSDataCommon import XSDataInteger

        from XSDataMXv1   import XSDataBeam
        from XSDataMXv1   import XSDataStructure
        from XSDataMXv1   import XSDataChain
        from XSDataMXv1   import XSDataAtom
        from XSDataMXv1   import XSDataLigand
        from XSDataMXv1   import XSDataCrystal
        from XSDataMXv1   import XSDataSpaceGroup
        from XSDataMXv1   import XSDataSampleCrystalMM
        from XSDataMXv1   import XSDataChemicalCompositionMM
        from XSDataMXv1   import XSDataAtomicComposition
        from XSDataMXv1   import XSDataSolvent
        from XSDataMXv1   import XSDataCell

        from EDHandlerXSDataRaddosev10 import EDHandlerXSDataRaddosev10

        EDFactoryPluginStatic.loadModule("XSDataRaddosev10")
        from XSDataRaddosev10 import XSDataRaddoseInput

        xsDataBeam = XSDataBeam()
        xsDataBeam.setSize(XSDataSize(x=XSDataLength(0.1), y=XSDataLength(0.1)))
        xsDataBeam.setWavelength(XSDataWavelength(2.41))
        xsDataBeam.setFlux(XSDataFlux(1e+12))

        xsDataSample = XSDataSampleCrystalMM()
        xsDataStructure = XSDataStructure()
        xsDataComposition = XSDataChemicalCompositionMM()

        xsDataChain = XSDataChain()
        xsDataChain.setType(XSDataString("protein"))
        xsDataChain.setNumberOfCopies(XSDataDouble(2))
        xsDataAtomicComposition = XSDataAtomicComposition()
        xsDataAtom1 = XSDataAtom()
        xsDataAtom1.setSymbol(XSDataString("Se"))
        xsDataAtom1.setNumberOf(XSDataDouble(4))
        xsDataAtomicComposition.addAtom(xsDataAtom1)
        xsDataAtom2 = XSDataAtom()
        xsDataAtom2.setSymbol(XSDataString("S"))
        xsDataAtom2.setNumberOf(XSDataDouble(5))
        xsDataAtomicComposition.addAtom(xsDataAtom2)
        xsDataChain.setHeavyAtoms(xsDataAtomicComposition)
        xsDataChain.setNumberOfMonomers(XSDataDouble(100))
        xsDataStructure.addChain(xsDataChain)

        xsDataChain2 = XSDataChain()
        xsDataChain2.setType(XSDataString("rna"))
        xsDataChain2.setNumberOfCopies(XSDataDouble(1))
        xsDataChain2.setNumberOfMonomers(XSDataDouble(60))
        xsDataStructure.addChain(xsDataChain2)

        xsDataLigand = XSDataLigand()
        xsDataLigand.setNumberOfCopies(XSDataDouble(2))
        xsDataLigand.setNumberOfLightAtoms(XSDataDouble(42))
        xsDataAtomicComposition = XSDataAtomicComposition()
        xsDataAtom3 = XSDataAtom()
        xsDataAtom3.setSymbol(XSDataString("Fe"))
        xsDataAtom3.setNumberOf(XSDataDouble(1))
        xsDataAtomicComposition.addAtom(xsDataAtom3)
        xsDataLigand.setHeavyAtoms(xsDataAtomicComposition)
        xsDataStructure.addLigand(xsDataLigand)
        xsDataStructure.setNumberOfCopiesInAsymmetricUnit(XSDataDouble(0.25))

        xsDataSolvent = XSDataSolvent()
        xsDataAtomicComposition = XSDataAtomicComposition()
        xsDataAtomNa = XSDataAtom()
        xsDataAtomNa.setSymbol(XSDataString("Na"))
        xsDataAtomNa.setConcentration(XSDataDouble(1000))
        xsDataAtomicComposition.addAtom(xsDataAtomNa)
        xsDataAtomCl = XSDataAtom()
        xsDataAtomCl.setSymbol(XSDataString("Cl"))
        xsDataAtomCl.setConcentration(XSDataDouble(1000))
        xsDataAtomicComposition.addAtom(xsDataAtomCl)
        xsDataSolvent.setAtoms(xsDataAtomicComposition)

        xsDataComposition.setStructure(xsDataStructure)
        xsDataComposition.setSolvent(xsDataSolvent)
        xsDataSample.setChemicalComposition(xsDataComposition)

        xsDataSample.setSize(XSDataSize(XSDataLength(0.1), XSDataLength(0.1), XSDataLength(0.1)))
        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))

        xsDataCrystal = XSDataCrystal()
        xsDataSpaceGroup = XSDataSpaceGroup()

        xsDataCrystal.setCell(xsDataCell)

        xsDataSpaceGroup.setITNumber(XSDataInteger(16))
        xsDataCrystal.setSpaceGroup(xsDataSpaceGroup)

        xsDataSample.setCrystal(xsDataCrystal)

        iNumSymOperators = 4


        xsDataRaddosev01Input = EDHandlerXSDataRaddosev10().getXSDataRaddoseInput(xsDataBeam,
                                                                                      xsDataSample,
                                                                                      iNumSymOperators)


        xsDataRaddosev01Input.exportToFile(self.strObtainedInputFile2)
        strExpectedInput = EDUtilsTest.readAndParseFile (self.strReferenceInputFile2)
        strObtainedInput = EDUtilsTest.readAndParseFile (self.strObtainedInputFile2)

        xsDataInputExpected = XSDataRaddoseInput.parseString(strExpectedInput)
        xsDataInputObtained = XSDataRaddoseInput.parseString(strObtainedInput)

        EDAssert.equal(xsDataInputExpected.marshal(), xsDataInputObtained.marshal())
    def testMergeAtomicComposition(self):
        from XSDataRaddosev10 import XSDataAtomicComposition
        from XSDataRaddosev10 import XSDataAtom
        from XSDataCommon import XSDataDouble
        from XSDataCommon import XSDataString
        from XSDataCommon import XSDataInteger

        xsDataAtomicComposition1 = XSDataAtomicComposition()
        xsDataAtom1 = XSDataAtom()
        xsDataAtom1.setSymbol(XSDataString("S"))
        xsDataAtom1.setNumberOf(XSDataDouble(4))
        xsDataAtomicComposition1.addAtom(xsDataAtom1)

        xsDataAtom2 = XSDataAtom()
        xsDataAtom2.setSymbol(XSDataString("Se"))
        xsDataAtom2.setNumberOf(XSDataDouble(3))
        xsDataAtomicComposition1.addAtom(xsDataAtom2)

        xsDataAtomicComposition2 = XSDataAtomicComposition()
        xsDataAtom3 = XSDataAtom()
        xsDataAtom3.setSymbol(XSDataString("S"))
        xsDataAtom3.setNumberOf(XSDataDouble(1))
        xsDataAtomicComposition2.addAtom(xsDataAtom3)

        xsDataAtom4 = XSDataAtom()
        xsDataAtom4.setSymbol(XSDataString("Fe"))
        xsDataAtom4.setNumberOf(XSDataDouble(5))
        xsDataAtomicComposition2.addAtom(xsDataAtom4)

        from EDHandlerXSDataRaddosev10 import EDHandlerXSDataRaddosev10
        xsDataMergedAtomicComposition = EDHandlerXSDataRaddosev10().mergeAtomicComposition(xsDataAtomicComposition1,
                                                                                           xsDataAtomicComposition2)

        EDAssert.equal(3, len(xsDataMergedAtomicComposition.getAtom()))

        for atom in xsDataMergedAtomicComposition.getAtom():
            if(atom.getSymbol().getValue() == "S"):
                EDAssert.equal(5, atom.getNumberOf().getValue())
            if(atom.getSymbol().getValue() == "Se"):
                EDAssert.equal(3, atom.getNumberOf().getValue())
            if(atom.getSymbol().getValue() == "Fe"):
                EDAssert.equal(5, atom.getNumberOf().getValue())

        xsDataMergedAtomicComposition = EDHandlerXSDataRaddosev10().mergeAtomicComposition(XSDataAtomicComposition(),
                                                                                           xsDataAtomicComposition2)
        EDAssert.equal(2, len(xsDataMergedAtomicComposition.getAtom()))
        for atom in xsDataMergedAtomicComposition.getAtom():
            if(atom.getSymbol().getValue() == "S"):
                EDAssert.equal(1, atom.getNumberOf().getValue())
            if(atom.getSymbol().getValue() == "Fe"):
                EDAssert.equal(5, atom.getNumberOf().getValue())
    def testGetXSDataRaddoseInput(self):
        """
        """
        from XSDataCommon import XSDataLength
        from XSDataCommon import XSDataWavelength
        from XSDataCommon import XSDataFlux
        from XSDataCommon import XSDataSize
        from XSDataCommon import XSDataDouble
        from XSDataCommon import XSDataString
        from XSDataCommon import XSDataAngle
        from XSDataCommon import XSDataTime
        from XSDataCommon import XSDataInteger

        from XSDataMXv1 import XSDataBeam
        from XSDataMXv1 import XSDataStructure
        from XSDataMXv1 import XSDataChain
        from XSDataMXv1 import XSDataAtom
        from XSDataMXv1 import XSDataLigand
        from XSDataMXv1 import XSDataCrystal
        from XSDataMXv1 import XSDataSpaceGroup
        from XSDataMXv1 import XSDataSampleCrystalMM
        from XSDataMXv1 import XSDataChemicalCompositionMM
        from XSDataMXv1 import XSDataAtomicComposition
        from XSDataMXv1 import XSDataSolvent
        from XSDataMXv1 import XSDataCell

        from EDHandlerXSDataRaddosev10 import EDHandlerXSDataRaddosev10

        EDFactoryPluginStatic.loadModule("XSDataRaddosev10")
        from XSDataRaddosev10 import XSDataRaddoseInput

        xsDataBeam = XSDataBeam()
        xsDataBeam.setSize(XSDataSize(x=XSDataLength(0.1),
                                      y=XSDataLength(0.1)))
        xsDataBeam.setWavelength(XSDataWavelength(2.41))
        xsDataBeam.setFlux(XSDataFlux(1e+12))
        xsDataBeam.setExposureTime(XSDataTime(0.037))

        xsDataSample = XSDataSampleCrystalMM()
        xsDataStructure = XSDataStructure()
        xsDataComposition = XSDataChemicalCompositionMM()

        xsDataChain = XSDataChain()
        xsDataChain.setType(XSDataString("protein"))
        xsDataChain.setNumberOfCopies(XSDataDouble(2))
        xsDataAtomicComposition = XSDataAtomicComposition()
        xsDataAtom1 = XSDataAtom()
        xsDataAtom1.setSymbol(XSDataString("Se"))
        xsDataAtom1.setNumberOf(XSDataDouble(4))
        xsDataAtomicComposition.addAtom(xsDataAtom1)
        xsDataAtom2 = XSDataAtom()
        xsDataAtom2.setSymbol(XSDataString("S"))
        xsDataAtom2.setNumberOf(XSDataDouble(5))
        xsDataAtomicComposition.addAtom(xsDataAtom2)
        xsDataChain.setHeavyAtoms(xsDataAtomicComposition)
        xsDataChain.setNumberOfMonomers(XSDataDouble(100))
        xsDataStructure.addChain(xsDataChain)

        xsDataChain2 = XSDataChain()
        xsDataChain2.setType(XSDataString("rna"))
        xsDataChain2.setNumberOfCopies(XSDataDouble(1))
        xsDataChain2.setNumberOfMonomers(XSDataDouble(60))
        xsDataStructure.addChain(xsDataChain2)

        xsDataLigand = XSDataLigand()
        xsDataLigand.setNumberOfCopies(XSDataDouble(2))
        xsDataLigand.setNumberOfLightAtoms(XSDataDouble(42))
        xsDataAtomicComposition = XSDataAtomicComposition()
        xsDataAtom3 = XSDataAtom()
        xsDataAtom3.setSymbol(XSDataString("Fe"))
        xsDataAtom3.setNumberOf(XSDataDouble(1))
        xsDataAtomicComposition.addAtom(xsDataAtom3)
        xsDataLigand.setHeavyAtoms(xsDataAtomicComposition)
        xsDataStructure.addLigand(xsDataLigand)
        xsDataStructure.setNumberOfCopiesInAsymmetricUnit(XSDataDouble(0.25))

        xsDataSolvent = XSDataSolvent()
        xsDataAtomicComposition = XSDataAtomicComposition()
        xsDataAtomNa = XSDataAtom()
        xsDataAtomNa.setSymbol(XSDataString("Na"))
        xsDataAtomNa.setConcentration(XSDataDouble(1000))
        xsDataAtomicComposition.addAtom(xsDataAtomNa)
        xsDataAtomCl = XSDataAtom()
        xsDataAtomCl.setSymbol(XSDataString("Cl"))
        xsDataAtomCl.setConcentration(XSDataDouble(1000))
        xsDataAtomicComposition.addAtom(xsDataAtomCl)
        xsDataSolvent.setAtoms(xsDataAtomicComposition)

        xsDataComposition.setStructure(xsDataStructure)
        xsDataComposition.setSolvent(xsDataSolvent)
        xsDataSample.setChemicalComposition(xsDataComposition)

        xsDataSample.setSize(
            XSDataSize(XSDataLength(0.1), XSDataLength(0.1),
                       XSDataLength(0.1)))
        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))

        xsDataCrystal = XSDataCrystal()
        xsDataSpaceGroup = XSDataSpaceGroup()

        xsDataCrystal.setCell(xsDataCell)

        xsDataSpaceGroup.setITNumber(XSDataInteger(16))
        xsDataCrystal.setSpaceGroup(xsDataSpaceGroup)

        xsDataSample.setCrystal(xsDataCrystal)

        iNumSymOperators = 4
        iNumberOfImages = 2

        xsDataRaddosev01Input = EDHandlerXSDataRaddosev10(
        ).getXSDataRaddoseInput(xsDataBeam, xsDataSample, iNumSymOperators,
                                iNumberOfImages)

        xsDataRaddosev01Input.exportToFile(self.strObtainedInputFile2)
        strExpectedInput = EDUtilsTest.readAndParseFile(
            self.strReferenceInputFile2)
        strObtainedInput = EDUtilsTest.readAndParseFile(
            self.strObtainedInputFile2)

        xsDataInputExpected = XSDataRaddoseInput.parseString(strExpectedInput)
        xsDataInputObtained = XSDataRaddoseInput.parseString(strObtainedInput)

        EDAssert.equal(xsDataInputExpected.marshal(),
                       xsDataInputObtained.marshal())
    def testMergeAtomicComposition(self):
        from XSDataRaddosev10 import XSDataAtomicComposition
        from XSDataRaddosev10 import XSDataAtom
        from XSDataCommon import XSDataDouble
        from XSDataCommon import XSDataString
        from XSDataCommon import XSDataInteger

        xsDataAtomicComposition1 = XSDataAtomicComposition()
        xsDataAtom1 = XSDataAtom()
        xsDataAtom1.setSymbol(XSDataString("S"))
        xsDataAtom1.setNumberOf(XSDataDouble(4))
        xsDataAtomicComposition1.addAtom(xsDataAtom1)

        xsDataAtom2 = XSDataAtom()
        xsDataAtom2.setSymbol(XSDataString("Se"))
        xsDataAtom2.setNumberOf(XSDataDouble(3))
        xsDataAtomicComposition1.addAtom(xsDataAtom2)

        xsDataAtomicComposition2 = XSDataAtomicComposition()
        xsDataAtom3 = XSDataAtom()
        xsDataAtom3.setSymbol(XSDataString("S"))
        xsDataAtom3.setNumberOf(XSDataDouble(1))
        xsDataAtomicComposition2.addAtom(xsDataAtom3)

        xsDataAtom4 = XSDataAtom()
        xsDataAtom4.setSymbol(XSDataString("Fe"))
        xsDataAtom4.setNumberOf(XSDataDouble(5))
        xsDataAtomicComposition2.addAtom(xsDataAtom4)

        from EDHandlerXSDataRaddosev10 import EDHandlerXSDataRaddosev10
        xsDataMergedAtomicComposition = EDHandlerXSDataRaddosev10(
        ).mergeAtomicComposition(xsDataAtomicComposition1,
                                 xsDataAtomicComposition2)

        EDAssert.equal(3, len(xsDataMergedAtomicComposition.getAtom()))

        for atom in xsDataMergedAtomicComposition.getAtom():
            if (atom.getSymbol().getValue() == "S"):
                EDAssert.equal(5, atom.getNumberOf().getValue())
            if (atom.getSymbol().getValue() == "Se"):
                EDAssert.equal(3, atom.getNumberOf().getValue())
            if (atom.getSymbol().getValue() == "Fe"):
                EDAssert.equal(5, atom.getNumberOf().getValue())

        xsDataMergedAtomicComposition = EDHandlerXSDataRaddosev10(
        ).mergeAtomicComposition(XSDataAtomicComposition(),
                                 xsDataAtomicComposition2)
        EDAssert.equal(2, len(xsDataMergedAtomicComposition.getAtom()))
        for atom in xsDataMergedAtomicComposition.getAtom():
            if (atom.getSymbol().getValue() == "S"):
                EDAssert.equal(1, atom.getNumberOf().getValue())
            if (atom.getSymbol().getValue() == "Fe"):
                EDAssert.equal(5, atom.getNumberOf().getValue())