Beispiel #1
0
def fileName2xml(filename):
    """Here we create the XML string to be passed to the EDNA plugin from the input filename
    This can / should be modified by the final user
    
    @param filename: full path of the input file
    @type filename: python string representing the path
    @rtype: XML string
    @return: python string  
    """
    if filename.endswith(".jpg"):
        xm = None
    else:
        upperDir = os.path.dirname(os.path.dirname(filename))
        if not os.path.isdir(os.path.join(upperDir, "Thumbnail")):
            os.makedirs(os.path.join(upperDir, "Thumbnail"), int("775", 8))
        destinationPath = os.path.join(upperDir, "Thumbnail")
        xsd = XSDataInputExecThumbnail()
        xsdFile = XSDataFile()
        xsdFile.setPath(XSDataString(filename))
        xsd.setInputImagePath(xsdFile)
        xsdPath = XSDataFile()
        xsdPath.setPath(XSDataString(destinationPath))
        xsd.setOutputPath(xsdPath)
        xsd.setLevelsColorize(XSDataBoolean(True))
        xsd.setLevelsNormalize(XSDataBoolean(True))
        xsd.setLevelsGamma(XSDataFloat(gamma))
        xml = xsd.marshal()
    return xml
def functionXMLin(_strFilename):
    """Here we create the XML string to be passed to the EDNA plugin from the input strFilename
    This can / should be modified by the final user
    
    @param _strFilename: full path of the input file
    @type _strFilename: python string representing the path
    @return: string  
    """
    EDVerbose.screen("Starting processing of image %s" % (_strFilename))
    # First check if the filename end with .img or .mccd:
    strXML = None
    if (_strFilename.endswith(".img") or _strFilename.endswith(".mccd") or _strFilename.endswith(".cbf")):
        xsDataInputGridScreening = XSDataInputGridScreening()
        xsDataDiffractionPlan = XSDataDiffractionPlan()
        xsDataDiffractionPlan.setMaxExposureTimePerDataCollection(XSDataTime(EDParallelExecuteGridScreening.fMaxExposureTime))
        xsDataInputGridScreening.setDiffractionPlan(xsDataDiffractionPlan)
        xsDataFile = XSDataFile()
        xsDataFile.setPath(XSDataString(_strFilename))
        xsDataInputGridScreening.setImageFile(xsDataFile)
        if EDParallelExecuteGridScreening.bOnlyImageQualityIndicators:
            xsDataInputGridScreening.setDoOnlyImageQualityIndicators(XSDataBoolean(True))
        if EDParallelExecuteGridScreening.bStoreInISPyB:
            xsDataInputGridScreening.setStoreImageQualityIndicatorsInISPyB(XSDataBoolean(True))
        if EDParallelExecuteGridScreening.bDoOnlyIntegrationWithXMLOutput:
            xsDataInputGridScreening.setDoOnlyIntegrationWithXMLOutput(XSDataBoolean(True))
        strXML = xsDataInputGridScreening.marshal()
    else:
        EDVerbose.screen("File name not ending with .img or .mccd - ignored : %s" % _strFilename)
    return strXML
    def checkParameters(self):
        """
        Checks the mandatory parameters.
        """
        self.DEBUG("EDPluginExecMinimalXdsv1_0.checkParameters")
        self.checkMandatoryParameters(self.dataInput, "Data Input is None")
        self.checkMandatoryParameters(self.dataInput.input_file,
                                      "No XDS input file given")

        # really look into the mandatory arg
        xds_input = os.path.abspath(self.dataInput.input_file.value)
        if not (os.path.exists(xds_input) and os.path.isfile(xds_input)):
            strErrorMessage = "Cannot find or read XDS input file {0}".format(
                xds_input)
            self.ERROR(strErrorMessage)
            self.addErrorMessage(strErrorMessage)
            self.dataOutput.succeeded = XSDataBoolean(False)
            self.setFailure()
            return

        # if we have a resolution it has to be a list of 2 XSDataDouble
        resrange = self.dataInput.resolution_range
        if resrange is not None and len(resrange) != 0:
            # a non specified list input parameter has a default value
            # of [], seriously???
            if len(resrange) != 2:
                strErrorMessage = "Resolution range must be 2 in length ({0} given)".format(
                    resrange)
                self.ERROR(strErrorMessage)
                self.addErrorMessage(strErrorMessage)
                self.dataOutput.succeeded = XSDataBoolean(False)
                self.setFailure()
                return
Beispiel #4
0
    def preProcess(self):
        EDPluginControl.preProcess(self)
        self.DEBUG('Import : preprocess')
        self.anom = self.loadPlugin('EDPluginControlFileConversion')
        self.noanom = self.loadPlugin('EDPluginControlFileConversion')
        tocopy = [
            'dataCollectionID', 'start_image', 'end_image', 'res', 'nres',
            'image_prefix'
        ]

        anom_in = XSDataFileConversion()
        noanom_in = XSDataFileConversion()

        # copy the common attributes from our data model to the subplugins'
        for a in tocopy:
            for dm in anom_in, noanom_in:
                setattr(dm, a, getattr(self.dataInput, a))

        # now set the specific bits
        anom_in.anom = XSDataBoolean(True)
        anom_in.input_file = self.dataInput.input_anom
        anom_in.output_file = XSDataString(
            os.path.join(self.outdir, OUTFILE_TEMPLATE.format('anom')))
        self.anom.dataInput = anom_in

        noanom_in.anom = XSDataBoolean(False)
        noanom_in.input_file = self.dataInput.input_noanom
        noanom_in.output_file = XSDataString(
            os.path.join(self.outdir, OUTFILE_TEMPLATE.format('noanom')))
        self.noanom.dataInput = noanom_in
Beispiel #5
0
    def preProcess(self):
        EDPluginControl.preProcess(self)
        self.DEBUG('Import : preprocess')
        tocopy = ['dataCollectionID', 'start_image', 'end_image',
                  'res', 'nres', 'image_prefix']

        if self.dataInput.input_anom:
            self.anom = self.loadPlugin('EDPluginControlFileConversionv1_0')
            anom_in = XSDataFileConversion()
            for a in tocopy:
                setattr(anom_in, a, getattr(self.dataInput, a))
            anom_in.anom = XSDataBoolean(True)
            anom_in.input_file = self.dataInput.input_anom
            anom_in.output_file = XSDataString(os.path.join(self.outdir, OUTFILE_TEMPLATE.format('anom')))
            anom_in.choose_spacegroup = self.dataInput.choose_spacegroup
            self.anom.dataInput = anom_in

        if self.dataInput.input_noanom:
            self.noanom = self.loadPlugin('EDPluginControlFileConversionv1_0')
            noanom_in = XSDataFileConversion()
            for a in tocopy:
                setattr(noanom_in, a, getattr(self.dataInput, a))
            noanom_in.anom = XSDataBoolean(False)
            noanom_in.input_file = self.dataInput.input_noanom
            noanom_in.output_file = XSDataString(os.path.join(self.outdir, OUTFILE_TEMPLATE.format('noanom')))
            noanom_in.choose_spacegroup = self.dataInput.choose_spacegroup
            self.noanom.dataInput = noanom_in
Beispiel #6
0
 def doSuccessReadImageHeader(self, _edPlugin=None):
     self.DEBUG("EDPluginControlGridScreeningv1_0.doSuccessReadImageHeader")
     self.retrieveSuccessMessages(_edPlugin, "EDPluginControlGridScreeningv1_0.doSuccessReadImageHeader")
     xsDataResultReadImageHeader = self.edPluginControlReadImageHeader.getDataOutput()
     if xsDataResultReadImageHeader is not None:
         xsDataSubWedge = xsDataResultReadImageHeader.getSubWedge()
         self.xsDataCollection = XSDataCollection()
         self.xsDataCollection.addSubWedge(xsDataSubWedge)
         self.xsDataCollection.setDiffractionPlan(self.xsDataDiffractionPlan)
         if not self.bDoOnlyIntegrationWithXMLOutput:
             xsDataInputControlImageQualityIndicators = XSDataInputControlImageQualityIndicators()
             if self.bStoreImageQualityIndicatorsInISPyB:
                 xsDataInputControlImageQualityIndicators.doUploadToIspyb = XSDataBoolean(True)
             else:
                 xsDataInputControlImageQualityIndicators.doUploadToIspyb = XSDataBoolean(False)
             xsDataInputControlImageQualityIndicators.addImage(XSDataImage(path=XSDataString(self.strImageFile)))
             self.edPluginControlIndicators.setDataInput(xsDataInputControlImageQualityIndicators)
             self.edPluginControlIndicators.connectSUCCESS(self.doSuccessIndicators)
             self.edPluginControlIndicators.connectFAILURE(self.doFailureIndicators)
             self.executePluginSynchronous(self.edPluginControlIndicators)
         else:
             xsDataIndexingInput = XSDataIndexingInput()
             xsDataIndexingInput.setDataCollection(self.xsDataCollection)
             from EDHandlerXSDataMOSFLMv10 import EDHandlerXSDataMOSFLMv10
             xsDataMOSFLMIndexingInput = EDHandlerXSDataMOSFLMv10.generateXSDataMOSFLMInputIndexing(xsDataIndexingInput)
             self.edPluginMOSFLMIndexing.connectSUCCESS(self.doSuccessIndexingMOSFLM)
             self.edPluginMOSFLMIndexing.connectFAILURE(self.doFailureIndexingMOSFLM)
             self.edPluginMOSFLMIndexing.setDataInput(xsDataMOSFLMIndexingInput)
             self.edPluginMOSFLMIndexing.executeSynchronous()
Beispiel #7
0
 def buildChildren(self, child_, nodeName_):
     if child_.nodeType == Node.ELEMENT_NODE and \
      nodeName_ == 'imageFile':
         obj_ = XSDataFile()
         obj_.build(child_)
         self.setImageFile(obj_)
     elif child_.nodeType == Node.ELEMENT_NODE and \
      nodeName_ == 'diffractionPlan':
         obj_ = XSDataDiffractionPlan()
         obj_.build(child_)
         self.setDiffractionPlan(obj_)
     elif child_.nodeType == Node.ELEMENT_NODE and \
      nodeName_ == 'storeImageQualityIndicatorsInISPyB':
         obj_ = XSDataBoolean()
         obj_.build(child_)
         self.setStoreImageQualityIndicatorsInISPyB(obj_)
     elif child_.nodeType == Node.ELEMENT_NODE and \
      nodeName_ == 'doOnlyImageQualityIndicators':
         obj_ = XSDataBoolean()
         obj_.build(child_)
         self.setDoOnlyImageQualityIndicators(obj_)
     elif child_.nodeType == Node.ELEMENT_NODE and \
      nodeName_ == 'doOnlyIntegrationWithXMLOutput':
         obj_ = XSDataBoolean()
         obj_.build(child_)
         self.setDoOnlyIntegrationWithXMLOutput(obj_)
     XSDataInput.buildChildren(self, child_, nodeName_)
    def postProcess(self, _edObject=None):
        EDPluginExecProcessScript.postProcess(self)
        self.DEBUG("EDPluginMinimalXds.postProcess")
        # Check log for warning and errors
        strPathToLogFile = os.path.join(self.getWorkingDirectory(),
                                        self.getScriptLogFileName())
        self.checkLogForWarningAndErrors(strPathToLogFile)

        # XDS is considered to have succeeded iff CORRECT.LP has been created
        outfile = os.path.join(self.getWorkingDirectory(), 'CORRECT.LP')
        self.DEBUG('looking for {0}'.format(outfile))
        if not os.path.isfile(outfile):
            self.DEBUG('NOT FOUND')
            self.dataOutput.succeeded = XSDataBoolean(False)
            strErrorMessage = "Cannot find CORRECT.LP output file"
            self.ERROR(strErrorMessage)
            if len(self.getListOfErrorMessages()) == 0:
                self.addErrorMessage(strErrorMessage)
            else:
                self.addWarningMessage(strErrorMessage)
            self.setFailure()
            return
        else:
            self.DEBUG('FOUND')
            self.dataOutput.succeeded = XSDataBoolean(True)
        self.DEBUG('succeeded is {0} and succeeded.value is {1}'.format(
            self.dataOutput.succeeded, self.dataOutput.succeeded.value))
 def buildChildren(self, child_, nodeName_):
     if 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_)
     elif child_.nodeType == Node.ELEMENT_NODE and \
         nodeName_ == 'dataCollectionId':
         obj_ = XSDataInteger()
         obj_.build(child_)
         self.setDataCollectionId(obj_)
     elif child_.nodeType == Node.ELEMENT_NODE and \
         nodeName_ == 'processDirectory':
         obj_ = XSDataFile()
         obj_.build(child_)
         self.setProcessDirectory(obj_)
     elif child_.nodeType == Node.ELEMENT_NODE and \
         nodeName_ == 'doAnom':
         obj_ = XSDataBoolean()
         obj_.build(child_)
         self.setDoAnom(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_ == 'hdf5ToCbfDirectory':
         obj_ = XSDataFile()
         obj_.build(child_)
         self.setHdf5ToCbfDirectory(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_ == 'useXdsAsciiToXml':
         obj_ = XSDataBoolean()
         obj_.build(child_)
         self.setUseXdsAsciiToXml(obj_)
     elif child_.nodeType == Node.ELEMENT_NODE and \
         nodeName_ == 'reprocess':
         obj_ = XSDataBoolean()
         obj_.build(child_)
         self.setReprocess(obj_)
     XSDataInput.buildChildren(self, child_, nodeName_)
    def postProcess(self, _edObject=None):
        EDPluginControl.postProcess(self)
        self.DEBUG("EDPluginControlXdsBest.postProcess")

        self.dataOutput = XSDataOutputXdsBurnStrategy()
        self.dataOutput.status = XSDataStatus()
        # check if a XDS.HKL file has been generated
        expected = os.path.join(self._xds.getWorkingDirectory(),
                                'XDS_ASCII.HKL')
        if os.path.exists(expected):
            self.dataOutput.status.isSuccess = XSDataBoolean(True)
            self.dataOutput.xds_hkl = XSDataString(expected)
        else:
            self.dataOutput.status.isSuccess = XSDataBoolean(False)
Beispiel #11
0
    def preProcess(self, _edObject=None):
        EDPluginControl.preProcess(self)
        self.DEBUG("EDPluginControlXscaleGenerate.preProcess")
        # Load the execution plugin
        self.xscale_anom_merged = self.loadPlugin("EDPluginExecXscale")
        anom_merged_in = XSDataXscaleInput.copyViaDict()
        anom_merged_in.friedels_law = XSDataBoolean(True)
        anom_merged_in.merge = XSDataBoolean(True)
        self.xscale_anom_merged.dataInput = anom_merged_in
        self.xscale_anom_merged.connectSUCCESS(self.xscale_success)
        self.xscale_anom_merged.connectFAILURE(self.xscale_failure)

        self.xscale_anom_unmerged = self.loadPlugin("EDPluginExecXscale")
        anom_unmerged_in = XSDataXscaleInput.copyViaDict()
        anom_unmerged_in.friedels_law = XSDataBoolean(True)
        anom_unmerged_in.merge = XSDataBoolean(False)
        self.xscale_anom_unmerged.dataInput = anom_unmerged_in
        self.xscale_anom_unmerged.connectSUCCESS(self.xscale_success)
        self.xscale_anom_unmerged.connectFAILURE(self.xscale_failure)

        self.xscale_noanom_merged = self.loadPlugin("EDPluginExecXscale")
        noanom_merged_in = XSDataXscaleInput.copyViaDict()
        noanom_merged_in.friedels_law = XSDataBoolean(False)
        noanom_merged_in.merge = XSDataBoolean(True)
        self.xscale_noanom_merged.dataInput = noanom_merged_in
        self.xscale_noanom_merged.connectSUCCESS(self.xscale_success)
        self.xscale_noanom_merged.connectFAILURE(self.xscale_failure)

        self.xscale_noanom_unmerged = self.loadPlugin("EDPluginExecXscale")
        noanom_unmerged_in = XSDataXscaleInput.copyViaDict()
        noanom_unmerged_in.friedels_law = XSDataBoolean(False)
        noanom_unmerged_in.merge = XSDataBoolean(False)
        self.xscale_noanom_unmerged.dataInput = noanom_unmerged_in
        self.xscale_noanom_unmerged.connectSUCCESS(self.xscale_success)
        self.xscale_noanom_unmerged.connectFAILURE(self.xscale_failure)
Beispiel #12
0
    def postProcess(self, _edObject=None):
        EDPluginExecProcessScript.postProcess(self)
        self.DEBUG("EDPluginMinimalXds.postProcess")
        # Create some output data
        xsDataResult = XSDataMinimalXdsOut()

        # XDS is considered to have succeeded iff CORRECT.LP has been created
        outfile = os.path.join(self.getWorkingDirectory(), 'CORRECT.LP')
        if not os.path.isfile(outfile):
            xsDataResult.succeeded = XSDataBoolean(False)
            self.setFailure()
        else:
            xsDataResult.succeeded = XSDataBoolean(True)
        self.setDataOutput(xsDataResult)
Beispiel #13
0
    def preProcess(self, _edObject = None):
        EDPluginControl.preProcess(self)
        self.DEBUG("EDPluginControlAutoproc.preProcess")

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

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

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


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

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

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

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


        # let's make some links!
        for f in self._to_link:
            os.symlink(f, os.path.join(xds_anom_dir, os.path.basename(f)))
            os.symlink(f, os.path.join(xds_noanom_dir, os.path.basename(f)))
Beispiel #14
0
    def preProcess(self, _edObject=None):
        EDPluginControl.preProcess(self)
        self.DEBUG("EDPluginControlAutoproc.preProcess")

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

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

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

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

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

        sgre = re.compile(
            """ \* Space group = '(?P<sgstr>.*)' \(number\s+(?P<sgnumber>\d+)\)"""
        )

        sgnumber = sgstr = None

        res = XSDataPointlessOut()
        status = XSDataStatus()
        status.isSuccess = XSDataBoolean(False)
        if os.path.exists(_outputFile):
            res.status = status

            strLog = EDUtilsFile.readFile(_outputFile)
            if strLog is not None:
                # we'll apply the regexp to the whole file contents which
                # hopefully won't be that long.
                m = sgre.search(strLog)
                if m is not None:
                    d = m.groupdict()
                    sgnumber = d['sgnumber']
                    sgstr = d['sgstr']

                    res.sgnumber = XSDataInteger(sgnumber)
                    res.sgstr = XSDataString(sgstr)
                    status.isSuccess = XSDataBoolean(True)
                    # Search first for unit cell after the Laue group...
                    unitCellRe = re.compile(
                        """  Laue group confidence.+\\n\\n\s+Unit cell:(.+)""")
                    m2 = unitCellRe.search(strLog)
                    if m2 is None:
                        # Then search it from the end...
                        unitCellRe = re.compile(
                            """ \* Cell Dimensions : \(obsolete \- refer to dataset cell dimensions above\)\\n\\n(.+)"""
                        )
                        m2 = unitCellRe.search(strLog)
                    if m2 is not None:
                        listCell = m2.groups()[0].split()
                        xsDataCCP4Cell = XSDataCCP4Cell()
                        xsDataCCP4Cell.length_a = XSDataLength(listCell[0])
                        xsDataCCP4Cell.length_b = XSDataLength(listCell[1])
                        xsDataCCP4Cell.length_c = XSDataLength(listCell[2])
                        xsDataCCP4Cell.angle_alpha = XSDataAngle(listCell[3])
                        xsDataCCP4Cell.angle_beta = XSDataAngle(listCell[4])
                        xsDataCCP4Cell.angle_gamma = XSDataAngle(listCell[5])
                        res.cell = xsDataCCP4Cell
        return res
Beispiel #16
0
def process(_listInputFile,
            _output,
            dummy=0,
            autoscale=False,
            center=None,
            width=None,
            blending=None,
            mask=None):
    """
    call EDNA with this options:
    @param _listInputFile: list of input files as strings
    @param _output: output file name
    @param dummy: value for dummy pixels
    @param autoscale: shall image intensity be scaled (boolean)
    @param center: 2-list of int representing the center of the ROI
    @param width:  2-list of int representing the width of the ROI
    @param blending: blending method: max, mean or min 
    @param mask: name of the file containing the mask
    """
    xsd = XSDataInputStitchImage()
    xsd.dummyValue = XSDataDouble(dummy)
    xsd.autoscale = XSDataBoolean(autoscale)
    if blending:
        xsd.blending = XSDataString(blending)
    if mask:
        xsd.mask = XSDataImage(XSDataString(mask))
    xsd.outputImage = XSDataImage(XSDataString(_output))
    xsd.inputImages = [XSDataImage(XSDataString(i)) for i in _listInputFile]
    if isinstance(width, list):
        xsd.widthROI = [XSDataInteger(i) for i in width]
    if isinstance(center, list):
        xsd.centerROI = [XSDataInteger(i) for i in center]
    job = EDJob(EDNAPluginName)
    job.setDataInput(xsd)
    job.execute()
Beispiel #17
0
    def postProcess(self):
        self.DEBUG('Import: postProcess')
        EDPluginControl.postProcess(self)

        res = XSDataEDNAprocImportOut()
        status = XSDataStatus()
        res.status = status
        if self.dataInput.input_noanom:
            all_good = not self.anom.isFailure() and not self.noanom.isFailure(
            )
        else:
            all_good = not self.anom.isFailure()
        status.isSuccess = XSDataBoolean(all_good)
        files = list()
        if not self.anom.isFailure():
            files.append(self.anom.dataInput.output_file)
        if self.dataInput.input_noanom and not self.noanom.isFailure():
            files.append(self.noanom.dataInput.output_file)
        res.files = files

        if self.dataInput.input_noanom:
            res.pointless_sgnumber = self.noanom.dataOutput.pointless_sgnumber
            res.pointless_sgstring = self.noanom.dataOutput.pointless_sgstring
            res.pointless_cell = self.noanom.dataOutput.pointless_cell
        else:
            res.pointless_sgnumber = self.anom.dataOutput.pointless_sgnumber
            res.pointless_sgstring = self.anom.dataOutput.pointless_sgstring
            res.pointless_cell = self.anom.dataOutput.pointless_cell

        res.aimless_log_anom = self.anom.dataOutput.aimless_log

        if self.dataInput.input_noanom:
            res.aimless_log_noanom = self.noanom.dataOutput.aimless_log

        self.dataOutput = res
Beispiel #18
0
 def buildChildren(self, child_, nodeName_):
     if child_.nodeType == Node.ELEMENT_NODE and \
      nodeName_ == 'b':
         obj_ = XSDataBoolean()
         obj_.build(child_)
         self.setB(obj_)
     XSData.buildChildren(self, child_, nodeName_)
Beispiel #19
0
    def create_processing_input_file(self, processing_input_filename):
        """Creates dozor input file base on data collection parameters

        :param processing_input_filename
        :type : str
        """
        input_file = XSDataInputControlDozor()
        input_file.setTemplate(XSDataString(self.params_dict["template"]))
        input_file.setFirst_image_number(
            XSDataInteger(self.params_dict["first_image_num"]))
        input_file.setLast_image_number(
            XSDataInteger(self.params_dict["images_num"]))
        input_file.setFirst_run_number(
            XSDataInteger(self.params_dict["run_number"]))
        input_file.setLast_run_number(
            XSDataInteger(self.params_dict["run_number"]))
        input_file.setLine_number_of(
            XSDataInteger(self.params_dict["lines_num"]))
        input_file.setReversing_rotation(
            XSDataBoolean(self.params_dict["reversing_rotation"]))
        input_file.setPixelMin(
            XSDataInteger(self.detector_hwobj.get_pixel_min()))
        input_file.setPixelMax(
            XSDataInteger(self.detector_hwobj.get_pixel_max()))
        input_file.setBeamstopSize(XSDataDouble(
            self.beamstop_hwobj.get_size()))
        input_file.setBeamstopDistance(
            XSDataDouble(self.beamstop_hwobj.get_distance()))
        input_file.setBeamstopDirection(
            XSDataString(self.beamstop_hwobj.get_direction()))

        input_file.exportToFile(processing_input_filename)
 def doSuccessExecThumbnail(self, _edPlugin=None):
     EDVerbose.DEBUG(
         "EDPluginControlPyarchThumbnailGeneratorv1_0.doSuccessExecThumbnail"
     )
     self.retrieveSuccessMessages(
         _edPlugin,
         "EDPluginControlPyarchThumbnailGeneratorv1_0.doSuccessExecThumbnail"
     )
     # Retrieve the output path
     self.xsDataFilePathToThumbnail = self.edPluginExecThumbnail.getDataOutput(
     ).getThumbnailPath()
     # Run the plugin again, this time with the first thumbnail as input
     self.edPluginExecThumbnail2 = self.loadPlugin(
         self.strExecThumbnailPluginName)
     xsDataInputExecThumbnail = XSDataInputExecThumbnail()
     xsDataInputExecThumbnail.setInputImagePath(
         self.edPluginExecThumbnail.getDataOutput().getThumbnailPath())
     xsDataInputExecThumbnail.setThumbHeight(XSDataInteger(256))
     xsDataInputExecThumbnail.setThumbWidth(XSDataInteger(256))
     xsDataInputExecThumbnail.setKeepRatio(XSDataBoolean(False))
     xsDataInputExecThumbnail.setOutputPath(
         XSDataFile(
             XSDataString(self.strOutputPathWithoutExtension +
                          ".thumb.jpeg")))
     self.edPluginExecThumbnail2.setDataInput(xsDataInputExecThumbnail)
     self.edPluginExecThumbnail2.connectSUCCESS(
         self.doSuccessExecThumbnail2)
     self.edPluginExecThumbnail2.connectFAILURE(
         self.doFailureExecThumbnail2)
     self.edPluginExecThumbnail2.executeSynchronous()
Beispiel #21
0
 def doSuccessMOSFLMIndexing(self, _edPlugin=None):
     self.DEBUG(
         "EDPluginControlIndexingIndicatorsv10.doSuccessMOSFLMIndexing")
     self.synchronizeOn()
     xsDataMOSFLMIndexingOutput = self.__edPluginMOSFLMIndexing.getDataOutput(
     )
     xsDataExperimentalConditionRefined = None
     if self.hasDataInput("refinedExperimentalCondition"):
         xsDataExperimentalConditionRefined = self.getDataInput(
             "refinedExperimentalCondition")[0]
     else:
         # Use the experimental condition from the xsDataCollection
         xsDataCollection = self.getDataInput("dataCollection")[0]
         xsDataExperimentalConditionRefined = xsDataCollection.getSubWedge(
         )[0].getExperimentalCondition()
     from EDHandlerXSDataMOSFLMv10 import EDHandlerXSDataMOSFLMv10
     xsDataIndexingResult = EDHandlerXSDataMOSFLMv10.generateXSDataIndexingResult(
         xsDataMOSFLMIndexingOutput, xsDataExperimentalConditionRefined)
     xsDataCollection = self.getDataInput("dataCollection")[0]
     xsDataListImage = self.generateImageList(xsDataCollection)
     xsDataIndexingResult.setImage(xsDataListImage)
     xsDataIndexingResult.setLabelitIndexing(XSDataBoolean(False))
     self.setDataOutput(xsDataIndexingResult, "indexingResult")
     #        self.generateExecutiveSummaryMOSFLM(_edPlugin)
     self.addExecutiveSummarySeparator()
     self.addExecutiveSummaryLine("Summary of indexing with %s :" %
                                  self.__strMOSFLMIndexingPluginName)
     self.addExecutiveSummaryLine("")
     self.appendExecutiveSummary(self.__edPluginMOSFLMIndexing,
                                 "MOSFLM : ",
                                 _bAddSeparator=False)
     # Short summary:
     self.generateIndexingShortSummary(xsDataIndexingResult)
     self.synchronizeOff()
Beispiel #22
0
 def buildChildren(self, child_, nodeName_):
     if child_.nodeType == Node.ELEMENT_NODE and \
         nodeName_ == 'image':
         obj_ = XSDataFile()
         obj_.build(child_)
         self.setImage(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_)
     elif child_.nodeType == Node.ELEMENT_NODE and \
         nodeName_ == 'anomalous':
         obj_ = XSDataBoolean()
         obj_.build(child_)
         self.setAnomalous(obj_)
     elif child_.nodeType == Node.ELEMENT_NODE and \
         nodeName_ == 'spacegroup':
         obj_ = XSDataString()
         obj_.build(child_)
         self.setSpacegroup(obj_)
     XSDataInput.buildChildren(self, child_, nodeName_)
    def process(self, _edObject=None):
        EDPluginControl.process(self)
        self.DEBUG('EDPluginControlDozorAndXDSAPPv1_0.process starting')

        # Run the Dozor control plugin keeping the CBF file directory
        xsDataInputControlDozor = XSDataInputControlDozor()
        xsDataInputControlDozor.dataCollectionId = self.dataInput.dataCollectionId
        xsDataInputControlDozor.processDirectory = self.dataInput.dozorProcessDirectory
        xsDataInputControlDozor.keepCbfTmpDirectory = XSDataBoolean(True)
        edPluginControlDozor = self.loadPlugin("EDPluginControlDozorv1_0")
        edPluginControlDozor.dataInput = xsDataInputControlDozor
        edPluginControlDozor.executeSynchronous()

        # Run the XDSAPP control plugin
        xsDataInputControlXDSAPP = XSDataInputControlXDSAPP()
        xsDataInputControlXDSAPP.dataCollectionId = self.dataInput.dataCollectionId
        xsDataInputControlXDSAPP.doAnomAndNonanom = self.dataInput.doAnomAndNonanom
        xsDataInputControlXDSAPP.hdf5ToCbfDirectory = edPluginControlDozor.dataOutput.pathToCbfDirectory
        xsDataInputControlXDSAPP.processDirectory = self.dataInput.xdsappProcessDirectory
        edPluginControlXDSAPP = self.loadPlugin("EDPluginControlXDSAPPv1_0")
        edPluginControlXDSAPP.dataInput = xsDataInputControlXDSAPP
        edPluginControlXDSAPP.executeSynchronous()

        # Delete the temporary directory containing the CBF images
        shutil.rmtree(
            edPluginControlDozor.dataOutput.pathToCbfDirectory.path.value)
 def __init__(self):
     EDPluginExecProcessScript.__init__(self)
     self.setXSDataInputClass(XSDataMinimalXdsIn)
     self.setDataOutput(XSDataMinimalXdsOut())
     self.dataOutput.succeeded = XSDataBoolean(False)
     self.maxNoProcessors = 10
     self.pathToNeggiaPlugin = None
Beispiel #25
0
    def postProcess(self):
        self.DEBUG('Pointless: postProcess')
        EDPluginExecProcessScript.postProcess(self)
        output_file = self.dataInput.output_file.value

        sgre = re.compile(
            """ \* Space group = '(?P<sgstr>.*)' \(number\s+(?P<sgnumber>\d+)\)"""
        )

        sgnumber = sgstr = None
        # returns None if the file does not exist...
        log = self.readProcessLogFile()
        if log is not None:
            # we'll apply the regexp to the whole file contents which
            # hopefully won't be that long.
            m = sgre.match(log)
            if m is not None:
                d = m.groupdict()
                sgnumber = d['sgnumber']
                sgstr = d['sgstr']

        res = XSDataPointlessOut()
        if sgnumber is not None:
            res.sgnumber = XSDataInteger(sgnumber)
        if sgstr is not None:
            res.sgstr = XSDataString(sgstr)
        status = XSDataStatus()
        status.isSuccess = XSDataBoolean(os.path.exists(output_file))
        res.status = status

        self.dataOutput = res
Beispiel #26
0
 def buildChildren(self, child_, nodeName_):
     if child_.nodeType == Node.ELEMENT_NODE and \
         nodeName_ == 'image':
         obj_ = XSDataFile()
         obj_.build(child_)
         self.image.append(obj_)
     elif child_.nodeType == Node.ELEMENT_NODE and \
         nodeName_ == 'anomalous':
         obj_ = XSDataBoolean()
         obj_.build(child_)
         self.setAnomalous(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_)
Beispiel #27
0
    def process(self, _edObject=None):
        EDPluginControl.process(self)
        self.DEBUG("EDPluginWaitMultiFile.process  global time-out is set to: %s (default value)" % (self.getTimeOut()))
        self.setTimeInit()
################################################################################
# Initialize the accumulator with the query
################################################################################
        xsdiAccumulator = XSDataInputAccumulator()
        xsdQuery = XSDataQuery()
        xsdQuery.setRemoveItems(XSDataBoolean(1))
        xsdQuery.setItem(self.listXsdStrings)
        xsdiAccumulator.setQuery([xsdQuery])
        edPluginAccumulator = self.loadPlugin(self.__strControlledPluginAccumulator)
        edPluginAccumulator.setDataInput(xsdiAccumulator)
        edPluginAccumulator.connectSUCCESS(self.doSuccessAccumulator)
        edPluginAccumulator.connectFAILURE(self.doFailureAccumulator)
        edPluginAccumulator.execute()

        for oneXSDImage in self.listXsdFiles:
            xsdiWaitFile = XSDataInputWaitFile()
            xsdiWaitFile.setExpectedFile(oneXSDImage)
            xsdiWaitFile.setExpectedSize(self.dataInput.expectedSize)
            xsdiWaitFile.setTimeOut(self.dataInput.timeOut)
            edPluginWaitFile = self.loadPlugin(self.__strControlledPluginWaitFile)
            edPluginWaitFile.setDataInput(xsdiWaitFile)
            edPluginWaitFile.connectSUCCESS(self.doSuccessWaitFile)
            edPluginWaitFile.connectFAILURE(self.doFailureWaitFile)
            edPluginWaitFile.execute()
Beispiel #28
0
    def preProcess(self, _edObject=None):
        """
        The pre-process of ED Plugin Control DiffractionCT Powder Integration consists in preparing the input data for SPD Cake. 
        and declares the execution plugin as EDPluginFit2DCacke
        """
        EDPluginControl.preProcess(self)
        EDVerbose.DEBUG("EDPluginControlDCTPowderIntegrationv1_1.preProcess")
        # Load the execution plugin
        self.m_edPluginPowderIntegration = self.loadPlugin(self.m_edStringControlledPluginName)
        #Retrive its'datamodel

        xsDataInputSPDCake = XSDataInputSPDCake()

        instrumentParameters = self.getDataInput().getInstrumentParameters()
        imageParameters = self.getDataInput().getImageParameters()

        xsDataInputSPDCake.setInputFile(self.getDataInput().getImageFile())

        xsDataInputSPDCake.setWavelength(instrumentParameters.get_diffrn_radiation_wavelength())

        xsDataInputSPDCake.setSampleToDetectorDistance(instrumentParameters.get_pd_instr_dist_spec_detc())


        xsDataInputSPDCake.setAngleOfTilt(imageParameters.get_pd_instr_special_details_tilt_angle())
        xsDataInputSPDCake.setTiltRotation(imageParameters.get_pd_instr_special_details_tilt_rotation())

        xsDataInputSPDCake.setDarkCurrentImageFile(imageParameters.get_file_correction_image_dark_current())
        xsDataInputSPDCake.setFlatFieldImageFile(imageParameters.get_file_correction_image_flat_field())
        xsDataInputSPDCake.setSpatialDistortionFile(imageParameters.get_file_correction_spline_spatial_distortion())

#        EDVerbose.screen("imageParameters.get_array_element_size_1: %s" % imageParameters.get_array_element_size_1().marshal())
        xsDataInputSPDCake.setBeamCentreInPixelsX(XSDataDouble(\
                            EDUtilsUnit.getSIValue(imageParameters.get_diffrn_detector_element_center_1()) / \
                            EDUtilsUnit.getSIValue(imageParameters.get_array_element_size_1())))
        xsDataInputSPDCake.setBeamCentreInPixelsY(XSDataDouble(\
                            EDUtilsUnit.getSIValue(imageParameters.get_diffrn_detector_element_center_2()) / \
                            EDUtilsUnit.getSIValue(imageParameters.get_array_element_size_2())))
        xsDataInputSPDCake.setPixelSizeX(imageParameters.get_array_element_size_1())
                            #imageParameters.get_diffrn_detector_element_center_1())
        xsDataInputSPDCake.setPixelSizeY(imageParameters.get_array_element_size_2())
                            #imageParameters.get_diffrn_detector_element_center_1())

        xsDataInputSPDCake.setBufferSizeX(XSDataInteger(2048))
        xsDataInputSPDCake.setBufferSizeY(XSDataInteger(2048))
        xsDataInputSPDCake.setStartAzimuth(XSDataAngle(0))
        xsDataInputSPDCake.setStopAzimuth(XSDataAngle(360))
        xsDataInputSPDCake.setStepAzimuth(XSDataAngle(360))
        xsDataInputSPDCake.setOutputDirCake(self.getDataInput().getDestinationDir())
        xsDataInputSPDCake.setDeleteCorImg(XSDataBoolean(True))

        try:
            self.m_edPluginPowderIntegration.setDataInput(xsDataInputSPDCake)
        except Exception, error:
           # This exception handling needs to be rethought, see bug #43.
            errorMessage = EDMessage.ERROR_DATA_HANDLER_02 % ("EDPluginControlDCTPowderIntegrationv1_1.preProcess: Unexpected error in SPD handler: ", error)
            EDVerbose.error(errorMessage)
            self.addErrorMessage(errorMessage)
            raise RuntimeError, errorMessage
Beispiel #29
0
    def setPluginInput(self, _edPlugin):
        xsDataDiffractionPlan = XSDataDiffractionPlan()
        if (not self.__fMaxExposureTimePerDataCollection is None):
            xsDataDiffractionPlan.setMaxExposureTimePerDataCollection(XSDataTime(self.__fMaxExposureTimePerDataCollection))
        if (not self.__strForcedSpaceGroup is None):
            xsDataDiffractionPlan.setForcedSpaceGroup(XSDataString(self.__strForcedSpaceGroup))
        if (not self.__bAnomalousData is None):
            xsDataDiffractionPlan.setAnomalousData(XSDataBoolean(self.__bAnomalousData))
        if (not self.__strStrategyOption is None):
            xsDataDiffractionPlan.setStrategyOption(XSDataString(self.__strStrategyOption))
        if (not self.__strComplexity is None):
            xsDataDiffractionPlan.setComplexity(XSDataString(self.__strComplexity))
        _edPlugin.setDataInput(xsDataDiffractionPlan, "diffractionPlan")

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

        if (not self.__xsDataInputCharacterisation is None):
            _edPlugin.setDataInput(self.__xsDataInputCharacterisation, "inputCharacterisation")
        if (not self.__fFlux is None):
            _edPlugin.setDataInput(XSDataFloat(self.__fFlux), "flux")
        if (not self.__fMinExposureTimePerImage is None):
            _edPlugin.setDataInput(XSDataFloat(self.__fMinExposureTimePerImage), "minExposureTimePerImage")
        if (not self.__fBeamSize is None):
            _edPlugin.setDataInput(XSDataFloat(self.__fBeamSize), "beamSize")
        if (not self.__bTemplateMode is None):
            _edPlugin.setDataInput(XSDataBoolean(self.__bTemplateMode), "templateMode")
        if (not self.__strGeneratedTemplateFile is None):
            _edPlugin.setDataInput(XSDataString(self.__strGeneratedTemplateFile), "generatedTemplateFile")
        if (not self.__strResultsFilePath is None):
            _edPlugin.setDataInput(XSDataString(self.__strResultsFilePath), "resultsFilePath")
        if (not self.__fBeamPosX is None):
            _edPlugin.setDataInput(XSDataFloat(self.__fBeamPosX), "beamPosX")
        if (not self.__fBeamPosY is None):
            _edPlugin.setDataInput(XSDataFloat(self.__fBeamPosY), "beamPosY")
        if (not self.__iDataCollectionId is None):
            _edPlugin.setDataInput(XSDataInteger(self.__iDataCollectionId), "dataCollectionId")
        if (not self.__strShortComments is None):
            _edPlugin.setDataInput(XSDataString(self.__strShortComments), "shortComments")
        if (not self.__strComments is None):
            _edPlugin.setDataInput(XSDataString(self.__strComments), "comments")
        if (not self.__fTransmission is None):
            _edPlugin.setDataInput(XSDataDouble(self.__fTransmission), "transmission")
Beispiel #30
0
 def getDataIndexingResult(self, _edPlugin):
     """
     This method retrieves the indexing results from a MOSFLM indexing plugin.
     """
     self.verboseDebug("EDPluginControlIndexingv10.getDataIndexingResultFromMOSFLM")
     xsDataMOSFLMOutputIndexing = _edPlugin.getDataOutput()
     from EDHandlerXSDataMOSFLMv10 import EDHandlerXSDataMOSFLMv10
     xsDataIndexingResult = EDHandlerXSDataMOSFLMv10.generateXSDataIndexingResult(xsDataMOSFLMOutputIndexing, self.getExperimentalCondition())
     xsDataIndexingResult.setLabelitIndexing(XSDataBoolean(False))
     return xsDataIndexingResult