Exemplo n.º 1
0
    def getMOSFLMIntegrationStatistics(self, _xsDataList):
        """
        This method creates a new XSDataMOSFLMIntegrationStatistics object and populates it with
        values (averaged intensity, sigma, average I over sigma and number of reflections) 
        from the _xsDataList object.
        """
        xsDataMOSFLMIntegrationStatistics = XSDataMOSFLMIntegrationStatistics()

        strAverageIntensity = EDUtilsTable.getItemFromList(_xsDataList,
                                                           "i").getValueOf_()
        xsDataMOSFLMIntegrationStatistics.setAverageIntensity(
            XSDataFloat(float(strAverageIntensity)))

        strAverageSigma = EDUtilsTable.getItemFromList(_xsDataList,
                                                       "sig").getValueOf_()
        xsDataMOSFLMIntegrationStatistics.setAverageSigma(
            XSDataFloat(float(strAverageSigma)))

        strAverageIOverSigma = EDUtilsTable.getItemFromList(
            _xsDataList, "i_sig").getValueOf_()
        xsDataMOSFLMIntegrationStatistics.setAverageIOverSigma(
            XSDataFloat(float(strAverageIOverSigma)))

        strNumberOfReflections = EDUtilsTable.getItemFromList(
            _xsDataList, "count").getValueOf_()
        xsDataMOSFLMIntegrationStatistics.setNumberOfReflections(
            XSDataInteger(int(strNumberOfReflections)))

        return xsDataMOSFLMIntegrationStatistics
    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())
Exemplo n.º 3
0
def _extract_completeness_entries(lines, output):
    for line in lines:
        if line.find('total') != -1:
            # special case for the last table line which contains the
            # totals
            infos = [
                float(x.replace('%', '').replace('*', ''))
                for x in line.split()[1:]
            ]
            output.total_completeness = XSDataXdsCompletenessEntry()
            output.total_completeness.outer_complete = XSDataFloat(infos[3])
            output.total_completeness.outer_rfactor = XSDataFloat(infos[4])
            output.total_completeness.outer_isig = XSDataFloat(infos[7])
            output.total_completeness.half_dataset_correlation = XSDataFloat(
                infos[10])
        else:
            # regular line, do not strip the first elem and bump the
            # indices by 1
            infos = [
                float(x.replace('%', '').replace('*', ''))
                for x in line.split()
            ]
            res = XSDataXdsCompletenessEntry()
            res.outer_res = XSDataFloat(infos[0])
            res.outer_complete = XSDataFloat(infos[4])
            res.outer_rfactor = XSDataFloat(infos[5])
            res.outer_isig = XSDataFloat(infos[8])
            res.half_dataset_correlation = XSDataFloat(infos[10])
            output.completeness_entries.append(res)
Exemplo n.º 4
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
Exemplo n.º 5
0
 def readIdxrefLp(self, _pathToIdxrefLp, _xsDataResultXDSIndexing=None):
     self.DEBUG("EDPluginXDSIndexingv1_0.readIdxrefLp")
     if _xsDataResultXDSIndexing is None:
         xsDataResultXDSIndexing = XSDataResultXDSIndexing()
     else:
         xsDataResultXDSIndexing = _xsDataResultXDSIndexing
     if os.path.exists(_pathToIdxrefLp):
         xsDataResultXDSIndexing.pathToLogFile = XSDataFile(XSDataString(_pathToIdxrefLp))
         with open(_pathToIdxrefLp) as f:
             listLines = f.readlines()
         indexLine = 0
         doParseParameters = False
         doParseLattice = False
         while (indexLine < len(listLines)):
             if "DIFFRACTION PARAMETERS USED AT START OF INTEGRATION" in listLines[indexLine]:
                 doParseParameters = True
                 doParseLattice = False
             elif "DETERMINATION OF LATTICE CHARACTER AND BRAVAIS LATTICE" in listLines[indexLine]:
                 doParseParameters = False
                 doParseLattice = True
             if doParseParameters:
                 if "MOSAICITY" in listLines[indexLine]:
                     mosaicity = float(listLines[indexLine].split()[-1])
                     xsDataResultXDSIndexing.mosaicity = XSDataAngle(mosaicity)
                 elif "DETECTOR COORDINATES (PIXELS) OF DIRECT BEAM" in listLines[indexLine]:
                     xBeam = float(listLines[indexLine].split()[-2])
                     yBeam = float(listLines[indexLine].split()[-1])
                     xsDataResultXDSIndexing.beamCentreX = XSDataFloat(xBeam)
                     xsDataResultXDSIndexing.beamCentreY = XSDataFloat(yBeam)
                 elif "CRYSTAL TO DETECTOR DISTANCE" in listLines[indexLine]:
                     distance = float(listLines[indexLine].split()[-1])
                     xsDataResultXDSIndexing.distance = XSDataLength(distance)
             elif doParseLattice:
                 if listLines[indexLine].startswith(" * ") and not listLines[indexLine + 1].startswith(" * "):
                     listLine = listLines[indexLine].split()
                     xsDataResultXDSIndexing.latticeCharacter = XSDataInteger(int(listLine[1]))
                     bravaisLattice = listLine[2]
                     xsDataResultXDSIndexing.bravaisLattice = XSDataString(bravaisLattice)
                     spaceGroup = EDUtilsSymmetry.getMinimumSymmetrySpaceGroupFromBravaisLattice(bravaisLattice)
                     xsDataResultXDSIndexing.spaceGroup = XSDataString(spaceGroup)
                     spaceGroupNumber = EDUtilsSymmetry.getITNumberFromSpaceGroupName(spaceGroup)
                     xsDataResultXDSIndexing.spaceGroupNumber = XSDataInteger(spaceGroupNumber)
                     xsDataResultXDSIndexing.qualityOfFit = XSDataFloat(float(listLine[3]))
                     xsDataXDSCell = XSDataXDSCell()
                     xsDataXDSCell.length_a = XSDataLength(float(listLine[4]))
                     xsDataXDSCell.length_b = XSDataLength(float(listLine[5]))
                     xsDataXDSCell.length_c = XSDataLength(float(listLine[6]))
                     xsDataXDSCell.angle_alpha = XSDataAngle(float(listLine[7]))
                     xsDataXDSCell.angle_beta = XSDataAngle(float(listLine[8]))
                     xsDataXDSCell.angle_gamma = XSDataAngle(float(listLine[9]))
                     xsDataResultXDSIndexing.unitCell = xsDataXDSCell
             indexLine += 1
     return xsDataResultXDSIndexing
Exemplo n.º 6
0
 def createInputCharacterisationFromSubWedges(self):
     EDVerbose.DEBUG(
         "EDPluginControlInterfacev2_0.createInputCharacterisationFromSubWedges"
     )
     xsDataResultSubWedgeAssemble = self.edPluginControlSubWedgeAssemble.getDataOutput(
     )
     self.xsDataInputCharacterisation = XSDataInputCharacterisation()
     xsDataCollection = XSDataCollection()
     # Default exposure time (for the moment, this value should be
     # possible to read from the command line)
     xsDataDiffractionPlan = XSDataDiffractionPlan()
     if (not xsDataResultSubWedgeAssemble is None):
         pyListSubWedge = xsDataResultSubWedgeAssemble.getSubWedge()
         xsDataCollection.setSubWedge(pyListSubWedge)
         for xsDataSubWedge in pyListSubWedge:
             if (self.strComplexity is not None):
                 xsDataDiffractionPlan.setComplexity(
                     XSDataString(self.strComplexity))
             if (self.fFlux is not None):
                 xsDataSubWedge.getExperimentalCondition().getBeam(
                 ).setFlux(XSDataFloat(self.fFlux))
             if (self.fBeamSize is not None):
                 xsDataSize = XSDataSize()
                 xsDataSize.setX(XSDataLength(self.fBeamSize))
                 xsDataSize.setY(XSDataLength(self.fBeamSize))
                 xsDataSubWedge.getExperimentalCondition().getBeam(
                 ).setSize(xsDataSize)
             if (self.fBeamPosX is not None):
                 xsDataSubWedge.getExperimentalCondition().getDetector(
                 ).setBeamPositionX(XSDataLength(self.fBeamPosX))
             if (self.fBeamPosY is not None):
                 xsDataSubWedge.getExperimentalCondition().getDetector(
                 ).setBeamPositionY(XSDataLength(self.fBeamPosY))
             if (self.fMinExposureTimePerImage is not None):
                 xsDataSubWedge.getExperimentalCondition().getBeam(
                 ).setMinExposureTimePerImage(
                     XSDataFloat(self.fMinExposureTimePerImage))
             if (self.fTransmission is not None):
                 xsDataSubWedge.getExperimentalCondition().getBeam(
                 ).setTransmission(XSDataDouble(self.fTransmission))
     if (self.strForcedSpaceGroup is not None):
         xsDataDiffractionPlan.setForcedSpaceGroup(
             XSDataString(self.strForcedSpaceGroup))
     xsDataDiffractionPlan.setAnomalousData(
         XSDataBoolean(self.bAnomalousData))
     xsDataDiffractionPlan.setMaxExposureTimePerDataCollection(
         XSDataTime(self.fMaxExposureTimePerDataCollection))
     if (self.strStrategyOption is not None):
         xsDataDiffractionPlan.setStrategyOption(
             XSDataString(self.strStrategyOption))
     xsDataCollection.setDiffractionPlan(xsDataDiffractionPlan)
     self.xsDataInputCharacterisation.setDataCollection(xsDataCollection)
Exemplo n.º 7
0
    def strategySummaryItemListToStrategySummary(self,
                                                 _xsStrategySummaryItemList):
        xsDataStrategySummary = XSDataBestStrategySummary()
        pyStrItemAttenuation = EDUtilsTable.getItemFromList(
            _xsStrategySummaryItemList, "attenuation")
        fAttenuation = float(pyStrItemAttenuation.getValueOf_())
        xsDataStrategySummary.setAttenuation(XSDataFloat(fAttenuation))

        pyStrItemCompleteness = EDUtilsTable.getItemFromList(
            _xsStrategySummaryItemList, "completeness")
        # For homegeneity concerns, EDNA data model should store all the completeness value in fraction
        # ( DNA table xml file stores the summary strategy completeness in percentage whereas
        # the resolution bin completeness are in fraction )
        fCompleteness = float(pyStrItemCompleteness.getValueOf_()) / 100
        xsDataStrategySummary.setCompleteness(XSDataFloat(fCompleteness))

        pyStrItemISigma = EDUtilsTable.getItemFromList(
            _xsStrategySummaryItemList, "i_sigma")
        fISigma = float(pyStrItemISigma.getValueOf_())
        xsDataStrategySummary.setISigma(XSDataFloat(fISigma))

        pyStrItemRedundancy = EDUtilsTable.getItemFromList(
            _xsStrategySummaryItemList, "redundancy")
        fRedundancy = float(pyStrItemRedundancy.getValueOf_())
        xsDataStrategySummary.setRedundancy(XSDataFloat(fRedundancy))

        pyStrItemResolution = EDUtilsTable.getItemFromList(
            _xsStrategySummaryItemList, "resolution")
        fResolution = float(pyStrItemResolution.getValueOf_())
        xsDataStrategySummary.setResolution(XSDataFloat(fResolution))

        pyStrItemResolutionReasoning = EDUtilsTable.getItemFromList(
            _xsStrategySummaryItemList, "resolution_reasoning")
        strResolutionReasoning = pyStrItemResolutionReasoning.getValueOf_()
        xsDataStrategySummary.setResolutionReasoning(
            XSDataString(strResolutionReasoning))

        pyStrItemTotalDataCollectionTime = EDUtilsTable.getItemFromList(
            _xsStrategySummaryItemList, "total_data_collection_time")
        fTotalDataCollectionTime = float(
            pyStrItemTotalDataCollectionTime.getValueOf_())
        xsDataStrategySummary.setTotalDataCollectionTime(
            XSDataTime(fTotalDataCollectionTime))

        pyStrItemTotalExposureTime = EDUtilsTable.getItemFromList(
            _xsStrategySummaryItemList, "total_exposure_time")
        fTotalExposureTime = float(pyStrItemTotalExposureTime.getValueOf_())
        xsDataStrategySummary.setTotalExposureTime(
            XSDataTime(fTotalExposureTime))

        return xsDataStrategySummary
Exemplo n.º 8
0
    def preProcess(self, _edObject=None):
        EDPluginControl.preProcess(self)
        self.DEBUG("EDPluginControlAutoproc.preProcess")

        self.xds_anom = self.loadPlugin('EDPluginExecMinimalXds')
        self.xds_noanom = self.loadPlugin('EDPluginExecMinimalXds')

        path = os.path.abspath(self.dataInput.previous_run_dir.value)

        # create the data inputs now we know the files are here
        input_anom = XSDataMinimalXdsIn()
        input_anom.input_file = XSDataString(os.path.join(path, 'XDS.INP'))
        input_anom.friedels_law = XSDataBoolean(True)
        input_anom.job = XSDataString('CORRECT')
        input_anom.resolution = self.dataInput.resolution
        input_anom.resolution_range = [
            XSDataFloat(60), self.dataInput.resolution
        ]
        self.xds_anom.dataInput = input_anom

        input_noanom = XSDataMinimalXdsIn()
        input_noanom.input_file = XSDataString(os.path.join(path, 'XDS.INP'))
        input_noanom.fridels_law = XSDataBoolean(False)
        input_noanom.job = XSDataString('CORRECT')
        input_noanom.resolution_range = [
            XSDataFloat(60), self.dataInput.resolution
        ]
        self.xds_noanom.dataInput = input_noanom

        xds_anom_dir = os.path.abspath(self.xds_anom.getWorkingDirectory())
        xds_noanom_dir = os.path.abspath(self.xds_noanom.getWorkingDirectory())
        # let's make some links!
        for f in self._to_link:
            os.symlink(f, os.path.join(xds_anom_dir, os.path.basename(f)))
            os.symlink(f, os.path.join(xds_noanom_dir, os.path.basename(f)))
        # now this is the horrible part, we need to make symlinks to
        # the images also. for now we rely on the fact that the links
        # in the previous run are most likely the links to the
        # images. So we will make the same links and rely on the fact
        # that in the input file the path to the images is already
        # relative to the CWD
        path = os.path.abspath(self.dataInput.previous_run_dir.value)
        for f in os.listdir(path):
            fullpath = os.path.join(path, f)
            if os.path.islink(fullpath):
                # symlink the symlink...
                os.symlink(fullpath, os.path.join(xds_anom_dir, f))
                os.symlink(fullpath, os.path.join(xds_noanom_dir, f))
Exemplo n.º 9
0
    def preProcess(self, _edObject = None):
        EDPluginControl.preProcess(self)
        self.DEBUG("EDPluginControlAutoproc.preProcess")

        self.xds_anom = self.loadPlugin('EDPluginExecMinimalXds')
        self.xds_noanom = self.loadPlugin('EDPluginExecMinimalXds')

        path = os.path.abspath(self.dataInput.previous_run_dir.value)

        # The MinimalXds plugin takes care of creating determining the
        # real images directory and creating a symlink to it so we
        # only need to update the NAMED_TEMPLATE_OF_DATA_FILES keyword
        # to not be relative anymore. We'll copy it to our own dir
        # beforehand to avoid clobbering it
        xdsinp = os.path.join(path, 'XDS.INP')
        new_xdsinp = os.path.join(self.getWorkingDirectory(), 'XDS.INP')
        copyfile(xdsinp, new_xdsinp)


        parsed_config = parse_xds_file(new_xdsinp)
        file_template = parsed_config['NAME_TEMPLATE_OF_DATA_FRAMES='][0]
        parsed_config['NAME_TEMPLATE_OF_DATA_FRAMES='] = os.path.abspath(os.path.join(path, file_template))
        dump_xds_file(new_xdsinp, parsed_config)

        # create the data inputs now we know the files are here
        input_anom = XSDataMinimalXdsIn()
        input_anom.input_file = XSDataString(new_xdsinp)
        input_anom.friedels_law = XSDataBoolean(True)
        input_anom.job = XSDataString('CORRECT')
        input_anom.resolution = self.dataInput.resolution
        input_anom.resolution_range = [XSDataFloat(60), self.dataInput.resolution]
        self.xds_anom.dataInput = input_anom

        input_noanom = XSDataMinimalXdsIn()
        input_noanom.input_file = XSDataString(new_xdsinp)
        input_noanom.friedels_law = XSDataBoolean(False)
        input_noanom.job = XSDataString('CORRECT')
        input_noanom.resolution_range = [XSDataFloat(60), self.dataInput.resolution]
        self.xds_noanom.dataInput = input_noanom

        xds_anom_dir = os.path.abspath(self.xds_anom.getWorkingDirectory())
        xds_noanom_dir = os.path.abspath(self.xds_noanom.getWorkingDirectory())


        # let's make some links!
        for f in self._to_link:
            os.symlink(f, os.path.join(xds_anom_dir, os.path.basename(f)))
            os.symlink(f, os.path.join(xds_noanom_dir, os.path.basename(f)))
Exemplo n.º 10
0
 def postProcess(self):
     # parse the output, the code's not very good looking
     # maybe rewrite the parsing without using regexpes
     outfile = self.getScriptLogFileName()
     best_p = 0
     best_sol = None
     with open(outfile, 'r') as out:
         # have we seen the start of the table we seek yet?
         started = False
         for line in out:
             if not started:
                 # see if our table is beginning yet
                 if self.start_re.match(line): started = True
                 continue
             else:
                 # try parsing the line as a table line
                 m = self.good_re.match(line)
                 bad = self.bad_re.match(line)
                 if m is not None and bad is None:
                     p = float(m.group(1))
                     if p > best_p:
                         best_p = p
                         best_sol = m.group(2)
     # we found what we were looking for
     if best_sol is not None:
         self.dataOutput = XSDataMatthewsCoeffOut(best_p=XSDataFloat(best_p),
                                                  best_sol=XSDataString(best_sol))
Exemplo n.º 11
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
Exemplo n.º 12
0
def fileName2xml(filename):
    """Here we create the XML string to be passed to the EDNA plugin from the input filename
    This can / should be modified by the final user
    
    @param filename: full path of the input file
    @type filename: python string representing the path
    @rtype: XML string
    @return: python string  
    """
    if filename.endswith(".jpg"):
        xm = None
    else:
        upperDir = os.path.dirname(os.path.dirname(filename))
        if not os.path.isdir(os.path.join(upperDir, "Thumbnail")):
            os.makedirs(os.path.join(upperDir, "Thumbnail"), int("775", 8))
        destinationPath = os.path.join(upperDir, "Thumbnail")
        xsd = XSDataInputExecThumbnail()
        xsdFile = XSDataFile()
        xsdFile.setPath(XSDataString(filename))
        xsd.setInputImagePath(xsdFile)
        xsdPath = XSDataFile()
        xsdPath.setPath(XSDataString(destinationPath))
        xsd.setOutputPath(xsdPath)
        xsd.setLevelsColorize(XSDataBoolean(True))
        xsd.setLevelsNormalize(XSDataBoolean(True))
        xsd.setLevelsGamma(XSDataFloat(gamma))
        xml = xsd.marshal()
    return xml
Exemplo n.º 13
0
    def setPluginInput(self, _edPlugin):
        xsDataDiffractionPlan = XSDataDiffractionPlan()
        if (not self.__fMaxExposureTimePerDataCollection is None):
            xsDataDiffractionPlan.setMaxExposureTimePerDataCollection(XSDataTime(self.__fMaxExposureTimePerDataCollection))
        if (not self.__strForcedSpaceGroup is None):
            xsDataDiffractionPlan.setForcedSpaceGroup(XSDataString(self.__strForcedSpaceGroup))
        if (not self.__bAnomalousData is None):
            xsDataDiffractionPlan.setAnomalousData(XSDataBoolean(self.__bAnomalousData))
        if (not self.__strStrategyOption is None):
            xsDataDiffractionPlan.setStrategyOption(XSDataString(self.__strStrategyOption))
        if (not self.__strComplexity is None):
            xsDataDiffractionPlan.setComplexity(XSDataString(self.__strComplexity))
        _edPlugin.setDataInput(xsDataDiffractionPlan, "diffractionPlan")

        if (not self.__listImagePaths is None):
            for strImagePath in self.__listImagePaths:
                _edPlugin.setDataInput(XSDataString(strImagePath), "imagePaths")

        if (not self.__xsDataInputCharacterisation is None):
            _edPlugin.setDataInput(self.__xsDataInputCharacterisation, "inputCharacterisation")
        if (not self.__fFlux is None):
            _edPlugin.setDataInput(XSDataFloat(self.__fFlux), "flux")
        if (not self.__fMinExposureTimePerImage is None):
            _edPlugin.setDataInput(XSDataFloat(self.__fMinExposureTimePerImage), "minExposureTimePerImage")
        if (not self.__fBeamSize is None):
            _edPlugin.setDataInput(XSDataFloat(self.__fBeamSize), "beamSize")
        if (not self.__bTemplateMode is None):
            _edPlugin.setDataInput(XSDataBoolean(self.__bTemplateMode), "templateMode")
        if (not self.__strGeneratedTemplateFile is None):
            _edPlugin.setDataInput(XSDataString(self.__strGeneratedTemplateFile), "generatedTemplateFile")
        if (not self.__strResultsFilePath is None):
            _edPlugin.setDataInput(XSDataString(self.__strResultsFilePath), "resultsFilePath")
        if (not self.__fBeamPosX is None):
            _edPlugin.setDataInput(XSDataFloat(self.__fBeamPosX), "beamPosX")
        if (not self.__fBeamPosY is None):
            _edPlugin.setDataInput(XSDataFloat(self.__fBeamPosY), "beamPosY")
        if (not self.__iDataCollectionId is None):
            _edPlugin.setDataInput(XSDataInteger(self.__iDataCollectionId), "dataCollectionId")
        if (not self.__strShortComments is None):
            _edPlugin.setDataInput(XSDataString(self.__strShortComments), "shortComments")
        if (not self.__strComments is None):
            _edPlugin.setDataInput(XSDataString(self.__strComments), "comments")
        if (not self.__fTransmission is None):
            _edPlugin.setDataInput(XSDataDouble(self.__fTransmission), "transmission")
Exemplo n.º 14
0
    def getMOSFLMIntegrationStatisticsPerResolutionBin(self, _xsDataDnaTables, _strListName, _fMinResolution=None):
        """
        This method creates an XSDataMOSFLMIntegrationStatisticsPerResolutionBin object given an XSDataDnaTables object
        and a list name, e.g. "bin_1". If _fMinResolution is provided it is used for setting the minimum resolution,
        otherwise the min and max resolution are set to the same value provided by the xsDataList object.
        """
        xsDataTableProfileFittedFull = EDUtilsTable.getTableFromTables(_xsDataDnaTables, "profile_fitted_full")
        xsDataTableProfileFittedPartial = EDUtilsTable.getTableFromTables(_xsDataDnaTables, "profile_fitted_partial")
        xsDataTableSummationFull = EDUtilsTable.getTableFromTables(_xsDataDnaTables, "summation_full")
        xsDataTableSummationPartial = EDUtilsTable.getTableFromTables(_xsDataDnaTables, "summation_partial")

        xsListProfileFittedFull = EDUtilsTable.getListsFromTable(xsDataTableProfileFittedFull, _strListName)[0]
        xsListProfileFittedPartial = EDUtilsTable.getListsFromTable(xsDataTableProfileFittedPartial, _strListName)[0]
        xsListSummationFull = EDUtilsTable.getListsFromTable(xsDataTableSummationFull, _strListName)[0]
        xsListSummationPartial = EDUtilsTable.getListsFromTable(xsDataTableSummationPartial, _strListName)[0]

        xsDataMOSFLMIntegrationDataProfileFittedFull = self.getMOSFLMIntegrationStatistics(xsListProfileFittedFull)
        xsDataMOSFLMIntegrationDataProfileFittedPartials = self.getMOSFLMIntegrationStatistics(xsListProfileFittedPartial)
        xsDataMOSFLMIntegrationSummationFull = self.getMOSFLMIntegrationStatistics(xsListSummationFull)
        xsDataMOSFLMIntegrationSummationPartial = self.getMOSFLMIntegrationStatistics(xsListSummationPartial)

        xsDataMOSFLMIntegrationStatisticsPerReflectionTypeProfileFitted = XSDataMOSFLMIntegrationStatisticsPerReflectionType()
        xsDataMOSFLMIntegrationStatisticsPerReflectionTypeProfileFitted.setFullyRecorded(xsDataMOSFLMIntegrationDataProfileFittedFull)
        xsDataMOSFLMIntegrationStatisticsPerReflectionTypeProfileFitted.setPartials(xsDataMOSFLMIntegrationDataProfileFittedPartials)

        xsDataMOSFLMIntegrationStatisticsPerReflectionTypeSummation = XSDataMOSFLMIntegrationStatisticsPerReflectionType()
        xsDataMOSFLMIntegrationStatisticsPerReflectionTypeSummation.setFullyRecorded(xsDataMOSFLMIntegrationSummationFull)
        xsDataMOSFLMIntegrationStatisticsPerReflectionTypeSummation.setPartials(xsDataMOSFLMIntegrationSummationPartial)

        xsDataMOSFLMIntegrationStatisticsPerResolutionBin = XSDataMOSFLMIntegrationStatisticsPerResolutionBin()
        xsDataMOSFLMIntegrationStatisticsPerResolutionBin.setProfileFitted(xsDataMOSFLMIntegrationStatisticsPerReflectionTypeProfileFitted)
        xsDataMOSFLMIntegrationStatisticsPerResolutionBin.setSummation(xsDataMOSFLMIntegrationStatisticsPerReflectionTypeSummation)

        strMaxResolution = EDUtilsTable.getItemFromList(xsListProfileFittedFull, "resolution").getValueOf_()
        if strMaxResolution != "overall":
            xsDataMOSFLMIntegrationStatisticsPerResolutionBin.setMaxResolution(XSDataFloat(float(strMaxResolution)))
            if (_fMinResolution is not None):
                xsDataMOSFLMIntegrationStatisticsPerResolutionBin.setMinResolution(XSDataFloat(_fMinResolution))
            else:
                xsDataMOSFLMIntegrationStatisticsPerResolutionBin.setMinResolution(XSDataFloat(float(strMaxResolution)))

        return xsDataMOSFLMIntegrationStatisticsPerResolutionBin
Exemplo n.º 15
0
    def getXSDataBestInput(self, _xsDataBeam, _xsDataSample, _xsDataDetector, _xsDataGoniostat, _xsDataDiffractionPlan,
                               _oedStrBestFileContentDat, _oedStrBestFileContentPar, _oedListBestFileContentHKL):
        xsDataBestInput = XSDataBestInput()

        # Sample      
        xdDataAbsorbedDose = None
        xsDataSusceptibility = None

        # Could be None if sample has not been set
        # It could be not None in case Raddose has calculated an absorbed dose with default sample values
        if(_xsDataSample is not None):
            xdDataAbsorbedDose = _xsDataSample.getAbsorbedDoseRate()
            xsDataSusceptibility = _xsDataSample.getSusceptibility()

        # Could be None if Raddose failed to calculate the absorbed dose
        if(xdDataAbsorbedDose is not None):
            xsDataBestInput.setCrystalAbsorbedDoseRate(_xsDataSample.getAbsorbedDoseRate())

        xsDataBestInput.setCrystalSusceptibility(xsDataSusceptibility)

        # crystalShape
        # Default value is 1 (We assume that Xtal is smaller than beam)
        xsDataFloatCrystalShape = _xsDataSample.getShape()
        if(xsDataFloatCrystalShape is None):
            xsDataBestInput.setCrystalShape(XSDataFloat(1))
        else:
            xsDataBestInput.setCrystalShape(xsDataFloatCrystalShape)

        # Detector
        xsDataBestInput.setDetectorType(_xsDataDetector.getType())

        # Beam
        xsDataBestInput.setBeamExposureTime(_xsDataBeam.getExposureTime())
        xsDataBestInput.setBeamMinExposureTime(_xsDataBeam.getMinExposureTimePerImage())

        # Goniostat
        xsDataBestInput.setGoniostatMaxRotationSpeed(_xsDataGoniostat.getMaxOscillationSpeed())
        xsDataBestInput.setGoniostatMinRotationWidth(_xsDataGoniostat.getMinOscillationWidth())

        # Diffraction plan
        xsDataBestInput.setAimedResolution(_xsDataDiffractionPlan.getAimedResolution())
        xsDataBestInput.setAimedRedundancy(_xsDataDiffractionPlan.getAimedMultiplicity())
        xsDataBestInput.setAimedCompleteness(_xsDataDiffractionPlan.getAimedCompleteness())
        xsDataBestInput.setAimedIOverSigma(_xsDataDiffractionPlan.getAimedIOverSigmaAtHighestResolution())
        xsDataBestInput.setBeamMaxExposureTime(_xsDataDiffractionPlan.getMaxExposureTimePerDataCollection())
        xsDataBestInput.setComplexity(_xsDataDiffractionPlan.getComplexity())

        # Best Files
        xsDataBestInput.setBestFileContentDat(_oedStrBestFileContentDat)
        xsDataBestInput.setBestFileContentPar(_oedStrBestFileContentPar)
        xsDataBestInput.setBestFileContentHKL(_oedListBestFileContentHKL)

        return xsDataBestInput
Exemplo n.º 16
0
    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())
Exemplo n.º 17
0
def _extract_infos(lines, output):
    # extract values into the output obj modified in place
    # stuff we want:
    tmp_params = [
        'CRYSTAL MOSAICITY (DEGREES)',
        'DIRECT BEAM COORDINATES (REC. ANGSTROEM)',
        'DETECTOR COORDINATES (PIXELS) OF DIRECT BEAM',
        'DETECTOR ORIGIN (PIXELS) AT',
        'CRYSTAL TO DETECTOR DISTANCE (mm)',
        'COORDINATES OF UNIT CELL A-AXIS',
        'COORDINATES OF UNIT CELL B-AXIS',
        'COORDINATES OF UNIT CELL C-AXIS',
        'UNIT_CELL_CONSTANTS=',
    ]

    params = [(item, len(item.split())) for item in tmp_params]

    parsed = dict()

    for line in lines:
        for param, param_len in params:
            if line.find(param) != -1:
                values = [float(x) for x in line.split()[param_len:]]
                parsed[param] = values

    # now fill in the data model with the values we got (and stop if
    # any of them is missing)
    try:
        output.crystal_mosaicity = XSDataFloat(
            parsed['CRYSTAL MOSAICITY (DEGREES)'][0])

        output.direct_beam_coordinates = XSDataVectorDouble()
        output.direct_beam_coordinates.v1 = parsed[
            'DIRECT BEAM COORDINATES (REC. ANGSTROEM)'][0]
        output.direct_beam_coordinates.v2 = parsed[
            'DIRECT BEAM COORDINATES (REC. ANGSTROEM)'][1]
        output.direct_beam_coordinates.v3 = parsed[
            'DIRECT BEAM COORDINATES (REC. ANGSTROEM)'][2]

        output.direct_beam_detector_coordinates = XSData2DCoordinates()
        output.direct_beam_detector_coordinates.x = XSDataFloat(
            parsed['DETECTOR COORDINATES (PIXELS) OF DIRECT BEAM'][0])
        output.direct_beam_detector_coordinates.y = XSDataFloat(
            parsed['DETECTOR COORDINATES (PIXELS) OF DIRECT BEAM'][1])

        output.detector_origin = XSData2DCoordinates()
        output.detector_origin.x = XSDataFloat(
            parsed['DETECTOR ORIGIN (PIXELS) AT'][0])
        output.detector_origin.y = XSDataFloat(
            parsed['DETECTOR ORIGIN (PIXELS) AT'][1])

        output.crystal_to_detector_distance = XSDataFloat(
            parsed['CRYSTAL TO DETECTOR DISTANCE (mm)'][0])

        output.coordinates_of_unit_cell_a_axis = XSDataVectorDouble()
        output.coordinates_of_unit_cell_a_axis.v1 = parsed[
            'COORDINATES OF UNIT CELL A-AXIS'][0]
        output.coordinates_of_unit_cell_a_axis.v2 = parsed[
            'COORDINATES OF UNIT CELL A-AXIS'][1]
        output.coordinates_of_unit_cell_a_axis.v3 = parsed[
            'COORDINATES OF UNIT CELL A-AXIS'][2]

        output.coordinates_of_unit_cell_b_axis = XSDataVectorDouble()
        output.coordinates_of_unit_cell_b_axis.v1 = parsed[
            'COORDINATES OF UNIT CELL B-AXIS'][0]
        output.coordinates_of_unit_cell_b_axis.v2 = parsed[
            'COORDINATES OF UNIT CELL B-AXIS'][1]
        output.coordinates_of_unit_cell_b_axis.v3 = parsed[
            'COORDINATES OF UNIT CELL B-AXIS'][2]

        output.coordinates_of_unit_cell_c_axis = XSDataVectorDouble()
        output.coordinates_of_unit_cell_c_axis.v1 = parsed[
            'COORDINATES OF UNIT CELL C-AXIS'][0]
        output.coordinates_of_unit_cell_c_axis.v2 = parsed[
            'COORDINATES OF UNIT CELL C-AXIS'][1]
        output.coordinates_of_unit_cell_c_axis.v3 = parsed[
            'COORDINATES OF UNIT CELL C-AXIS'][2]

        parsed['UNIT_CELL_CONSTANTS='] = [
            XSDataFloat(x) for x in parsed['UNIT_CELL_CONSTANTS=']
        ]

        # there may be trailing information after the 6 floats (the
        # string "as used by INTEGRATE")
        unit_cells = parsed['UNIT_CELL_CONSTANTS='][:6]
        output.cell_a, output.cell_b, output.cell_c, \
        output.cell_alpha, output.cell_beta, output.cell_gamma = unit_cells

    except KeyError, ke:
        EDVerbose.ERROR('Some parameters could not be found!')
        EDVerbose.DEBUG('Those found were: %s' % parsed)
        raise ValueError('Some parameters missing')
Exemplo n.º 18
0
    def process(self, _edObject=None):
        EDPlugin.process(self)

        output = XSDataXdsOutput()

        # get all the file's contents, find where the info is and then
        # use helper functions to retrieve stuff and put it in the
        # data model
        try:
            f = open(self.dataInput.correct_lp.path.value, 'r')
            lines = f.readlines()
        except IOError:
            EDVerbose.ERROR(
                'Could not open the specified XDS output file for reading')
            self.setFailure()
            return

        # look for the "big piece of information"
        info_begin = None
        info_end = None
        for lineno, line in enumerate(lines):
            if info_begin is None:
                if line.find(
                        'REFINEMENT OF DIFFRACTION PARAMETERS USING ALL IMAGES'
                ) != -1:
                    info_begin = lineno
            else:
                if line.find(
                        'MEAN INTENSITY AS FUNCTION OF SPINDLE POSITION WITHIN DATA IMAGE'
                ) != -1:
                    info_end = lineno
                    break

        if info_begin is None or info_end is None:
            EDVerbose.ERROR('could not find the refined parameters')
            self.setFailure()
            return

        _extract_infos(lines[info_begin:info_end], output)

        # second pass, look for the interesting table
        info_begin = None
        info_end = None
        started = False
        for line_no, line in enumerate(lines):
            if line.find(
                    'REFLECTIONS OF TYPE H,0,0  0,K,0  0,0,L OR EXPECTED TO BE ABSENT (*)'
            ) != -1:
                # the table will start shortly after
                started = True
                continue
            if started:
                # look if we are at the table yet
                if line.find(
                        'LIMIT     OBSERVED  UNIQUE  POSSIBLE     OF DATA   observed  expected'
                ) != -1:
                    # there's an empty line after the header
                    info_begin = line_no + 2
                if info_begin is not None and line.find('total') != -1:
                    # we're at the last table line
                    info_end = line_no
        if info_begin is None or info_end is None:
            EDVerbose.ERROR('could not find the completeness table')
            self.setFailure()
            return

        _extract_completeness_entries(lines[info_begin:info_end + 1], output)

        # now for the last bit: check if we were given a path to the
        # gxparm file and if it exists get the space group and unit
        # cell constants from it
        if self.dataInput.gxparm is not None:
            gxparm_path = self.dataInput.gxparm.path.value
            if os.path.exists(gxparm_path):
                with open(gxparm_path, 'r') as f:
                    lines = f.readlines()
                for line in lines:
                    # the one we want has 7 floats
                    chunks = line.split()
                    if len(chunks) == 7:
                        output.sg_number = XSDataInteger(int(chunks[0]))
                        output.unit_cell_constants = [
                            XSDataFloat(float(x)) for x in chunks[1:]
                        ]

        input_file = self.dataInput.correct_lp.path.value
        output.xds_run_directory = XSDataString(os.path.dirname(input_file))
        self.dataOutput = output
Exemplo n.º 19
0
    def process(self, _edObject=None):
        EDPlugin.process(self)
        detector_max_res = self.dataInput.detector_max_res
        if detector_max_res is not None:
            detector_max_res = detector_max_res.value

        completeness_cutoff_param = self.dataInput.completeness_cutoff
        if completeness_cutoff_param is None:
            completeness_cutoff = 80
        else:
            completeness_cutoff = completeness_cutoff_param.value

        isig_cutoff_param = self.dataInput.isig_cutoff
        if isig_cutoff_param is None:
            isig_cutoff = 3
        else:
            isig_cutoff = isig_cutoff_param.value

        res_override = self.dataInput.res_override

        bins = list()

        # for the first iteration
        # comment from max's code: "less stringent at low res"
        local_completeness_cutoff = 70
        # declared but not initialized in the perl code
        prev_isig = prev_res = 0

        # XXX: if res is still not defined at the end it is set to
        # detector_max_res, which we should somehow defined (in the
        # data model?) and used as the default value before we start
        # the processing
        res = detector_max_res

        for entry in self.dataInput.completeness_entries:
            outer_res = entry.outer_res.value
            outer_complete = entry.outer_complete.value
            outer_rfactor = entry.outer_rfactor.value
            outer_isig = entry.outer_isig.value

            if outer_complete < local_completeness_cutoff or outer_isig < isig_cutoff or \
                    (res_override is not None and outer_res < res_override.value):
                if outer_complete < completeness_cutoff:
                    EDVerbose.DEBUG('incomplete data (%s) in this shell' %
                                    outer_complete)
                    res = prev_res
                else:
                    res = _calculate_res_from_bins(prev_isig, prev_res,
                                                   outer_isig, outer_res,
                                                   isig_cutoff)
                bins.append(outer_res)

                #NOTE: get out of the loop, see the value of `skip` in
                #max's code
                break
            else:
                bins.append(outer_res)
            prev_res, prev_isig = outer_res, outer_isig

        # Now the implementation of what max does when he encouters
        # the total values, which are conveniently already parsed in
        # our case
        if len(bins) < 2:
            EDVerbose.DEBUG("No bins with I/sigma greater than %s" %
                            isig_cutoff)
            EDVerbose.DEBUG(
                """something could be wrong, or the completeness could be too low!
bravais lattice/SG could be incorrect or something more insidious like
incorrect parameters in XDS.INP like distance, X beam, Y beam, etc.
Stopping""")
            self.setFailure()
            return
        if res is None:
            res = sorted(bins)[0]
        if res_override is not None:
            res = res_override.value
        # remove last bin (see why w/ max)
        retbins = [XSDataFloat(x) for x in bins[:-1]]

        data_output = XSDataResCutoffResult()
        data_output.res = XSDataFloat(res)
        data_output.bins = retbins
        totals = self.dataInput.total_completeness
        data_output.total_complete = totals.outer_complete
        data_output.total_rfactor = totals.outer_rfactor
        data_output.total_isig = totals.outer_isig

        self.dataOutput = data_output
Exemplo n.º 20
0
    def resolutionBinItemListToResolutionBin(self, _xsResolutionBinItemList):
        xsDataResolutionBin = XSDataBestResolutionBin()

        pyStrItem = EDUtilsTable.getItemFromList(_xsResolutionBinItemList,
                                                 "min_resolution")
        fItem = float(pyStrItem.getValueOf_())
        xsDataResolutionBin.setMinResolution(XSDataFloat(fItem))

        pyStrItem = EDUtilsTable.getItemFromList(_xsResolutionBinItemList,
                                                 "max_resolution")
        fItem = float(pyStrItem.getValueOf_())
        xsDataResolutionBin.setMaxResolution(XSDataFloat(fItem))

        pyStrItem = EDUtilsTable.getItemFromList(_xsResolutionBinItemList,
                                                 "completeness")
        fItem = float(pyStrItem.getValueOf_())
        xsDataResolutionBin.setCompleteness(XSDataFloat(fItem))

        pyStrItem = EDUtilsTable.getItemFromList(_xsResolutionBinItemList,
                                                 "redundancy")
        fItem = float(pyStrItem.getValueOf_())
        xsDataResolutionBin.setRedundancy(XSDataFloat(fItem))

        pyStrItem = EDUtilsTable.getItemFromList(_xsResolutionBinItemList,
                                                 "average_intensity")
        fItem = float(pyStrItem.getValueOf_())
        xsDataResolutionBin.setAverageIntensity(XSDataFloat(fItem))

        pyStrItem = EDUtilsTable.getItemFromList(_xsResolutionBinItemList,
                                                 "average_error")
        fItem = float(pyStrItem.getValueOf_())
        xsDataResolutionBin.setAverageSigma(XSDataFloat(fItem))

        pyStrItem = EDUtilsTable.getItemFromList(_xsResolutionBinItemList,
                                                 "average_i_over_sigma")
        fItem = float(pyStrItem.getValueOf_())
        xsDataResolutionBin.setIOverSigma(XSDataFloat(fItem))

        pyStrItem = EDUtilsTable.getItemFromList(_xsResolutionBinItemList,
                                                 "R_factor")
        fItem = float(pyStrItem.getValueOf_())
        xsDataResolutionBin.setRFactor(XSDataFloat(fItem))

        pyStrItem = EDUtilsTable.getItemFromList(_xsResolutionBinItemList,
                                                 "Chi**2")
        if (pyStrItem is not None):
            fItem = float(pyStrItem.getValueOf_())
            xsDataResolutionBin.setChi2(XSDataFloat(fItem))

        pyStrItem = EDUtilsTable.getItemFromList(
            _xsResolutionBinItemList, "average_i_over_sigma_Chi**2")
        if (pyStrItem is not None):
            fItem = float(pyStrItem.getValueOf_())
            xsDataResolutionBin.setIOverSigmaChi(XSDataFloat(fItem))

        pyStrItem = EDUtilsTable.getItemFromList(_xsResolutionBinItemList,
                                                 "fract_overload")
        fItem = float(pyStrItem.getValueOf_())
        xsDataResolutionBin.setPercentageOverload(XSDataFloat(fItem))

        return xsDataResolutionBin
Exemplo n.º 21
0
 def buildChildren(self, child_, nodeName_):
     if child_.nodeType == Node.ELEMENT_NODE and \
         nodeName_ == 'experimentalCondition':
         obj_ = XSDataExperimentalCondition()
         obj_.build(child_)
         self.setExperimentalCondition(obj_)
     elif child_.nodeType == Node.ELEMENT_NODE and \
         nodeName_ == 'diffractionPlan':
         obj_ = XSDataDiffractionPlan()
         obj_.build(child_)
         self.setDiffractionPlan(obj_)
     elif child_.nodeType == Node.ELEMENT_NODE and \
         nodeName_ == 'sample':
         obj_ = XSDataSampleCrystalMM()
         obj_.build(child_)
         self.setSample(obj_)
     elif child_.nodeType == Node.ELEMENT_NODE and \
         nodeName_ == 'imagePath':
         obj_ = XSDataFile()
         obj_.build(child_)
         self.imagePath.append(obj_)
     elif child_.nodeType == Node.ELEMENT_NODE and \
         nodeName_ == 'flux':
         obj_ = XSDataFloat()
         obj_.build(child_)
         self.setFlux(obj_)
     elif child_.nodeType == Node.ELEMENT_NODE and \
         nodeName_ == 'minExposureTimePerImage':
         obj_ = XSDataTime()
         obj_.build(child_)
         self.setMinExposureTimePerImage(obj_)
     elif child_.nodeType == Node.ELEMENT_NODE and \
         nodeName_ == 'beamSize':
         obj_ = XSDataLength()
         obj_.build(child_)
         self.setBeamSize(obj_)
     elif child_.nodeType == Node.ELEMENT_NODE and \
         nodeName_ == 'beamSizeX':
         obj_ = XSDataLength()
         obj_.build(child_)
         self.setBeamSizeX(obj_)
     elif child_.nodeType == Node.ELEMENT_NODE and \
         nodeName_ == 'beamSizeY':
         obj_ = XSDataLength()
         obj_.build(child_)
         self.setBeamSizeY(obj_)
     elif child_.nodeType == Node.ELEMENT_NODE and \
         nodeName_ == 'apertureSize':
         obj_ = XSDataLength()
         obj_.build(child_)
         self.setApertureSize(obj_)
     elif child_.nodeType == Node.ELEMENT_NODE and \
         nodeName_ == 'templateMode':
         obj_ = XSDataBoolean()
         obj_.build(child_)
         self.setTemplateMode(obj_)
     elif child_.nodeType == Node.ELEMENT_NODE and \
         nodeName_ == 'generatedTemplateFile':
         obj_ = XSDataFile()
         obj_.build(child_)
         self.setGeneratedTemplateFile(obj_)
     elif child_.nodeType == Node.ELEMENT_NODE and \
         nodeName_ == 'resultsFilePath':
         obj_ = XSDataFile()
         obj_.build(child_)
         self.setResultsFilePath(obj_)
     elif child_.nodeType == Node.ELEMENT_NODE and \
         nodeName_ == 'beamPosX':
         obj_ = XSDataFloat()
         obj_.build(child_)
         self.setBeamPosX(obj_)
     elif child_.nodeType == Node.ELEMENT_NODE and \
         nodeName_ == 'beamPosY':
         obj_ = XSDataFloat()
         obj_.build(child_)
         self.setBeamPosY(obj_)
     elif child_.nodeType == Node.ELEMENT_NODE and \
         nodeName_ == 'wavelength':
         obj_ = XSDataWavelength()
         obj_.build(child_)
         self.setWavelength(obj_)
     elif child_.nodeType == Node.ELEMENT_NODE and \
         nodeName_ == 'transmission':
         obj_ = XSDataDouble()
         obj_.build(child_)
         self.setTransmission(obj_)
     elif child_.nodeType == Node.ELEMENT_NODE and \
         nodeName_ == 'dataCollectionId':
         obj_ = XSDataInteger()
         obj_.build(child_)
         self.setDataCollectionId(obj_)
     elif child_.nodeType == Node.ELEMENT_NODE and \
         nodeName_ == 'shortComments':
         obj_ = XSDataString()
         obj_.build(child_)
         self.setShortComments(obj_)
     elif child_.nodeType == Node.ELEMENT_NODE and \
         nodeName_ == 'comments':
         obj_ = XSDataString()
         obj_.build(child_)
         self.setComments(obj_)
     elif child_.nodeType == Node.ELEMENT_NODE and \
         nodeName_ == 'inputCharacterisation':
         obj_ = XSDataInputCharacterisation()
         obj_.build(child_)
         self.setInputCharacterisation(obj_)
    def testSetDataModelInput(self):
        """
        """
        edPluginStrategy = self.createPlugin()
        xsPluginItemGood01 = self.getPluginConfiguration(os.path.join(self.strDataPath, "XSConfiguration_ESRF.xml"))
        edPluginStrategy.setConfiguration(xsPluginItemGood01)
        edPluginStrategy.configure()

        from XSDataMXv1 import XSDataStrategyInput
        xSDataStrategy = XSDataStrategyInput()

        # Beam
        from XSDataCommon import XSDataFlux
        from XSDataCommon import XSDataWavelength
        from XSDataCommon import XSDataSize
        from XSDataCommon import XSDataLength
        from XSDataCommon import XSDataTime
        from XSDataMXv1 import XSDataBeam
        from XSDataMXv1 import XSDataExperimentalCondition

        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
        from XSDataMXv1     import XSDataDetector
        from XSDataCommon   import XSDataString
        from XSDataMXv1     import XSDataGoniostat

        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"))
        listBestFileContentHKL = []
        listBestFileContentHKL.append(XSDataString(bestFileContentHKL))
        xSDataStrategy.setBestFileContentHKL(listBestFileContentHKL)

        # Crystal
        from XSDataCommon import XSDataFloat
        from XSDataCommon import XSDataAngle
        from XSDataCommon import XSDataInteger
        from XSDataMXv1 import XSDataCrystal
        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


        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.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(XSDataFloat(1.5))

        xSDataStrategy.setCrystalRefined(xsDataCrystal)

        xSDataStrategy.setSample(xsDataSampleCrystalMM)

        xSDataStrategy.outputFile(self.strObtainedInputFile)

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

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

        EDAssert.equal(xsDataInputExpected.marshal(), xsDataInputObtained.marshal())
Exemplo n.º 23
0
from XSDataCommon import XSDataString
from XSDataCommon import XSDataInteger
from XSDataCommon import XSDataFloat
x = XSDataBoolean(True)
print x.value
print x.marshal()
x = XSDataBoolean(False)
print x.value
print x.marshal()
x = XSDataBoolean('true')
print x.value
print x.marshal()
x = XSDataBoolean('False')
print x.value
print x.marshal()
x = XSDataBoolean(0)
print x.value
print x.marshal()
x = XSDataBoolean(1)
print x.value
print x.marshal()
x = XSDataBoolean(2)
print x.value
print x.marshal()
y = XSDataFloat('this is not a float')
print y.value
print y.marshal()
z = XSDataInteger('this is not an integer')
print z.value
print z.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)
Exemplo n.º 25
0
            0].outer_rfactor.value
        self.custom_stats[
            'outer_i_over_sigma'] = xdsresult.completeness_entries[
                -1].outer_isig.value
        self.custom_stats['outer_r_value'] = xdsresult.completeness_entries[
            -1].outer_rfactor.value

        res_cutoff_in = XSDataResCutoff()
        res_cutoff_in.xds_res = xdsresult
        res_cutoff_in.completeness_entries = xdsresult.completeness_entries
        res_cutoff_in.detector_max_res = self.dataInput.detector_max_res

        #XXX: remove from the data model as it is just pass-through?
        res_cutoff_in.total_completeness = xdsresult.total_completeness
        res_cutoff_in.completeness_cutoff = self.dataInput.completeness_cutoff
        res_cutoff_in.isig_cutoff = XSDataFloat(1.0)
        #res_cutoff_in.isig_cutoff = self.dataInput.isig_cutoff
        res_cutoff_in.r_value_cutoff = self.dataInput.r_value_cutoff
        res_cutoff_in.cc_half_cutoff = self.dataInput.cc_half_cutoff
        self.first_res_cutoff.dataInput = res_cutoff_in
        self.first_res_cutoff.executeSynchronous()

        self.stats['first_res_cutoff'] = time.time() - t0

        if self.first_res_cutoff.isFailure():
            EDVerbose.ERROR("res cutoff failed")
            log_to_ispyb(
                [self.integration_id_noanom, self.integration_id_anom],
                'Indexing', 'Failed', 'res cutoff failed in {0}s'.format(
                    self.stats['first_res_cutoff']))
            self.setFailure()
    def createDataMOSFLMOutputIndexing(self):
        self.DEBUG("EDPluginMOSFLMIndexingv10.createDataMOSFLMOutputIndexing")
        xsDataMOSFLMOutputIndexing = XSDataMOSFLMOutputIndexing()
        # Read Newmat file
        xsDataMOSFLMNewmat = self.getDataMOSFLMNewmat()
        if (xsDataMOSFLMNewmat is None):
            strError = "MOSFLM indexing error : No solution was obtained!"
            self.ERROR(strError)
            self.setFailure()
        else:
            xsDataMOSFLMOutputIndexing.setRefinedNewmat(xsDataMOSFLMNewmat)
            # Then read the XML file
            strDnaTablesXML = self.readProcessFile(self.getScriptBaseName() +
                                                   "_dnaTables.xml")
            xsDataDnaTables = dna_tables.parseString(strDnaTablesXML)

            listXSTableMosaicityEstimation = EDUtilsTable.getTableListFromTables(
                xsDataDnaTables, "mosaicity_estimation")
            dMosaicityValueSum = 0.0
            nValues = 0
            for xsTableMosaicityEstimation in listXSTableMosaicityEstimation:
                for xsListMosaicity in EDUtilsTable.getListsFromTable(
                        xsTableMosaicityEstimation, "mosaicity"):
                    dMosaicityValue = float(
                        EDUtilsTable.getItemFromList(xsListMosaicity,
                                                     "value").getValueOf_())
                    dMosaicityValueSum += dMosaicityValue
                    nValues += 1
            xsDataFloatMosaicityEstimation = XSDataFloat()
            xsDataFloatMosaicityEstimation.setValue(dMosaicityValueSum /
                                                    nValues)
            xsDataMOSFLMOutputIndexing.setMosaicityEstimation(
                xsDataFloatMosaicityEstimation)

            xsTableRefinement = EDUtilsTable.getTableFromTables(
                xsDataDnaTables, "refinement")
            if (xsTableRefinement is None):
                strError = "MOSFLM indexing error : No solution was refined!"
                self.ERROR(strError)
                self.setFailure()
            else:
                xsListDeviations = EDUtilsTable.getListsFromTable(
                    xsTableRefinement, "deviations")[0]
                dDeviationAngular = float(
                    EDUtilsTable.getItemFromList(xsListDeviations,
                                                 "angular").getValueOf_())
                dDeviationPositional = float(
                    EDUtilsTable.getItemFromList(xsListDeviations,
                                                 "positional").getValueOf_())
                xsDataMOSFLMOutputIndexing.setDeviationAngular(
                    XSDataAngle(dDeviationAngular))
                xsDataMOSFLMOutputIndexing.setDeviationPositional(
                    XSDataLength(dDeviationPositional))
                xsListResults = EDUtilsTable.getListsFromTable(
                    xsTableRefinement, "results")[0]
                dDetectorDistance = float(
                    EDUtilsTable.getItemFromList(
                        xsListResults, "detector_distance").getValueOf_())
                xsDataMOSFLMOutputIndexing.setRefinedDistance(
                    XSDataLength(dDetectorDistance))
                xsListParameters = EDUtilsTable.getListsFromTable(
                    xsTableRefinement, "parameters")[0]
                iSpotsUsed = int(
                    EDUtilsTable.getItemFromList(xsListParameters,
                                                 "used").getValueOf_())
                iSpotsTotal = int(
                    EDUtilsTable.getItemFromList(xsListParameters,
                                                 "out_of").getValueOf_())
                xsDataMOSFLMOutputIndexing.setSpotsUsed(
                    XSDataInteger(iSpotsUsed))
                xsDataMOSFLMOutputIndexing.setSpotsTotal(
                    XSDataInteger(iSpotsTotal))

                xsTableSolutionRefinement = EDUtilsTable.getTableFromTables(
                    xsDataDnaTables, "solution_refinement")
                xsListParameters = EDUtilsTable.getListsFromTable(
                    xsTableSolutionRefinement, "selection")[0]
                iSelectedSolutionNumber = int(
                    EDUtilsTable.getItemFromList(xsListParameters,
                                                 "number").getValueOf_())
                xsDataMOSFLMOutputIndexing.setSelectedSolutionNumber(
                    XSDataInteger(iSelectedSolutionNumber))
                strSelectedSolutionSpaceGroup = (EDUtilsTable.getItemFromList(
                    xsListParameters, "spacegroup").getValueOf_())
                xsDataMOSFLMOutputIndexing.setSelectedSolutionSpaceGroup(
                    XSDataString(strSelectedSolutionSpaceGroup))
                iSelectedSolutionSpaceGroupNumber = int(
                    EDUtilsTable.getItemFromList(
                        xsListParameters, "spacegroup_number").getValueOf_())
                xsDataMOSFLMOutputIndexing.setSelectedSolutionSpaceGroupNumber(
                    XSDataInteger(iSelectedSolutionSpaceGroupNumber))

                xsTableAutoIndexSolutions = EDUtilsTable.getTableFromTables(
                    xsDataDnaTables, "autoindex_solutions")
                xsListsSolution = xsTableAutoIndexSolutions.getList()
                for xsListSolution in xsListsSolution:
                    xsDataMOSFLMIndexingSolution = XSDataMOSFLMIndexingSolution(
                    )
                    xsDataCell = XSDataCell()
                    iSolutionNumber = int(
                        EDUtilsTable.getItemFromList(xsListSolution,
                                                     "index").getValueOf_())
                    xsDataMOSFLMIndexingSolution.setIndex(
                        XSDataInteger(iSolutionNumber))
                    iPenalty = int(
                        EDUtilsTable.getItemFromList(xsListSolution,
                                                     "penalty").getValueOf_())
                    xsDataMOSFLMIndexingSolution.setPenalty(
                        XSDataInteger(iPenalty))
                    strLattice = (EDUtilsTable.getItemFromList(
                        xsListSolution, "lattice").getValueOf_())
                    xsDataMOSFLMIndexingSolution.setLattice(
                        XSDataString(strLattice))
                    dA = float(
                        EDUtilsTable.getItemFromList(xsListSolution,
                                                     "a").getValueOf_())
                    xsDataCell.setLength_a(XSDataLength(dA))
                    dB = float(
                        EDUtilsTable.getItemFromList(xsListSolution,
                                                     "b").getValueOf_())
                    xsDataCell.setLength_b(XSDataLength(dB))
                    dC = float(
                        EDUtilsTable.getItemFromList(xsListSolution,
                                                     "c").getValueOf_())
                    xsDataCell.setLength_c(XSDataLength(dC))
                    dAlpha = float(
                        EDUtilsTable.getItemFromList(xsListSolution,
                                                     "alpha").getValueOf_())
                    xsDataCell.setAngle_alpha(XSDataAngle(dAlpha))
                    dBeta = float(
                        EDUtilsTable.getItemFromList(xsListSolution,
                                                     "beta").getValueOf_())
                    xsDataCell.setAngle_beta(XSDataAngle(dBeta))
                    dGamma = float(
                        EDUtilsTable.getItemFromList(xsListSolution,
                                                     "gamma").getValueOf_())
                    xsDataCell.setAngle_gamma(XSDataAngle(dGamma))
                    xsDataMOSFLMIndexingSolution.setCell(xsDataCell)
                    xsDataMOSFLMOutputIndexing.addPossibleSolutions(
                        xsDataMOSFLMIndexingSolution)

                xsTableBeamRefinement = EDUtilsTable.getTableFromTables(
                    xsDataDnaTables, "beam_refinement")
                xsDataMOSFLMBeamPositionRefined = XSDataMOSFLMBeamPosition()
                xsDataMOSFLMBeamPositionShift = XSDataMOSFLMBeamPosition()
                dInitialBeamX = 0.0
                dInitialBeamY = 0.0
                dRefinedBeamX = 0.0
                dRefinedBeamY = 0.0
                xsListInitialBeam = EDUtilsTable.getListsFromTable(
                    xsTableBeamRefinement, "initial_beam")[0]
                fInitialBeamPositionX = float(
                    EDUtilsTable.getItemFromList(xsListInitialBeam,
                                                 "x").getValueOf_())
                fInitialBeamPositionY = float(
                    EDUtilsTable.getItemFromList(xsListInitialBeam,
                                                 "y").getValueOf_())
                xsListRefinedBeam = EDUtilsTable.getListsFromTable(
                    xsTableBeamRefinement, "refined_beam")[0]
                fRefinedBeamPositionX = float(
                    EDUtilsTable.getItemFromList(xsListRefinedBeam,
                                                 "x").getValueOf_())
                fRefinedBeamPositionY = float(
                    EDUtilsTable.getItemFromList(xsListRefinedBeam,
                                                 "y").getValueOf_())
                xsDataMOSFLMBeamPositionRefined.setX(
                    XSDataLength(fRefinedBeamPositionX))
                xsDataMOSFLMBeamPositionRefined.setY(
                    XSDataLength(fRefinedBeamPositionY))
                xsDataMOSFLMBeamPositionShift.setX(
                    XSDataLength(fInitialBeamPositionX -
                                 fRefinedBeamPositionX))
                xsDataMOSFLMBeamPositionShift.setY(
                    XSDataLength(fInitialBeamPositionY -
                                 fRefinedBeamPositionY))
                xsDataMOSFLMOutputIndexing.setRefinedBeam(
                    xsDataMOSFLMBeamPositionRefined)
                xsDataMOSFLMOutputIndexing.setBeamShift(
                    xsDataMOSFLMBeamPositionShift)
        # Path to log file
        xsDataMOSFLMOutputIndexing.setPathToLogFile(
            XSDataFile(
                XSDataString(
                    os.path.join(self.getWorkingDirectory(),
                                 self.getScriptLogFileName()))))
        return xsDataMOSFLMOutputIndexing
Exemplo n.º 27
0
    def createDataMOSFLMOutputIntegration(self):
        self.DEBUG("EDPluginMOSFLMIntegrationv10.createDataMOSFLMOutputIntegration")
        xsDataMOSFLMOutputIntegration = XSDataMOSFLMOutputIntegration()
        # Read bestfile.par, bestfile.hkl and bestfile.dat
        strBestfilePar = self.readBestFile("bestfile.par")
        bContinue = True
        if (strBestfilePar is not None):
            xsDataMOSFLMOutputIntegration.setBestfilePar(XSDataString(strBestfilePar))
        else:
            bContinue = False

        if bContinue:
            strBestfileHKL = self.readBestFile("bestfile.hkl")
            if (strBestfileHKL is not None):
                xsDataMOSFLMOutputIntegration.setBestfileHKL(XSDataString(strBestfileHKL))
            else:
                bContinue = False

        if bContinue:
            strBestfileDat = self.readBestFile("bestfile.dat")
            if (strBestfileDat is not None):
                xsDataMOSFLMOutputIntegration.setBestfileDat(XSDataString(strBestfileDat))
            else:
                bContinue = False

        if bContinue:
            strDnaTablesXML = self.readProcessFile(self.getBaseName() + "_dnaTables.xml")
            xsDataDnaTables = dna_tables.parseString(strDnaTablesXML)

            xsTableIntegrationResults = EDUtilsTable.getTableFromTables(xsDataDnaTables, "integration_results")
            xsListFinalResiduals = EDUtilsTable.getListsFromTable(xsTableIntegrationResults, "final_residuals")[0]
            strRMSSpotDeviation = EDUtilsTable.getItemFromList(xsListFinalResiduals, "rms").getValueOf_()
            xsDataMOSFLMOutputIntegration.setRMSSpotDeviation(XSDataLength(float(strRMSSpotDeviation)))
            strBeamPositionX = EDUtilsTable.getItemFromList(xsListFinalResiduals, "xcen").getValueOf_()
            strBeamPositionY = EDUtilsTable.getItemFromList(xsListFinalResiduals, "ycen").getValueOf_()
            xsDataMOSFLMBeamPosition = XSDataMOSFLMBeamPosition()
            xsDataMOSFLMBeamPosition.setX(XSDataLength(float(strBeamPositionX)))
            xsDataMOSFLMBeamPosition.setY(XSDataLength(float(strBeamPositionY)))
            xsDataMOSFLMOutputIntegration.setRefinedBeam(xsDataMOSFLMBeamPosition)

            xsDataMOSFLMNewmatMatrix = self.getDataMOSFLMMatrix()
            xsDataMOSFLMOutputIntegration.setRefinedNewmat(xsDataMOSFLMNewmatMatrix)

            # New results (described in bug #63)

            xsTableIntegrationOutput = EDUtilsTable.getTableFromTables(xsDataDnaTables, "integration_output")
            xsListOutputFiles = EDUtilsTable.getListsFromTable(xsTableIntegrationOutput, "output_files")[0]

            strMTZFilename = EDUtilsTable.getItemFromList(xsListOutputFiles, "hklout").getValueOf_()
            strMTZPath = os.path.join(self.getWorkingDirectory(), strMTZFilename)
            xsDataFile = XSDataFile()
            xsDataFile.setPath(XSDataString(strMTZPath))
            xsDataMOSFLMOutputIntegration.setGeneratedMTZFile(xsDataFile)

            xsTableSummaryInformation = EDUtilsTable.getTableFromTables(xsDataDnaTables, "summary_information")
            xsListSummary = EDUtilsTable.getListsFromTable(xsTableSummaryInformation, "summary")[0]
            xsListSpots = EDUtilsTable.getListsFromTable(xsTableSummaryInformation, "spots")[0]

            strDistance = EDUtilsTable.getItemFromList(xsListSummary, "distance").getValueOf_()
            xsDataMOSFLMOutputIntegration.setRefinedDistance(XSDataLength(float(strDistance)))

            strYScale = EDUtilsTable.getItemFromList(xsListSummary, "yscale").getValueOf_()
            xsDataMOSFLMOutputIntegration.setRefinedYScale(XSDataFloat(float(strYScale)))

            strOverallIOverSigma = EDUtilsTable.getItemFromList(xsListSummary, "isigall").getValueOf_()
            xsDataMOSFLMOutputIntegration.setOverallIOverSigma(XSDataFloat(float(strOverallIOverSigma)))

            strHighestResolutionIOverSigma = EDUtilsTable.getItemFromList(xsListSummary, "isigout").getValueOf_()
            xsDataMOSFLMOutputIntegration.setHighestResolutionIOverSigma(XSDataFloat(float(strHighestResolutionIOverSigma)))

            strNumberOfBadReflections = EDUtilsTable.getItemFromList(xsListSpots, "bad_spots").getValueOf_()
            xsDataMOSFLMOutputIntegration.setNumberOfBadReflections(XSDataInteger(int(strNumberOfBadReflections)))

            strNumberOfFullyRecordedReflections = EDUtilsTable.getItemFromList(xsListSpots, "full").getValueOf_()
            xsDataMOSFLMOutputIntegration.setNumberOfFullyRecordedReflections(XSDataInteger(int(strNumberOfFullyRecordedReflections)))

            strNumberOfNegativeReflections = EDUtilsTable.getItemFromList(xsListSpots, "negative").getValueOf_()
            xsDataMOSFLMOutputIntegration.setNumberOfNegativeReflections(XSDataInteger(int(strNumberOfNegativeReflections)))

            strNumberOfOverlappedReflections = EDUtilsTable.getItemFromList(xsListSpots, "overlap").getValueOf_()
            xsDataMOSFLMOutputIntegration.setNumberOfOverlappedReflections(XSDataInteger(int(strNumberOfOverlappedReflections)))

            strNumberOfPartialReflections = EDUtilsTable.getItemFromList(xsListSpots, "partial").getValueOf_()
            xsDataMOSFLMOutputIntegration.setNumberOfPartialReflections(XSDataInteger(int(strNumberOfPartialReflections)))

            # Fill in the statistics

            xsDataMOSFLMOutputIntegration.setOverallStatistics(self.getMOSFLMIntegrationStatisticsPerResolutionBin(xsDataDnaTables, "bin_0"))

            iIndex = 1
            bContinue = True
            fMinResolution = None
            while (bContinue == True):
                strBin = "bin_%d" % iIndex
                # I don't know how many intensity bins there are. Since the EDUtilsTable.getListsFromTable
                # method crashes if the list is not present, I had to wrap the calls to this method in
                # try - except:
                try:
                    xsDataMOSFLMIntegrationStatisticsPerResolutionBin = self.getMOSFLMIntegrationStatisticsPerResolutionBin(xsDataDnaTables, strBin, fMinResolution)
                    fMinResolution = xsDataMOSFLMIntegrationStatisticsPerResolutionBin.getMaxResolution().getValue()
                    xsDataMOSFLMOutputIntegration.addStatisticsPerResolutionBin(xsDataMOSFLMIntegrationStatisticsPerResolutionBin)
                    iIndex += 1
                except:
                    bContinue = False

        # Path to log file
        xsDataMOSFLMOutputIntegration.setPathToLogFile(XSDataFile(XSDataString(os.path.join(self.getWorkingDirectory(), self.getScriptLogFileName()))))
        return xsDataMOSFLMOutputIntegration
    def createDataMOSFLMOutputIndexing(self):
        EDVerbose.DEBUG("EDPluginMOSFLMIndexingv10.createDataMOSFLMOutputIndexing")
        xsDataMOSFLMOutputIndexing = XSDataMOSFLMOutputIndexing()
        # Read Newmat file
        xsDataMOSFLMNewmat = self.getDataMOSFLMNewmat()
        if (xsDataMOSFLMNewmat is None):
            strError = "MOSFLM indexing error : No solution was obtained!"
            EDVerbose.ERROR(strError)
            self.setFailure()
        else:
            xsDataMOSFLMOutputIndexing.setRefinedNewmat(xsDataMOSFLMNewmat)
            # Then read the XML file
            strDnaTablesXML = self.readProcessFile(self.getScriptBaseName() + "_dnaTables.xml")
            xsDataDnaTables = dna_tables.parseString(strDnaTablesXML)

            listXSTableMosaicityEstimation = EDUtilsTable.getTableListFromTables(xsDataDnaTables, "mosaicity_estimation")
            dMosaicityValueSum = 0.0
            nValues = 0
            for xsTableMosaicityEstimation in listXSTableMosaicityEstimation:
                for xsListMosaicity in EDUtilsTable.getListsFromTable(xsTableMosaicityEstimation, "mosaicity"):
                    dMosaicityValue = float(EDUtilsTable.getItemFromList(xsListMosaicity, "value").getValueOf_())
                    dMosaicityValueSum += dMosaicityValue
                    nValues += 1
            xsDataFloatMosaicityEstimation = XSDataFloat()
            xsDataFloatMosaicityEstimation.setValue(dMosaicityValueSum / nValues)
            xsDataMOSFLMOutputIndexing.setMosaicityEstimation(xsDataFloatMosaicityEstimation)

            xsTableRefinement = EDUtilsTable.getTableFromTables(xsDataDnaTables, "refinement")
            if (xsTableRefinement is None):
                strError = "MOSFLM indexing error : No solution was refined!"
                EDVerbose.ERROR(strError)
                self.setFailure()
            else:
                xsListDeviations = EDUtilsTable.getListsFromTable(xsTableRefinement, "deviations")[0]
                dDeviationAngular = float(EDUtilsTable.getItemFromList(xsListDeviations, "angular").getValueOf_())
                dDeviationPositional = float(EDUtilsTable.getItemFromList(xsListDeviations, "positional").getValueOf_())
                xsDataMOSFLMOutputIndexing.setDeviationAngular(XSDataAngle(dDeviationAngular))
                xsDataMOSFLMOutputIndexing.setDeviationPositional(XSDataLength(dDeviationPositional))
                xsListResults = EDUtilsTable.getListsFromTable(xsTableRefinement, "results")[0]
                dDetectorDistance = float(EDUtilsTable.getItemFromList(xsListResults, "detector_distance").getValueOf_())
                xsDataMOSFLMOutputIndexing.setRefinedDistance(XSDataLength(dDetectorDistance))
                xsListParameters = EDUtilsTable.getListsFromTable(xsTableRefinement, "parameters")[0]
                iSpotsUsed = int(EDUtilsTable.getItemFromList(xsListParameters, "used").getValueOf_())
                iSpotsTotal = int(EDUtilsTable.getItemFromList(xsListParameters, "out_of").getValueOf_())
                xsDataMOSFLMOutputIndexing.setSpotsUsed(XSDataInteger(iSpotsUsed))
                xsDataMOSFLMOutputIndexing.setSpotsTotal(XSDataInteger(iSpotsTotal))

                xsTableSolutionRefinement = EDUtilsTable.getTableFromTables(xsDataDnaTables, "solution_refinement")
                xsListParameters = EDUtilsTable.getListsFromTable(xsTableSolutionRefinement, "selection")[0]
                iSelectedSolutionNumber = int(EDUtilsTable.getItemFromList(xsListParameters, "number").getValueOf_())
                xsDataMOSFLMOutputIndexing.setSelectedSolutionNumber(XSDataInteger(iSelectedSolutionNumber))
                strSelectedSolutionSpaceGroup = (EDUtilsTable.getItemFromList(xsListParameters, "spacegroup").getValueOf_())
                xsDataMOSFLMOutputIndexing.setSelectedSolutionSpaceGroup(XSDataString(strSelectedSolutionSpaceGroup))
                iSelectedSolutionSpaceGroupNumber = int(EDUtilsTable.getItemFromList(xsListParameters, "spacegroup_number").getValueOf_())
                xsDataMOSFLMOutputIndexing.setSelectedSolutionSpaceGroupNumber(XSDataInteger(iSelectedSolutionSpaceGroupNumber))

                xsTableAutoIndexSolutions = EDUtilsTable.getTableFromTables(xsDataDnaTables, "autoindex_solutions")
                xsListsSolution = xsTableAutoIndexSolutions.getList()
                for xsListSolution in xsListsSolution:
                    xsDataMOSFLMIndexingSolution = XSDataMOSFLMIndexingSolution()
                    xsDataCell = XSDataCell()
                    iSolutionNumber = int(EDUtilsTable.getItemFromList(xsListSolution, "index").getValueOf_())
                    xsDataMOSFLMIndexingSolution.setIndex(XSDataInteger(iSolutionNumber))
                    iPenalty = int(EDUtilsTable.getItemFromList(xsListSolution, "penalty").getValueOf_())
                    xsDataMOSFLMIndexingSolution.setPenalty(XSDataInteger(iPenalty))
                    strLattice = (EDUtilsTable.getItemFromList(xsListSolution, "lattice").getValueOf_())
                    xsDataMOSFLMIndexingSolution.setLattice(XSDataString(strLattice))
                    dA = float(EDUtilsTable.getItemFromList(xsListSolution, "a").getValueOf_())
                    xsDataCell.setLength_a(XSDataLength(dA))
                    dB = float(EDUtilsTable.getItemFromList(xsListSolution, "b").getValueOf_())
                    xsDataCell.setLength_b(XSDataLength(dB))
                    dC = float(EDUtilsTable.getItemFromList(xsListSolution, "c").getValueOf_())
                    xsDataCell.setLength_c(XSDataLength(dC))
                    dAlpha = float(EDUtilsTable.getItemFromList(xsListSolution, "alpha").getValueOf_())
                    xsDataCell.setAngle_alpha(XSDataAngle(dAlpha))
                    dBeta = float(EDUtilsTable.getItemFromList(xsListSolution, "beta").getValueOf_())
                    xsDataCell.setAngle_beta(XSDataAngle(dBeta))
                    dGamma = float(EDUtilsTable.getItemFromList(xsListSolution, "gamma").getValueOf_())
                    xsDataCell.setAngle_gamma(XSDataAngle(dGamma))
                    xsDataMOSFLMIndexingSolution.setCell(xsDataCell)
                    xsDataMOSFLMOutputIndexing.addPossibleSolutions(xsDataMOSFLMIndexingSolution)

                xsTableBeamRefinement = EDUtilsTable.getTableFromTables(xsDataDnaTables, "beam_refinement")
                xsDataMOSFLMBeamPositionRefined = XSDataMOSFLMBeamPosition()
                xsDataMOSFLMBeamPositionShift = XSDataMOSFLMBeamPosition()
                dInitialBeamX = 0.0
                dInitialBeamY = 0.0
                dRefinedBeamX = 0.0
                dRefinedBeamY = 0.0
                xsListInitialBeam = EDUtilsTable.getListsFromTable(xsTableBeamRefinement, "initial_beam")[0]
                fInitialBeamPositionX = float(EDUtilsTable.getItemFromList(xsListInitialBeam, "x").getValueOf_())
                fInitialBeamPositionY = float(EDUtilsTable.getItemFromList(xsListInitialBeam, "y").getValueOf_())
                xsListRefinedBeam = EDUtilsTable.getListsFromTable(xsTableBeamRefinement, "refined_beam")[0]
                fRefinedBeamPositionX = float(EDUtilsTable.getItemFromList(xsListRefinedBeam, "x").getValueOf_())
                fRefinedBeamPositionY = float(EDUtilsTable.getItemFromList(xsListRefinedBeam, "y").getValueOf_())
                xsDataMOSFLMBeamPositionRefined.setX(XSDataLength(fRefinedBeamPositionX))
                xsDataMOSFLMBeamPositionRefined.setY(XSDataLength(fRefinedBeamPositionY))
                xsDataMOSFLMBeamPositionShift.setX(XSDataLength(fInitialBeamPositionX - fRefinedBeamPositionX))
                xsDataMOSFLMBeamPositionShift.setY(XSDataLength(fInitialBeamPositionY - fRefinedBeamPositionY))
                xsDataMOSFLMOutputIndexing.setRefinedBeam(xsDataMOSFLMBeamPositionRefined)
                xsDataMOSFLMOutputIndexing.setBeamShift(xsDataMOSFLMBeamPositionShift)

        return xsDataMOSFLMOutputIndexing
    def generateXSDataIndexingResult(_xsDataMOSFLMIndexingOutput,
                                     _xsDataExperimentalCondition=None):
        """
        Translation from XSDataMOSFLMIndexingOutput to XSDataIndexingResult.
        """
        EDVerbose.DEBUG(
            "EDHandlerXSDataMOSFLMv10.generateXSDataIndexingOutput")
        xsDataMOSFLMBeamPositionRefined = _xsDataMOSFLMIndexingOutput.getRefinedBeam(
        )
        xsDataMOSFLMBeamPositionShift = _xsDataMOSFLMIndexingOutput.getBeamShift(
        )
        dDeviationAngular = _xsDataMOSFLMIndexingOutput.getDeviationAngular(
        ).getValue()
        dDeviationPositional = _xsDataMOSFLMIndexingOutput.getDeviationPositional(
        ).getValue()
        dMosaicityEstimation = _xsDataMOSFLMIndexingOutput.getMosaicityEstimation(
        ).getValue()
        dDistanceRefined = _xsDataMOSFLMIndexingOutput.getRefinedDistance(
        ).getValue()
        iSelectedSolution = _xsDataMOSFLMIndexingOutput.getSelectedSolutionNumber(
        ).getValue()
        iSpotsTotal = _xsDataMOSFLMIndexingOutput.getSpotsTotal().getValue()
        iSpotsUsed = _xsDataMOSFLMIndexingOutput.getSpotsUsed().getValue()
        xsDataCellRefined = _xsDataMOSFLMIndexingOutput.getRefinedNewmat(
        ).getRefinedCell()
        xsDataMatrixA = _xsDataMOSFLMIndexingOutput.getRefinedNewmat(
        ).getAMatrix()
        xsDataMatrixU = _xsDataMOSFLMIndexingOutput.getRefinedNewmat(
        ).getUMatrix()
        strSelectedSpaceGroupName = _xsDataMOSFLMIndexingOutput.getSelectedSolutionSpaceGroup(
        ).getValue()
        iSelectedSpaceGroupNumber = _xsDataMOSFLMIndexingOutput.getSelectedSolutionSpaceGroupNumber(
        ).getValue()

        xsDataIndexingResult = XSDataIndexingResult()
        xsDataIndexingSolutionSelected = None

        for possibleSolutions in _xsDataMOSFLMIndexingOutput.getPossibleSolutions(
        ):
            xsDataCrystal = XSDataCrystal()
            xsDataSpaceGroup = XSDataSpaceGroup()
            xsDataSpaceGroup.setName(
                XSDataString(possibleSolutions.getLattice().getValue()))
            xsDataCrystal.setSpaceGroup(xsDataSpaceGroup)
            xsDataCrystal.setCell(possibleSolutions.getCell())
            xsDataIndexingSolution = XSDataIndexingSolution()
            xsDataIndexingSolution.setCrystal(xsDataCrystal)
            iIndex = possibleSolutions.getIndex().getValue()
            xsDataIndexingSolution.setNumber(XSDataInteger(iIndex))
            xsDataIndexingSolution.setPenalty(
                XSDataFloat(possibleSolutions.getPenalty().getValue()))
            xsDataIndexingResult.addSolution(xsDataIndexingSolution)
            if (iIndex == iSelectedSolution):
                xsDataIndexingSolutionSelected = XSDataIndexingSolutionSelected(
                )
                xsDataIndexingSolutionSelected.setNumber(XSDataInteger(iIndex))
                xsDataIndexingSolutionSelected.setPenalty(
                    XSDataFloat(possibleSolutions.getPenalty().getValue()))

        xsDataCrystalSelected = XSDataCrystal()
        xsDataSpaceGroupSelected = XSDataSpaceGroup()
        xsDataSpaceGroupSelected.setName(
            XSDataString(strSelectedSpaceGroupName))
        xsDataSpaceGroupSelected.setITNumber(
            XSDataInteger(iSelectedSpaceGroupNumber))
        xsDataCrystalSelected.setSpaceGroup(xsDataSpaceGroupSelected)
        xsDataCrystalSelected.setCell(xsDataCellRefined)
        xsDataCrystalSelected.setMosaicity(XSDataDouble(dMosaicityEstimation))
        xsDataIndexingSolutionSelected.setCrystal(xsDataCrystalSelected)

        xsDataOrientation = XSDataOrientation()
        xsDataOrientation.setMatrixA(xsDataMatrixA)
        xsDataOrientation.setMatrixU(xsDataMatrixU)
        xsDataIndexingSolutionSelected.setOrientation(xsDataOrientation)

        xsDataStatisticsIndexing = XSDataStatisticsIndexing()

        xsDataStatisticsIndexing.setBeamPositionShiftX(
            XSDataLength(xsDataMOSFLMBeamPositionShift.getX().getValue()))
        xsDataStatisticsIndexing.setBeamPositionShiftY(
            XSDataLength(xsDataMOSFLMBeamPositionShift.getY().getValue()))
        xsDataStatisticsIndexing.setSpotDeviationAngular(
            XSDataAngle(dDeviationAngular))
        xsDataStatisticsIndexing.setSpotDeviationPositional(
            XSDataLength(dDeviationPositional))
        xsDataStatisticsIndexing.setSpotsUsed(XSDataInteger(iSpotsUsed))
        xsDataStatisticsIndexing.setSpotsTotal(XSDataInteger(iSpotsTotal))
        xsDataIndexingSolutionSelected.setStatistics(xsDataStatisticsIndexing)

        xsDataExperimentalConditionRefined = None
        if (_xsDataExperimentalCondition is None):
            xsDataExperimentalConditionRefined = XSDataExperimentalCondition()
        else:
            # Copy the incoming experimental condition
            xmlExperimentalCondition = _xsDataExperimentalCondition.marshal()
            xsDataExperimentalConditionRefined = XSDataExperimentalCondition.parseString(
                xmlExperimentalCondition)

        xsDataDetector = xsDataExperimentalConditionRefined.getDetector()
        if (xsDataDetector is None):
            xsDataDetector = XSDataDetector()

        xsDataDetector.setBeamPositionX(
            XSDataLength(xsDataMOSFLMBeamPositionRefined.getX().getValue()))
        xsDataDetector.setBeamPositionY(
            XSDataLength(xsDataMOSFLMBeamPositionRefined.getY().getValue()))
        xsDataDetector.setDistance(XSDataLength(dDistanceRefined))

        xsDataExperimentalConditionRefined.setDetector(xsDataDetector)
        xsDataIndexingSolutionSelected.setExperimentalConditionRefined(
            xsDataExperimentalConditionRefined)

        xsDataIndexingResult.setSelectedSolution(
            xsDataIndexingSolutionSelected)

        xsDataIndexingResult.setIndexingLogFile(
            _xsDataMOSFLMIndexingOutput.getPathToLogFile())

        return xsDataIndexingResult
Exemplo n.º 30
0
    def testSetDataModelInput(self):
        """
        """
        edPluginBest = self.createPlugin()
        xsPluginItemGood01 = self.getPluginConfiguration(
            os.path.join(self.strDataPath, "XSConfiguration.xml"))
        edPluginBest.setConfiguration(xsPluginItemGood01)
        edPluginBest.setScriptExecutable("cat")
        edPluginBest.configure()

        from XSDataBestv10 import XSDataBestInput
        xsDataBestInput = XSDataBestInput()

        from XSDataCommon import XSDataAbsorbedDoseRate
        from XSDataCommon import XSDataFloat
        from XSDataCommon import XSDataString
        from XSDataCommon import XSDataTime
        from XSDataCommon import XSDataFile
        from XSDataCommon import XSDataSpeed
        from XSDataCommon import XSDataString
        from XSDataCommon import XSDataAngle

        xsDataBestInput.setCrystalAbsorbedDoseRate(
            XSDataAbsorbedDoseRate(0.22E+06))
        xsDataBestInput.setCrystalShape(XSDataFloat(1))
        xsDataBestInput.setCrystalSusceptibility(XSDataFloat(1.5))
        xsDataBestInput.setDetectorType(XSDataString("q210-2x"))
        xsDataBestInput.setBeamExposureTime(XSDataTime(1))
        xsDataBestInput.setBeamMaxExposureTime(XSDataTime(10000))
        xsDataBestInput.setBeamMinExposureTime(XSDataTime(0.1))
        xsDataBestInput.setGoniostatMinRotationWidth(XSDataAngle(0.1))
        xsDataBestInput.setGoniostatMaxRotationSpeed(XSDataSpeed(10))
        xsDataBestInput.setAimedResolution(XSDataFloat(2))
        xsDataBestInput.setAimedRedundancy(XSDataFloat(6.5))
        xsDataBestInput.setAimedCompleteness(XSDataFloat(0.9))
        xsDataBestInput.setAimedIOverSigma(XSDataFloat(3))
        xsDataBestInput.setComplexity(XSDataString("min"))
        fileDirectory = edPluginBest.getWorkingDirectory()

        bestFileContentDat = EDUtilsFile.readFile(
            os.path.join(self.strDataPath, "bestfile.dat"))
        xsDataBestInput.setBestFileContentDat(XSDataString(bestFileContentDat))

        bestFileContentPar = EDUtilsFile.readFile(
            os.path.join(self.strDataPath, "bestfile.par"))
        xsDataBestInput.setBestFileContentPar(XSDataString(bestFileContentPar))

        bestFileContentHKL = EDUtilsFile.readFile(
            os.path.join(self.strDataPath, "bestfile1.hkl"))
        listBestFileContentHKL = []
        listBestFileContentHKL.append(XSDataString(bestFileContentHKL))
        xsDataBestInput.setBestFileContentHKL(listBestFileContentHKL)

        xsDataBestInput.outputFile(self.strObtainedInputFile)

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

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

        EDAssert.equal(xsDataInputExpected.marshal(),
                       xsDataInputObtained.marshal())

        self.cleanUp(edPluginBest)
Exemplo n.º 31
0
    def getOutputDataFromDNATableFile(self, _strFileName):
        """
        """

        xsDataBestOutput = XSDataBestOutput()
        strDnaTablesXML = self.readProcessFile(_strFileName)
        xsDataDnaTables = dna_tables.parseString(strDnaTablesXML)
        # Loop through all the tables and fill in the relevant parts of xsDataBestOutput

        # SubWedges
        xsTablesCollectionStrategy = EDUtilsTable.getTableListFromTables(
            xsDataDnaTables, "data_collection_strategy")

        for xsTableCollectionStrategy in xsTablesCollectionStrategy:

            xsDataBestCollectionPlan = XSDataBestCollectionPlan()
            xsCollectionRunList = EDUtilsTable.getListsFromTable(
                xsTableCollectionStrategy, "collection_run")

            for xsCollectionRunItemList in xsCollectionRunList:
                xsDataCollectionRun = self.collectionRunItemListToCollectionRun(
                    xsCollectionRunItemList)
                xsDataBestCollectionPlan.addCollectionRun(xsDataCollectionRun)

            # Strategy Summary
            xsStrategySummaryItemList = EDUtilsTable.getListsFromTable(
                xsTableCollectionStrategy, "summary")
            xsDataStrategySummary = self.strategySummaryItemListToStrategySummary(
                xsStrategySummaryItemList[0])
            # Ranking Resolution
            # Not part of strategySummaryItemListToStrategySummary method since it is in the general_form part
            xsTableGeneralInform = EDUtilsTable.getTableFromTables(
                xsDataDnaTables, "general_inform")
            xsRankingResolutionItemList = EDUtilsTable.getListsFromTable(
                xsTableGeneralInform, "ranking_resolution")
            xsItemRankingResolution = EDUtilsTable.getItemFromList(
                xsRankingResolutionItemList[0], "dmin")
            fRankingResolution = float(xsItemRankingResolution.getValueOf_())
            xsDataStrategySummary.setRankingResolution(
                XSDataFloat(fRankingResolution))

            xsDataBestCollectionPlan.setStrategySummary(xsDataStrategySummary)

            # Satistics
            xsTablesStatisticalPrediction = EDUtilsTable.getTableListFromTables(
                xsDataDnaTables, "statistical_prediction")
            for xsTableStatisticalPrediction in xsTablesStatisticalPrediction:
                if (xsTableStatisticalPrediction.getIndex() ==
                        xsTableCollectionStrategy.getIndex()):
                    xsResolutionBinList = EDUtilsTable.getListsFromTable(
                        xsTableStatisticalPrediction, "resolution_bin")
                    xsDataStatisticalPrediction = XSDataBestStatisticalPrediction(
                    )
                    for xsResolutionBinItemList in xsResolutionBinList:
                        xsDataResolutionBin = self.resolutionBinItemListToResolutionBin(
                            xsResolutionBinItemList)
                        xsDataStatisticalPrediction.addResolutionBin(
                            xsDataResolutionBin)

                    xsDataBestCollectionPlan.setStatisticalPrediction(
                        xsDataStatisticalPrediction)

            xsDataBestOutput.addCollectionPlan(xsDataBestCollectionPlan)

        return xsDataBestOutput
Exemplo n.º 32
0
    def testSetDataModelInput(self):
        """
        A test for whether we can obtain the expected XML by setting a certain input for the plugin. 
        """
        edPluginISPyB = self.createPlugin()
        xsPluginItemISPyB = self.getPluginConfiguration(
            os.path.join(self.getPluginTestsDataHome(), "XSConfiguration.xml"))
        edPluginISPyB.setConfiguration(xsPluginItemISPyB)
        edPluginISPyB.configure()

        xsDataInputISPyB = XSDataInputISPyB()

        xsDataISPyBImage = XSDataISPyBImage()
        xsDataISPyBImage.setFileName(XSDataString("test.img"))
        xsDataISPyBImage.setFileLocation(XSDataString("/tmp"))

        xsDataISPyBScreening = XSDataISPyBScreening()
        #        xsDataISPyBScreening.setDataCollectionId( XSDataInteger ( 1 ) )
        xsDataISPyBScreening.setProgramVersion(XSDataString("EDNA Prototype"))

        xsDataISPyBScreeningInput = XSDataISPyBScreeningInput()
        xsDataISPyBScreeningInput.setBeamX(XSDataFloat(10.4))
        xsDataISPyBScreeningInput.setBeamY(XSDataFloat(2.31))
        xsDataISPyBScreeningInput.setRmsErrorLimits(XSDataFloat(0.8))
        xsDataISPyBScreeningInput.setMinimumFractionIndexed(XSDataFloat(0.4))
        xsDataISPyBScreeningInput.setMaximumFractionRejected(XSDataFloat(0.45))
        xsDataISPyBScreeningInput.setMinimumSignalToNoise(XSDataFloat(0.56))

        xsDataISPyBScreeningOutput = XSDataISPyBScreeningOutput()
        xsDataISPyBScreeningOutput.setStatusDescription(
            XSDataString("It's just fine."))
        xsDataISPyBScreeningOutput.setMosaicity(XSDataFloat(0.25))
        xsDataISPyBScreeningOutput.setBeamShiftX(XSDataFloat(0.141))
        xsDataISPyBScreeningOutput.setBeamShiftY(XSDataFloat(0.156))

        xsDataISPyBScreeningOutputLattice = XSDataISPyBScreeningOutputLattice()
        xsDataISPyBScreeningOutputLattice.setSpaceGroup(XSDataString("P222"))

        xsDataISPyBScreeningStrategy = XSDataISPyBScreeningStrategy()
        xsDataISPyBScreeningStrategy.setPhiStart(XSDataFloat(0))
        xsDataISPyBScreeningStrategy.setPhiEnd(XSDataFloat(20))
        xsDataISPyBScreeningStrategy.setRotation(XSDataFloat(1))
        xsDataISPyBScreeningStrategy.setProgram(XSDataString("EDNA"))
        xsDataISPyBScreeningStrategy.setAnomalous(XSDataBoolean(1))

        xsDataInputISPyB.setImage(xsDataISPyBImage)
        xsDataInputISPyB.setScreening(xsDataISPyBScreening)
        xsDataInputISPyB.setScreeningInput(xsDataISPyBScreeningInput)
        xsDataInputISPyB.setScreeningOutput(xsDataISPyBScreeningOutput)
        xsDataInputISPyB.setScreeningOutputLattice(
            xsDataISPyBScreeningOutputLattice)
        xsDataInputISPyB.setScreeningStrategy(xsDataISPyBScreeningStrategy)

        xsDataInputISPyB.outputFile(self.m_edObtainedInputFile)

        strExpectedInput = self.readAndParseFile(self.m_edReferenceInputFile)
        strObtainedInput = self.readAndParseFile(self.m_edObtainedInputFile)
        xsDataScreeningExpected = XSDataInputISPyB.parseString(
            strExpectedInput)
        xsDataScreeningObtained = XSDataInputISPyB.parseString(
            strObtainedInput)
        pyStrExpectedXML = xsDataScreeningExpected.marshal()
        pyStrObtainedXML = xsDataScreeningObtained.marshal()
        EDAssert.equal(pyStrExpectedXML, pyStrObtainedXML)

        self.cleanUp(edPluginISPyB)