def buildChildren(self, child_, nodeName_):
     if child_.nodeType == Node.ELEMENT_NODE and nodeName_ == "dataCollectionId":
         obj_ = XSDataInteger()
         obj_.build(child_)
         self.setDataCollectionId(obj_)
     elif child_.nodeType == Node.ELEMENT_NODE and nodeName_ == "processDirectory":
         obj_ = XSDataFile()
         obj_.build(child_)
         self.setProcessDirectory(obj_)
     elif child_.nodeType == Node.ELEMENT_NODE and nodeName_ == "doAnomAndNonanom":
         obj_ = XSDataBoolean()
         obj_.build(child_)
         self.setDoAnomAndNonanom(obj_)
     XSDataInput.buildChildren(self, child_, nodeName_)
예제 #2
0
	def buildChildren(self, child_, nodeName_):
		if child_.nodeType == Node.ELEMENT_NODE and \
			nodeName_ == 'lower':
			obj_ = XSDataInteger()
			obj_.build(child_)
			self.setLower(obj_)
		elif child_.nodeType == Node.ELEMENT_NODE and \
			nodeName_ == 'upper':
			obj_ = XSDataInteger()
			obj_.build(child_)
			self.setUpper(obj_)
		XSData.buildChildren(self, child_, nodeName_)
예제 #3
0
    def parseLabelitScreenOutput(self, _strLabelitLogText):
        """
        This method parses the labelit.screen log and populates the relevant
        parts of the XSDataLabelitScreenOutput object which is then returned.
        """
        self.DEBUG("EDPluginLabelitIndexingv1_1.parseLabelitLogText")
        xsDataLabelitScreenOutput = None

        iIndex = 0
        listLogLines = _strLabelitLogText.split('\n')
        bFoundLabelitIndexingResults = False
        bContinue = True
        while (bContinue):
            if (listLogLines[iIndex].find("LABELIT Indexing results:") != -1):
                bFoundLabelitIndexingResults = True
                bContinue = False
            else:
                if (iIndex < (len(listLogLines) - 2)):
                    iIndex += 1
                else:
                    bContinue = False

        if (bFoundLabelitIndexingResults == False):
            strErrorMessage = "EDPluginLabelitIndexingv1_1.parseLabelitLogText : Labelit log message: %s" % _strLabelitLogText
            self.error(strErrorMessage)
            self.addErrorMessage(strErrorMessage)
            self.setFailure()
        else:
            # We found some indexing results!
            xsDataLabelitScreenOutput = XSDataLabelitScreenOutput()

            iIndex += 1
            strBeamDistanceMosaicity = listLogLines[iIndex]
            strBeamDistanceMosaicity = strBeamDistanceMosaicity.replace(
                ',', '')
            strBeamDistanceMosaicity = strBeamDistanceMosaicity.replace(
                'mm', ' ')
            strBeamDistanceMosaicity = strBeamDistanceMosaicity.replace(
                '=', ' ')
            listStringBeamDistanceMosaicity = strBeamDistanceMosaicity.split()

            fBeamX = float(listStringBeamDistanceMosaicity[3])
            fBeamY = float(listStringBeamDistanceMosaicity[5])
            xsDataLabelitScreenOutput.setBeamCentreX(XSDataLength(fBeamX))
            xsDataLabelitScreenOutput.setBeamCentreY(XSDataLength(fBeamY))
            fDistance = float(listStringBeamDistanceMosaicity[7])
            xsDataLabelitScreenOutput.setDistance(XSDataLength(fDistance))

            fMosaicity = float(listStringBeamDistanceMosaicity[11])
            xsDataLabelitScreenOutput.setMosaicity(XSDataAngle(fMosaicity))

            iIndex += 3
            bContinue = True
            bFoundSelectedSolution = False
            while (bContinue):
                xsDataLabelitScreenSolution = XSDataLabelitScreenSolution()
                strLabelitSolution = listLogLines[iIndex]
                listStringLabelitSolution = strLabelitSolution.split()

                if (listStringLabelitSolution[0] == ":)"):
                    xsDataLabelitScreenSolution.setHappy(XSDataBoolean(True))
                elif (listStringLabelitSolution[0] == ":("):
                    xsDataLabelitScreenSolution.setHappy(XSDataBoolean(False))
                elif (listStringLabelitSolution[0] == ";("):
                    xsDataLabelitScreenSolution.setHappy(XSDataBoolean(False))
                else:
                    # We have an error...
                    strErrorMessage = "Indexing with labelit.screen failed! Log file:"
                    self.ERROR(strErrorMessage)
                    self.addErrorMessage(strErrorMessage)
                    self.ERROR(_strLabelitLogText)
                    self.addErrorMessage(_strLabelitLogText)
                    self.setFailure()
                    bContinue = False

                if bContinue:

                    iSolutionNumber = int(listStringLabelitSolution[1])
                    xsDataLabelitScreenSolution.setSolutionNumber(
                        XSDataInteger(iSolutionNumber))

                    fMetricFitValue = float(listStringLabelitSolution[2])
                    xsDataLabelitScreenSolution.setMetricFitValue(
                        XSDataDouble(fMetricFitValue))

                    strMetricFitCode = listStringLabelitSolution[3]
                    xsDataLabelitScreenSolution.setMetricFitCode(
                        XSDataString(strMetricFitCode))

                    fRMSD = float(listStringLabelitSolution[4])
                    xsDataLabelitScreenSolution.setRmsd(XSDataLength(fRMSD))

                    iNumberOfSpots = int(listStringLabelitSolution[5])
                    xsDataLabelitScreenSolution.setNumberOfSpots(
                        XSDataInteger(iNumberOfSpots))

                    strCrystalSystem = listStringLabelitSolution[6]
                    strBravaisLattice = listStringLabelitSolution[7]
                    xsDataLabelitScreenSolution.setCrystalSystem(
                        XSDataString(strCrystalSystem))
                    xsDataLabelitScreenSolution.setBravaisLattice(
                        XSDataString(strBravaisLattice))

                    xsDataCell = XSDataCell()
                    xsDataCell.setLength_a(
                        XSDataLength(float(listStringLabelitSolution[8])))
                    xsDataCell.setLength_b(
                        XSDataLength(float(listStringLabelitSolution[9])))
                    xsDataCell.setLength_c(
                        XSDataLength(float(listStringLabelitSolution[10])))
                    xsDataCell.setAngle_alpha(
                        XSDataAngle(float(listStringLabelitSolution[11])))
                    xsDataCell.setAngle_beta(
                        XSDataAngle(float(listStringLabelitSolution[12])))
                    xsDataCell.setAngle_gamma(
                        XSDataAngle(float(listStringLabelitSolution[13])))
                    xsDataLabelitScreenSolution.setUnitCell(xsDataCell)

                    iVolume = int(listStringLabelitSolution[14])
                    xsDataLabelitScreenSolution.setVolume(
                        XSDataInteger(iVolume))

                    # Find the selected solution
                    if (bFoundSelectedSolution == False):
                        if (xsDataLabelitScreenSolution.getHappy().getValue()
                                == True):
                            # Check if forced space group
                            if self.__strForcedSpaceGroup == None:
                                bFoundSelectedSolution = True
                                xsDataLabelitScreenOutput.setSelectedSolutionNumber(
                                    XSDataInteger(iSolutionNumber))
                            else:
                                listBravaisLattice = self.getBravaisLatticeFromSpaceGroup(
                                    self.__strForcedSpaceGroup)
                                for strPossibleBravaisLattice in listBravaisLattice:
                                    if strBravaisLattice == strPossibleBravaisLattice:
                                        bFoundSelectedSolution = True
                                        xsDataLabelitScreenOutput.setSelectedSolutionNumber(
                                            XSDataInteger(iSolutionNumber))

                    xsDataLabelitScreenOutput.addLabelitScreenSolution(
                        xsDataLabelitScreenSolution)
                    if (iIndex < (len(listLogLines) - 2)):
                        iIndex += 1
                    else:
                        bContinue = False

        return xsDataLabelitScreenOutput
예제 #4
0
    def preProcess(self, _edObject=None):
        EDPluginControl.preProcess(self)
        self.DEBUG("EDPluginControlCharacterisationv1_3.preProcess")
        # Load the plugins
        self._edPluginControlIndexingIndicators = self.loadPlugin(self._strPluginControlIndexingIndicators, \
                                                                   "Indexing")
        self._edPluginControlIndexingLabelit = self.loadPlugin(self._strPluginControlIndexingLabelit, \
                                                                   "IndexingLabelit")
        self._edPluginExecEvaluationIndexingMOSFLM = self.loadPlugin(self._strPluginExecEvaluationIndexing, \
                                                                   "IndexingEvalualtionMOSFLM")
        self._edPluginExecEvaluationIndexingLABELIT = self.loadPlugin(self._strPluginExecEvaluationIndexing, \
                                                                   "IndexingEvalualtionLABELIT")
        self._edPluginControlGeneratePrediction = self.loadPlugin(self._strPluginControlGeneratePrediction, \
                                                                   "GeneratePrediction")
        self._edPluginControlIntegration = self.loadPlugin(self._strPluginControlIntegration, \
                                                            "Integration")
        self._edPluginControlXDSGenerateBackgroundImage = self.loadPlugin(self._strPluginControlXDSGenerateBackgroundImage, \
                                                            "ControlXDSGenerateBackgroundImage")
        self._edPluginControlStrategy = self.loadPlugin(self._strPluginControlStrategy, \
                                                         "Strategy")
        if (self._edPluginControlIndexingIndicators is not None):
            self.DEBUG("EDPluginControlCharacterisationv1_3.preProcess: " +
                       self._strPluginControlIndexingIndicators +
                       " Found... setting Data Input")
            # create Data Input for indexing
            xsDataInputCharacterisation = self.getDataInput()
            self._xsDataCollection = xsDataInputCharacterisation.getDataCollection(
            )
            # MXSUP-1445: Check if transmission is less than 10% and warn if it's the case
            xsDataFirstSubWedge = self._xsDataCollection.getSubWedge()[0]
            xsDataBeam = xsDataFirstSubWedge.getExperimentalCondition(
            ).getBeam()
            if xsDataBeam.getTransmission() is not None:
                fTransmission = xsDataBeam.getTransmission().getValue()
                if fTransmission < self._fMinTransmission:
                    strWarningMessageBanner = "^" * 80
                    strWarningMessage1 = "WARNING! Transmission for characterisation set to %.1f %%" % fTransmission
                    strWarningMessage2 = "Please consider re-characterising with transmission set to 100 %"
                    self.warning(strWarningMessageBanner)
                    self.warning(strWarningMessage1)
                    self.warning(strWarningMessage2)
                    self.warning(strWarningMessageBanner)
                    self.addWarningMessage(strWarningMessageBanner)
                    self.addWarningMessage(strWarningMessage1)
                    self.addWarningMessage(strWarningMessage2)
                    self.addWarningMessage(strWarningMessageBanner)
            xsDataCrystal = None
            xsDataSubWedgeList = self._xsDataCollection.getSubWedge()
            if ((xsDataSubWedgeList is None) or (xsDataSubWedgeList == [])):
                strError = "EDPluginControlCharacterisationv1_3.preProcess: No subwedges in input data."
                self.ERROR(strError)
                self.setFailure()
            else:
                xsDataExperimentalCondition = xsDataSubWedgeList[
                    0].getExperimentalCondition()

                # Fix for bug 431: if the flux is zero raise an error
                xsDataDoubleFlux = xsDataExperimentalCondition.getBeam(
                ).getFlux()
                if (xsDataDoubleFlux is not None):
                    if (xsDataDoubleFlux.getValue() < 0.1):
                        strErrorMessage = "Input flux is negative or close to zero. Execution of characterisation aborted."
                        self.ERROR(strErrorMessage)
                        self.addErrorMessage(
                            "EDPluginControlCharacterisationv1_3.preProcess ERROR: "
                            + strErrorMessage)
                        #self.addComment(strErrorMessage)
                        self.setFailure()

                xsDataDiffractionPlan = self._xsDataCollection.getDiffractionPlan(
                )
                xsDataStringForcedSpaceGroup = xsDataDiffractionPlan.getForcedSpaceGroup(
                )
                if (xsDataStringForcedSpaceGroup is not None):
                    self._xsDataCrystal = XSDataCrystal()
                    xsDataSpaceGroup = XSDataSpaceGroup()
                    xsDataSpaceGroup.setName(xsDataStringForcedSpaceGroup)
                    self._xsDataCrystal.setSpaceGroup(xsDataSpaceGroup)

                self._edPluginControlIndexingIndicators.setDataInput(
                    self._xsDataCollection, "dataCollection")
                if self._xsDataCrystal is not None:
                    self._edPluginControlIndexingIndicators.setDataInput(
                        self._xsDataCrystal, "crystal")

                # Populate characterisation object
                self._xsDataResultCharacterisation = XSDataResultCharacterisation(
                )
                self._xsDataResultCharacterisation.setDataCollection(
                    XSDataCollection.parseString(
                        self._xsDataCollection.marshal()))
            # Load the thumbnail plugins
            for subWedge in xsDataInputCharacterisation.dataCollection.subWedge:
                for image in subWedge.image:
                    edPluginJpeg = self.loadPlugin(
                        self._strPluginGenerateThumbnailName)
                    xsDataInputMXThumbnail = XSDataInputMXThumbnail()
                    xsDataInputMXThumbnail.image = XSDataFile(image.path)
                    xsDataInputMXThumbnail.height = XSDataInteger(1024)
                    xsDataInputMXThumbnail.width = XSDataInteger(1024)
                    jpegFilename = os.path.splitext(
                        os.path.basename(image.path.value))[0] + ".jpg"
                    xsDataInputMXThumbnail.outputPath = XSDataFile(
                        XSDataString(
                            os.path.join(self.getWorkingDirectory(),
                                         jpegFilename)))
                    edPluginJpeg.dataInput = xsDataInputMXThumbnail
                    edPluginThumnail = self.loadPlugin(
                        self._strPluginGenerateThumbnailName)
                    xsDataInputMXThumbnail = XSDataInputMXThumbnail()
                    xsDataInputMXThumbnail.image = XSDataFile(image.path)
                    xsDataInputMXThumbnail.height = XSDataInteger(256)
                    xsDataInputMXThumbnail.width = XSDataInteger(256)
                    thumbnailFilename = os.path.splitext(
                        os.path.basename(
                            image.path.value))[0] + ".thumbnail.jpg"
                    xsDataInputMXThumbnail.outputPath = XSDataFile(
                        XSDataString(
                            os.path.join(self.getWorkingDirectory(),
                                         thumbnailFilename)))
                    edPluginThumnail.dataInput = xsDataInputMXThumbnail
                    self._listPluginGenerateThumbnail.append(
                        (image, edPluginJpeg, edPluginThumnail))
    def process(self, _edObject=None):
        EDPluginExec.process(self)
        self.DEBUG("EDPluginExecReadImageHeaderEiger4Mv10.process")
        xsDataInputReadImageHeader = self.getDataInput()
        xsDataFile = xsDataInputReadImageHeader.getImage()
        strPath = xsDataFile.getPath().getValue()
        dictEiger4MHeader = self.readHeaderEiger4M(strPath)
        if (dictEiger4MHeader is None):
            strErrorMessage = "EDPluginExecReadImageHeaderEiger4Mv10.process : Cannot read header : %s" % strPath
            self.error(strErrorMessage)
            self.addErrorMessage(strErrorMessage)
            self.setFailure()
        else:
            xsDataExperimentalCondition = XSDataExperimentalCondition()
            xsDataDetector = XSDataDetector()

            iNoPixelsX = 4150
            iNoPixelsY = 4371
            xsDataDetector.setNumberPixelX(XSDataInteger(iNoPixelsX))
            xsDataDetector.setNumberPixelY(XSDataInteger(iNoPixelsY))
            # Pixel size
            listPixelSizeXY = dictEiger4MHeader[ "Pixel_size"   ].split(" ")
            fPixelSizeX = float(listPixelSizeXY[0]) * 1000
            xsDataDetector.setPixelSizeX(XSDataLength(fPixelSizeX))
            fPixelSizeY = float(listPixelSizeXY[3]) * 1000
            xsDataDetector.setPixelSizeY(XSDataLength(fPixelSizeY))
            # Beam position
            listBeamPosition = dictEiger4MHeader["Beam_xy"].replace("(", " ").replace(")", " ").replace(",", " ").split()
            fBeamPositionX = float(listBeamPosition[1]) * fPixelSizeX
            fBeamPositionY = float(listBeamPosition[0]) * fPixelSizeY
            xsDataDetector.setBeamPositionX(XSDataLength(fBeamPositionX))
            xsDataDetector.setBeamPositionY(XSDataLength(fBeamPositionY))
            fDistance = float(dictEiger4MHeader[ "Detector_distance" ].split(" ")[0]) * 1000
            xsDataDetector.setDistance(XSDataLength(fDistance))
#            xsDataDetector.setNumberBytesInHeader(XSDataInteger(float(dictEiger4MHeader[ "header_size"   ])))
            xsDataDetector.setSerialNumber(XSDataString(dictEiger4MHeader[ "Detector:"   ]))
#            #xsDataDetector.setBin(                 XSDataString(   dictEiger4MHeader[ "BIN" ] ) ) )
#            #xsDataDetector.setDataType(            XSDataString(   dictEiger4MHeader[ "TYPE" ] ) ) )
#            #xsDataDetector.setByteOrder(           XSDataString(   dictEiger4MHeader[ "BYTE_ORDER" ] ) ) )
#            xsDataDetector.setImageSaturation(XSDataInteger(int(dictEiger4MHeader[ "saturation_level" ])))
            xsDataDetector.setName(XSDataString("EIGER 16M"))
            xsDataDetector.setType(XSDataString("eiger16m"))
            xsDataExperimentalCondition.setDetector(xsDataDetector)

            # Beam object

            xsDataBeam = XSDataBeam()
            xsDataBeam.setWavelength(XSDataWavelength(float(dictEiger4MHeader[ "Wavelength" ].split(" ")[0])))
            xsDataBeam.setExposureTime(XSDataTime(float(dictEiger4MHeader[ "Exposure_time" ].split(" ")[0])))
            xsDataExperimentalCondition.setBeam(xsDataBeam)

            # Goniostat object
            xsDataGoniostat = XSDataGoniostat()
            fRotationAxisStart = float(dictEiger4MHeader[ "Start_angle" ].split(" ")[0])
            fOscillationWidth = float(dictEiger4MHeader[ "Angle_increment" ].split(" ")[0])
            xsDataGoniostat.setRotationAxisStart(XSDataAngle(fRotationAxisStart))
            xsDataGoniostat.setRotationAxisEnd(XSDataAngle(fRotationAxisStart + fOscillationWidth))
            xsDataGoniostat.setOscillationWidth(XSDataAngle(fOscillationWidth))
            xsDataExperimentalCondition.setGoniostat(xsDataGoniostat)
#
            # Create the image object
            xsDataImage = XSDataImage()
            xsDataImage.setPath(XSDataString(strPath))
            if "DateTime" in dictEiger4MHeader:
                strTimeStamp = dictEiger4MHeader[ "DateTime" ]
                xsDataImage.setDate(XSDataString(strTimeStamp))
            iImageNumber = EDUtilsImage.getImageNumber(strPath)
            xsDataImage.setNumber(XSDataInteger(iImageNumber))

            xsDataSubWedge = XSDataSubWedge()
            xsDataSubWedge.setExperimentalCondition(xsDataExperimentalCondition)
            xsDataSubWedge.addImage(xsDataImage)

            self.__xsDataResultReadImageHeader = XSDataResultReadImageHeader()
            self.__xsDataResultReadImageHeader.setSubWedge(xsDataSubWedge)
예제 #6
0
    def makeXML(self, 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  
        """
        self.header = None
        dirname, basename = os.path.split(filename)
        if not basename.startswith(self.prefix):
            return
        if self.normalizedSuffix and basename.endswith(self.normalizedSuffix):
            return
        if basename.startswith(self.flatPrefix):
            return
        if not basename.endswith(self.suffix):
            return

        if self.fScaleData:
            fScaleData = self.fScaleData
        else:
            fScaleData = self.getNbFrames(filename)
        if not fScaleData:
            fScaleData = 1.0

        if self.fScaleDark:
            fScaleDark = self.fScaleDark
        else:
            fScaleDark = self.getNbFrames(self.darks[0]["path"])
        if not fScaleDark:
            fScaleDark = 1.0

        if isinstance(self.reference, int):
            reference = self.reference
        else:
            reference = -1

        xsd = XSDataInputFullFieldXAS(
            HDF5File=XSDataFile(path=XSDataString(self.HDF5)),
            internalHDF5Path=XSDataString(self.internalHdf5),
            measureOffset=self.getXSDMeasureOffset(),
            dark=self.getXsdDark(),
            reference=XSDataInteger(reference),
            data=[
                XSDataImageExt(path=XSDataString(filename),
                               exposureTime=XSDataTime(
                                   self.getExposureTime(filename)))
            ],
            dataScaleFactor=XSDataDouble(fScaleData),
            darkScaleFactor=XSDataDouble(fScaleDark),
        )
        if self.dontAlign:
            xsd.dontAlign = XSDataBoolean(self.dontAlign)
        extendedPrefix = ""
        number = ""
        started = False
        if self.lstSubscanSize:
            subScanDigit = []
            for i in basename[len(self.prefix):]:
                if started and i == "_":
                    if len(number) > 0:
                        subScanDigit.append(number)
                        number = ""
                    continue
                if started and not i.isdigit():
                    if number:
                        subScanDigit.append(number)
                    number = ""
                    break
                if not started:
                    if i.isdigit():
                        started = True
                    else:
                        extendedPrefix += i
                if started:
                    number += i

            if not subScanDigit:
                print("ERROR: no index guessed !!!")
                return ""
            elif len(subScanDigit) == 1:
                index = int(subScanDigit[0])
            else:  # len(subScanDigit) > 1:
                index = 0
                for i in range(int(subScanDigit[0])):
                    index += self.lstSubscanSize[i]
                index += int(subScanDigit[1])
                extendedPrefix += "_".join(subScanDigit[:2])
        else:
            for i in basename[len(self.prefix):]:
                extendedPrefix += i
                if started and not i.isdigit():
                    break
                if not started and i.isdigit():
                    started = True
                if started:
                    number += i
            index = int(number)
        xsd.index = XSDataInteger(index)

        if self.normalizedSuffix:
            pr = os.path.splitext(os.path.abspath(filename))[0]
            xsd.saveNormalized = XSDataFile(
                path=XSDataString(pr + self.normalizedSuffix))
        energy = self.getEnergy(filename)
        if energy is not None:
            xsd.energy = XSDataDouble(energy)

        flatprefix = self.flatPrefix + extendedPrefix
        listFlats = []
        for oneFile in os.listdir(dirname):
            if oneFile.startswith(flatprefix) and oneFile.endswith(
                    self.suffix):
                oneCompleteFile = os.path.abspath(
                    os.path.join(dirname, oneFile))
                xsdFileFlat1 = XSDataImageExt(
                    path=XSDataString(oneCompleteFile),
                    exposureTime=XSDataTime(
                        self.getExposureTime(oneCompleteFile)))
                listFlats.append(xsdFileFlat1)
        xsd.flat = listFlats
        if len(listFlats) != 2:
            EDVerbose.WARNING("Not exactly 2 flats were found:" +
                              " ".join([a.path.value for a in listFlats]))
            EDVerbose.WARNING("Those are the flat prefix ans suffix: %s\t%s" %
                              (flatprefix, self.suffix))

        if self.fScaleFlat:
            fScaleFlat = self.fScaleFlat
        else:
            fScaleFlat = self.getNbFrames(oneCompleteFile)
        if not fScaleFlat:
            fScaleFlat = 1.0
        xsd.flatScaleFactor = XSDataDouble(fScaleFlat)
        return xsd.marshal()
예제 #7
0
    def process(self, _edObject=None):
        EDPluginControl.process(self)
        self.DEBUG("EDPluginControlSaxsAnalysisv1_1.process")
        if self.autoRg is None:
            self.edPluginAutoRg = self.loadPlugin(self.cpAutoRg)
            self.edPluginAutoRg.dataInput = XSDataInputAutoRg(inputCurve=[self.dataInput.scatterCurve])
            self.edPluginAutoRg.connectSUCCESS(self.doSuccessRg)
            self.edPluginAutoRg.connectFAILURE(self.doFailureRg)
            self.edPluginAutoRg.executeSynchronous()

        if self.autoRg is None:
            self.setFailure()

        if self.isFailure():
            return

        self.edPluginDatGnom = self.loadPlugin(self.cpDatGnom)
        self.edPluginDatGnom.dataInput = XSDataInputDatGnom(inputCurve=self.dataInput.scatterCurve,
                                             output=XSDataFile(XSDataString(self.gnomFile)),
                                             rg=self.autoRg.rg,
                                             skip=XSDataInteger(self.autoRg.firstPointUsed.value - 1))
        self.edPluginDatGnom.connectSUCCESS(self.doSuccessGnom)
        self.edPluginDatGnom.connectFAILURE(self.doFailureGnom)
        self.edPluginDatGnom.executeSynchronous()

        if self.gnom is None:
            return

        self.edPluginDatPorod = self.loadPlugin(self.cpDatPorod)
        self.edPluginDatPorod.dataInput = XSDataInputDatPorod(gnomFile=XSDataFile(XSDataString(self.gnomFile)))
        self.edPluginDatPorod.connectSUCCESS(self.doSuccessPorod)
        self.edPluginDatPorod.connectFAILURE(self.doFailurePorod)
        self.edPluginDatPorod.execute()

        if self.dataInput.graphFormat:
            ext = self.dataInput.graphFormat.value
            if not ext.startswith("."):
                ext = "." + ext
            plt = sys.modules.get("matplotlib.pyplot")
            try:
                guinierfile = os.path.join(self.getWorkingDirectory(), os.path.basename(self.scatterFile).split(".")[0] + "-Guinier" + ext)
#                 guinierplot = guinierPlot(self.scatterFile, unit="nm",
#                                        filename=guinierfile, format=ext[1:])
                guinierplot = guinierPlot(self.scatterFile, unit="nm",
                                       filename=guinierfile, format=ext[1:], first_point=self.autoRg.firstPointUsed.value,
                                       last_point=self.autoRg.lastPointUsed.value)
                guinierplot.clf()
                if plt:
                    plt.close(guinierplot)
            except Exception as error:
                self.ERROR("EDPluginControlSaxsAnalysisv1_1 in guinierplot: %s" % error)
            else:
                self.xsDataResult.guinierPlot = XSDataFile(XSDataString(guinierfile))

            try:
                kratkyfile = os.path.join(self.getWorkingDirectory(), os.path.basename(self.scatterFile).split(".")[0] + "-Kratky" + ext)
                kratkyplot = kartkyPlot(self.scatterFile, unit="nm",
                                           filename=kratkyfile, format=ext[1:])
                kratkyplot.clf()
                if plt:
                    plt.close(kratkyplot)
            except Exception as error:
                self.ERROR("EDPluginControlSaxsAnalysisv1_1 in kratkyplot: %s" % error)
            else:
                self.xsDataResult.kratkyPlot = XSDataFile(XSDataString(kratkyfile))
            if self.autoRg is not None:    
                if self.autoRg.i0.value > 0 and self.autoRg.rg.value > 0:
                    try:
                        kratkyRgfile = os.path.join(self.getWorkingDirectory(), os.path.basename(self.scatterFile).split(".")[0] + "-KratkyRg" + ext)
                        kratkyRgplot = kratkyRgPlot(self.scatterFile, self.autoRg.i0.value, self.autoRg.rg.value,
                                                   filename=kratkyRgfile, format=ext[1:])
                        kratkyRgplot.clf()
                        if plt:
                            plt.close(kratkyRgplot)
                    except Exception as error:
                        self.ERROR("EDPluginControlSaxsAnalysisv1_1 in kratkyRgplot: %s" % error)
                    else:
                        self.xsDataResult.kratkyRgPlot = XSDataFile(XSDataString(kratkyRgfile))       
            if self.autoRg is not None and self.rti is not None:            
                if self.autoRg.i0.value > 0 and self.rti.vc.value > 0:
                    try:
                        kratkyVcfile = os.path.join(self.getWorkingDirectory(), os.path.basename(self.scatterFile).split(".")[0] + "-KratkyVc" + ext)
                        kratkyVcplot = kratkyVcPlot(self.scatterFile, self.autoRg.i0.value, self.rti.vc.value,
                                                        filename=kratkyVcfile, format=ext[1:])
                        kratkyVcplot.clf()
                        if plt:
                            plt.close(kratkyVcplot)
                    except Exception as error:
                        self.ERROR("EDPluginControlSaxsAnalysisv1_1 in kratkyVcplot: %s" % error)
                    else:
                        self.xsDataResult.kratkyVcPlot = XSDataFile(XSDataString(kratkyVcfile))
            try:
                scatterplotfile = os.path.join(self.getWorkingDirectory(), os.path.basename(self.scatterFile).split(".")[0] + "-scattering" + ext)
                scatterplot = scatterPlot(self.scatterFile, unit="nm", gnomfile=self.gnomFile,
                                           filename=scatterplotfile, format=ext[1:])
                scatterplot.clf()
                if plt:
                    plt.close(scatterplot)
            except Exception as error:
                self.ERROR("EDPluginControlSaxsAnalysisv1_1 in scatterplot: %s" % error)
            else:
                self.xsDataResult.scatterPlot = XSDataFile(XSDataString(scatterplotfile))
            try:
                densityplotfile = os.path.join(self.getWorkingDirectory(), os.path.basename(self.scatterFile).split(".")[0] + "-density" + ext)
                densityplot = densityPlot(gnomfile=self.gnomFile, unit="nm",
                                           filename=densityplotfile, format=ext[1:])
                densityplot.clf()
                if plt:
                    plt.close(densityplot)
            except Exception as error:
                self.ERROR("EDPluginControlSaxsAnalysisv1_1 in scatterplot: %s" % error)
            else:
                self.xsDataResult.densityPlot = XSDataFile(XSDataString(densityplotfile))
            gc.collect()
        self.synchronizePlugins()
예제 #8
0
    def create_autoproc_input(self, event, params):
        """
        Descript. :
        """
        WAIT_XDS_TIMEOUT = 20
        WAIT_XDS_RESOLUTION = 1

        file_name_timestamp = time.strftime("%Y%m%d_%H%M%S")

        autoproc_path = params.get("xds_dir")
        autoproc_xds_filename = os.path.join(autoproc_path, "XDS.INP")
        autoproc_input_filename = os.path.join(autoproc_path,
                                                "edna-autoproc-input-%s" % \
                                                file_name_timestamp)
        autoproc_output_file_name = os.path.join(autoproc_path,
                                                 "edna-autoproc-results-%s" % \
                                                 file_name_timestamp)

        autoproc_input = XSDataAutoprocInput()
        autoproc_xds_file = XSDataFile()
        autoproc_xds_file.setPath(XSDataString(autoproc_xds_filename))
        autoproc_input.setInput_file(autoproc_xds_file)

        autoproc_output_file = XSDataFile()
        autoproc_output_file.setPath(XSDataString(autoproc_output_file_name))
        autoproc_input.setOutput_file(autoproc_output_file)

        autoproc_input.setData_collection_id(
            XSDataInteger(params.get("collection_id")))
        residues_num = float(params.get("residues", 0))
        if residues_num != 0:
            autoproc_input.setNres(XSDataDouble(residues_num))
        space_group = params.get("sample_reference").get("spacegroup", "")
        if type(space_group) != int and len(space_group) > 0:
            autoproc_input.setSpacegroup(XSDataString(space_group))
        unit_cell = params.get("sample_reference").get("cell", "")
        if len(unit_cell) > 0:
            autoproc_input.setUnit_cell(XSDataString(unit_cell))

        autoproc_input.setCc_half_cutoff(XSDataDouble(18.0))

        #Maybe we have to check if directory is there. Maybe create dir with mxcube
        xds_appeared = False
        wait_xds_start = time.time()
        logging.info('MAXIVAutoprocessing: Waiting for XDS.INP file: %s' %
                     autoproc_xds_filename)
        while not xds_appeared and time.time(
        ) - wait_xds_start < WAIT_XDS_TIMEOUT:
            if os.path.exists(autoproc_xds_filename
                              ) and os.stat(autoproc_xds_filename).st_size > 0:
                xds_appeared = True
                logging.debug('MAXIVAutoprocessing: XDS.INP file is there, size={0}'.\
                        format(os.stat(autoproc_xds_filename).st_size))
            else:
                os.system("ls %s> /dev/null" %
                          (os.path.dirname(autoproc_path)))
                gevent.sleep(WAIT_XDS_RESOLUTION)
        if not xds_appeared:
            logging.error('MAXIVAutoprocessing: XDS.INP file ({0}) failed to appear after {1} seconds'.\
                    format(autoproc_xds_filename, WAIT_XDS_TIMEOUT))
            return None, False

        autoproc_input.exportToFile(autoproc_input_filename)

        return autoproc_input_filename, True
예제 #9
0
    def generateXSDataIndexingResult(_xsDataLabelitScreenOutput, _xsDataLabelitMosflmScriptsOutput, \
                                     _xsDataExperimentalCondition=None, _strSymopFileName=None):
        EDVerbose.DEBUG("EDHandlerXSDataLabelitv1_1.generateXSDataIndexingOutput")

        iSelectedSolutionNumber = _xsDataLabelitScreenOutput.getSelectedSolutionNumber().getValue()

        xsDataIndexingResult = XSDataIndexingResult()
        xsDataIndexingSolutionSelected = None

        for xsDataLabelitSolution in _xsDataLabelitScreenOutput.getLabelitScreenSolution():
            xsDataCrystal = XSDataCrystal()
            xsDataSpaceGroup = XSDataSpaceGroup()
            edStringSpaceGroupName = EDUtilsSymmetry.getMinimumSymmetrySpaceGroupFromBravaisLattice(xsDataLabelitSolution.getBravaisLattice().getValue())
            xsDataSpaceGroup.setName(XSDataString(edStringSpaceGroupName))
            xsDataCrystal.setSpaceGroup(xsDataSpaceGroup)
            xsDataCrystal.setCell(xsDataLabelitSolution.getUnitCell())
            xsDataIndexingSolution = XSDataIndexingSolution()
            xsDataIndexingSolution.setCrystal(xsDataCrystal)
            iIndex = xsDataLabelitSolution.getSolutionNumber().getValue()
            xsDataIndexingSolution.setNumber(XSDataInteger(iIndex))
            xsDataIndexingResult.addSolution(xsDataIndexingSolution)
            if (iIndex == iSelectedSolutionNumber):
                xsDataIndexingSolutionSelected = XSDataIndexingSolutionSelected()
                xsDataIndexingSolutionSelected.setNumber(XSDataInteger(iIndex))
                edStringSelectedSpaceGroupName = edStringSpaceGroupName
                xsDataCellSelected = xsDataLabelitSolution.getUnitCell()
                fRmsdSelected = xsDataLabelitSolution.getRmsd().getValue()
                iNumberOfSpotsSelected = xsDataLabelitSolution.getNumberOfSpots().getValue()

        xsDataCrystalSelected = XSDataCrystal()
        xsDataSpaceGroupSelected = XSDataSpaceGroup()
        xsDataSpaceGroupSelected.setName(XSDataString(edStringSelectedSpaceGroupName))
        if not _strSymopFileName is None:
            xsDataSpaceGroupSelected.setITNumber(XSDataInteger(EDUtilsSymmetry.getITNumberFromSpaceGroupName(edStringSelectedSpaceGroupName, _strSymopFileName)))
        xsDataCrystalSelected.setSpaceGroup(xsDataSpaceGroupSelected)
        xsDataCrystalSelected.setCell(xsDataCellSelected)
        xsDataCrystalSelected.setMosaicity(XSDataDouble(_xsDataLabelitScreenOutput.getMosaicity().getValue()))
        xsDataIndexingSolutionSelected.setCrystal(xsDataCrystalSelected)

        xsDataOrientation = XSDataOrientation()
        xsDataOrientation.setMatrixA(_xsDataLabelitMosflmScriptsOutput.getAMatrix())
        xsDataOrientation.setMatrixU(_xsDataLabelitMosflmScriptsOutput.getUMatrix())
        xsDataIndexingSolutionSelected.setOrientation(xsDataOrientation)

        xsDataStatisticsIndexing = XSDataStatisticsIndexing()

        if (_xsDataExperimentalCondition is not None):
            fBeamPositionXOrig = _xsDataExperimentalCondition.getDetector().getBeamPositionX().getValue()
            fBeamPositionYOrig = _xsDataExperimentalCondition.getDetector().getBeamPositionY().getValue()
            fBeamPositionXNew = _xsDataLabelitScreenOutput.getBeamCentreX().getValue()
            fBeamPositionYNew = _xsDataLabelitScreenOutput.getBeamCentreY().getValue()
            xsDataStatisticsIndexing.setBeamPositionShiftX(XSDataLength(fBeamPositionXOrig - fBeamPositionXNew))
            xsDataStatisticsIndexing.setBeamPositionShiftY(XSDataLength(fBeamPositionYOrig - fBeamPositionYNew))

        #xsDataStatisticsIndexing.setSpotDeviXSDataLength( dDistanceRefinedationAngular( XSDataAngle( dDeviationAngular ) )
        xsDataStatisticsIndexing.setSpotDeviationPositional(XSDataLength(fRmsdSelected))
        xsDataStatisticsIndexing.setSpotsUsed(XSDataInteger(iNumberOfSpotsSelected))
        xsDataStatisticsIndexing.setSpotsTotal(XSDataInteger(iNumberOfSpotsSelected))
        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(_xsDataLabelitScreenOutput.getBeamCentreX())
        xsDataDetector.setBeamPositionY(_xsDataLabelitScreenOutput.getBeamCentreY())
        xsDataDetector.setDistance(_xsDataLabelitScreenOutput.getDistance())

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

        xsDataIndexingResult.setSelectedSolution(xsDataIndexingSolutionSelected)

        xsDataIndexingResult.setIndexingLogFile(_xsDataLabelitScreenOutput.getPathToLogFile())

        return xsDataIndexingResult
예제 #10
0
    def getDataCollectionOutputDataFromDNATables(self, _xsDataDnaTables):
        xsDataResultBest = XSDataResultBest()
        # SubWedges
        xsTablesCollectionStrategy = EDUtilsTable.getTableListFromTables(
            _xsDataDnaTables, "data_collection_strategy")

        iCollectionPlanNumber = 1
        for xsTableCollectionStrategy in xsTablesCollectionStrategy:

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

            iCollectionRunNumber = 1
            for xsCollectionRunItemList in xsCollectionRunList:
                xsDataCollectionRun = self.collectionRunItemListToCollectionRun(
                    xsCollectionRunItemList, iCollectionRunNumber)
                xsDataBestCollectionPlan.addCollectionRun(xsDataCollectionRun)
                iCollectionRunNumber = iCollectionRunNumber + 1

            # 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(
                XSDataDouble(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)

            xsDataBestCollectionPlan.setCollectionPlanNumber(
                XSDataInteger(iCollectionPlanNumber))
            xsDataResultBest.addCollectionPlan(xsDataBestCollectionPlan)
            iCollectionPlanNumber = iCollectionPlanNumber + 1

        # Fix the order of the collection plans - then low resolution pass should be the first one
        listCollectionPlan = xsDataResultBest.getCollectionPlan()
        if (len(listCollectionPlan) > 1):
            bIsModified = False
            for xsDataCollectionPlan in listCollectionPlan:
                xsDataStrategySummary = xsDataCollectionPlan.getStrategySummary(
                )
                strReasoning = xsDataStrategySummary.getResolutionReasoning(
                ).getValue()
                if ((strReasoning.find("Low-resolution") != -1)
                        and xsDataCollectionPlan.getCollectionPlanNumber(
                        ).getValue() != 1):
                    listCollectionPlan.remove(xsDataCollectionPlan)
                    listCollectionPlan.insert(0, xsDataCollectionPlan)
                    bIsModified = True
            if (bIsModified):
                iCollectionPlanNumber = 1
                for xsDataCollectionPlan in listCollectionPlan:
                    xsDataCollectionPlan.setCollectionPlanNumber(
                        XSDataInteger(iCollectionPlanNumber))
                    iCollectionPlanNumber = iCollectionPlanNumber + 1

        return xsDataResultBest
 def buildChildren(self, child_, nodeName_):
     if child_.nodeType == Node.ELEMENT_NODE and \
         nodeName_ == 'dataCollectionId':
         obj_ = XSDataInteger()
         obj_.build(child_)
         self.setDataCollectionId(obj_)
     elif child_.nodeType == Node.ELEMENT_NODE and \
         nodeName_ == 'processDirectory':
         obj_ = XSDataFile()
         obj_.build(child_)
         self.setProcessDirectory(obj_)
     elif child_.nodeType == Node.ELEMENT_NODE and \
         nodeName_ == 'doAnomAndNonanom':
         obj_ = XSDataBoolean()
         obj_.build(child_)
         self.setDoAnomAndNonanom(obj_)
     elif child_.nodeType == Node.ELEMENT_NODE and \
         nodeName_ == 'spaceGroup':
         obj_ = XSDataString()
         obj_.build(child_)
         self.setSpaceGroup(obj_)
     elif child_.nodeType == Node.ELEMENT_NODE and \
         nodeName_ == 'unitCell':
         obj_ = XSDataString()
         obj_.build(child_)
         self.setUnitCell(obj_)
     elif child_.nodeType == Node.ELEMENT_NODE and \
         nodeName_ == 'startFrame':
         obj_ = XSDataInteger()
         obj_.build(child_)
         self.setStartFrame(obj_)
     elif child_.nodeType == Node.ELEMENT_NODE and \
         nodeName_ == 'endFrame':
         obj_ = XSDataInteger()
         obj_.build(child_)
         self.setEndFrame(obj_)
     XSDataInput.buildChildren(self, child_, nodeName_)
예제 #12
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()
예제 #13
0
 def buildChildren(self, child_, nodeName_):
     if child_.nodeType == Node.ELEMENT_NODE and \
         nodeName_ == 'imageNumber':
         obj_ = XSDataInteger()
         obj_.build(child_)
         self.setImageNumber(obj_)
     elif child_.nodeType == Node.ELEMENT_NODE and \
         nodeName_ == 'hdf5ImageNumber':
         obj_ = XSDataInteger()
         obj_.build(child_)
         self.setHdf5ImageNumber(obj_)
     elif child_.nodeType == Node.ELEMENT_NODE and \
         nodeName_ == 'hdf5File':
         obj_ = XSDataFile()
         obj_.build(child_)
         self.setHdf5File(obj_)
     elif child_.nodeType == Node.ELEMENT_NODE and \
         nodeName_ == 'forcedOutputDirectory':
         obj_ = XSDataFile()
         obj_.build(child_)
         self.setForcedOutputDirectory(obj_)
     elif child_.nodeType == Node.ELEMENT_NODE and \
         nodeName_ == 'forcedOutputImageNumber':
         obj_ = XSDataInteger()
         obj_.build(child_)
         self.setForcedOutputImageNumber(obj_)
     elif child_.nodeType == Node.ELEMENT_NODE and \
         nodeName_ == 'startImageNumber':
         obj_ = XSDataInteger()
         obj_.build(child_)
         self.setStartImageNumber(obj_)
     elif child_.nodeType == Node.ELEMENT_NODE and \
         nodeName_ == 'endImageNumber':
         obj_ = XSDataInteger()
         obj_.build(child_)
         self.setEndImageNumber(obj_)
     XSDataInput.buildChildren(self, child_, nodeName_)
    def process(self, _edPlugin=None):
        """
        Executes the execution plugins
        """
        EDPluginControl.process(self, _edPlugin)
        self.DEBUG("EDPluginControlImageQualityIndicatorsv1_5.process")
        EDUtilsParallel.initializeNbThread()
        # Check batch size
        if self.dataInput.batchSize is None:
            batchSize = 1
        else:
            batchSize = self.dataInput.batchSize.value
        self.screen(
            "Image quality indicators batch size: {0}".format(batchSize))
        # Check if we should do distlSignalStrength:
        bDoDistlSignalStrength = True
        if self.dataInput.doDistlSignalStrength is not None:
            if not self.dataInput.doDistlSignalStrength.value:
                bDoDistlSignalStrength = False
        # Check if we should do indexing:
        bDoIndexing = False
        if self.dataInput.doIndexing is not None:
            if self.dataInput.doIndexing.value:
                bDoIndexing = True
        # Check if fast mesh (for HDF5)
        isFastMesh = False
        if self.dataInput.fastMesh:
            isFastMesh = self.dataInput.fastMesh.value
        # Loop through all the incoming reference images
        if len(self.dataInput.image) == 0:
            directory = self.dataInput.directory.path.value
            template = self.dataInput.template.value
            startNo = self.dataInput.startNo.value
            endNo = self.dataInput.endNo.value
            listXSDataImage = []
            for index in range(startNo, endNo + 1):
                imageName = template.replace("####", "{0:04d}".format(index))
                imagePath = os.path.join(directory, imageName)
                xsDataImage = XSDataImage(path=XSDataString(imagePath),
                                          number=XSDataInteger(index))
                listXSDataImage.append(xsDataImage)
        else:
            listXSDataImage = self.dataInput.image
        xsDataInputMXWaitFile = XSDataInputMXWaitFile()
        self.xsDataResultControlImageQualityIndicators = XSDataResultControlImageQualityIndicators(
        )
        listPluginDistl = []
        listPluginDozor = []
        listOfImagesInBatch = []
        listOfAllBatches = []
        indexBatch = 0
        listH5FilePath = []
        # Process data in batches
        for xsDataImage in listXSDataImage:
            listOfImagesInBatch.append(xsDataImage.copy())
            if len(listOfImagesInBatch) == batchSize:
                listOfAllBatches.append(listOfImagesInBatch)
                listOfImagesInBatch = []
        if len(listOfImagesInBatch) > 0:
            listOfAllBatches.append(listOfImagesInBatch)
            listOfImagesInBatch = []
        # Loop over batches
        for listOfImagesInBatch in listOfAllBatches:
            # First wait for images
            for image in listOfImagesInBatch:
                strPathToImage = image.path.value
                # If Eiger, just wait for the h5 file
                if strPathToImage.endswith(".h5"):
                    h5MasterFilePath, h5DataFilePath, hdf5ImageNumber = self.getH5FilePath(
                        strPathToImage,
                        batchSize=batchSize,
                        isFastMesh=isFastMesh)
                    #                print(h5FilePath)
                    #                print(hdf5ImageNumber)
                    if not h5DataFilePath in listH5FilePath:
                        self.screen(
                            "ID30a3 Eiger data, waiting for master and data files..."
                        )
                        listH5FilePath.append(h5DataFilePath)
                        self.edPluginMXWaitFile = self.loadPlugin(
                            self.strPluginMXWaitFileName)
                        xsDataInputMXWaitFile.file = XSDataFile(
                            XSDataString(h5DataFilePath))
                        xsDataInputMXWaitFile.setSize(
                            XSDataInteger(self.minImageSize))
                        xsDataInputMXWaitFile.setTimeOut(
                            XSDataTime(self.fMXWaitFileTimeOut))
                        self.screen(
                            "Waiting for file {0}".format(h5DataFilePath))
                        self.DEBUG("Wait file timeOut set to %f" %
                                   self.fMXWaitFileTimeOut)
                        self.edPluginMXWaitFile.setDataInput(
                            xsDataInputMXWaitFile)
                        self.edPluginMXWaitFile.executeSynchronous()
                        #                    hdf5FilePath = strPathToImage.replace(".cbf", ".h5")
                        time.sleep(1)
                    if not os.path.exists(h5DataFilePath):
                        strError = "Time-out while waiting for image %s" % h5DataFilePath
                        self.error(strError)
                        self.addErrorMessage(strError)
                        self.setFailure()
                else:
                    if not os.path.exists(strPathToImage):
                        # self.screen("Waiting for file {0}".format(strPathToImage))
                        self.edPluginMXWaitFile = self.loadPlugin(
                            self.strPluginMXWaitFileName)
                        xsDataInputMXWaitFile.file = XSDataFile(
                            XSDataString(strPathToImage))
                        xsDataInputMXWaitFile.setSize(
                            XSDataInteger(self.minImageSize))
                        xsDataInputMXWaitFile.setTimeOut(
                            XSDataTime(self.fMXWaitFileTimeOut))
                        self.screen("Wait file timeOut set to %.0f s" %
                                    self.fMXWaitFileTimeOut)
                        self.edPluginMXWaitFile.setDataInput(
                            xsDataInputMXWaitFile)
                        self.edPluginMXWaitFile.executeSynchronous()
                    if not os.path.exists(strPathToImage):
                        strError = "Time-out while waiting for image %s" % strPathToImage
                        self.error(strError)
                        self.addErrorMessage(strError)
                        self.setFailure()
            if not self.isFailure():
                strPathToFirstImage = listOfImagesInBatch[0].path.value
                if strPathToImage.endswith(".h5"):
                    indexLoop = 1
                    continueLoop = True
                    while continueLoop:
                        directory = os.path.dirname(strPathToFirstImage)
                        firstImage = EDUtilsImage.getImageNumber(
                            listOfImagesInBatch[0].path.value)
                        lastImage = EDUtilsImage.getImageNumber(
                            listOfImagesInBatch[-1].path.value)
                        xsDataInputH5ToCBF = XSDataInputH5ToCBF()
                        xsDataInputH5ToCBF.hdf5File = XSDataFile(
                            listOfImagesInBatch[0].path)
                        xsDataInputH5ToCBF.hdf5ImageNumber = XSDataInteger(1)
                        xsDataInputH5ToCBF.startImageNumber = XSDataInteger(
                            firstImage)
                        xsDataInputH5ToCBF.endImageNumber = XSDataInteger(
                            lastImage)
                        xsDataInputH5ToCBF.forcedOutputDirectory = XSDataFile(
                            XSDataString(directory))
                        edPluginH5ToCBF = self.loadPlugin(
                            "EDPluginH5ToCBFv1_1")
                        edPluginH5ToCBF.dataInput = xsDataInputH5ToCBF
                        edPluginH5ToCBF.execute()
                        edPluginH5ToCBF.synchronize()
                        outputCBFFileTemplate = edPluginH5ToCBF.dataOutput.outputCBFFileTemplate
                        if outputCBFFileTemplate is not None:
                            lastCbfFile = outputCBFFileTemplate.path.value.replace(
                                "######", "{0:06d}".format(
                                    EDUtilsImage.getImageNumber(
                                        listOfImagesInBatch[-1].path.value)))
                            strPathToImage = os.path.join(
                                directory, lastCbfFile)
                            #                        print(cbfFile.path.value)
                            if os.path.exists(strPathToImage):
                                # Rename all images
                                for image in listOfImagesInBatch:
                                    image.path.value = image.path.value.replace(
                                        ".h5", ".cbf")
                                    imageNumber = EDUtilsImage.getImageNumber(
                                        image.path.value)
                                    oldPath = os.path.join(
                                        directory,
                                        outputCBFFileTemplate.path.value.
                                        replace("######",
                                                "{0:06d}".format(imageNumber)))
                                    newPath = os.path.join(
                                        directory,
                                        outputCBFFileTemplate.path.value.
                                        replace("######",
                                                "{0:04d}".format(imageNumber)))
                                    os.rename(oldPath, newPath)
                                lastCbfFile = outputCBFFileTemplate.path.value.replace(
                                    "######", "{0:04d}".format(
                                        EDUtilsImage.getImageNumber(
                                            listOfImagesInBatch[-1].path.value)
                                    ))
                                strPathToImage = os.path.join(
                                    directory, lastCbfFile)
                                self.screen(
                                    "Image has been converted to CBF file: {0}"
                                    .format(strPathToImage))
                                continueLoop = False
    #                    print(continueLoop)
                        if continueLoop:
                            self.screen(
                                "Still waiting for converting to CBF file: {0}"
                                .format(strPathToImage))
                            indexLoop += 1
                            time.sleep(5)
                            if indexLoop > 10:
                                continueLoop = False

                for image in listOfImagesInBatch:
                    strPathToImage = image.path.value
                    # Check if we should run distl.signalStrength
                    xsDataImageNew = XSDataImage(XSDataString(strPathToImage))
                    xsDataImageNew.number = XSDataInteger(
                        EDUtilsImage.getImageNumber(image.path.value))
                    edPluginPluginExecImageQualityIndicator = None
                    if bDoDistlSignalStrength:
                        if self.bUseThinClient:
                            strPluginName = self.strPluginNameThinClient
                        else:
                            strPluginName = self.strPluginName
                        edPluginPluginExecImageQualityIndicator = self.loadPlugin(
                            strPluginName)
                        self.listPluginExecImageQualityIndicator.append(
                            edPluginPluginExecImageQualityIndicator)
                        xsDataInputDistlSignalStrength = XSDataInputDistlSignalStrength(
                        )
                        xsDataInputDistlSignalStrength.setReferenceImage(
                            xsDataImageNew)
                        edPluginPluginExecImageQualityIndicator.setDataInput(
                            xsDataInputDistlSignalStrength)
                        edPluginPluginExecImageQualityIndicator.execute()
                    listPluginDistl.append(
                        (xsDataImageNew.copy(),
                         edPluginPluginExecImageQualityIndicator))

                edPluginControlDozor = self.loadPlugin(
                    self.strPluginNameControlDozor, "ControlDozor_{0}".format(
                        os.path.splitext(
                            os.path.basename(strPathToFirstImage))[0]))
                xsDataInputControlDozor = XSDataInputControlDozor()
                for image in listOfImagesInBatch:
                    xsDataInputControlDozor.addImage(XSDataFile(image.path))
                xsDataInputControlDozor.batchSize = XSDataInteger(
                    len(listOfImagesInBatch))
                edPluginControlDozor.dataInput = xsDataInputControlDozor
                edPluginControlDozor.execute()
                listPluginDozor.append(
                    (edPluginControlDozor, list(listOfImagesInBatch)))

        if not self.isFailure():
            listIndexing = []
            # Synchronize all image quality indicator plugins and upload to ISPyB
            xsDataInputStoreListOfImageQualityIndicators = XSDataInputStoreListOfImageQualityIndicators(
            )

            for (xsDataImage,
                 edPluginPluginExecImageQualityIndicator) in listPluginDistl:
                xsDataImageQualityIndicators = XSDataImageQualityIndicators()
                xsDataImageQualityIndicators.image = xsDataImage.copy()
                if edPluginPluginExecImageQualityIndicator is not None:
                    edPluginPluginExecImageQualityIndicator.synchronize()
                    if edPluginPluginExecImageQualityIndicator.dataOutput is not None:
                        if edPluginPluginExecImageQualityIndicator.dataOutput.imageQualityIndicators is not None:
                            xsDataImageQualityIndicators = XSDataImageQualityIndicators.parseString(\
                                    edPluginPluginExecImageQualityIndicator.dataOutput.imageQualityIndicators.marshal())
                self.xsDataResultControlImageQualityIndicators.addImageQualityIndicators(
                    xsDataImageQualityIndicators)

            for (edPluginControlDozor, listBatch) in listPluginDozor:
                edPluginControlDozor.synchronize()
                # Check that we got at least one result
                if len(edPluginControlDozor.dataOutput.imageDozor) == 0:
                    # Run the dozor plugin again, this time synchronously
                    firstImage = os.path.basename(listBatch[0].path.value)
                    lastImage = os.path.basename(listBatch[-1].path.value)
                    self.screen(
                        "No dozor results! Re-executing Dozor for images {0} to {1}"
                        .format(firstImage, lastImage))
                    time.sleep(5)
                    edPluginControlDozor = self.loadPlugin(
                        self.strPluginNameControlDozor,
                        "ControlDozor_reexecution_{0}".format(
                            os.path.splitext(firstImage)[0]))
                    xsDataInputControlDozor = XSDataInputControlDozor()
                    for image in listBatch:
                        xsDataInputControlDozor.addImage(XSDataFile(
                            image.path))
                    xsDataInputControlDozor.batchSize = XSDataInteger(
                        batchSize)
                    edPluginControlDozor.dataInput = xsDataInputControlDozor
                    edPluginControlDozor.executeSynchronous()
                for imageDozor in edPluginControlDozor.dataOutput.imageDozor:
                    for xsDataImageQualityIndicators in self.xsDataResultControlImageQualityIndicators.imageQualityIndicators:
                        if xsDataImageQualityIndicators.image.path.value == imageDozor.image.path.value:
                            xsDataImageQualityIndicators.dozor_score = imageDozor.mainScore
                            xsDataImageQualityIndicators.dozorSpotFile = imageDozor.spotFile
                            if imageDozor.spotFile is not None:
                                if os.path.exists(
                                        imageDozor.spotFile.path.value):
                                    numpyArray = numpy.loadtxt(
                                        imageDozor.spotFile.path.value,
                                        skiprows=3)
                                    xsDataImageQualityIndicators.dozorSpotList = XSDataString(
                                        base64.b64encode(
                                            numpyArray.tostring()))
                                    xsDataImageQualityIndicators.addDozorSpotListShape(
                                        XSDataInteger(numpyArray.shape[0]))
                                    if len(numpyArray.shape) > 1:
                                        xsDataImageQualityIndicators.addDozorSpotListShape(
                                            XSDataInteger(numpyArray.shape[1]))
                            xsDataImageQualityIndicators.dozorSpotsIntAver = imageDozor.spotsIntAver
                            xsDataImageQualityIndicators.dozorSpotsResolution = imageDozor.spotsResolution
                            xsDataImageQualityIndicators.dozorVisibleResolution = imageDozor.visibleResolution
                            if self.xsDataResultControlImageQualityIndicators.inputDozor is None:
                                if edPluginControlDozor.dataOutput.inputDozor is not None:
                                    self.xsDataResultControlImageQualityIndicators.inputDozor = XSDataDozorInput(
                                    ).parseString(
                                        edPluginControlDozor.dataOutput.
                                        inputDozor.marshal())
                if self.dataInput.doUploadToIspyb is not None and self.dataInput.doUploadToIspyb.value:
                    xsDataISPyBImageQualityIndicators = \
                        XSDataISPyBImageQualityIndicators.parseString(xsDataImageQualityIndicators.marshal())
                    xsDataInputStoreListOfImageQualityIndicators.addImageQualityIndicators(
                        xsDataISPyBImageQualityIndicators)

    #        print xsDataInputStoreListOfImageQualityIndicators.marshal()
            if self.dataInput.doUploadToIspyb is not None and self.dataInput.doUploadToIspyb.value:
                self.edPluginISPyB = self.loadPlugin(self.strISPyBPluginName)
                self.edPluginISPyB.dataInput = xsDataInputStoreListOfImageQualityIndicators
                self.edPluginISPyB.execute()
            #
            if bDoIndexing:
                # Find the 5 most intensive images (TIS):
                listImage = []
                # Check that we have dozor_score from all images:
                has_dozor_score = True
                for imageQualityIndicators in self.xsDataResultControlImageQualityIndicators.imageQualityIndicators:
                    if imageQualityIndicators.dozor_score is None:
                        has_dozor_score = False
                if has_dozor_score:
                    listSorted = sorted(
                        self.xsDataResultControlImageQualityIndicators.
                        imageQualityIndicators,
                        key=lambda imageQualityIndicators:
                        imageQualityIndicators.dozor_score.value)
                else:
                    listSorted = sorted(
                        self.xsDataResultControlImageQualityIndicators.
                        imageQualityIndicators,
                        key=lambda imageQualityIndicators:
                        imageQualityIndicators.totalIntegratedSignal.value)
                for xsDataResultControlImageQualityIndicator in listSorted[
                        -5:]:
                    if xsDataResultControlImageQualityIndicator.dozor_score.value > 1:
                        xsDataInputReadImageHeader = XSDataInputReadImageHeader(
                        )
                        xsDataInputReadImageHeader.image = XSDataFile(
                            xsDataResultControlImageQualityIndicator.image.path
                        )
                        self.edPluginReadImageHeader = self.loadPlugin(
                            self.strPluginReadImageHeaderName)
                        self.edPluginReadImageHeader.dataInput = xsDataInputReadImageHeader
                        self.edPluginReadImageHeader.executeSynchronous()
                        xsDataResultReadImageHeader = self.edPluginReadImageHeader.dataOutput
                        if xsDataResultReadImageHeader is not None:
                            edPluginLabelitIndexing = self.loadPlugin(
                                self.strIndexingLabelitPluginName)
                            xsDataInputLabelitIndexing = XSDataInputLabelitIndexing(
                            )
                            xsDataInputLabelitIndexing.image.append(
                                XSDataImage(
                                    xsDataResultControlImageQualityIndicator.
                                    image.path))
                            edPluginLabelitIndexing.setDataInput(
                                xsDataInputLabelitIndexing)
                            self.listPluginLabelit.append([
                                edPluginLabelitIndexing,
                                xsDataResultControlImageQualityIndicator
                            ])
                            edPluginLabelitIndexing.execute()
                for tupleLabelit in self.listPluginLabelit:
                    edPluginLabelitIndexing = tupleLabelit[0]
                    xsDataResultControlImageQualityIndicator = tupleLabelit[1]
                    edPluginLabelitIndexing.synchronize()
                    if not edPluginLabelitIndexing.isFailure(
                    ) and edPluginLabelitIndexing.dataOutput is not None:
                        xsDataResultLabelitIndexing = edPluginLabelitIndexing.getDataOutput(
                        )
                        xsDataIndexingResult = EDHandlerXSDataPhenixv1_1.generateXSDataIndexingResult(
                            xsDataResultLabelitIndexing)
                        selectedSolution = xsDataIndexingResult.selectedSolution
                        if selectedSolution is not None:
                            xsDataResultControlImageQualityIndicator.selectedIndexingSolution = selectedSolution
예제 #15
0
    def process(self, _edObject=None):
        EDPluginControl.process(self)
        self.DEBUG("EDPluginBioSaxsSmartMergev1_2.process")

        xsdwf = XSDataInputWaitMultiFile(
            timeOut=XSDataTime(30),
            expectedSize=XSDataInteger(10000),
            expectedFile=[XSDataFile(i.path) for i in self.lstInput])
        self.__edPluginExecWaitFile.setDataInput(xsdwf)
        self.__edPluginExecWaitFile.connectFAILURE(self.doFailureExecWait)
        self.__edPluginExecWaitFile.connectSUCCESS(self.doSuccessExecWait)
        self.__edPluginExecWaitFile.executeSynchronous()
        if self.isFailure():
            return
        if len(self.lstInput) == 1:
            shutil.copyfile(self.lstInput[0].path.value,
                            self.dataInput.mergedCurve.path.value)
        else:
            self.lstMerged = []
            if (self.absoluteFidelity is not None) or (self.relativeFidelity
                                                       is not None):
                if self.absoluteFidelity is not None:
                    for idx, oneFile in enumerate(self.lstInput[1:]):
                        self.DEBUG("Calculating similarity of 0 and %s" % idx)
                        edPluginExecAbsoluteFidelity = self.loadPlugin(
                            self.__strControlledPluginDatcmp)
                        xsd = XSDataInputDatcmp(
                            inputCurve=[self.lstInput[0], oneFile])
                        edPluginExecAbsoluteFidelity.setDataInput(xsd)
                        edPluginExecAbsoluteFidelity.connectFAILURE(
                            self.doFailureExecDatcmp)
                        edPluginExecAbsoluteFidelity.connectSUCCESS(
                            self.doSuccessExecDatcmp)
                        edPluginExecAbsoluteFidelity.execute()
                if (self.relativeFidelity is not None):
                    if (self.absoluteFidelity is None):
                        self.DEBUG("Calculating similarity of 0 and 1")
                        edPluginExecAbsoluteFidelity = self.loadPlugin(
                            self.__strControlledPluginDatcmp)
                        xsd = XSDataInputDatcmp(
                            inputCurve=[self.lstInput[0], self.lstInput[1]])
                        edPluginExecAbsoluteFidelity.setDataInput(xsd)
                        edPluginExecAbsoluteFidelity.connectFAILURE(
                            self.doFailureExecDatcmp)
                        edPluginExecAbsoluteFidelity.connectSUCCESS(
                            self.doSuccessExecDatcmp)
                        edPluginExecAbsoluteFidelity.execute()
                    if (len(self.lstInput) > 2):
                        for idx, oneFile in enumerate(self.lstInput[2:]):
                            self.DEBUG("Calculating similarity of %s and %s" %
                                       (idx, idx + 1))
                            edPluginExecRelativeFidelity = self.loadPlugin(
                                self.__strControlledPluginDatcmp)
                            xsd = XSDataInputDatcmp(
                                inputCurve=[self.lstInput[idx + 1], oneFile])
                            edPluginExecRelativeFidelity.setDataInput(xsd)
                            edPluginExecRelativeFidelity.connectFAILURE(
                                self.doFailureExecDatcmp)
                            edPluginExecRelativeFidelity.connectSUCCESS(
                                self.doSuccessExecDatcmp)
                            edPluginExecRelativeFidelity.execute()
            self.synchronizePlugins()

            for idx, oneFile in enumerate(self.lstInput):
                if idx == 0:
                    self.lstMerged.append(oneFile)
                elif (self.absoluteFidelity
                      is not None) and (self.relativeFidelity is not None):
                    if (idx - 1, idx) not in self.dictSimilarities:
                        self.ERROR("dict missing %i,%i: \n" % (idx - 1, idx) +
                                   "\n".join([
                                       "%s: %s" %
                                       (key, self.dictSimilarities[key])
                                       for key in self.dictSimilarities
                                   ]))
                    if (0, idx) not in self.dictSimilarities:
                        self.ERROR("dict missing %i,%i: \n" % (0, idx) +
                                   "\n".join([
                                       "%s: %s" %
                                       (key, self.dictSimilarities[key])
                                       for key in self.dictSimilarities
                                   ]))

                    if (self.dictSimilarities[(0, idx)] >=
                            self.absoluteFidelity) and (self.dictSimilarities[
                                (idx - 1, idx)] >= self.relativeFidelity):
                        self.lstMerged.append(oneFile)
                    else:
                        break
                elif (self.absoluteFidelity is not None):
                    if (0, idx) not in self.dictSimilarities:
                        self.ERROR("dict missing %i,%i: \n" % (0, idx) +
                                   "\n".join([
                                       "%s: %s" %
                                       (key, self.dictSimilarities[key])
                                       for key in self.dictSimilarities
                                   ]))

                    if (self.dictSimilarities[(0, idx)] >=
                            self.absoluteFidelity):
                        self.lstMerged.append(oneFile)
                    else:
                        break
                elif (self.relativeFidelity is not None):
                    if (idx - 1, idx) not in self.dictSimilarities:
                        self.ERROR("dict missing %i,%i: \n" % (idx - 1, idx) +
                                   "\n".join([
                                       "%s: %s" %
                                       (key, self.dictSimilarities[key])
                                       for key in self.dictSimilarities
                                   ]))

                    if (self.dictSimilarities[(idx - 1, idx)] >=
                            self.relativeFidelity):
                        self.lstMerged.append(oneFile)
                    else:
                        break
                else:
                    self.lstMerged.append(oneFile)
            self.lstMerged.sort(cmp)
            if len(self.lstMerged) != len(self.lstInput):
                self.strRadiationDamage = "Radiation damage detected, merged %i curves" % len(
                    self.lstMerged)
                self.WARNING(self.strRadiationDamage)
                self.lstSummary.append("WARNING: " + self.strRadiationDamage)
            self.lstSummary.append("Merging files: " + " ".join(
                [os.path.basename(i.path.value) for i in self.lstMerged]))
            if len(self.lstMerged) == 1:
                self.rewriteHeader(self.lstMerged[0].path.value,
                                   self.strMergedFile)
            else:
                self.__edPluginExecDataver = self.loadPlugin(
                    self.__strControlledPluginDataver)
                xsd = XSDataInputDataver(inputCurve=self.lstMerged)
                #outputCurve=self.dataInput.mergedCurve,
                self.__edPluginExecDataver.setDataInput(xsd)
                self.__edPluginExecDataver.connectSUCCESS(
                    self.doSuccessExecDataver)
                self.__edPluginExecDataver.connectFAILURE(
                    self.doFailureExecDataver)
                self.__edPluginExecDataver.executeSynchronous()

            self.dictAve[self.tKey] = self.dataInput.mergedCurve
            if len(self.tKey) == 3 and (self.tKey[0], self.tKey[1],
                                        0.0) in self.dictAve:
                #try to subtract buffer automatically
                bufferKey = (self.tKey[0], self.tKey[1], 0.0)
                bufferPath = self.dictAve[bufferKey]
                if self.strSubFile is None:
                    self.strSubFile = self.strMergedFile.replace(
                        "_ave.dat", "_sub.dat")
                    if self.strMergedFile == self.strSubFile:
                        self.strSubFile = None
                        return
                xsdSubFile = XSDataFile(XSDataString(self.strSubFile))
                xsdSub = XSDataInputDatop(
                    inputCurve=[self.dataInput.mergedCurve, bufferPath],
                    outputCurve=xsdSubFile,
                    operation=XSDataString("SUB"))
                self.lstSub.append("Merged data from : %s" %
                                   self.dataInput.mergedCurve.path.value)
                self.lstSub.append("Subtracted buffer: %s" %
                                   bufferPath.path.value)
                self.__edPluginExecDataop = self.loadPlugin(
                    self.__strControlledPluginDatop)
                self.__edPluginExecDataop.setDataInput(xsdSub)
                self.__edPluginExecDataop.connectSUCCESS(
                    self.doSuccessExecDatop)
                self.__edPluginExecDataop.connectFAILURE(
                    self.doFailureExecDatop)
                self.__edPluginExecDataop.executeSynchronous()
                if self.isFailure():
                    return
                elif self.strSubFile is not None:
                    self.__edPluginExecAutoRg = self.loadPlugin(
                        self.__strControlledPluginAutoRG)
                    xsd = XSDataInputAutoRg(inputCurve=[xsdSubFile])
                    self.__edPluginExecAutoRg.setDataInput(xsd)
                    self.__edPluginExecAutoRg.connectSUCCESS(
                        self.doSuccessExecAutoRg)
                    self.__edPluginExecAutoRg.connectFAILURE(
                        self.doFailureExecAutoRg)
                    self.__edPluginExecAutoRg.executeSynchronous()
                    self.rewriteHeader(self.strSubFile, self.strSubFile)
            else:
                self.__edPluginExecAutoRg = self.loadPlugin(
                    self.__strControlledPluginAutoRG)
                xsd = XSDataInputAutoRg(
                    inputCurve=[self.dataInput.mergedCurve])
                self.__edPluginExecAutoRg.setDataInput(xsd)
                self.__edPluginExecAutoRg.connectSUCCESS(
                    self.doSuccessExecAutoRg)
                self.__edPluginExecAutoRg.connectFAILURE(
                    self.doFailureExecAutoRg)
                self.__edPluginExecAutoRg.executeSynchronous()
 def testIsSameExperimentalCondition(self):
     edPluginSubWedgeMergev1_1 = self.createPlugin()
     xsDataExperimentalConditionReference = self.getTestExperimentalCondition(
     )
     xsDataExperimentalConditionSameAsReference = self.getTestExperimentalCondition(
     )
     EDAssert.equal(
         edPluginSubWedgeMergev1_1.isSameExperimentalCondition(
             xsDataExperimentalConditionReference,
             xsDataExperimentalConditionSameAsReference), True)
     xsDataExperimentalConditionDifferentExposureTime = self.getTestExperimentalCondition(
     )
     xsDataExperimentalConditionDifferentExposureTime.getBeam(
     ).setExposureTime(XSDataTime(10.0))
     EDAssert.equal(
         edPluginSubWedgeMergev1_1.isSameExperimentalCondition(
             xsDataExperimentalConditionReference,
             xsDataExperimentalConditionDifferentExposureTime), False)
     xsDataExperimentalConditionDifferentWavelength = self.getTestExperimentalCondition(
     )
     xsDataExperimentalConditionDifferentWavelength.getBeam().setWavelength(
         XSDataWavelength(1.5))
     EDAssert.equal(
         edPluginSubWedgeMergev1_1.isSameExperimentalCondition(
             xsDataExperimentalConditionReference,
             xsDataExperimentalConditionDifferentWavelength), False)
     xsDataExperimentalConditionDifferentBeamPositionX = self.getTestExperimentalCondition(
     )
     xsDataExperimentalConditionDifferentBeamPositionX.getDetector(
     ).setBeamPositionX(XSDataLength(20.0))
     EDAssert.equal(
         edPluginSubWedgeMergev1_1.isSameExperimentalCondition(
             xsDataExperimentalConditionReference,
             xsDataExperimentalConditionDifferentBeamPositionX), False)
     xsDataExperimentalConditionDifferentBeamPositionY = self.getTestExperimentalCondition(
     )
     xsDataExperimentalConditionDifferentBeamPositionY.getDetector(
     ).setBeamPositionY(XSDataLength(20.0))
     EDAssert.equal(
         edPluginSubWedgeMergev1_1.isSameExperimentalCondition(
             xsDataExperimentalConditionReference,
             xsDataExperimentalConditionDifferentBeamPositionY), False)
     xsDataExperimentalConditionDifferentDistance = self.getTestExperimentalCondition(
     )
     xsDataExperimentalConditionDifferentDistance.getDetector().setDistance(
         XSDataLength(220.0))
     EDAssert.equal(
         edPluginSubWedgeMergev1_1.isSameExperimentalCondition(
             xsDataExperimentalConditionReference,
             xsDataExperimentalConditionDifferentDistance), False)
     xsDataExperimentalConditionDifferentName = self.getTestExperimentalCondition(
     )
     xsDataExperimentalConditionDifferentName.getDetector().setName(
         XSDataString(u"EDNA"))
     EDAssert.equal(
         edPluginSubWedgeMergev1_1.isSameExperimentalCondition(
             xsDataExperimentalConditionReference,
             xsDataExperimentalConditionDifferentName), False)
     xsDataExperimentalConditionDifferentNumberPixelX = self.getTestExperimentalCondition(
     )
     xsDataExperimentalConditionDifferentNumberPixelX.getDetector(
     ).setNumberPixelX(XSDataInteger(2))
     EDAssert.equal(
         edPluginSubWedgeMergev1_1.isSameExperimentalCondition(
             xsDataExperimentalConditionReference,
             xsDataExperimentalConditionDifferentNumberPixelX), False)
     xsDataExperimentalConditionDifferentNumberPixelY = self.getTestExperimentalCondition(
     )
     xsDataExperimentalConditionDifferentNumberPixelY.getDetector(
     ).setNumberPixelY(XSDataInteger(2))
     EDAssert.equal(
         edPluginSubWedgeMergev1_1.isSameExperimentalCondition(
             xsDataExperimentalConditionReference,
             xsDataExperimentalConditionDifferentNumberPixelY), False)
     xsDataExperimentalConditionDifferentSerialNumber = self.getTestExperimentalCondition(
     )
     xsDataExperimentalConditionDifferentSerialNumber.getDetector(
     ).setSerialNumber(XSDataString(u"EDNA"))
     EDAssert.equal(
         edPluginSubWedgeMergev1_1.isSameExperimentalCondition(
             xsDataExperimentalConditionReference,
             xsDataExperimentalConditionDifferentSerialNumber), False)
     xsDataExperimentalConditionDifferentTwoTheta = self.getTestExperimentalCondition(
     )
     xsDataExperimentalConditionDifferentTwoTheta.getDetector().setTwoTheta(
         XSDataAngle(90.0))
     EDAssert.equal(
         edPluginSubWedgeMergev1_1.isSameExperimentalCondition(
             xsDataExperimentalConditionReference,
             xsDataExperimentalConditionDifferentTwoTheta), False)
     xsDataExperimentalConditionDifferentOscillationWidth = self.getTestExperimentalCondition(
     )
     xsDataExperimentalConditionDifferentOscillationWidth.getGoniostat(
     ).setOscillationWidth(XSDataAngle(2.0))
     EDAssert.equal(
         edPluginSubWedgeMergev1_1.isSameExperimentalCondition(
             xsDataExperimentalConditionReference,
             xsDataExperimentalConditionDifferentOscillationWidth), False)
     xsDataExperimentalConditionDifferentRotationAxis = self.getTestExperimentalCondition(
     )
     xsDataExperimentalConditionDifferentRotationAxis.getGoniostat(
     ).setRotationAxis(XSDataString(u"EDNA"))
     EDAssert.equal(
         edPluginSubWedgeMergev1_1.isSameExperimentalCondition(
             xsDataExperimentalConditionReference,
             xsDataExperimentalConditionDifferentRotationAxis), False)
예제 #17
0
 def buildChildren(self, child_, nodeName_):
     if child_.nodeType == Node.ELEMENT_NODE and \
         nodeName_ == 'title':
         obj_ = XSDataString()
         obj_.build(child_)
         self.setTitle(obj_)
     elif child_.nodeType == Node.ELEMENT_NODE and \
         nodeName_ == 'experimentalDataQ':
         obj_ = XSDataDouble()
         obj_.build(child_)
         self.experimentalDataQ.append(obj_)
     elif child_.nodeType == Node.ELEMENT_NODE and \
         nodeName_ == 'experimentalDataQArray':
         obj_ = XSDataArray()
         obj_.build(child_)
         self.setExperimentalDataQArray(obj_)
     elif child_.nodeType == Node.ELEMENT_NODE and \
         nodeName_ == 'experimentalDataValues':
         obj_ = XSDataDouble()
         obj_.build(child_)
         self.experimentalDataValues.append(obj_)
     elif child_.nodeType == Node.ELEMENT_NODE and \
         nodeName_ == 'experimentalDataIArray':
         obj_ = XSDataArray()
         obj_.build(child_)
         self.setExperimentalDataIArray(obj_)
     elif child_.nodeType == Node.ELEMENT_NODE and \
         nodeName_ == 'experimentalDataStdDev':
         obj_ = XSDataDouble()
         obj_.build(child_)
         self.experimentalDataStdDev.append(obj_)
     elif child_.nodeType == Node.ELEMENT_NODE and \
         nodeName_ == 'experimentalDataStdArray':
         obj_ = XSDataArray()
         obj_.build(child_)
         self.setExperimentalDataStdArray(obj_)
     elif child_.nodeType == Node.ELEMENT_NODE and \
         nodeName_ == 'experimentalDataFile':
         obj_ = XSDataFile()
         obj_.build(child_)
         self.setExperimentalDataFile(obj_)
     elif child_.nodeType == Node.ELEMENT_NODE and \
         nodeName_ == 'rMaxSearchSettings':
         obj_ = XSDataSolutionScatteringSettings()
         obj_.build(child_)
         self.setRMaxSearchSettings(obj_)
     elif child_.nodeType == Node.ELEMENT_NODE and \
         nodeName_ == 'angularUnits':
         obj_ = XSDataInteger()
         obj_.build(child_)
         self.setAngularUnits(obj_)
     elif child_.nodeType == Node.ELEMENT_NODE and \
         nodeName_ == 'symmetry':
         obj_ = XSDataString()
         obj_.build(child_)
         self.setSymmetry(obj_)
     elif child_.nodeType == Node.ELEMENT_NODE and \
         nodeName_ == 'mode':
         obj_ = XSDataString()
         obj_.build(child_)
         self.setMode(obj_)
     elif child_.nodeType == Node.ELEMENT_NODE and \
         nodeName_ == 'iNbThreads':
         obj_ = XSDataInteger()
         obj_.build(child_)
         self.setINbThreads(obj_)
     elif child_.nodeType == Node.ELEMENT_NODE and \
         nodeName_ == 'onlyGnom':
         obj_ = XSDataBoolean()
         obj_.build(child_)
         self.setOnlyGnom(obj_)
     elif child_.nodeType == Node.ELEMENT_NODE and \
         nodeName_ == 'plotFit':
         obj_ = XSDataBoolean()
         obj_.build(child_)
         self.setPlotFit(obj_)
     elif child_.nodeType == Node.ELEMENT_NODE and \
         nodeName_ == 'qMin':
         obj_ = XSDataDouble()
         obj_.build(child_)
         self.setQMin(obj_)
     elif child_.nodeType == Node.ELEMENT_NODE and \
         nodeName_ == 'qMax':
         obj_ = XSDataDouble()
         obj_.build(child_)
         self.setQMax(obj_)
     XSDataInput.buildChildren(self, child_, nodeName_)
 def buildChildren(self, child_, nodeName_):
     if child_.nodeType == Node.ELEMENT_NODE and \
         nodeName_ == 'dataCollectionId':
         obj_ = XSDataInteger()
         obj_.build(child_)
         self.setDataCollectionId(obj_)
     elif child_.nodeType == Node.ELEMENT_NODE and \
         nodeName_ == 'dirN':
         obj_ = XSDataFile()
         obj_.build(child_)
         self.setDirN(obj_)
     elif child_.nodeType == Node.ELEMENT_NODE and \
         nodeName_ == 'templateN':
         obj_ = XSDataString()
         obj_.build(child_)
         self.setTemplateN(obj_)
     elif child_.nodeType == Node.ELEMENT_NODE and \
         nodeName_ == 'fromN':
         obj_ = XSDataInteger()
         obj_.build(child_)
         self.setFromN(obj_)
     elif child_.nodeType == Node.ELEMENT_NODE and \
         nodeName_ == 'toN':
         obj_ = XSDataInteger()
         obj_.build(child_)
         self.setToN(obj_)
     elif child_.nodeType == Node.ELEMENT_NODE and \
         nodeName_ == 'processDirectory':
         obj_ = XSDataFile()
         obj_.build(child_)
         self.setProcessDirectory(obj_)
     elif child_.nodeType == Node.ELEMENT_NODE and \
         nodeName_ == 'doAnomAndNonanom':
         obj_ = XSDataBoolean()
         obj_.build(child_)
         self.setDoAnomAndNonanom(obj_)
     XSDataInput.buildChildren(self, child_, nodeName_)
예제 #19
0
    def getXSDataXDSDetector(_xsDataDetector):
        EDFactoryPluginStatic.loadModule("XSDataXDSv1_0")
        from XSDataXDSv1_0 import XSDataXDSDetector
        from XSDataXDSv1_0 import XSDataXDSIntegerRange
        xsDataXDSDetector = XSDataXDSDetector()
        strDetectorType = _xsDataDetector.getType().getValue()
        if ((strDetectorType == "q4")      or \
             (strDetectorType == "q4-2x")   or \
             (strDetectorType == "q210")    or \
             (strDetectorType == "q210-2x") or \
             (strDetectorType == "q315")    or \
             (strDetectorType == "q315-2x")):
            xsDataXDSDetector.setDetector_name(XSDataString("ADSC"))
            xsDataXDSDetector.setMinimum_valid_pixel_value(XSDataInteger(1))
            xsDataXDSDetector.setOverload(XSDataInteger(65535))

            xsDataXDSIntegerRangeTrustedPixel = XSDataXDSIntegerRange()
            xsDataXDSIntegerRangeTrustedPixel.setLower(XSDataInteger(6000))
            xsDataXDSIntegerRangeTrustedPixel.setUpper(XSDataInteger(30000))
            xsDataXDSDetector.setValue_range_for_trusted_detector_pixels(
                xsDataXDSIntegerRangeTrustedPixel)
#        elif ( strDetectorType == "mar165") or \
#               strDetectorType == "mar225") ):
#            xsDataXDSDetector.setType( XSDataString( "MARCCD" ) )
        elif strDetectorType == "pilatus6m":
            xsDataXDSDetector.setDetector_name(XSDataString("PILATUS"))
            listUntrustedRectangle = \
               [[ 487, 495, 0, 2528], \
                [ 981, 989, 0, 2528], \
                [1475, 1483, 0, 2528], \
                [1969, 1977, 0, 2528], \
                [   0, 2464, 195, 213], \
                [   0, 2464, 407, 425], \
                [   0, 2464, 619, 637], \
                [   0, 2464, 831, 849], \
                [   0, 2464, 1043, 1061], \
                [   0, 2464, 1255, 1273], \
                [   0, 2464, 1467, 1485], \
                [   0, 2464, 1679, 1697], \
                [   0, 2464, 1891, 1909], \
                [   0, 2464, 2103, 2121], \
                [   0, 2464, 2315, 2333]]
            for listRectangle in listUntrustedRectangle:
                xsDataXDSRectangle = XSDataXDSRectangle()
                xsDataXDSRectangle.setX1(XSDataInteger(listRectangle[0]))
                xsDataXDSRectangle.setX2(XSDataInteger(listRectangle[1]))
                xsDataXDSRectangle.setY1(XSDataInteger(listRectangle[2]))
                xsDataXDSRectangle.setY2(XSDataInteger(listRectangle[3]))
                xsDataXDSDetector.addUntrusted_rectangle(xsDataXDSRectangle)
            xsDataXDSDetector.setMinimum_valid_pixel_value(XSDataInteger(0))
            xsDataXDSDetector.setOverload(XSDataInteger(1048500))

            xsDataXDSIntegerRangeTrustedPixel = XSDataXDSIntegerRange()
            xsDataXDSIntegerRangeTrustedPixel.setLower(XSDataInteger(7000))
            xsDataXDSIntegerRangeTrustedPixel.setUpper(XSDataInteger(30000))
            xsDataXDSDetector.setValue_range_for_trusted_detector_pixels(
                xsDataXDSIntegerRangeTrustedPixel)

            xsDataXDSDoubleRangeTrustedRegion = XSDataXDSDoubleRange()
            xsDataXDSDoubleRangeTrustedRegion.setLower(XSDataDouble(0.0))
            xsDataXDSDoubleRangeTrustedRegion.setUpper(XSDataDouble(1.41))
            xsDataXDSDetector.setTrusted_region(
                xsDataXDSDoubleRangeTrustedRegion)

            xsDataXDSDetector.setSensor_thickness(XSDataDouble(0.32))
        else:
            # This is a temporary solution for the exception problem pointed out in bug #43.
            # Instead of raising an exception with a known type we send the error message as a string.
            pyStrErrorMessage = "EDHandlerXSDataXDSv1_0.getXSDataXDSDetector: Unknown detector type : " + strDetectorType
            raise Exception, pyStrErrorMessage

        xsDataXDSDetector.setNx(_xsDataDetector.getNumberPixelX())
        xsDataXDSDetector.setNy(_xsDataDetector.getNumberPixelY())
        xsDataXDSDetector.setQx(_xsDataDetector.getPixelSizeX())
        xsDataXDSDetector.setQy(_xsDataDetector.getPixelSizeY())
        xsDataXDSDetector.setDetector_distance(_xsDataDetector.getDistance())

        fOrgx = _xsDataDetector.getBeamPositionY().getValue(
        ) / _xsDataDetector.getPixelSizeY().getValue()
        fOrgy = _xsDataDetector.getBeamPositionX().getValue(
        ) / _xsDataDetector.getPixelSizeX().getValue()
        xsDataXDSDetector.setOrgx(XSDataDouble(fOrgx))
        xsDataXDSDetector.setOrgy(XSDataDouble(fOrgy))
        xsDataVectorDoubleXAxis = XSDataVectorDouble()

        xsDataVectorDoubleXAxis.setV1(1.0)
        xsDataVectorDoubleXAxis.setV2(0.0)
        xsDataVectorDoubleXAxis.setV3(0.0)
        xsDataXDSDetector.setDirection_of_detector_x_axis(
            xsDataVectorDoubleXAxis)

        xsDataVectorDoubleYAxis = XSDataVectorDouble()
        xsDataVectorDoubleYAxis.setV1(0.0)
        xsDataVectorDoubleYAxis.setV2(1.0)
        xsDataVectorDoubleYAxis.setV3(0.0)
        xsDataXDSDetector.setDirection_of_detector_y_axis(
            xsDataVectorDoubleYAxis)

        return xsDataXDSDetector
예제 #20
0
 def finallyProcess(self, _edObject=None):
     EDPluginExec.finallyProcess(self)
     self.DEBUG(
         "EDPluginISPyBUpdateDataCollectionGroupWorkflowIdv1_4.finallyProcess"
     )
     xsDataResultISPyBUpdateDataCollectionGroupWorkflowId = XSDataResultISPyBUpdateDataCollectionGroupWorkflowId(
     )
     if self.iDataCollectionGroupId is not None:
         xsDataResultISPyBUpdateDataCollectionGroupWorkflowId.dataCollectionGroupId = XSDataInteger(
             self.iDataCollectionGroupId)
     self.setDataOutput(
         xsDataResultISPyBUpdateDataCollectionGroupWorkflowId)
예제 #21
0
    def generateXSDataInputXDS(_xsDataCollection):

        xsDataCollection = _xsDataCollection
        xsDataExperimentalCondition = _xsDataCollection.getSubWedge(
        )[0].getExperimentalCondition()
        xsDataSubWedgeList = xsDataCollection.getSubWedge()

        xsDataInputXDS = XSDataInputXDSGenerateBackgroundImage()

        xsDataBeam = xsDataExperimentalCondition.getBeam()
        xsDataDetector = xsDataExperimentalCondition.getDetector()
        xsDataGoniostat = xsDataExperimentalCondition.getGoniostat()

        dWavelength = xsDataBeam.getWavelength().getValue()
        dDistance = xsDataDetector.getDistance().getValue()
        dBeamPositionX = xsDataDetector.getBeamPositionX().getValue()
        dBeamPositionY = xsDataDetector.getBeamPositionY().getValue()

        # Start with the detector

        xsDataXDSDetector = EDHandlerXSDataXDSv1_0.getXSDataXDSDetector(
            xsDataDetector)
        xsDataInputXDS.setDetector(xsDataXDSDetector)

        # Then the beam

        xsDataXDSBeam = XSDataXDSBeam()

        xsDataVectorDoubleIncidentBeam = XSDataVectorDouble()
        xsDataVectorDoubleIncidentBeam.setV1(0.0)
        xsDataVectorDoubleIncidentBeam.setV2(0.0)
        xsDataVectorDoubleIncidentBeam.setV3(1.0)
        xsDataXDSBeam.setIncident_beam_direction(
            xsDataVectorDoubleIncidentBeam)

        xsDataVectorDoublePolarizationPlaneNormal = XSDataVectorDouble()
        xsDataVectorDoublePolarizationPlaneNormal.setV1(0.0)
        xsDataVectorDoublePolarizationPlaneNormal.setV2(1.0)
        xsDataVectorDoublePolarizationPlaneNormal.setV3(0.0)
        xsDataXDSBeam.setPolarization_plane_normal(
            xsDataVectorDoublePolarizationPlaneNormal)

        xsDataXDSBeam.setX_ray_wavelength(XSDataWavelength(dWavelength))

        xsDataInputXDS.setBeam(xsDataXDSBeam)

        # Then the goniostat

        xsDataXDSGoniostat = XSDataXDSGoniostat()

        xsDataVectorDoubleRotationAxis = XSDataVectorDouble()
        xsDataVectorDoubleRotationAxis.setV1(1.0)
        xsDataVectorDoubleRotationAxis.setV2(0.0)
        xsDataVectorDoubleRotationAxis.setV3(0.0)
        xsDataXDSGoniostat.setRotation_axis(xsDataVectorDoubleRotationAxis)

        xsDataXDSGoniostat.setOscillation_range(
            xsDataGoniostat.getOscillationWidth())

        xsDataXDSGoniostat.setStarting_angle(
            xsDataGoniostat.getRotationAxisStart())

        xsDataInputXDS.setGoniostat(xsDataXDSGoniostat)

        #        # Then the Crystal
        #
        #        xsDataXDSCrystal = XSDataXDSCrystal()
        #
        #        xsDataXDSCrystal.setFriedels_law(XSDataString("FALSE"))
        #
        ##        if ( xsDataCrystal is not None ):
        ##            xsDataSpaceGroup = xsDataCrystal.getSpaceGroup()
        ##            if ( xsDataSpaceGroup is not None ):
        ##                xsDataStringName = xsDataSpaceGroup.getName()
        ##                if ( xsDataStringName is not None ):
        ##                    xsDataInputXDS.setSymmetry( XSDataString( xsDataStringName.getValue() ) )
        #        xsDataXDSCrystal.setSpace_group_number(XSDataInteger(0))
        #
        #        xsDataXDSCrystal.setStrong_pixel(XSDataInteger(8))
        #
        #        xsDataCell = XSDataCell()
        #        xsDataCell.setLength_a(XSDataLength(0.0))
        #        xsDataCell.setLength_b(XSDataLength(0.0))
        #        xsDataCell.setLength_c(XSDataLength(0.0))
        #        xsDataCell.setAngle_alpha(XSDataAngle(0.0))
        #        xsDataCell.setAngle_beta(XSDataAngle(0.0))
        #        xsDataCell.setAngle_gamma(XSDataAngle(0.0))
        #        xsDataXDSCrystal.setUnit_cell_constants(xsDataCell)
        #
        #        xsDataInputXDS.setCrystal(xsDataXDSCrystal)

        # Finaly the images

        xsDataXDSImage = XSDataXDSImage()

        xsDataSubWedgeFirst = xsDataSubWedgeList[0]
        xsDataImageFirst = xsDataSubWedgeFirst.getImage()[0]
        pyStrPath = xsDataImageFirst.getPath().getValue()
        pyStrFileName = EDUtilsFile.getBaseName(pyStrPath)
        pyStrDirectory = EDUtilsPath.getFolderName(pyStrPath)

        pyStrPrefix = EDUtilsImage.getPrefix(pyStrFileName)
        pyStrSuffix = EDUtilsImage.getSuffix(pyStrFileName)
        pyStrXDSTemplate = "%s_xdslink_?????.%s" % (pyStrPrefix, pyStrSuffix)

        xsDataXDSImage.setName_template_of_data_frames(
            XSDataString(pyStrXDSTemplate))

        iXDSLowestImageNumberGlobal = 1
        xsDataXDSImage.setStarting_frame(
            XSDataInteger(iXDSLowestImageNumberGlobal))

        # First we have to find the smallest goniostat rotation axis start:
        fGonioStatOscillationStartMin = None
        for xsDataSubWedge in xsDataSubWedgeList:
            xsDataGoniostat = xsDataSubWedge.getExperimentalCondition(
            ).getGoniostat()
            fGonioStatOscillationStart = xsDataGoniostat.getRotationAxisStart(
            ).getValue()
            if (fGonioStatOscillationStartMin is None):
                fGonioStatOscillationStartMin = fGonioStatOscillationStart
            elif (fGonioStatOscillationStartMin > fGonioStatOscillationStart):
                fGonioStatOscillationStartMin = fGonioStatOscillationStart

        # Loop through the list of sub wedges

        for xsDataSubWedge in xsDataSubWedgeList:

            xsDataImageList = xsDataSubWedge.getImage()
            xsDataGoniostat = xsDataSubWedge.getExperimentalCondition(
            ).getGoniostat()
            fGonioStatOscillationStart = xsDataGoniostat.getRotationAxisStart(
            ).getValue()
            fGonioStatOscillationRange = xsDataGoniostat.getOscillationWidth(
            ).getValue()

            # First find the lowest and highest image numbers
            iLowestImageNumber = None
            for xsDataImage in xsDataImageList:
                iImageNumber = xsDataImage.getNumber().getValue()
                if (iLowestImageNumber is None):
                    iLowestImageNumber = iImageNumber
                elif (iImageNumber < iLowestImageNumber):
                    iLowestImageNumber = iImageNumber

            # Loop through the list of images
            iLowestXDSImageNumber = None
            iHighestXDSImageNumber = None
            for xsDataImage in xsDataImageList:
                iImageNumber = xsDataImage.getNumber().getValue()
                fImageOscillationStart = fGonioStatOscillationStart + (
                    iImageNumber -
                    iLowestImageNumber) * fGonioStatOscillationRange
                iXDSImageNumber = iXDSLowestImageNumberGlobal + int(
                    (fImageOscillationStart - fGonioStatOscillationStartMin) /
                    fGonioStatOscillationRange)
                #print iXDSImageNumber, fImageOscillationStart, fGonioStatOscillationStartMin, fGonioStatOscillationRange
                pyStrSourcePath = xsDataImage.getPath()
                pyStrTarget = "%s_xdslink_%05d.%s" % (
                    pyStrPrefix, iXDSImageNumber, pyStrSuffix)
                xsDataXDSImageLink = XSDataXDSImageLink()
                xsDataFileSource = XSDataFile()
                xsDataFileSource.setPath(pyStrSourcePath)
                xsDataXDSImageLink.setSource(xsDataFileSource)
                xsDataXDSImageLink.setTarget(XSDataString(pyStrTarget))
                xsDataInputXDS.addImage_link(xsDataXDSImageLink)
                if (iLowestXDSImageNumber is None):
                    iLowestXDSImageNumber = iXDSImageNumber
                elif (iLowestXDSImageNumber > iXDSImageNumber):
                    iLowestXDSImageNumber = iXDSImageNumber
                if (iHighestXDSImageNumber is None):
                    iHighestXDSImageNumber = iXDSImageNumber
                elif (iHighestXDSImageNumber < iXDSImageNumber):
                    iHighestXDSImageNumber = iXDSImageNumber
            xsDataXDSIntegerRange = XSDataXDSIntegerRange()
            xsDataXDSIntegerRange.setLower(
                XSDataInteger(iLowestXDSImageNumber))
            xsDataXDSIntegerRange.setUpper(
                XSDataInteger(iHighestXDSImageNumber))

            xsDataXDSImage.addBackground_range(xsDataXDSIntegerRange)
            xsDataXDSImage.addData_range(xsDataXDSIntegerRange)
            xsDataXDSImage.addSpot_range(xsDataXDSIntegerRange)

        xsDataInputXDS.setImage(xsDataXDSImage)

        return xsDataInputXDS
예제 #22
0
            "Usage: id29_create_thumbnail image_directory_path image1 [image2]"
        )
        sys.exit(1)
    EDVerbose.screen("Arguments: %r" % sys.argv)
    strPathToTempDir = tempfile.mkdtemp(prefix="id29_create_thumbnail_")
    os.chdir(strPathToTempDir)
    EDVerbose.setLogFileName(
        os.path.join(strPathToTempDir, "id29_create_thumbnail.log"))
    strImageDirectory = sys.argv[1]
    listImageName = sys.argv[2:]
    # Quick check if the two image names are the same. If they are launch the thumbnail generator only once
    if len(listImageName) == 2:
        if listImageName[0] == listImageName[1]:
            listImageName = [listImageName[0]]
    for strImageName in listImageName:
        xsDataInputPyarchThumbnailGenerator = XSDataInputPyarchThumbnailGenerator(
        )
        xsDataInputPyarchThumbnailGenerator.setWaitForFileTimeOut(
            XSDataInteger(1000))
        strImagePath = os.path.join(strImageDirectory, strImageName)
        xsDataInputPyarchThumbnailGenerator.setDiffractionImage(
            XSDataFile(XSDataString(strImagePath)))
        EDVerbose.screen(
            "XML input for EDPluginControlPyarchThumbnailGeneratorv1_0: %s" %
            xsDataInputPyarchThumbnailGenerator.marshal())
        edPluginControlPyarchThumbnailGeneratorv1_0 = EDPluginControlPyarchThumbnailGeneratorv1_0(
        )
        edPluginControlPyarchThumbnailGeneratorv1_0.setDataInput(
            xsDataInputPyarchThumbnailGenerator)
        edPluginControlPyarchThumbnailGeneratorv1_0.execute()
    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.__fDoseLimit is None):
            xsDataDiffractionPlan.setDoseLimit(XSDataDouble(self.__fDoseLimit))
        if (not self.__fAimedCompleteness is None):
            xsDataDiffractionPlan.setAimedCompleteness(
                XSDataDouble(self.__fAimedCompleteness))
        if (not self.__fAimedMultiplicity is None):
            xsDataDiffractionPlan.setAimedMultiplicity(
                XSDataDouble(self.__fAimedMultiplicity))
        if (not self.__fAimedResolution is None):
            xsDataDiffractionPlan.setAimedResolution(
                XSDataDouble(self.__fAimedResolution))
        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")
    def testSetDataModelInput(self):
        edPluginStrategy = self.createPlugin()
        strPathToTestConfigFile = os.path.join(self.getPluginTestsDataHome(),
                                               "XSConfiguration_ESRF.xml")
        edConfiguration = EDConfiguration(strPathToTestConfigFile)
        dictItem = edConfiguration.get(edPluginStrategy.getPluginName())
        edPluginStrategy.setConfig(dictItem)
        edPluginStrategy.configure()

        xsDataStrategy = XSDataInputStrategy()

        # Beam

        xsExperimentalCondition = XSDataExperimentalCondition()

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

        xsExperimentalCondition.setBeam(xsBeam)

        # Detector and Exposure Time

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

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

        xsDataStrategy.setExperimentalCondition(xsExperimentalCondition)

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

        # Crystal

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

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

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

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

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

        xsDataSolvent = XSDataSolvent()
        xsDataAtomicComposition = XSDataAtomicComposition()

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

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

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

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

        xsDataCrystal = XSDataCrystal()
        xsDataCell = XSDataCell(angle_alpha=XSDataAngle(90.0),
                                angle_beta=XSDataAngle(90.0),
                                angle_gamma=XSDataAngle(90.0),
                                length_a=XSDataLength(78.9),
                                length_b=XSDataLength(95.162),
                                length_c=XSDataLength(104.087))
        xsDataCrystal.setCell(xsDataCell)

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

        xsDataSampleCrystalMM.setSusceptibility(XSDataDouble(1.5))

        xsDataStrategy.setCrystalRefined(xsDataCrystal)

        xsDataStrategy.setSample(xsDataSampleCrystalMM)

        xsDataStrategy.exportToFile(self.strObtainedInputFile)

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

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

        EDAssert.equal(xsDataInputExpected.marshal(),
                       xsDataInputObtained.marshal())
예제 #25
0
    def process(self, _edObject=None):
        EDPluginControl.process(self)
        self.DEBUG('EDPluginControlXDSAPPv1_0.process starting')

        directory = None
        template = None
        imageNoStart = None
        imageNoEnd = None
        pathToStartImage = None
        pathToEndImage = None
        userName = os.environ["USER"]
        beamline = "unknown"
        proposal = "unknown"

        if self.dataInput.startImageNumber is not None:
            imageNoStart = self.dataInput.startImageNumber.value
        if self.dataInput.endImageNumber is not None:
            imageNoEnd = self.dataInput.endImageNumber.value
        # If we have a data collection id, use it
        if self.dataInput.dataCollectionId is not None:
            # Recover the data collection from ISPyB
            xsDataInputRetrieveDataCollection = XSDataInputRetrieveDataCollection(
            )
            identifier = str(self.dataInput.dataCollectionId.value)
            xsDataInputRetrieveDataCollection.dataCollectionId = self.dataInput.dataCollectionId
            self.edPluginRetrieveDataCollection.dataInput = xsDataInputRetrieveDataCollection
            self.edPluginRetrieveDataCollection.executeSynchronous()
            ispybDataCollection = self.edPluginRetrieveDataCollection.dataOutput.dataCollection
            directory = ispybDataCollection.imageDirectory
            template = ispybDataCollection.fileTemplate.replace("%04d", "####")
            if imageNoStart is None:
                imageNoStart = ispybDataCollection.startImageNumber
            if imageNoEnd is None:
                imageNoEnd = ispybDataCollection.startImageNumber + \
                             ispybDataCollection.numberOfImages - 1

#            # DEBUG we set the end image to 20 in order to speed up things
#            self.warning("End image set to 20 (was {0})".format(imageNoEnd))
#            imageNoEnd = 20
            pathToStartImage = os.path.join(
                directory, ispybDataCollection.fileTemplate % imageNoStart)
            pathToEndImage = os.path.join(
                directory, ispybDataCollection.fileTemplate % imageNoEnd)
        else:
            identifier = str(int(time.time()))
            directory = self.dataInput.dirN.value
            template = self.dataInput.templateN.value
            fileTemplate = template.replace("####", "%04d")
            pathToStartImage = os.path.join(directory,
                                            fileTemplate % imageNoStart)
            pathToEndImage = os.path.join(directory, fileTemplate % imageNoEnd)

        # Try to get proposal from path
        if EDUtilsPath.isESRF():
            listDirectory = directory.split(os.sep)
            try:
                if listDirectory[1] == "data":
                    if listDirectory[2] == "visitor":
                        beamline = listDirectory[4]
                        proposal = listDirectory[3]
                    else:
                        beamline = listDirectory[2]
                        proposal = listDirectory[4]
            except:
                beamline = "unknown"
                proposal = userName

        if imageNoEnd - imageNoStart < 8:
            error_message = "There are fewer than 8 images, aborting"
            self.addErrorMessage(error_message)
            self.ERROR(error_message)
            self.setFailure()
            return

        # Process directory
        if self.dataInput.processDirectory is not None:
            processDirectory = self.dataInput.processDirectory.path.value
        else:
            processDirectory = directory.replace("RAW_DATA", "PROCESSED_DATA")

        # Make results directory
        self.resultsDirectory = os.path.join(processDirectory, "results")
        if not os.path.exists(self.resultsDirectory):
            os.makedirs(self.resultsDirectory, 0o755)

        # Create path to pyarch
        if self.dataInput.reprocess is not None and self.dataInput.reprocess.value:
            self.pyarchDirectory = EDHandlerESRFPyarchv1_0.createPyarchReprocessDirectoryPath(
                beamline, "XDSAPP", self.dataInput.dataCollectionId.value)
        else:
            self.pyarchDirectory = EDHandlerESRFPyarchv1_0.createPyarchFilePath(
                self.resultsDirectory)
        self.pyarchDirectory = self.pyarchDirectory.replace(
            'PROCESSED_DATA', 'RAW_DATA')
        if self.pyarchDirectory is not None and not os.path.exists(
                self.pyarchDirectory):
            try:
                os.makedirs(self.pyarchDirectory, 0o755)
            except:
                self.pyarchDirectory = None

        # Determine pyarch prefix
        listPrefix = template.split("_")
        self.pyarchPrefix = "xa_{0}_run{1}".format(listPrefix[-3],
                                                   listPrefix[-2])

        isH5 = False
        if any(beamline in pathToStartImage
               for beamline in ["id23eh1", "id29"]):
            minSizeFirst = 6000000
            minSizeLast = 6000000
        elif any(beamline in pathToStartImage
                 for beamline in ["id23eh2", "id30a1"]):
            minSizeFirst = 2000000
            minSizeLast = 2000000
        elif any(beamline in pathToStartImage for beamline in ["id30a3"]):
            minSizeFirst = 100000
            minSizeLast = 100000
            pathToStartImage = os.path.join(
                directory,
                self.eiger_template_to_image(template, imageNoStart))
            pathToEndImage = os.path.join(
                directory, self.eiger_template_to_image(template, imageNoEnd))
            isH5 = True
        else:
            minSizeFirst = 1000000
            minSizeLast = 1000000

        fWaitFileTimeout = 3600  # s

        xsDataInputMXWaitFileFirst = XSDataInputMXWaitFile()
        xsDataInputMXWaitFileFirst.file = XSDataFile(
            XSDataString(pathToStartImage))
        xsDataInputMXWaitFileFirst.timeOut = XSDataTime(fWaitFileTimeout)
        self.edPluginWaitFileFirst.size = XSDataInteger(minSizeFirst)
        self.edPluginWaitFileFirst.dataInput = xsDataInputMXWaitFileFirst
        self.edPluginWaitFileFirst.executeSynchronous()
        if self.edPluginWaitFileFirst.dataOutput.timedOut.value:
            strWarningMessage = "Timeout after %d seconds waiting for the first image %s!" % (
                fWaitFileTimeout, pathToStartImage)
            self.addWarningMessage(strWarningMessage)
            self.WARNING(strWarningMessage)

        xsDataInputMXWaitFileLast = XSDataInputMXWaitFile()
        xsDataInputMXWaitFileLast.file = XSDataFile(
            XSDataString(pathToEndImage))
        xsDataInputMXWaitFileLast.timeOut = XSDataTime(fWaitFileTimeout)
        self.edPluginWaitFileLast.size = XSDataInteger(minSizeLast)
        self.edPluginWaitFileLast.dataInput = xsDataInputMXWaitFileLast
        self.edPluginWaitFileLast.executeSynchronous()
        if self.edPluginWaitFileLast.dataOutput.timedOut.value:
            strErrorMessage = "Timeout after %d seconds waiting for the last image %s!" % (
                fWaitFileTimeout, pathToEndImage)
            self.addErrorMessage(strErrorMessage)
            self.ERROR(strErrorMessage)
            self.setFailure()

        if self.dataInput.hdf5ToCbfDirectory is not None:
            dir = self.dataInput.hdf5ToCbfDirectory.path.value
            pathToStartImage = glob.glob(os.path.join(dir, "*000001*"))[0]

        self.timeStart = time.localtime()
        # Prepare input to execution plugin
        if self.doAnom:
            xsDataInputXDSAPPAnom = XSDataInputXDSAPP()
            xsDataInputXDSAPPAnom.startImageNumber = self.dataInput.startImageNumber
            xsDataInputXDSAPPAnom.endImageNumber = self.dataInput.endImageNumber
            xsDataInputXDSAPPAnom.anomalous = XSDataBoolean(True)
            xsDataInputXDSAPPAnom.image = XSDataFile(
                XSDataString(pathToStartImage))
            if self.xdsAppSpacegroup is not None:
                xsDataInputXDSAPPAnom.spacegroup = XSDataString(
                    self.xdsAppSpacegroup)
            self.edPluginExecXDSAPPAnom.dataInput = xsDataInputXDSAPPAnom
            self.edPluginExecXDSAPPAnom.execute()
            if self.dataInput.dataCollectionId is not None:
                # Set ISPyB to started
                self.autoProcIntegrationIdAnom, self.autoProcProgramIdAnom = \
                  EDHandlerXSDataISPyBv1_4.setIspybToRunning(self, dataCollectionId=self.dataInput.dataCollectionId.value,
                                                             processingPrograms=self.processingPrograms, isAnom=True,
                                                             timeStart=self.timeStart)
        if self.doNoanom:
            xsDataInputXDSAPPNoanom = XSDataInputXDSAPP()
            xsDataInputXDSAPPNoanom.startImageNumber = self.dataInput.startImageNumber
            xsDataInputXDSAPPNoanom.endImageNumber = self.dataInput.endImageNumber
            xsDataInputXDSAPPNoanom.anomalous = XSDataBoolean(False)
            xsDataInputXDSAPPNoanom.image = XSDataFile(
                XSDataString(pathToStartImage))
            if self.xdsAppSpacegroup is not None:
                xsDataInputXDSAPPNoanom.spacegroup = XSDataString(
                    self.xdsAppSpacegroup)
            self.edPluginExecXDSAPPNoanom.dataInput = xsDataInputXDSAPPNoanom
            self.edPluginExecXDSAPPNoanom.execute()
            if self.dataInput.dataCollectionId is not None:
                # Set ISPyB to started
                self.autoProcIntegrationIdNoanom, self.autoProcProgramIdNoanom = \
                    EDHandlerXSDataISPyBv1_4.setIspybToRunning(self, dataCollectionId=self.dataInput.dataCollectionId.value,
                                                               processingPrograms=self.processingPrograms, isAnom=False,
                                                               timeStart=self.timeStart)
        if self.doAnom:
            self.edPluginExecXDSAPPAnom.synchronize()
            xsDataResultXDSAPPAnom = self.edPluginExecXDSAPPAnom.dataOutput
            # Run XSCALE even if XSCALE.LP is present
            strPathXscaleLpAnom = self.runXscale(
                self.edPluginExecXDSAPPAnom.getWorkingDirectory(),
                anom=True,
                merged=True)
        if self.doNoanom:
            self.edPluginExecXDSAPPNoanom.synchronize()
            xsDataResultXDSAPPNoanom = self.edPluginExecXDSAPPNoanom.dataOutput
            strPathXscaleLpNoanom = self.runXscale(
                self.edPluginExecXDSAPPNoanom.getWorkingDirectory(),
                anom=False,
                merged=True)
        self.timeEnd = time.localtime()
        # Upload to ISPyB
        if self.dataInput.dataCollectionId is not None:
            # Check if we should use XDS_ASCII_to_XML.pl
            if self.doAnom:
                if self.useXdsAsciiToXml:
                    # Only for anom runs
                    self.runXdsAsciiToXml(
                        xsDataResultXDSAPPAnom,
                        self.dataInput.dataCollectionId.value,
                        self.autoProcIntegrationIdAnom,
                        self.autoProcProgramIdAnom)
                else:
                    self.hasUploadedAnomResultsToISPyB = self.uploadToISPyB(
                        xsDataResultXDSAPPAnom, processDirectory, template,
                        strPathXscaleLpAnom, True, proposal, self.timeStart,
                        self.timeEnd, self.dataInput.dataCollectionId.value,
                        self.autoProcIntegrationIdAnom,
                        self.autoProcProgramIdAnom)
                    if self.hasUploadedAnomResultsToISPyB:
                        self.screen("Anom results uploaded to ISPyB")
                    else:
                        self.ERROR("Could not upload anom results to ISPyB!")

            if self.doNoanom:
                self.hasUploadedNoanomResultsToISPyB = self.uploadToISPyB(
                    xsDataResultXDSAPPNoanom, processDirectory, template,
                    strPathXscaleLpNoanom, False, proposal, self.timeStart,
                    self.timeEnd, self.dataInput.dataCollectionId.value,
                    self.autoProcIntegrationIdNoanom,
                    self.autoProcProgramIdNoanom)
                if self.hasUploadedNoanomResultsToISPyB:
                    self.screen("Noanom results uploaded to ISPyB")
                else:
                    self.ERROR("Could not upload noanom results to ISPyB!")
예제 #26
0
    def process(self, _edObject=None):
        EDPluginControl.process(self)
        self.DEBUG("EDPluginControlSaxsModelingv1_1.process")
        xsDataInputDammif = XSDataInputDammif(gnomOutputFile=self.xsGnomFile,
                                              unit=XSDataString(self.unit),
                                              symmetry=XSDataString(
                                                  self.symmetry),
                                              mode=XSDataString(self.mode))
        for i in range(self.dammif_jobs):
            dammif = self.loadPlugin(self.strPluginExecDammif)
            dammif.connectSUCCESS(self.doSuccessExecDammif)
            dammif.connectFAILURE(self.doFailureExecDammif)
            xsd = xsDataInputDammif.copyViaDict()
            xsd.order = XSDataInteger(i + 1)
            dammif.dataInput = xsd
            self.addPluginToActionCluster(dammif)
            self.dammif_plugins.append(dammif)
        self.executeActionCluster()
        self.synchronizeActionCluster()
        for plugin in self.dammif_plugins:
            if plugin.isFailure():
                self.ERROR("dammif plugin %s-%08i failed" %
                           (plugin.getName(), plugin.getId()))
                self.setFailure()
            self.retrieveMessages(plugin)
        if self.isFailure():
            return

        # retrieve results from best dammif
        self.dammif = self.bestDammif()

        self.chi2plot("chi2_R.png")
        self.result.chiRfactorPlot = XSDataFile(
            XSDataString(os.path.join(self.getWorkingDirectory(),
                                      "chi2_R.png")))

        # temporary results: use best dammif
        self.result.fitFile = self.dammif.dataOutput.fitFile
        self.result.logFile = self.dammif.dataOutput.logFile
        self.result.pdbMoleculeFile = self.dammif.dataOutput.pdbMoleculeFile
        self.result.pdbSolventFile = self.dammif.dataOutput.pdbSolventFile

        # align models, compute NSD and choose the reference model
        inputfiles = [
            self.dammif_plugins[idx].dataOutput.pdbMoleculeFile.path.value
            for idx in range(self.dammif_jobs)
        ]
        align = AlignModels(inputfiles, slow=False)

        outputfiles = []
        for i in range(self.dammif_jobs):
            outputfiles.append(
                os.path.join(self.getWorkingDirectory(),
                             "model-%02i.pdb" % (i + 1)))
        align.outputfiles = outputfiles
        #align.outputfiles = ["model-%02i.pdb" % (i+1) for i in range(self.dammif_jobs)]
        align.validmodels = self.valid
        align.assign_models()
        align.makeNSDarray()
        align.alignment_reference()
        self.ref = align.reference

        pngfile = os.path.join(self.getWorkingDirectory(), "nsd.png")
        align.plotNSDarray(filename=pngfile, save=True)
        self.result.nsdPlot = XSDataFile(XSDataString(pngfile))

        #        Now that all (valid) models are aligned we can combine them using damaver
        pdbFiles = [XSDataFile(XSDataString(align.outputfiles[self.ref]))]

        for idx in range(self.dammif_jobs):
            if self.valid[idx] and idx != self.ref:
                pdbFiles.append(
                    XSDataFile(XSDataString(align.outputfiles[idx])))

        damaver = self.loadPlugin(self.strPluginExecDamaver)
        damaver.dataInput = XSDataInputDamaver(pdbInputFiles=pdbFiles,
                                               automatic=XSDataBoolean(False))
        damaver.connectSUCCESS(self.doSuccessExecDamaver)
        damaver.connectFAILURE(self.doFailureExecDamaver)
        damaver.executeSynchronous()

        if self.isFailure():
            return

        damfilt = self.loadPlugin(self.strPluginExecDamfilt)
        damfilt.dataInput = XSDataInputDamfilt(
            inputPdbFile=damaver.dataOutput.damaverPdbFile)
        damfilt.connectSUCCESS(self.doSuccessExecDamfilt)
        damfilt.connectFAILURE(self.doFailureExecDamfilt)
        damfilt.execute()
        ########################################################################
        # TODO: This is a dead end : do it in parallel
        ########################################################################

        if self.isFailure():
            return

        damstart = self.loadPlugin(self.strPluginExecDamstart)
        damstart.dataInput = XSDataInputDamstart(
            inputPdbFile=damaver.dataOutput.damaverPdbFile)
        damstart.connectSUCCESS(self.doSuccessExecDamstart)
        damstart.connectFAILURE(self.doFailureExecDamstart)
        damstart.executeSynchronous()

        if self.isFailure():
            return
        ########################################################################
        # Finally call dammin
        ########################################################################
        if self.config.get("do_dammin") in ["False", "0", False, 0]:
            pass
            #return
        dammin = self.loadPlugin(self.strPluginExecDammin)
        dammin.dataInput = XSDataInputDammin(
            pdbInputFile=damstart.dataOutput.outputPdbFile,
            gnomOutputFile=self.xsGnomFile,
            symmetry=XSDataString(self.symmetry),
            mode=XSDataString(self.mode))
        dammin.connectSUCCESS(self.doSuccessExecDammin)
        dammin.connectFAILURE(self.doFailureExecDammin)
        dammin.executeSynchronous()
예제 #27
0
 def buildChildren(self, child_, nodeName_):
     if child_.nodeType == Node.ELEMENT_NODE and \
         nodeName_ == 'imageNumber':
         obj_ = XSDataInteger()
         obj_.build(child_)
         self.setImageNumber(obj_)
     elif child_.nodeType == Node.ELEMENT_NODE and \
         nodeName_ == 'hdf5ImageNumber':
         obj_ = XSDataInteger()
         obj_.build(child_)
         self.setHdf5ImageNumber(obj_)
     elif child_.nodeType == Node.ELEMENT_NODE and \
         nodeName_ == 'hdf5File':
         obj_ = XSDataFile()
         obj_.build(child_)
         self.setHdf5File(obj_)
     elif child_.nodeType == Node.ELEMENT_NODE and \
         nodeName_ == 'forcedOutputDirectory':
         obj_ = XSDataFile()
         obj_.build(child_)
         self.setForcedOutputDirectory(obj_)
     elif child_.nodeType == Node.ELEMENT_NODE and \
         nodeName_ == 'forcedOutputImageNumber':
         obj_ = XSDataInteger()
         obj_.build(child_)
         self.setForcedOutputImageNumber(obj_)
     elif child_.nodeType == Node.ELEMENT_NODE and \
         nodeName_ == 'startImageNumber':
         obj_ = XSDataInteger()
         obj_.build(child_)
         self.setStartImageNumber(obj_)
     elif child_.nodeType == Node.ELEMENT_NODE and \
         nodeName_ == 'endImageNumber':
         obj_ = XSDataInteger()
         obj_.build(child_)
         self.setEndImageNumber(obj_)
     XSDataInput.buildChildren(self, child_, nodeName_)
    def process(self, _edObject=None):
        EDPluginControl.process(self)
        self.DEBUG("EDPluginBioSaxsSmartMergev1_5.process")

        xsdwf = XSDataInputWaitMultiFile(timeOut=XSDataTime(30),
                                        expectedSize=XSDataInteger(10000),
                                        expectedFile=[XSDataFile(i.path) for i in self.lstInput])
        self.__edPluginExecWaitFile.setDataInput(xsdwf)
        self.__edPluginExecWaitFile.connectFAILURE(self.doFailureExecWait)
        self.__edPluginExecWaitFile.connectSUCCESS(self.doSuccessExecWait)
        self.__edPluginExecWaitFile.executeSynchronous()
        if self.isFailure():
            return
        if len(self.lstInput) == 1:
            inp = self.lstInput[0].path.value
            dst = self.dataInput.mergedCurve.path.value
            if not os.path.isdir(os.path.dirname(dst)):
                self.error("Output directory for %s does not exist" % dst)
                os.makedirs(os.path.dirname(dst))
            if not os.path.exists(inp):
                self.warning("Input %s does not (yet?) exist" % inp)
                time.sleep(1.0)
            shutil.copyfile(inp, dst)
            self.lstSummary.append("Got only one frame ... nothing to merge !!!")
        else:
            self.lstMerged = []
            if (self.absoluteFidelity is not None) or (self.relativeFidelity is not None):
                if self.absoluteFidelity is not None :
                    for idx, oneFile in enumerate(self.lstInput[1:]):
                        self.DEBUG("Calculating similarity of 0 and %s" % idx)
                        edPluginExecAbsoluteFidelity = self.loadPlugin(self.__strControlledPluginDatcmp)
                        xsd = XSDataInputDatcmp(inputCurve=[self.lstInput[0], oneFile])
                        edPluginExecAbsoluteFidelity.setDataInput(xsd)
                        edPluginExecAbsoluteFidelity.connectFAILURE(self.doFailureExecDatcmp)
                        edPluginExecAbsoluteFidelity.connectSUCCESS(self.doSuccessExecDatcmp)
                        edPluginExecAbsoluteFidelity.execute()
                if (self.relativeFidelity is not None):
                    if (self.absoluteFidelity is  None):
                        self.DEBUG("Calculating similarity of 0 and 1")
                        edPluginExecAbsoluteFidelity = self.loadPlugin(self.__strControlledPluginDatcmp)
                        xsd = XSDataInputDatcmp(inputCurve=[self.lstInput[0], self.lstInput[1] ])
                        edPluginExecAbsoluteFidelity.setDataInput(xsd)
                        edPluginExecAbsoluteFidelity.connectFAILURE(self.doFailureExecDatcmp)
                        edPluginExecAbsoluteFidelity.connectSUCCESS(self.doSuccessExecDatcmp)
                        edPluginExecAbsoluteFidelity.execute()
                    if (len(self.lstInput) > 2):
                        for idx, oneFile in enumerate(self.lstInput[2:]):
                            self.DEBUG("Calculating similarity of %s and %s" % (idx, idx + 1))
                            edPluginExecRelativeFidelity = self.loadPlugin(self.__strControlledPluginDatcmp)
                            xsd = XSDataInputDatcmp(inputCurve=[self.lstInput[idx + 1], oneFile])
                            edPluginExecRelativeFidelity.setDataInput(xsd)
                            edPluginExecRelativeFidelity.connectFAILURE(self.doFailureExecDatcmp)
                            edPluginExecRelativeFidelity.connectSUCCESS(self.doSuccessExecDatcmp)
                            edPluginExecRelativeFidelity.execute()
            self.synchronizePlugins()

            for idx, oneFile in enumerate(self.lstInput):
                if idx == 0:
                    self.lstMerged.append(oneFile)
                elif (self.absoluteFidelity is not None) and (self.relativeFidelity is not None):
                    if (idx - 1, idx) not in self.dictSimilarities:
                        self.ERROR("dict missing %i,%i: \n" % (idx - 1, idx) + "\n".join([ "%s: %s" % (key, self.dictSimilarities[key]) for key in self.dictSimilarities]))
                        self.resynchronize()

                    if (0, idx) not in self.dictSimilarities:
                        self.ERROR("dict missing %i,%i: \n" % (0, idx) + "\n".join([ "%s: %s" % (key, self.dictSimilarities[key]) for key in self.dictSimilarities]))
                        self.resynchronize()

                    if (self.dictSimilarities[(0, idx)] >= self.absoluteFidelity) and (self.dictSimilarities[(idx - 1, idx)] >= self.relativeFidelity):
                        self.lstMerged.append(oneFile)
                    else:
                        break
                elif (self.absoluteFidelity is not None) :
                    if (0, idx) not in self.dictSimilarities:
                        self.ERROR("dict missing %i,%i: \n" % (0, idx) + "\n".join([ "%s: %s" % (key, self.dictSimilarities[key]) for key in self.dictSimilarities]))
                        self.resynchronize()

                    if (self.dictSimilarities[(0, idx)] >= self.absoluteFidelity):
                        self.lstMerged.append(oneFile)
                    else:
                        break
                elif (self.relativeFidelity is not None) :
                    if (idx - 1, idx) not in self.dictSimilarities:
                        self.ERROR("dict missing %i,%i: \n" % (idx - 1, idx) + "\n".join([ "%s: %s" % (key, self.dictSimilarities[key]) for key in self.dictSimilarities]))
                        self.resynchronize()

                    if (self.dictSimilarities[(idx - 1, idx)] >= self.relativeFidelity):
                        self.lstMerged.append(oneFile)
                    else:
                        break
                else:
                    self.lstMerged.append(oneFile)
            self.lstMerged.sort(cmp)
            if len(self.lstMerged) != len(self.lstInput):
                self.strRadiationDamage = "Radiation damage detected, merged %i curves" % len(self.lstMerged)
                self.WARNING(self.strRadiationDamage)
                self.lstSummary.append("WARNING: " + self.strRadiationDamage)
            self.lstSummary.append("Merging files: " + " ".join([os.path.basename(i.path.value) for i in self.lstMerged]))
            if len(self.lstMerged) == 1:
                self.rewriteHeader(self.lstMerged[0].path.value, self.strMergedFile)
            else:
                self.__edPluginExecDataver = self.loadPlugin(self.__strControlledPluginDataver)
                xsd = XSDataInputDataver(inputCurve=self.lstMerged)
                # outputCurve=self.dataInput.mergedCurve,
                self.__edPluginExecDataver.setDataInput(xsd)
                self.__edPluginExecDataver.connectSUCCESS(self.doSuccessExecDataver)
                self.__edPluginExecDataver.connectFAILURE(self.doFailureExecDataver)
                self.__edPluginExecDataver.executeSynchronous()

        if (self.fConcentration == 0) and (self.strSubFile is not None):
            if (self.__class__.lastBuffer is not None) and (self.__class__.lastSample is not None):
                self.__edPluginExecAutoSub = self.loadPlugin(self.__strControlledPluginAutoSub)
                base = "_".join(os.path.basename(self.__class__.lastSample.path.value).split("_")[:-1])
                suff = os.path.basename(self.strSubFile).split("_")[-1]
                sub = os.path.join(os.path.dirname(self.strSubFile), base + "_" + suff)
                xsdSubtractedCurve = XSDataFile(XSDataString(sub))
                self.curves.append(xsdSubtractedCurve)
                self.__edPluginExecAutoSub.dataInput = XSDataInputAutoSub(sampleCurve=self.__class__.lastSample,
                                         buffers=[self.__class__.lastBuffer, self.dataInput.mergedCurve],
                                         subtractedCurve=xsdSubtractedCurve)
                self.__edPluginExecAutoSub.connectSUCCESS(self.doSuccessExecAutoSub)
                self.__edPluginExecAutoSub.connectFAILURE(self.doFailureExecAutoSub)
                self.__edPluginExecAutoSub.executeSynchronous()

                if self.isFailure():
                    return

                self.__edPluginSaxsAnalysis = self.loadPlugin(self.__strControlledPluginSaxsAnalysis)
                self.__edPluginSaxsAnalysis.dataInput = XSDataInputSaxsAnalysis(scatterCurve=xsdSubtractedCurve,
                                                                                autoRg=self.autoRg)
                self.__edPluginSaxsAnalysis.connectSUCCESS(self.doSuccessSaxsAnalysis)
                self.__edPluginSaxsAnalysis.connectFAILURE(self.doFailureSaxsAnalysis)
                self.__edPluginSaxsAnalysis.executeSynchronous()


            self.__class__.lastBuffer = self.dataInput.mergedCurve
            self.__class__.lastSample = None
        else:
            self.__class__.lastSample = self.dataInput.mergedCurve

        if self.dataInput.sample.login and self.dataInput.sample.passwd and self.dataInput.sample.measurementID:
            self.lstSummary.append("Registering to ISPyB")
            self.__edPluginSaxsISPyB = self.loadPlugin(self.__strControlledPluginSaxsISPyB)
            if len(self.lstInput) > 1:
                frameAverage = XSDataInteger(len(self.lstInput))
                frameMerged = XSDataInteger(len(self.lstMerged))
            else:
                frameMerged = frameAverage = XSDataInteger(1)
            self.curves = [XSDataFile(i.path) for i in self.lstInput]
            if self.strMergedFile is not None:
                self.curves.append(XSDataFile(XSDataString(self.strMergedFile)))
            xsdin = XSDataInputBioSaxsISPyBv1_0(sample=self.dataInput.sample,
                                                     autoRg=self.autoRg,
                                                     gnom=self.gnom,
                                                     volume=self.volume,
                                                     frameAverage=frameAverage,
                                                     frameMerged=frameMerged,
                                                     curves=self.curves,
                                                     bestBuffer=self.xsBestBuffer
#                                                     destination=self.dataInput.sample.ispybDestination #duplicate, already in sample
                                               )
            self.__edPluginSaxsISPyB.dataInput = xsdin
            self.__edPluginSaxsISPyB.connectSUCCESS(self.doSuccessISPyB)
            self.__edPluginSaxsISPyB.connectFAILURE(self.doFailureISPyB)
            self.__edPluginSaxsISPyB.execute()
    def process(self, _edPlugin=None):
        """
        Executes the execution plugins
        """
        EDPluginControl.process(self, _edPlugin)
        self.DEBUG("EDPluginControlImageQualityIndicatorsv1_2.process")
        EDUtilsParallel.initializeNbThread()
        # Check if we should do indexing:
        bDoIndexing = False
        if self.dataInput.doIndexing is not None:
            if self.dataInput.doIndexing.value:
                bDoIndexing = True
        # Loop through all the incoming reference images
        listXSDataImage = self.dataInput.image
        xsDataInputMXWaitFile = XSDataInputMXWaitFile()
        self.xsDataResultControlImageQualityIndicators = XSDataResultControlImageQualityIndicators(
        )
        listPlugin = []
        for xsDataImage in listXSDataImage:
            self.edPluginMXWaitFile = self.loadPlugin(
                self.strPluginMXWaitFileName)
            xsDataInputMXWaitFile.file = XSDataFile(xsDataImage.path)
            xsDataInputMXWaitFile.setSize(XSDataInteger(self.minImageSize))
            xsDataInputMXWaitFile.setTimeOut(
                XSDataTime(self.fMXWaitFileTimeOut))
            self.DEBUG("Wait file timeOut set to %f" % self.fMXWaitFileTimeOut)
            self.edPluginMXWaitFile.setDataInput(xsDataInputMXWaitFile)
            self.edPluginMXWaitFile.executeSynchronous()
            if not os.path.exists(xsDataImage.path.value):
                strError = "Time-out while waiting for image %s" % xsDataImage.path.value
                self.error(strError)
                self.addErrorMessage(strError)
                self.setFailure()
            else:
                if self.bUseThinClient:
                    strPluginName = self.strPluginNameThinClient
                else:
                    strPluginName = self.strPluginName
                edPluginPluginExecImageQualityIndicator = self.loadPlugin(
                    strPluginName)
                listPlugin.append(edPluginPluginExecImageQualityIndicator)
                self.listPluginExecImageQualityIndicator.append(
                    edPluginPluginExecImageQualityIndicator)
                xsDataInputDistlSignalStrength = XSDataInputDistlSignalStrength(
                )
                xsDataInputDistlSignalStrength.setReferenceImage(xsDataImage)
                edPluginPluginExecImageQualityIndicator.setDataInput(
                    xsDataInputDistlSignalStrength)
                edPluginPluginExecImageQualityIndicator.execute()
        listIndexing = []
        # Synchronize all image quality indicator plugins and upload to ISPyB
        xsDataInputStoreListOfImageQualityIndicators = XSDataInputStoreListOfImageQualityIndicators(
        )
        for edPluginPluginExecImageQualityIndicator in listPlugin:
            edPluginPluginExecImageQualityIndicator.synchronize()
            xsDataImageQualityIndicators = XSDataImageQualityIndicators.parseString( \
                                             edPluginPluginExecImageQualityIndicator.dataOutput.imageQualityIndicators.marshal())
            self.xsDataResultControlImageQualityIndicators.addImageQualityIndicators(
                xsDataImageQualityIndicators)
            xsDataISPyBImageQualityIndicators = \
                XSDataISPyBImageQualityIndicators.parseString(xsDataImageQualityIndicators.marshal())
            xsDataInputStoreListOfImageQualityIndicators.addImageQualityIndicators(
                xsDataISPyBImageQualityIndicators)
#        print xsDataInputStoreListOfImageQualityIndicators.marshal()
        if self.bDoISPyBUpload:
            self.edPluginISPyB = self.loadPlugin(self.strISPyBPluginName)
            self.edPluginISPyB.dataInput = xsDataInputStoreListOfImageQualityIndicators
            self.edPluginISPyB.execute()
        #
        if bDoIndexing:
            # Find the 5 most intensive images (TIS):
            listImage = []
            listSorted = sorted(
                self.xsDataResultControlImageQualityIndicators.
                imageQualityIndicators,
                key=lambda imageQualityIndicators: imageQualityIndicators.
                totalIntegratedSignal.value)
            for xsDataResultControlImageQualityIndicator in listSorted[-5:]:
                if xsDataResultControlImageQualityIndicator.goodBraggCandidates.value > 30:
                    xsDataInputReadImageHeader = XSDataInputReadImageHeader()
                    xsDataInputReadImageHeader.image = XSDataFile(
                        xsDataResultControlImageQualityIndicator.image.path)
                    self.edPluginReadImageHeader = self.loadPlugin(
                        self.strPluginReadImageHeaderName)
                    self.edPluginReadImageHeader.dataInput = xsDataInputReadImageHeader
                    self.edPluginReadImageHeader.executeSynchronous()
                    xsDataResultReadImageHeader = self.edPluginReadImageHeader.dataOutput
                    if xsDataResultReadImageHeader is not None:
                        xsDataSubWedge = xsDataResultReadImageHeader.subWedge
                        self.xsDataCollection = XSDataCollection()
                        self.xsDataCollection.addSubWedge(xsDataSubWedge)
                        xsDataIndexingInput = XSDataIndexingInput()
                        xsDataIndexingInput.setDataCollection(
                            self.xsDataCollection)
                        xsDataMOSFLMIndexingInput = EDHandlerXSDataMOSFLMv10.generateXSDataMOSFLMInputIndexing(
                            xsDataIndexingInput)
                        edPluginMOSFLMIndexing = self.loadPlugin(
                            self.strIndexingMOSFLMPluginName)
                        self.listPluginMOSFLM.append([
                            edPluginMOSFLMIndexing,
                            xsDataResultControlImageQualityIndicator
                        ])
                        edPluginMOSFLMIndexing.setDataInput(
                            xsDataMOSFLMIndexingInput)
                        edPluginMOSFLMIndexing.execute()
            for tupleMOSFLM in self.listPluginMOSFLM:
                edPluginMOSFLMIndexing = tupleMOSFLM[0]
                xsDataResultControlImageQualityIndicator = tupleMOSFLM[1]
                edPluginMOSFLMIndexing.synchronize()
                if not edPluginMOSFLMIndexing.isFailure():
                    xsDataMOSFLMOutput = edPluginMOSFLMIndexing.dataOutput
                    xsDataIndexingResult = EDHandlerXSDataMOSFLMv10.generateXSDataIndexingResult(
                        xsDataMOSFLMOutput)
                    selectedSolution = xsDataIndexingResult.selectedSolution
                    if selectedSolution is not None:
                        xsDataResultControlImageQualityIndicator.selectedIndexingSolution = selectedSolution
예제 #30
0
    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
예제 #31
0
    def generateXSDataISPyBScreeningOutputContainer(
            _xsDataResultCharacterisation, _strStatusMessage, _fKappa, _fPhi):
        xsDataISPyBScreeningOutput = XSDataISPyBScreeningOutput()
        xsDataISPyBScreeningOutput.program = XSDataString("EDNA MXv1")
        xsDataISPyBScreeningOutputLattice = None
        # Indexing information
        bSuccessfulIndexing = False
        xsDataIndexingResult = _xsDataResultCharacterisation.getIndexingResult(
        )
        if (xsDataIndexingResult is not None):
            xsDataIndexingSolutionSelected = xsDataIndexingResult.getSelectedSolution(
            )
            if (xsDataIndexingSolutionSelected is not None):
                xsDataISPyBScreeningOutputLattice = XSDataISPyBScreeningOutputLattice(
                )
                bSuccessfulIndexing = True
                xsDataStatisticsIndexing = xsDataIndexingSolutionSelected.getStatistics(
                )
                if (xsDataStatisticsIndexing is not None):
                    xsDataISPyBScreeningOutput.beamShiftX = xsDataStatisticsIndexing.beamPositionShiftX
                    xsDataISPyBScreeningOutput.beamShiftY = xsDataStatisticsIndexing.beamPositionShiftY
                    xsDataISPyBScreeningOutput.spotDeviationR = xsDataStatisticsIndexing.spotDeviationPositional
                    xsDataISPyBScreeningOutput.spotDeviationTheta = xsDataStatisticsIndexing.spotDeviationAngular
                    if ((xsDataStatisticsIndexing.spotsTotal is not None) and
                        (xsDataStatisticsIndexing.spotsUsed is not None)):
                        iSpotsTotal = xsDataStatisticsIndexing.spotsTotal.value
                        iSpotsUsed = xsDataStatisticsIndexing.spotsUsed.value
                        xsDataISPyBScreeningOutput.numSpotsFound = xsDataStatisticsIndexing.spotsTotal
                        xsDataISPyBScreeningOutput.numSpotsUsed = xsDataStatisticsIndexing.spotsUsed
                        xsDataISPyBScreeningOutput.numSpotsRejected = XSDataInteger(
                            iSpotsTotal - iSpotsUsed)
                xsDataCrystal = xsDataIndexingSolutionSelected.crystal
                xsDataISPyBScreeningOutput.mosaicityEstimated = XSDataBoolean(
                    False)
                if (xsDataCrystal is not None):
                    if xsDataCrystal.mosaicity is not None:
                        xsDataISPyBScreeningOutput.mosaicity = xsDataCrystal.mosaicity
                        xsDataISPyBScreeningOutput.mosaicityEstimated = XSDataBoolean(
                            True)
                    xsDataCell = xsDataCrystal.cell
                    if xsDataCell is not None:
                        xsDataISPyBScreeningOutputLattice.unitCell_a = xsDataCell.length_a
                        xsDataISPyBScreeningOutputLattice.unitCell_b = xsDataCell.length_b
                        xsDataISPyBScreeningOutputLattice.unitCell_c = xsDataCell.length_c
                        xsDataISPyBScreeningOutputLattice.unitCell_alpha = xsDataCell.angle_alpha
                        xsDataISPyBScreeningOutputLattice.unitCell_beta = xsDataCell.angle_beta
                        xsDataISPyBScreeningOutputLattice.unitCell_gamma = xsDataCell.angle_gamma
                    xsDataSpaceGroup = xsDataCrystal.spaceGroup
                    if xsDataSpaceGroup is not None:
                        xsDataISPyBScreeningOutputLattice.spaceGroup = xsDataSpaceGroup.name
        if (bSuccessfulIndexing):
            xsDataISPyBScreeningOutput.setIndexingSuccess(XSDataBoolean(True))
            if _strStatusMessage:
                xsDataISPyBScreeningOutput.setStatusDescription(
                    XSDataString(_strStatusMessage))
            else:
                xsDataISPyBScreeningOutput.setStatusDescription(
                    XSDataString("Indexing successful"))
        else:
            xsDataISPyBScreeningOutput.setIndexingSuccess(XSDataBoolean(False))
            if _strStatusMessage:
                xsDataISPyBScreeningOutput.setStatusDescription(
                    XSDataString(_strStatusMessage))
            else:
                xsDataISPyBScreeningOutput.setStatusDescription(
                    XSDataString("Indexing failed"))

        # Strategy information
        xsDataResultStrategy = _xsDataResultCharacterisation.strategyResult
        xsDataISPyBScreeningStrategyContainer = None
        xsDataISPyBScreeningStrategyWedgeContainer = None
        if xsDataResultStrategy is None:
            xsDataISPyBScreeningOutput.setStrategySuccess(XSDataBoolean(False))
        else:
            if xsDataResultStrategy.collectionPlan == []:
                xsDataISPyBScreeningOutput.setStrategySuccess(
                    XSDataBoolean(False))
            else:
                xsDataISPyBScreeningOutput.setStrategySuccess(
                    XSDataBoolean(True))
                xsDataISPyBScreeningStrategyContainer = XSDataISPyBScreeningStrategyContainer(
                )
                xsDataISPyBScreeningStrategy = XSDataISPyBScreeningStrategy()
                listXSDataCollectionPlan = xsDataResultStrategy.collectionPlan
                fTotalExposureTime = 0.0
                iTotalNumberOfImages = 0
                fTotalRotationRange = 0.0
                for xsDataCollectionPlan in listXSDataCollectionPlan:
                    numberOfImagesWedge = None
                    xsDataISPyBScreeningStrategyWedge = XSDataISPyBScreeningStrategyWedge(
                    )
                    xsDataISPyBScreeningStrategyWedgeContainer = XSDataISPyBScreeningStrategyWedgeContainer(
                    )
                    xsDataISPyBScreeningStrategyWedge.wedgeNumber = xsDataCollectionPlan.collectionPlanNumber
                    fWavelength = _xsDataResultCharacterisation.dataCollection.subWedge[
                        0].experimentalCondition.beam.wavelength.value
                    xsDataISPyBScreeningStrategyWedge.wavelength = XSDataDouble(
                        fWavelength)
                    if _fKappa is not None:
                        xsDataISPyBScreeningStrategyWedge.kappa = XSDataDouble(
                            _fKappa)
                    if _fPhi is not None:
                        xsDataISPyBScreeningStrategyWedge.phi = XSDataDouble(
                            _fPhi)
                    if (xsDataCollectionPlan.getComment() is not None):
                        strCollectionPlanComment = xsDataCollectionPlan.getComment(
                        ).getValue()
                        xsDataISPyBScreeningStrategyWedge.comments = strCollectionPlanComment
                    xsDataStrategySummary = xsDataCollectionPlan.strategySummary
                    if xsDataStrategySummary is not None:
                        xsDataISPyBScreeningStrategyWedge.completeness = xsDataStrategySummary.completeness
                        xsDataISPyBScreeningStrategyWedge.resolution = xsDataStrategySummary.resolution
                        xsDataISPyBScreeningStrategyWedge.multiplicity = xsDataStrategySummary.redundancy
                        xsDataISPyBScreeningOutput.rankingResolution = xsDataStrategySummary.rankingResolution
                        if xsDataStrategySummary.totalExposureTime is not None:
                            fTotalExposureTime += xsDataStrategySummary.totalExposureTime.value
                    xsDataCollectionStrategy = xsDataCollectionPlan.collectionStrategy
                    if xsDataCollectionStrategy is not None:
                        for xsDataSubWedge in xsDataCollectionStrategy.subWedge:
                            numberOfImagesSubWedge = None
                            xsDataISPyBScreeningStrategySubWedge = XSDataISPyBScreeningStrategySubWedge(
                            )
                            xsDataISPyBScreeningStrategySubWedge.subWedgeNumber = xsDataSubWedge.subWedgeNumber
                            xsDataISPyBScreeningStrategySubWedge.axisStart = xsDataSubWedge.experimentalCondition.goniostat.rotationAxisStart
                            xsDataISPyBScreeningStrategySubWedge.axisEnd = xsDataSubWedge.experimentalCondition.goniostat.rotationAxisEnd
                            xsDataISPyBScreeningStrategySubWedge.oscillationRange = xsDataSubWedge.experimentalCondition.goniostat.oscillationWidth
                            # Number of images
                            if  (xsDataSubWedge.experimentalCondition.goniostat.rotationAxisStart is not None) and \
                                (xsDataSubWedge.experimentalCondition.goniostat.rotationAxisEnd is not None) and \
                                (xsDataSubWedge.experimentalCondition.goniostat.oscillationWidth is not None):
                                numberOfImagesSubWedge = int((xsDataSubWedge.experimentalCondition.goniostat.rotationAxisEnd.value - \
                                                 xsDataSubWedge.experimentalCondition.goniostat.rotationAxisStart.value) / \
                                                 xsDataSubWedge.experimentalCondition.goniostat.oscillationWidth.value + 0.5)
                                xsDataISPyBScreeningStrategySubWedge.numberOfImages = XSDataInteger(
                                    numberOfImagesSubWedge)
                                if numberOfImagesWedge is None:
                                    numberOfImagesWedge = numberOfImagesSubWedge
                                else:
                                    numberOfImagesWedge += numberOfImagesSubWedge
                                fTotalRotationRange += xsDataSubWedge.experimentalCondition.goniostat.oscillationWidth.value * numberOfImagesSubWedge
                            xsDataISPyBScreeningStrategySubWedge.exposureTime = xsDataSubWedge.experimentalCondition.beam.exposureTime
                            xsDataISPyBScreeningStrategySubWedge.transmission = xsDataSubWedge.experimentalCondition.beam.transmission
                            xsDataISPyBScreeningStrategyWedgeContainer.addScreeningStrategySubWedge(
                                xsDataISPyBScreeningStrategySubWedge)
                    if numberOfImagesWedge is not None:
                        xsDataISPyBScreeningStrategyWedge.numberOfImages = XSDataInteger(
                            numberOfImagesWedge)
                        iTotalNumberOfImages += numberOfImagesWedge
                    xsDataISPyBScreeningStrategyWedgeContainer.screeningStrategyWedge = xsDataISPyBScreeningStrategyWedge
                    xsDataISPyBScreeningStrategyContainer.addScreeningStrategyWedgeContainer(
                        xsDataISPyBScreeningStrategyWedgeContainer)
                xsDataISPyBScreeningOutput.totalExposureTime = XSDataDouble(
                    fTotalExposureTime)
                xsDataISPyBScreeningOutput.totalNumberOfImages = XSDataInteger(
                    iTotalNumberOfImages)
                xsDataISPyBScreeningOutput.totalRotationRange = XSDataDouble(
                    fTotalRotationRange)
                xsDataISPyBScreeningStrategyContainer.screeningStrategy = xsDataISPyBScreeningStrategy
        # Assembly
        xsDataISPyBScreeningOutputContainer = XSDataISPyBScreeningOutputContainer(
        )
        xsDataISPyBScreeningOutputContainer.screeningOutput = xsDataISPyBScreeningOutput
        if xsDataISPyBScreeningOutputLattice is not None:
            xsDataISPyBScreeningOutputContainer.addScreeningOutputLattice(
                xsDataISPyBScreeningOutputLattice)
        if xsDataISPyBScreeningStrategyContainer is not None:
            xsDataISPyBScreeningOutputContainer.addScreeningStrategyContainer(
                xsDataISPyBScreeningStrategyContainer)

        return xsDataISPyBScreeningOutputContainer
예제 #32
0
            qMax = None
        datapoint = numpy.loadtxt(self.strInFile)[firstPoint:lastPoint]

        q = datapoint[:, 0]
        I = datapoint[:, 1]
        s = datapoint[:, 2]
        if qMax is not None:
            mask = (q < qMax)
            q = q[mask]
            I = I[mask]
            s = s[mask]
        xsd = XSDataInputSolutionScattering(experimentalDataQArray=EDUtilsArray.arrayToXSData(q / 10.), #from nm-1 not A-1
                                            experimentalDataIArray=EDUtilsArray.arrayToXSData(I),
                                            experimentalDataStdArray=EDUtilsArray.arrayToXSData(s),
                                            title=XSDataString(title.strip()),
                                            angularUnits=XSDataInteger(1))
        if self.__class__.maxThreads is not None:
            xsd.iNbThreads = XSDataInteger(self.__class__.maxThreads)
        self.__edPluginExecSAS = self.loadPlugin(self.__strControlledPluginSAS)
        self.__edPluginExecSAS.dataInput = xsd
        self.__edPluginExecSAS.connectSUCCESS(self.doSuccessExecSAS)
        self.__edPluginExecSAS.connectFAILURE(self.doFailureExecSAS)
        self.__edPluginExecSAS.executeSynchronous()

        if self.isFailure():
            return
        if self.dataInput.destinationDirectory is None:
            outdir = os.path.join(os.path.dirname(os.path.dirname(self.strInFile)), "ednaSAS")
        else:
            outdir = self.dataInput.destinationDirectory.path.value
        outdir = os.path.join(outdir, os.path.basename(os.path.splitext(self.strInFile)[0]))
예제 #33
0
    def from_params(self, data_collection, char_params):
        edna_input = XSDataInputMXCuBE.parseString(self.edna_default_input)

        if data_collection.id:
            edna_input.setDataCollectionId(XSDataInteger(data_collection.id))

        #Beam object
        beam = edna_input.getExperimentalCondition().getBeam()

        try:
            transmission = self.collect_obj.get_transmission()
            beam.setTransmission(XSDataDouble(transmission))
        except AttributeError:
            pass

        try:
            wavelength = self.collect_obj.get_wavelength()
            beam.setWavelength(XSDataWavelength(wavelength))
        except AttributeError:
            pass

        try:
            beam.setFlux(XSDataFlux(self.collect_obj.get_measured_intensity()))
        except AttributeError:
            pass

        try:
            beamsize = self.get_beam_size()
            if not None in beamsize:
                beam.setSize(
                    XSDataSize(x=XSDataLength(float(beamsize[0])),
                               y=XSDataLength(float(beamsize[1]))))
        except AttributeError:
            pass

        #Optimization parameters
        diff_plan = edna_input.getDiffractionPlan()

        aimed_i_sigma = XSDataDouble(char_params.aimed_i_sigma)
        aimed_completness = XSDataDouble(char_params.aimed_completness)
        aimed_multiplicity = XSDataDouble(char_params.aimed_multiplicity)
        aimed_resolution = XSDataDouble(char_params.aimed_resolution)

        complexity = char_params.strategy_complexity
        complexity = XSDataString(qme.STRATEGY_COMPLEXITY[complexity])

        permitted_phi_start = XSDataAngle(char_params.permitted_phi_start)
        _range = char_params.permitted_phi_end - char_params.permitted_phi_start
        rotation_range = XSDataAngle(_range)

        diff_plan.setAimedIOverSigmaAtHighestResolution(aimed_i_sigma)
        diff_plan.setAimedCompleteness(aimed_completness)

        if char_params.use_aimed_multiplicity:
            diff_plan.setAimedMultiplicity(aimed_multiplicity)

        if char_params.use_aimed_resolution:
            diff_plan.setAimedResolution(aimed_resolution)

        diff_plan.setComplexity(complexity)

        if char_params.use_permitted_rotation:
            diff_plan.setUserDefinedRotationStart(permitted_phi_start)
            diff_plan.setUserDefinedRotationRange(rotation_range)

        #Vertical crystal dimension
        sample = edna_input.getSample()
        sample.getSize().setY(XSDataLength(char_params.max_crystal_vdim))
        sample.getSize().setZ(XSDataLength(char_params.min_crystal_vdim))

        #Radiation damage model
        sample.setSusceptibility(XSDataDouble(char_params.rad_suscept))
        sample.setChemicalComposition(None)
        sample.setRadiationDamageModelBeta(XSDataDouble(char_params.beta /
                                                        1e6))
        sample.setRadiationDamageModelGamma(
            XSDataDouble(char_params.gamma / 1e6))

        diff_plan.setForcedSpaceGroup(XSDataString(char_params.space_group))

        # Characterisation type - Routine DC
        if char_params.use_min_dose:
            pass

        if char_params.use_min_time:
            time = XSDataTime(char_params.min_time)
            diff_plan.setMaxExposureTimePerDataCollection(time)

        # Account for radiation damage
        if char_params.induce_burn:
            self.modify_strategy_option(diff_plan, "-DamPar")

        # Characterisation type - SAD
        if char_params.opt_sad:
            if char_params.auto_res:
                diff_plan.setAnomalousData(XSDataBoolean(True))
            else:
                diff_plan.setAnomalousData(XSDataBoolean(False))
                self.modify_strategy_option(diff_plan, "-SAD yes")
                diff_plan.setAimedResolution(XSDataDouble(char_params.sad_res))
        else:
            diff_plan.setAnomalousData(XSDataBoolean(False))

        #Data set
        data_set = XSDataMXCuBEDataSet()
        acquisition_parameters = data_collection.acquisitions[
            0].acquisition_parameters
        path_template = data_collection.acquisitions[0].path_template
        path_str = os.path.join(path_template.directory,
                                path_template.get_image_file_name())

        for img_num in range(int(acquisition_parameters.num_images)):
            image_file = XSDataFile()
            path = XSDataString()
            path.setValue(path_str % (img_num + 1))
            image_file.setPath(path)
            data_set.addImageFile(image_file)

        edna_input.addDataSet(data_set)
        edna_input.process_directory = path_template.process_directory

        return edna_input
예제 #34
0
    def create_autoproc_input(self, event, params):
        """Creates processing input xml

        :param event: processing type (after, before, image)
        :type event: str
        :param params: collection parameters
        :type params: dict
        """
        xds_input_file_wait_timeout = 20
        xds_input_file_wait_resolution = 1

        file_name_timestamp = time.strftime("%Y%m%d_%H%M%S")

        autoproc_path = params.get("xds_dir")
        autoproc_xds_filename = os.path.join(autoproc_path, "XDS.INP")
        autoproc_input_filename = os.path.join(\
            autoproc_path,
            "edna-autoproc-input-%s.xml" % \
            file_name_timestamp)
        autoproc_output_file_name = os.path.join(\
            autoproc_path,
            "edna-autoproc-results-%s.xml" % \
            file_name_timestamp)

        autoproc_input = XSDataAutoprocInput()
        autoproc_xds_file = XSDataFile()
        autoproc_xds_file.setPath(XSDataString(autoproc_xds_filename))
        autoproc_input.setInput_file(autoproc_xds_file)

        autoproc_output_file = XSDataFile()
        autoproc_output_file.setPath(XSDataString(autoproc_output_file_name))
        autoproc_input.setOutput_file(autoproc_output_file)

        autoproc_input.setData_collection_id(\
            XSDataInteger(params.get("collection_id")))
        residues_num = float(params.get("residues", 0))
        if residues_num != 0:
            autoproc_input.setNres(XSDataDouble(residues_num))
        space_group = params.get("sample_reference").get("spacegroup", "")
        if len(space_group) > 0:
            autoproc_input.setSpacegroup(XSDataString(space_group))
        unit_cell = params.get("sample_reference").get("cell", "")
        if len(unit_cell) > 0:
            autoproc_input.setUnit_cell(XSDataString(unit_cell))

        autoproc_input.setCc_half_cutoff(XSDataDouble(18.0))

        #Maybe we have to check if directory is there.
        #Maybe create dir with mxcube
        xds_appeared = False
        wait_xds_start = time.time()
        logging.debug("EMBLAutoprocessing: Waiting for XDS.INP " +\
                      "file: %s" % autoproc_xds_filename)
        while not xds_appeared and time.time() - wait_xds_start < xds_input_file_wait_timeout:
            if os.path.exists(autoproc_xds_filename) and \
               os.stat(autoproc_xds_filename).st_size > 0:
                xds_appeared = True
                logging.debug('EMBLAutoprocessing: XDS.INP file is there, size={0}'.\
                        format(os.stat(autoproc_xds_filename).st_size))
            else:
                os.system("ls %s> /dev/null"%(os.path.dirname(autoproc_path)))
                gevent.sleep(xds_input_file_wait_resolution)
        if not xds_appeared:
            logging.error("EMBLAutoprocessing: XDS.INP file ({0}) failed " +\
                          "to appear after {1} seconds".\
                    format(autoproc_xds_filename, xds_input_file_wait_timeout))
            return None, False

        autoproc_input.exportToFile(autoproc_input_filename)

        return autoproc_input_filename, True
 def process(self, _edObject=None):
     """
     Uses ToolsForCollectionWebService for storing the workflow status
     """
     EDPluginExec.process(self)
     self.DEBUG("EDPluginISPyBGetSampleInformationv1_4.process")
     # First get the image ID
     xsDataInputGetSampleInformation = self.getDataInput()
     httpAuthenticatedToolsForCollectionWebService = HttpAuthenticated(username=self.strUserName, password=self.strPassWord)
     clientToolsForBLSampleWebServiceWsdl = Client(self.strToolsForBLSampleWebServiceWsdl, transport=httpAuthenticatedToolsForCollectionWebService)
     iSampleId = self.getXSValue(xsDataInputGetSampleInformation.sampleId)
     sampleInfo = clientToolsForBLSampleWebServiceWsdl.service.getSampleInformation(iSampleId)
     self.DEBUG("Sample info from ISPyB: %r" % sampleInfo)
     if sampleInfo is not None:
         if "code" in sampleInfo:
             self.xsDataResultISPyBGetSampleInformation.code = XSDataString(sampleInfo.code)
         if "cellA" in sampleInfo:
             self.xsDataResultISPyBGetSampleInformation.cellA = XSDataDouble(sampleInfo.cellA)
         if "cellB" in sampleInfo:
             self.xsDataResultISPyBGetSampleInformation.cellB = XSDataDouble(sampleInfo.cellB)
         if "cellC" in sampleInfo:
             self.xsDataResultISPyBGetSampleInformation.cellC = XSDataDouble(sampleInfo.cellC)
         if "cellAlpha" in sampleInfo:
             self.xsDataResultISPyBGetSampleInformation.cellAlpha = XSDataDouble(sampleInfo.cellAlpha)
         if "cellBeta" in sampleInfo:
             self.xsDataResultISPyBGetSampleInformation.cellBeta = XSDataDouble(sampleInfo.cellBeta)
         if "cellGamma" in sampleInfo:
             self.xsDataResultISPyBGetSampleInformation.cellGamma = XSDataDouble(sampleInfo.cellGamma)
         if "containerSampleChangerLocation" in sampleInfo:
             self.xsDataResultISPyBGetSampleInformation.containerSampleChangerLocation = XSDataString(sampleInfo.containerSampleChangerLocation)
         if "crystalSpaceGroup" in sampleInfo:
             self.xsDataResultISPyBGetSampleInformation.crystalSpaceGroup = XSDataString(sampleInfo.crystalSpaceGroup)
         if "experimentType" in sampleInfo:
             self.xsDataResultISPyBGetSampleInformation.experimentType = XSDataString(sampleInfo.experimentType)
         if "holderLength" in sampleInfo:
             self.xsDataResultISPyBGetSampleInformation.holderLength = XSDataDouble(sampleInfo.holderLength)
         if "minimalResolution" in sampleInfo:
             self.xsDataResultISPyBGetSampleInformation.minimalResolution = XSDataDouble(sampleInfo.minimalResolution)
         if "proteinAcronym" in sampleInfo:
             self.xsDataResultISPyBGetSampleInformation.proteinAcronym = XSDataString(sampleInfo.proteinAcronym)
         if "sampleId" in sampleInfo:
             self.xsDataResultISPyBGetSampleInformation.sampleId = XSDataInteger(sampleInfo.sampleId)
         if "sampleLocation" in sampleInfo:
             self.xsDataResultISPyBGetSampleInformation.sampleLocation = XSDataString(sampleInfo.sampleLocation)
         if "sampleName" in sampleInfo:
             self.xsDataResultISPyBGetSampleInformation.sampleName = XSDataString(sampleInfo.sampleName)
         if "diffractionPlan" in sampleInfo:
             xsDataISPyBDiffractionPlan = XSDataISPyBDiffractionPlan()
             if "aimedCompleteness" in sampleInfo.diffractionPlan:
                 xsDataISPyBDiffractionPlan.aimedCompleteness = XSDataDouble(sampleInfo.diffractionPlan.aimedCompleteness)
             if "aimedIOverSigmaAtHighestResolution" in sampleInfo.diffractionPlan:
                 xsDataISPyBDiffractionPlan.aimedIOverSigmaAtHighestResolution = XSDataDouble(sampleInfo.diffractionPlan.aimedIOverSigmaAtHighestResolution)
             if "aimedMultiplicity" in sampleInfo.diffractionPlan:
                 xsDataISPyBDiffractionPlan.aimedMultiplicity = XSDataDouble(sampleInfo.diffractionPlan.aimedMultiplicity)
             if "aimedResolution" in sampleInfo.diffractionPlan:
                 xsDataISPyBDiffractionPlan.aimedResolution = XSDataDouble(sampleInfo.diffractionPlan.aimedResolution)
             if "anomalousData" in sampleInfo.diffractionPlan:
                 xsDataISPyBDiffractionPlan.anomalousData = XSDataBoolean(sampleInfo.diffractionPlan.anomalousData)
             if "comments" in sampleInfo.diffractionPlan:
                 xsDataISPyBDiffractionPlan.comments = XSDataString(sampleInfo.diffractionPlan.comments)
             if "complexity" in sampleInfo.diffractionPlan:
                 xsDataISPyBDiffractionPlan.complexity = XSDataString(sampleInfo.diffractionPlan.complexity)
             if "diffractionPlanId" in sampleInfo.diffractionPlan:
                 xsDataISPyBDiffractionPlan.diffractionPlanId = XSDataInteger(sampleInfo.diffractionPlan.diffractionPlanId)
             if "estimateRadiationDamage" in sampleInfo.diffractionPlan:
                 xsDataISPyBDiffractionPlan.estimateRadiationDamage = XSDataBoolean(sampleInfo.diffractionPlan.estimateRadiationDamage)
             if "experimentKind" in sampleInfo.diffractionPlan:
                 xsDataISPyBDiffractionPlan.experimentKind = XSDataString(sampleInfo.diffractionPlan.experimentKind)
             if "exposureTime" in sampleInfo.diffractionPlan:
                 xsDataISPyBDiffractionPlan.exposureTime = XSDataDouble(sampleInfo.diffractionPlan.exposureTime)
             if "forcedSpaceGroup" in sampleInfo.diffractionPlan:
                 xsDataISPyBDiffractionPlan.forcedSpaceGroup = XSDataString(sampleInfo.diffractionPlan.forcedSpaceGroup)
             if "kappaStrategyOption" in sampleInfo.diffractionPlan:
                 xsDataISPyBDiffractionPlan.kappaStrategyOption = XSDataString(sampleInfo.diffractionPlan.kappaStrategyOption)
             if "maxDimAccrossSpindleAxis" in sampleInfo.diffractionPlan:
                 xsDataISPyBDiffractionPlan.maxDimAccrossSpindleAxis = XSDataDouble(sampleInfo.diffractionPlan.maxDimAccrossSpindleAxis)
             if "maximalResolution" in sampleInfo.diffractionPlan:
                 xsDataISPyBDiffractionPlan.maximalResolution = XSDataDouble(sampleInfo.diffractionPlan.maximalResolution)
             if "minDimAccrossSpindleAxis" in sampleInfo.diffractionPlan:
                 xsDataISPyBDiffractionPlan.minDimAccrossSpindleAxis = XSDataDouble(sampleInfo.diffractionPlan.minDimAccrossSpindleAxis)
             if "minimalResolution" in sampleInfo.diffractionPlan:
                 xsDataISPyBDiffractionPlan.minimalResolution = XSDataDouble(sampleInfo.diffractionPlan.minimalResolution)
             if "numberOfPositions" in sampleInfo.diffractionPlan:
                 xsDataISPyBDiffractionPlan.numberOfPositions = XSDataInteger(sampleInfo.diffractionPlan.numberOfPositions)
             if "observedResolution" in sampleInfo.diffractionPlan:
                 xsDataISPyBDiffractionPlan.observedResolution = XSDataDouble(sampleInfo.diffractionPlan.observedResolution)
             if "oscillationRange" in sampleInfo.diffractionPlan:
                 xsDataISPyBDiffractionPlan.oscillationRange = XSDataDouble(sampleInfo.diffractionPlan.oscillationRange)
             if "preferredBeamSizeX" in sampleInfo.diffractionPlan:
                 xsDataISPyBDiffractionPlan.preferredBeamSizeX = XSDataDouble(sampleInfo.diffractionPlan.preferredBeamSizeX)
             if "preferredBeamSizeY" in sampleInfo.diffractionPlan:
                 xsDataISPyBDiffractionPlan.preferredBeamSizeY = XSDataDouble(sampleInfo.diffractionPlan.preferredBeamSizeY)
             if "radiationSensitivity" in sampleInfo.diffractionPlan:
                 xsDataISPyBDiffractionPlan.radiationSensitivity = XSDataDouble(sampleInfo.diffractionPlan.radiationSensitivity)
             if "radiationSensitivityBeta" in sampleInfo.diffractionPlan:
                 xsDataISPyBDiffractionPlan.radiationSensitivityBeta = XSDataDouble(sampleInfo.diffractionPlan.radiationSensitivityBeta)
             if "radiationSensitivityGamma" in sampleInfo.diffractionPlan:
                 xsDataISPyBDiffractionPlan.radiationSensitivityGamma = XSDataDouble(sampleInfo.diffractionPlan.radiationSensitivityGamma)
             if "requiredCompleteness" in sampleInfo.diffractionPlan:
                 xsDataISPyBDiffractionPlan.requiredCompleteness = XSDataDouble(sampleInfo.diffractionPlan.requiredCompleteness)
             if "requiredMultiplicity" in sampleInfo.diffractionPlan:
                 xsDataISPyBDiffractionPlan.requiredMultiplicity = XSDataDouble(sampleInfo.diffractionPlan.requiredMultiplicity)
             if "requiredResolution" in sampleInfo.diffractionPlan:
                 xsDataISPyBDiffractionPlan.requiredResolution = XSDataDouble(sampleInfo.diffractionPlan.requiredResolution)
             if "screeningResolution" in sampleInfo.diffractionPlan:
                 xsDataISPyBDiffractionPlan.screeningResolution = XSDataDouble(sampleInfo.diffractionPlan.screeningResolution)
             if "anomalousScatterer" in sampleInfo.diffractionPlan:
                 xsDataISPyBDiffractionPlan.anomalousScatterer = XSDataString(sampleInfo.diffractionPlan.anomalousScatterer)
             if "strategyOption" in sampleInfo.diffractionPlan:
                 xsDataISPyBDiffractionPlan.strategyOption = XSDataString(sampleInfo.diffractionPlan.strategyOption)
             self.xsDataResultISPyBGetSampleInformation.diffractionPlan = xsDataISPyBDiffractionPlan
     self.DEBUG("EDPluginISPyBGetSampleInformationv1_4.process: result=%s" % pprint.pformat(self.xsDataResultISPyBGetSampleInformation))
예제 #36
0
 def buildChildren(self, child_, nodeName_):
     if child_.nodeType == Node.ELEMENT_NODE and \
         nodeName_ == 'number':
         obj_ = XSDataInteger()
         obj_.build(child_)
         self.setNumber(obj_)
     elif child_.nodeType == Node.ELEMENT_NODE and \
         nodeName_ == 'scale':
         obj_ = XSDataDouble()
         obj_.build(child_)
         self.setScale(obj_)
     elif child_.nodeType == Node.ELEMENT_NODE and \
         nodeName_ == 'bfactor':
         obj_ = XSDataDouble()
         obj_.build(child_)
         self.setBfactor(obj_)
     elif child_.nodeType == Node.ELEMENT_NODE and \
         nodeName_ == 'resolution':
         obj_ = XSDataDouble()
         obj_.build(child_)
         self.setResolution(obj_)
     elif child_.nodeType == Node.ELEMENT_NODE and \
         nodeName_ == 'correlation':
         obj_ = XSDataDouble()
         obj_.build(child_)
         self.setCorrelation(obj_)
     elif child_.nodeType == Node.ELEMENT_NODE and \
         nodeName_ == 'rfactor':
         obj_ = XSDataDouble()
         obj_.build(child_)
         self.setRfactor(obj_)
     elif child_.nodeType == Node.ELEMENT_NODE and \
         nodeName_ == 'b_coef':
         obj_ = XSDataDouble()
         obj_.build(child_)
         self.setB_coef(obj_)
     elif child_.nodeType == Node.ELEMENT_NODE and \
         nodeName_ == 'b_cryst':
         obj_ = XSDataDouble()
         obj_.build(child_)
         self.setB_cryst(obj_)
     elif child_.nodeType == Node.ELEMENT_NODE and \
         nodeName_ == 'esitmate':
         obj_ = XSDataDouble()
         obj_.build(child_)
         self.setEsitmate(obj_)
 def preProcess(self, _edObject=None):
     EDPluginControl.preProcess(self)
     EDVerbose.DEBUG(
         "EDPluginControlPyarchThumbnailGeneratorv1_0.preProcess")
     # Check that the input image exists and is of the expected type
     strPathToDiffractionImage = self.getDataInput().getDiffractionImage(
     ).getPath().getValue()
     strImageFileNameExtension = os.path.splitext(
         strPathToDiffractionImage)[1]
     if not strImageFileNameExtension in [
             ".img", ".marccd", ".mccd", ".cbf"
     ]:
         EDVerbose.error(
             "Unknown image file name extension for pyarch thumbnail generator: %s"
             % strPathToDiffractionImage)
         self.setFailure()
     else:
         # Load the waitFile plugin
         xsDataInputWaitFile = XSDataInputWaitFile()
         xsDataInputWaitFile.setExpectedSize(
             XSDataInteger(self.iExpectedSize))
         xsDataInputWaitFile.setExpectedFile(
             self.getDataInput().getDiffractionImage())
         if self.getDataInput().getWaitForFileTimeOut():
             xsDataInputWaitFile.setTimeOut(
                 self.getDataInput().getWaitForFileTimeOut())
         self.edPluginWaitFile = EDPluginWaitFile()
         self.edPluginWaitFile.setDataInput(xsDataInputWaitFile)
         # Load the execution plugin
         self.edPluginExecThumbnail = self.loadPlugin(
             self.strExecThumbnailPluginName)
         xsDataInputExecThumbnail = XSDataInputExecThumbnail()
         xsDataInputExecThumbnail.setInputImagePath(
             self.getDataInput().getDiffractionImage())
         xsDataInputExecThumbnail.setLevelsInvert(XSDataBoolean(True))
         xsDataInputExecThumbnail.setLevelsMin(XSDataDoubleWithUnit(0.0))
         xsDataDoubleWithUnitLevelsMax = XSDataDoubleWithUnit(99.95)
         xsDataDoubleWithUnitLevelsMax.setUnit(XSDataString("%"))
         xsDataInputExecThumbnail.setLevelsMax(
             xsDataDoubleWithUnitLevelsMax)
         xsDataInputExecThumbnail.setFilterDilatation([XSDataInteger(4)])
         xsDataInputExecThumbnail.setLevelsColorize(XSDataBoolean(False))
         xsDataInputExecThumbnail.setThumbHeight(XSDataInteger(1024))
         xsDataInputExecThumbnail.setThumbWidth(XSDataInteger(1024))
         xsDataInputExecThumbnail.setKeepRatio(XSDataBoolean(False))
         # Output path
         strImageNameWithoutExt = os.path.basename(
             os.path.splitext(strPathToDiffractionImage)[0])
         strImageDirname = os.path.dirname(strPathToDiffractionImage)
         if self.getDataInput().getForcedOutputDirectory():
             strForcedOutputDirectory = self.getDataInput(
             ).getForcedOutputDirectory().getPath().getValue()
             if not os.access(strForcedOutputDirectory, os.W_OK):
                 EDVerbose.error(
                     "Cannot write to forced output directory : %s" %
                     strForcedOutputDirectory)
                 self.setFailure()
             else:
                 self.strOutputPathWithoutExtension = os.path.join(
                     strForcedOutputDirectory, strImageNameWithoutExt)
         else:
             # Try to store in the ESRF pyarch directory
             strOutputDirname = EDHandlerESRFPyarchv1_0.createPyarchFilePath(
                 strImageDirname)
             # Check that output pyarch path exists and is writeable:
             bIsOk = False
             if strOutputDirname:
                 if not os.path.exists(strOutputDirname):
                     # Try to create the directory
                     try:
                         os.makedirs(strOutputDirname)
                         bIsOk = True
                     except BaseException, e:
                         EDVerbose.WARNING(
                             "Couldn't create the directory %s" %
                             strOutputDirname)
                 elif os.access(strOutputDirname, os.W_OK):
                     bIsOk = True
             if not bIsOk:
                 EDVerbose.warning("Cannot write to pyarch directory: %s" %
                                   strOutputDirname)
                 strOutputDirname = tempfile.mkdtemp(
                     "", "EDPluginPyarchThumbnailv10_", "/tmp")
                 EDVerbose.warning("Writing thumbnail images to: %s" %
                                   strOutputDirname)
             self.strOutputPathWithoutExtension = os.path.join(
                 strOutputDirname, strImageNameWithoutExt)
         self.strOutputPath = os.path.join(
             self.strOutputPathWithoutExtension + ".jpeg")
         xsDataInputExecThumbnail.setOutputPath(
             XSDataFile(XSDataString(self.strOutputPath)))
         self.edPluginExecThumbnail.setDataInput(xsDataInputExecThumbnail)
예제 #38
0
 def buildChildren(self, child_, nodeName_):
     if child_.nodeType == Node.ELEMENT_NODE and \
         nodeName_ == 'number':
         obj_ = XSDataInteger()
         obj_.build(child_)
         self.setNumber(obj_)
     elif child_.nodeType == Node.ELEMENT_NODE and \
         nodeName_ == 'spots_num_of':
         obj_ = XSDataInteger()
         obj_.build(child_)
         self.setSpots_num_of(obj_)
     elif child_.nodeType == Node.ELEMENT_NODE and \
         nodeName_ == 'spots_int_aver':
         obj_ = XSDataDouble()
         obj_.build(child_)
         self.setSpots_int_aver(obj_)
     elif child_.nodeType == Node.ELEMENT_NODE and \
         nodeName_ == 'spots_resolution':
         obj_ = XSDataDouble()
         obj_.build(child_)
         self.setSpots_resolution(obj_)
     elif child_.nodeType == Node.ELEMENT_NODE and \
         nodeName_ == 'powder_wilson_scale':
         obj_ = XSDataDouble()
         obj_.build(child_)
         self.setPowder_wilson_scale(obj_)
     elif child_.nodeType == Node.ELEMENT_NODE and \
         nodeName_ == 'powder_wilson_bfactor':
         obj_ = XSDataDouble()
         obj_.build(child_)
         self.setPowder_wilson_bfactor(obj_)
     elif child_.nodeType == Node.ELEMENT_NODE and \
         nodeName_ == 'powder_wilson_resolution':
         obj_ = XSDataDouble()
         obj_.build(child_)
         self.setPowder_wilson_resolution(obj_)
     elif child_.nodeType == Node.ELEMENT_NODE and \
         nodeName_ == 'powder_wilson_correlation':
         obj_ = XSDataDouble()
         obj_.build(child_)
         self.setPowder_wilson_correlation(obj_)
     elif child_.nodeType == Node.ELEMENT_NODE and \
         nodeName_ == 'powder_wilson_rfactor':
         obj_ = XSDataDouble()
         obj_.build(child_)
         self.setPowder_wilson_rfactor(obj_)
     elif child_.nodeType == Node.ELEMENT_NODE and \
         nodeName_ == 'score':
         obj_ = XSDataDouble()
         obj_.build(child_)
         self.setScore(obj_)
 def buildChildren(self, child_, nodeName_):
     if child_.nodeType == Node.ELEMENT_NODE and \
         nodeName_ == 'dataCollectionId':
         obj_ = XSDataInteger()
         obj_.build(child_)
         self.setDataCollectionId(obj_)
     elif child_.nodeType == Node.ELEMENT_NODE and \
         nodeName_ == 'processDirectory':
         obj_ = XSDataFile()
         obj_.build(child_)
         self.setProcessDirectory(obj_)
     elif child_.nodeType == Node.ELEMENT_NODE and \
         nodeName_ == 'geomFile':
         obj_ = XSDataString()
         obj_.build(child_)
         self.setGeomFile(obj_)
     elif child_.nodeType == Node.ELEMENT_NODE and \
         nodeName_ == 'cellFile':
         obj_ = XSDataString()
         obj_.build(child_)
         self.setCellFile(obj_)
     elif child_.nodeType == Node.ELEMENT_NODE and \
         nodeName_ == 'imagesFullPath':
         obj_ = XSDataString()
         obj_.build(child_)
         self.setImagesFullPath(obj_)
     elif child_.nodeType == Node.ELEMENT_NODE and \
         nodeName_ == 'streamFile':
         obj_ = XSDataString()
         obj_.build(child_)
         self.setStreamFile(obj_)
     elif child_.nodeType == Node.ELEMENT_NODE and \
         nodeName_ == 'hklFile':
         obj_ = XSDataString()
         obj_.build(child_)
         self.setHklFile(obj_)
     elif child_.nodeType == Node.ELEMENT_NODE and \
         nodeName_ == 'mtzFile':
         obj_ = XSDataString()
         obj_.build(child_)
         self.setMtzFile(obj_)
     XSDataInput.buildChildren(self, child_, nodeName_)