def testExecute(self):
        """
        """
        self.run()

        # Checks that there are no error messages

        plugin = self.getPlugin()

        # Checks the expected result
        strExpectedOutput = self.readAndParseFile (self.getReferenceDataOutputFile())
#        strObtainedOutput = plugin.getDataOutput().marshal() # EDUtilsTest.readAndParseFile ( self.m_edObtainedOutputDataFile )    
        EDVerbose.DEBUG("Checking obtained result...")


        xsDataResultReference = XSDataResultDiffractionCT.parseString(strExpectedOutput)
        xsDataResultObtained = plugin.getDataOutput()# XSDataResultDiffractionCT.parseString(strObtainedOutput)

        EDAssert.equal(xsDataResultReference.marshal(), xsDataResultObtained.marshal())

        ref = self.readAndParseFile(os.path.join(self.getTestsDataImagesHome(), "DCT2011March.chi"))
        obt = self.readAndParseFile(xsDataResultObtained.getIntegratedIntensities().getPath().getValue())
        EDAssert.strAlmostEqual(ref, obt, "Chi files are the same", 0.001)

# clean up SPD when finished
        EDFactoryPluginStatic.loadPlugin("EDPluginSPDCorrectv10").killAllWorkers()
def runMXv1Pipeline():
    strLogFileName = os.path.join(returnWorkingDirectory(), "wsgi-server.log")
    EDVerbose.setLogFileName(strLogFileName)
    strInput = str(request['wsgi.input'].read(int(request['CONTENT_LENGTH'])))
    if strInput:
        # Take the parameters string, split off the title and run the bash script to generate the input char. XML  
        listParams = shlex.split(strInput)
        strComments = listParams[0]          # the 1st item
        strShortComments = listParams[1]     # the 2nd item
        strWorkingDir = listParams[2]        # the 3rd item
        strHTMLResultDir = listParams[3]     # the 4th item 
        
        os.chdir(strWorkingDir)
        
        strParamString = " ".join(listParams[4:])     # all but the first four items 
        edPluginMxv1ParamsToXML = EDFactoryPluginStatic.loadPlugin('EDPluginMxv1ParamsToXMLv1_0')
        edPluginMxv1ParamsToXML.setDataInput(XSDataString(strParamString), "paramString")
        edPluginMxv1ParamsToXML.executeSynchronous()
        xsDataFile = edPluginMxv1ParamsToXML.getDataOutput()

        # Read the XML and parse it into an object hierarchy        
        strXMLFile = xsDataFile.getPath().getValue()
        f = open(strXMLFile, 'r')
        xml = f.read()
        f.close()
        xsDataInputCharacterisation = XSDataInputCharacterisation.parseString(xml)

        # Run the MXv1 application pipeline
        edApplicationMXv1Characterisation = EDApplicationMXv1Characterisation(_strPluginName="EDPluginControlInterfacev1_2", \
                               _strConfigurationFileName=strConfigurationFilePath, \
                               _xsDataInputCharacterisation=xsDataInputCharacterisation, \
                               _strComments=strComments, \
                               _strShortComments=strShortComments)
        edApplicationMXv1Characterisation.execute()

        # Run the EDNA2HTML generator on the output from the MXv1 application 
        edPluginExecOutputHTML = EDFactoryPluginStatic.loadPlugin('EDPluginExecOutputHTMLv1_0')
        edPluginExecOutputHTML.setDataInput(XSDataString(strComments), "title")
        strWorkingDir = os.path.join(strWorkingDir, edApplicationMXv1Characterisation.getWorkingDir())
        edPluginExecOutputHTML.setDataInput(XSDataString(strWorkingDir), "workingDir")
        #strBaseDir = os.path.join(strHTMLResultDir, "edna")
        #edPluginExecOutputHTML.setDataInput(XSDataString(strBaseDir), "basename")
        edPluginExecOutputHTML.setDataInput(XSDataString(strHTMLResultDir), "basename")

        edPluginExecOutputHTML.executeSynchronous()
        
        strPathToHTMLFile = ""
        if (edPluginExecOutputHTML.hasDataOutput("htmlFile")):
            strPathToHTMLFile = edPluginExecOutputHTML.getDataOutput("htmlFile")[0].getPath().getValue()
        else:
            EDVerbose.ERROR("edna-mxv1-wsgi-server: edPluginExecOutputHTML has no dataOutput htmlFile!")
            
        if strPathToHTMLFile =="":
            EDVerbose.ERROR("edna-mxv1-wsgi-server: Returning empty string")
        return strPathToHTMLFile
    else:
        return strInput
Beispiel #3
0
    def process(self):
        """
        Calls the Plugin to be executed
        """
        EDVerbose.DEBUG("EDApplicationXAFSDataProcessing.process")
        if (not self.isFailure()) and (self.__bProcess):
            edPlugin = EDFactoryPluginStatic.loadPlugin(self.getPluginName())
            if (edPlugin is not None):
                edPlugin.setBaseDirectory(
                    self.getFullApplicationWorkingDirectory())
                edPlugin.setBaseName(self.getPluginName())

                self.setPluginInput(edPlugin)

                edPlugin.connectSUCCESS(self.doSuccessActionPlugin)
                edPlugin.connectFAILURE(self.doFailureActionPlugin)
                EDVerbose.DEBUG(
                    "EDApplicationXAFSDataProcessing.process: Executing " +
                    self.getPluginName())
                edPlugin.execute()
                edPlugin.synchronize()
            else:
                EDVerbose.error(
                    "EDApplicationXAFSDataProcessing .process : plugin not loaded : %s"
                    % self.getPluginName())
                self.setFailure(True)
Beispiel #4
0
 def preProcess(self):
     """
     Initialize the plugin to be launched
     """
     EDTestCasePlugin.preProcess(self)
     if(EDUtilsPath.EDNA_SITE == None):
         raise RuntimeError, "EDNA_SITE must be set"
     # Load the plugin that should be executed
     self._edPlugin = EDFactoryPluginStatic.loadPlugin(self.getPluginName())
     if(self._edPlugin is not None):
         for strInputDataKey in self._dictStrDataInputFiles.keys():
             if (type(self._dictStrDataInputFiles[ strInputDataKey ]) == types.ListType):
                 for strDataInputFile in self._dictStrDataInputFiles[ strInputDataKey ]:
                     strXMLData = self.readAndParseFile(strDataInputFile)
                     if (strInputDataKey == self._strDefaultInputDataKey):
                         self._edPlugin.setDataInput(strXMLData)
                     else:
                         self._edPlugin.setDataInput(strXMLData, strInputDataKey)
             else:
                 strXMLData = self.readAndParseFile(self._dictStrDataInputFiles[ strInputDataKey ])
                 if (strInputDataKey == self._strDefaultInputDataKey):
                     self._edPlugin.setDataInput(strXMLData)
                 else:
                     self._edPlugin.setDataInput(strXMLData, strInputDataKey)
         #self._edPlugin.setDataInput( self._strXMLData, "inputMXCuBE" )
     else:
         EDVerbose.ERROR("Cannot load plugin: %s" % self.getPluginName())
         raise RuntimeError
     self._edPlugin.setConfiguration(self.getPluginConfiguration())
Beispiel #5
0
    def process(self):
        """
        Calls the Plugin to be executed
        """
        EDVerbose.DEBUG("EDApplicationDimplev0.process")
        if (not self.isFailure()):
            edPlugin = EDFactoryPluginStatic.loadPlugin(self.getPluginName())
            if (edPlugin is not None):
                edPlugin.setBaseDirectory(
                    self.getFullApplicationWorkingDirectory())
                edPlugin.setBaseName(self.getPluginName())

                if self.ccp4DataInputControlPipelineCalcDiffMap is None:
                    self.ccp4DataInputControlPipelineCalcDiffMap = self.createInput(
                    )
                edPlugin.setDataInput(
                    self.ccp4DataInputControlPipelineCalcDiffMap)
                edPlugin.connectSUCCESS(self.doSuccessActionPlugin)
                edPlugin.connectFAILURE(self.doFailureActionPlugin)
                EDVerbose.DEBUG("EDApplicationDimplev0.process: Executing " +
                                self.getPluginName())
                edPlugin.execute()
                edPlugin.synchronize()
            else:
                EDVerbose.error(
                    "EDApplicationDimplev0.process : plugin not loaded : %s" %
                    self.getPluginName())
                self.setFailure(True)
 def preProcess(self):
     """
     PreProcess of the execution test: download an EDF file from http://www.edna-site.org
     """
     EDTestCasePluginExecuteControlMedianFilterImagev1_0.preProcess(self)
     self.loadTestImage([ "noise2.edf", "noise3.edf", "noise4.edf", "noise5.edf", "noise6.edf"])
     acc = EDFactoryPluginStatic.loadPlugin("EDPluginAccumulatorv1_0")
     xsdIn = XSDataInputAccumulator()
     xsdIn.setItem([XSDataString(os.path.join(self.getTestsDataImagesHome(), "noise%i.edf" % i)) for i in [2, 3, 5, 6]])
     acc.setDataInput(xsdIn)
     acc.executeSynchronous()
def runXAFSPipeline():
    xmlXSDataInput = str(request['wsgi.input'].read(int(request['CONTENT_LENGTH'])))
    if xmlXSDataInput:
        edPluginControlXAFSDataProcessing = EDFactoryPluginStatic.loadPlugin('EDPluginControlXAFSDataBatchProcessingv0_1')
        edPluginControlXAFSDataProcessing.setDataInput(xmlXSDataInput)
        edPluginControlXAFSDataProcessing.executeSynchronous()
        
        return os.path.join(edPluginControlXAFSDataProcessing.getWorkingDirectory(), \
                            edPluginControlXAFSDataProcessing.returnResultsFilename())
    else:
        return xmlXSDataInput
Beispiel #8
0
def runXAFSPipeline():
    xmlXSDataInput = str(request['wsgi.input'].read(
        int(request['CONTENT_LENGTH'])))
    if xmlXSDataInput:
        edPluginControlXAFSDataProcessing = EDFactoryPluginStatic.loadPlugin(
            'EDPluginControlXAFSDataBatchProcessingv0_1')
        edPluginControlXAFSDataProcessing.setDataInput(xmlXSDataInput)
        edPluginControlXAFSDataProcessing.executeSynchronous()

        return os.path.join(edPluginControlXAFSDataProcessing.getWorkingDirectory(), \
                            edPluginControlXAFSDataProcessing.returnResultsFilename())
    else:
        return xmlXSDataInput
 def cleanUp(self, listMethods=[]):
     """
     Final hook if you need to execute something after all processes finished (like killAllWorkers in SPD) 
     @param listMethods: allows to finish some things in the plugin. 
     @type listMethods: list of strings representing names of methods of the plugin to be called.
     """
     self.waitForAllProcessToFinish()
     edPlugin = EDFactoryPluginStatic.loadPlugin(self.__strPluginName)
     for strOneMethod in  listMethods:
         try:
             print "calling edPlugin.%s" % strOneMethod
             exec "edPlugin.%s" % strOneMethod
         except:
             print "error in processing %s" % strOneMethod
Beispiel #10
0
 def process(self):
     """
     Calls the Plugin to be executed
     """
     if (not self.__bIsFailure):
         self.__edPlugin = EDFactoryPluginStatic.loadPlugin(self.__strPluginName)
         if(self.__edPlugin is not None):
             self.__edPlugin.setBaseDirectory(self.__strFullApplicationWorkingDirectory)
             self.__edPlugin.setBaseName(self.__strPluginName)
             self.__edPlugin.setDataInput(self.__strXMLData)
             self.__edPlugin.connectSUCCESS(self.doSuccessActionPlugin)
             self.__edPlugin.connectFAILURE(self.doFailureActionPlugin)
             EDVerbose.DEBUG("EDApplication.process: Executing " + self.__strPluginName)
             self.__edPlugin.execute()
             self.__edPlugin.synchronize()
         else:
             EDVerbose.error(EDMessage.ERROR_PLUGIN_NOT_LOADED_02 % ('EDApplication.process', self.__strPluginName))
             self.__bIsFailure = True
 def preProcess(self):
     """
     PreProcess of the execution test: download an EDF file from http://www.edna-site.org
     """
     EDTestCasePluginExecuteControlMedianFilterImagev1_0.preProcess(self)
     self.loadTestImage([
         "noise2.edf", "noise3.edf", "noise4.edf", "noise5.edf",
         "noise6.edf"
     ])
     acc = EDFactoryPluginStatic.loadPlugin("EDPluginAccumulatorv1_0")
     xsdIn = XSDataInputAccumulator()
     xsdIn.setItem([
         XSDataString(
             os.path.join(self.getTestsDataImagesHome(), "noise%i.edf" % i))
         for i in [2, 3, 5, 6]
     ])
     acc.setDataInput(xsdIn)
     acc.executeSynchronous()
Beispiel #12
0
 def loadPlugin(self, _strPluginToBeControlledName=None, _strBaseName=None):
     """
     This method loads and returns a reference to the plugin to be controlled.
     
     The name of the plugin to be controlled can either be passed as an
     argument, or bet set before calling this method using the 
     "setPluginToBeControlledName". 
     
     The base name of the plugin to be controlled is used as the working
     directory name of the plugin in question. If no argument is supplied
     the name of the plugin is used as base name. In the case of creation of
     several plugins to be launched simultaneously, the base name should be
     different for each plugin and hence must be provided explicitly.
     """
     EDVerbose.DEBUG("EDPluginControl.loadPlugin")
     if (_strPluginToBeControlledName is None):
         strPluginName = self.__strPluginToBeControlledName
     else:
         strPluginName = _strPluginToBeControlledName
     edPlugin = EDFactoryPluginStatic.loadPlugin(strPluginName)
     if (edPlugin is None):
         strErrorMessage = "EDPluginControl.loadPlugin : Cannot load plugin %s" % strPluginName
         EDVerbose.error(strErrorMessage)
         self.addErrorMessage(strErrorMessage)
         raise RuntimeError, strErrorMessage
     else:
         self.__listOfLoadedPlugins.append(edPlugin)
     edPlugin.setBaseDirectory(self.getWorkingDirectory())
     if (_strBaseName is None):
         # Check if base name exists. OBS! Not thread safe so please set explicitly
         # _strBaseName for multi-threaded code
         strRenamedPlugin = self.compactPluginName(strPluginName)
         strNewWorkingDirectory = os.path.join(self.getWorkingDirectory(),
                                               strRenamedPlugin)
         if (os.path.exists(strNewWorkingDirectory)):
             edPlugin.setBaseName(edPlugin.createBaseName())
         else:
             edPlugin.setBaseName(strRenamedPlugin)
     else:
         edPlugin.setBaseName(_strBaseName)
     return edPlugin
    def process(self):
        """
        Calls the Plugin to be executed
        """
        EDVerbose.DEBUG("EDApplicationXAFSBatchProcessing.process")
        if (not self.isFailure()) and (self.__bProcess):
            self.__edPlugin = EDFactoryPluginStatic.loadPlugin(self.getPluginName())
            if(self.__edPlugin is not None):
                self.__edPlugin.setBaseDirectory(self.getFullApplicationWorkingDirectory())
                self.__edPlugin.setBaseName(self.getPluginName())

                self.setPluginInput(self.__edPlugin)

                self.__edPlugin.connectSUCCESS(self.doSuccessActionPlugin)
                self.__edPlugin.connectFAILURE(self.doFailureActionPlugin)
                EDVerbose.DEBUG("EDApplicationXAFSBatchProcessing.process: Executing " + self.getPluginName())
                self.__edPlugin.execute()
                self.__edPlugin.synchronize()
            else:
                EDVerbose.error("EDApplicationXAFSBatchProcessing .process : plugin not loaded : %s" % self.getPluginName())
                self.setFailure(True)
Beispiel #14
0
 def loadPlugins(self):
     """
     This method loads and returns a list of references to the plugins to be controlled.
     
     The name of the plugin to be controlled is set set before calling this method using the 
     "setControlledPluginName" method. 
     
     The base name of the plugin to be controlled is used as the working
     directory name of the plugin in question. The name of the plugin is used as 
     base name. 
     """
     EDVerbose.DEBUG("EDPluginControl.loadPlugins")
     listKeys = self.__dictControlledPlugins.keys()
     listLoadedPlugins = []
     for strKey in listKeys:
         strPluginName = self.__dictControlledPlugins[strKey]
         edPlugin = EDFactoryPluginStatic.loadPlugin(strPluginName)
         edPlugin.setBaseDirectory(self.getWorkingDirectory())
         edPlugin.setBaseName(strPluginName)
         listLoadedPlugins.append(edPlugin)
     return listLoadedPlugins
Beispiel #15
0
 def loadPlugins(self):
     """
     This method loads and returns a list of references to the plugins to be controlled.
     
     The name of the plugin to be controlled is set set before calling this method using the 
     "setControlledPluginName" method. 
     
     The base name of the plugin to be controlled is used as the working
     directory name of the plugin in question. The name of the plugin is used as 
     base name. 
     """
     EDVerbose.DEBUG("EDPluginControl.loadPlugins")
     listKeys = self.__dictControlledPlugins.keys()
     listLoadedPlugins = []
     for strKey in listKeys:
         strPluginName = self.__dictControlledPlugins[strKey]
         edPlugin = EDFactoryPluginStatic.loadPlugin(strPluginName)
         edPlugin.setBaseDirectory(self.getWorkingDirectory())
         edPlugin.setBaseName(strPluginName)
         listLoadedPlugins.append(edPlugin)
     return listLoadedPlugins
Beispiel #16
0
 def loadPlugin(self, _strPluginToBeControlledName=None, _strBaseName=None):
     """
     This method loads and returns a reference to the plugin to be controlled.
     
     The name of the plugin to be controlled can either be passed as an
     argument, or bet set before calling this method using the 
     "setPluginToBeControlledName". 
     
     The base name of the plugin to be controlled is used as the working
     directory name of the plugin in question. If no argument is supplied
     the name of the plugin is used as base name. In the case of creation of
     several plugins to be launched simultaneously, the base name should be
     different for each plugin and hence must be provided explicitly.
     """
     EDVerbose.DEBUG("EDPluginControl.loadPlugin")
     if (_strPluginToBeControlledName is None):
         strPluginName = self.__strPluginToBeControlledName
     else:
         strPluginName = _strPluginToBeControlledName
     edPlugin = EDFactoryPluginStatic.loadPlugin(strPluginName)
     if (edPlugin is None):
         strErrorMessage = "EDPluginControl.loadPlugin : Cannot load plugin %s" % strPluginName
         EDVerbose.error(strErrorMessage)
         self.addErrorMessage(strErrorMessage)
         raise RuntimeError, strErrorMessage
     else:
         self.__listOfLoadedPlugins.append(edPlugin)
     edPlugin.setBaseDirectory(self.getWorkingDirectory())
     if (_strBaseName is None):
         # Check if base name exists. OBS! Not thread safe so please set explicitly
         # _strBaseName for multi-threaded code
         strRenamedPlugin = self.compactPluginName(strPluginName)
         strNewWorkingDirectory = os.path.join(self.getWorkingDirectory(), strRenamedPlugin)
         if (os.path.exists(strNewWorkingDirectory)):
             edPlugin.setBaseName(edPlugin.createBaseName())
         else:
             edPlugin.setBaseName(strRenamedPlugin)
     else:
         edPlugin.setBaseName(_strBaseName)
     return edPlugin
Beispiel #17
0
 def process(self):
     """
     Calls the Plugin to be executed
     """
     EDVerbose.DEBUG("EDApplicationDimplev0.process")
     if (not self.isFailure()):
         edPlugin = EDFactoryPluginStatic.loadPlugin(self.getPluginName())
         if(edPlugin is not None):
             edPlugin.setBaseDirectory(self.getFullApplicationWorkingDirectory())
             edPlugin.setBaseName(self.getPluginName())
             
             if self.ccp4DataInputControlPipelineCalcDiffMap is None:
                 self.ccp4DataInputControlPipelineCalcDiffMap = self.createInput()
             edPlugin.setDataInput(self.ccp4DataInputControlPipelineCalcDiffMap)
             edPlugin.connectSUCCESS(self.doSuccessActionPlugin)
             edPlugin.connectFAILURE(self.doFailureActionPlugin)
             EDVerbose.DEBUG("EDApplicationDimplev0.process: Executing " + self.getPluginName())
             edPlugin.execute()
             edPlugin.synchronize()
         else:
             EDVerbose.error("EDApplicationDimplev0.process : plugin not loaded : %s" % self.getPluginName())
             self.setFailure(True)
        serialNumber = int(dictMatch["serialNumber"])
        imageNumber = int(dictMatch["imageNumber"])
        listSerialNumber.append((serialNumber, imageNumber))
        if firstSerialNumber is None or firstSerialNumber > serialNumber:
            firstSerialNumber = serialNumber

for serialNumber, imageNumber in listSerialNumber:
    imagePath = "{0}_{1:04d}.h5".format(imagePrefixAndRunNumber,
                                        int(imageNumber))
    xsDataInputControlH5ToCBF = XSDataInputControlH5ToCBF()
    xsDataInputControlH5ToCBF.hdf5File = XSDataFile(
        XSDataString(os.path.join(imageDirectory, imagePath)))
    newImageNumber = serialNumber - firstSerialNumber + 1
    xsDataInputControlH5ToCBF.imageNumber = XSDataInteger(1)
    xsDataInputControlH5ToCBF.hdf5ImageNumber = XSDataInteger(serialNumber)
    xsDataInputControlH5ToCBF.forcedOutputImageNumber = XSDataInteger(
        newImageNumber)
    edPlugin = EDFactoryPluginStatic.loadPlugin("EDPluginControlH5ToCBFv1_1")
    edPlugin.dataInput = xsDataInputControlH5ToCBF
    edPlugin.setBaseDirectory(pluginBaseDir)
    edPlugin.setBaseName(baseName)
    edPlugin.executeSynchronous()

#
# Now the edApplicationMXv1Characterisation can be imported and started
#
from EDApplicationMXv1Characterisation import EDApplicationMXv1Characterisation
edApplicationMXv1Characterisation = EDApplicationMXv1Characterisation(_strPluginName="EDPluginControlInterfacev1_2", \
                               _strConfigurationFileName=strConfigurationFilePath)
edApplicationMXv1Characterisation.execute()
Beispiel #19
0
import sys

sys.path.append("/opt/pxsoft/EDNA/vMX/edna/kernel/src")

from EDFactoryPluginStatic import EDFactoryPluginStatic

from XSDataCommon import XSDataString
from XSDataCommon import XSDataFile

EDFactoryPluginStatic.loadModule("XSDataCCP4v1_0")
from XSDataCCP4v1_0 import XSDataInputDimple

xsDataInputDimple = XSDataInputDimple()
xsDataInputDimple.mtz = XSDataFile(
    XSDataString(
        "/mntdirect/_sware/exp/pxsoft/EDNA/vMX/edna/tests/data/images/dimple_noanom_aimless.mtz"
    ))
xsDataInputDimple.pdb = XSDataFile(
    XSDataString(
        "/mntdirect/_sware/exp/pxsoft/EDNA/vMX/edna/tests/data/images/dimple_model.pdb"
    ))

edPluginExecDimple = EDFactoryPluginStatic.loadPlugin("EDPluginExecDimplev1_0")
edPluginExecDimple.dataInput = xsDataInputDimple
edPluginExecDimple.executeSynchronous()
print(edPluginExecDimple.dataOutput.marshal())

print edPluginExecDimple.dataOutput.refmac5restrLog
Beispiel #20
0
 for iIndex, strArg in enumerate(sys.argv[1:]):
     strarg = strArg.lower()
     if strarg == "--verbose":
         EDVerbose.setVerboseOn()
     elif strarg == "--debug":
         EDVerbose.setVerboseDebugOn()
     strArgPath = strArg
     if os.path.dirname(strArgPath) == "":
         strArgPath = os.path.join(strCwd, strArg)
     strArgPathAbsolute = os.path.abspath(strArgPath)
     if os.path.exists(strArgPathAbsolute):
         listPaths.append(strArgPathAbsolute)
 if listPaths == []:
     EDVerbose.ERROR("No valid XML file given as input!")
     EDVerbose.ERROR("Arguments: %r" % sys.argv)
     EDVerbose.ERROR("Usage: edna-autoproc2ispyb path_to_xml_file [--debug]")
     sys.exit(1)
 for strPath in listPaths:
     EDVerbose.screen("Starting EDNA AutoProc -> ISPyB for file %s" % strPath)
     xsDataInputStoreAutoProc = XSDataInputStoreAutoProc()
     strXMLAutoProcContainer = EDUtilsFile.readFile(strPath)
     xsDataAutoProcContainer = AutoProcContainer.parseString(strXMLAutoProcContainer)
     if xsDataAutoProcContainer is None:
         EDVerbose.WARNING("Couldn't parse file %s" % strPath)
     else:
         xsDataInputStoreAutoProc.setAutoProcContainer(xsDataAutoProcContainer)
         edPluginISPyBStoreAutoProc = EDFactoryPluginStatic.loadPlugin("EDPluginISPyBStoreAutoProcv1_4")
         edPluginISPyBStoreAutoProc.setDataInput(xsDataInputStoreAutoProc)
         edPluginISPyBStoreAutoProc.connectSUCCESS(successAction)
         edPluginISPyBStoreAutoProc.connectFAILURE(failureAction)
         edPluginISPyBStoreAutoProc.executeSynchronous()
Beispiel #21
0
 def preProcess(self, ):
     self.edluginHDF5 = EDFactoryPluginStatic.loadPlugin("EDPluginHDF5")
Beispiel #22
0
        pyStrEdnaHomePath = os.sep.join(pyLPath[:-5])
    else:
        print ("Problem in the EDNA_HOME path ..." + pyStrEdnaHomePath)
        sys.exit()

    os.environ["EDNA_HOME"] = pyStrEdnaHomePath



sys.path.append(os.path.join(os.environ["EDNA_HOME"], "kernel", "src"))
sys.path.append(os.path.join(os.environ["EDNA_HOME"], "kernel", "tests", "src"))
from EDVerbose import EDVerbose
from EDParallelExecute import EDParallelExecute
from EDFactoryPluginStatic import EDFactoryPluginStatic
EDFactoryPluginStatic.loadModule("XSDataID11v1_0")
edPluginSPD = EDFactoryPluginStatic.loadPlugin("EDPluginSPDCakev1_5")

from XSDataID11v1_0 import XSDataInputID11, XSDataFile, XSDataString, XSDataBoolean
EDNAPluginName = "EDPluginControlID11v1_0"
xsdParam = XSDataFile()
xsdOutputDir = None
xsdCorrectMask = None

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  
Beispiel #23
0
def run(token, projectId, runId, pdbFileId, mtzFileId, **kwargs):
    startDate = datetime.datetime.now()
    dstPdbFileName = 'pdbFile.pdb'
    dstMtzFileName = 'mtz.mtz'

    # Config file
    config = ConfigParser.ConfigParser()
    config.read(
        '/users/opd29/passerelle-edm/scripts/extispyb/extispyb.properties')

    # Connection parameters
    urlExtISPyB = config.get('Connection', 'urlExtISPyB')
    urlISPyB = config.get('Connection', 'urlISPyB')

    # Creating Working folder
    workingFolder = prepareWorkingFolder()

    # Getting PDB input
    os.chdir(workingFolder)
    filePdbUrl = "%s/rest/file/%s/download" % (urlExtISPyB, pdbFileId)
    urllib.urlretrieve(filePdbUrl, dstPdbFileName)

    # Getting MTZ input
    fileMtzUrl = "%s/rest/file/%s/download" % (urlExtISPyB, mtzFileId)
    urllib.urlretrieve(fileMtzUrl, dstMtzFileName)

    xsDataInputDimple = XSDataInputDimple()
    xsDataInputDimple.mtz = XSDataFile(
        XSDataString(workingFolder + "/" + dstMtzFileName))
    xsDataInputDimple.pdb = XSDataFile(
        XSDataString(workingFolder + "/" + dstPdbFileName))

    edPluginExecDimple = EDFactoryPluginStatic.loadPlugin(
        "EDPluginExecDimplev1_0")
    edPluginExecDimple.dataInput = xsDataInputDimple
    edPluginExecDimple.executeSynchronous()

    # Uploading files
    ids = []
    for i in range(len(edPluginExecDimple.dataOutput.getBlob())):
        ids.append(
            uploadFile(
                urlExtISPyB,
                edPluginExecDimple.dataOutput.getBlob()
                [i].getPath().getValue(), "blob"))

    ids.append(
        uploadFile(
            urlExtISPyB,
            edPluginExecDimple.dataOutput.getFinalMtz().getPath().getValue(),
            "finalMtz"))
    ids.append(
        uploadFile(
            urlExtISPyB,
            edPluginExecDimple.dataOutput.getFinalPdb().getPath().getValue(),
            "finalPdb"))
    ids.append(
        uploadFile(urlExtISPyB,
                   edPluginExecDimple.dataOutput.getLog().getPath().getValue(),
                   "log"))
    ids.append(
        uploadFile(
            urlExtISPyB,
            edPluginExecDimple.dataOutput.getFindBlobsLog().getPath().getValue(
            ), "findBlobsLog"))
    ids.append(
        uploadFile(
            urlExtISPyB,
            edPluginExecDimple.dataOutput.getRefmac5restrLog().getPath().
            getValue(), "refmac5restrLog"))

    #ids = uploadFiles(urlExtISPyB, files)

    # Upload results
    url = urlExtISPyB + "/rest/{token}/project/" + projectId + "/run/" + runId + "/job/add"
    params = {
        'name': 'Dimple',
        'startDate': startDate,
        'endDate': datetime.datetime.now(),
        'version': 'v2.8.3 (r2962)',
        'output': json.dumps(ids),
        'status': 'FINISHED'
    }

    r = requests.post(url, data=params)

    if r.status_code == 200:
        setFinished(projectId, urlExtISPyB, runId)
    else:
        setError(projectId, urlExtISPyB, runId)
    return {
        "ids": ids,
        "Output": edPluginExecDimple.dataOutput.marshal(),
        "dstMtzFileName": dstMtzFileName,
        "dstPdbFileName": dstPdbFileName
    }
Beispiel #24
0
 def initPlugin(self, strPluginName):
     plugin = EDFactoryPluginStatic.loadPlugin(strPluginName)
     if plugin is None:
         return "Plugin not found: %s" % strPluginName
     else:
         return "Plugin loaded: %s" % strPluginName
        dictMatch = m.groupdict()
        serialNumber = int(dictMatch["serialNumber"])
        imageNumber = int(dictMatch["imageNumber"])
        listSerialNumber.append((serialNumber, imageNumber))
        if firstSerialNumber is None or firstSerialNumber > serialNumber:
            firstSerialNumber = serialNumber



for serialNumber, imageNumber in listSerialNumber:
    imagePath = "{0}_{1:04d}.h5".format(imagePrefixAndRunNumber, int(imageNumber))
    xsDataInputControlH5ToCBF = XSDataInputControlH5ToCBF()
    xsDataInputControlH5ToCBF.hdf5File = XSDataFile(XSDataString(os.path.join(imageDirectory, imagePath)))
    newImageNumber = serialNumber - firstSerialNumber + 1
    xsDataInputControlH5ToCBF.imageNumber = XSDataInteger(1)
    xsDataInputControlH5ToCBF.hdf5ImageNumber = XSDataInteger(serialNumber)
    xsDataInputControlH5ToCBF.forcedOutputImageNumber = XSDataInteger(newImageNumber)
    edPlugin = EDFactoryPluginStatic.loadPlugin("EDPluginControlH5ToCBFv1_1")
    edPlugin.dataInput = xsDataInputControlH5ToCBF
    edPlugin.setBaseDirectory(pluginBaseDir)
    edPlugin.setBaseName(baseName)
    edPlugin.executeSynchronous()

#
# Now the edApplicationMXv1Characterisation can be imported and started
#
from EDApplicationMXv1Characterisation import EDApplicationMXv1Characterisation
edApplicationMXv1Characterisation = EDApplicationMXv1Characterisation(_strPluginName="EDPluginControlInterfacev1_2", \
                               _strConfigurationFileName=strConfigurationFilePath)
edApplicationMXv1Characterisation.execute()
Beispiel #26
0
        sys.exit(1)
    for strPath in listPaths:
        EDVerbose.screen("Starting EDNA AutoProc -> ISPyB for file %s" %
                         strPath)
        xsDataInputStoreAutoProc = XSDataInputStoreAutoProc()
        strXMLAutoProcContainer = EDUtilsFile.readFile(strPath)
        xsDataAutoProcContainer = AutoProcContainer.parseString(
            strXMLAutoProcContainer)
        if xsDataAutoProcContainer is None:
            EDVerbose.WARNING("Couldn't parse file %s" % strPath)
        else:
            if xsDataAutoProcContainer.AutoProcProgramContainer.AutoProcProgram.processingStatus == "True":
                xsDataAutoProcContainer.AutoProcProgramContainer.AutoProcProgram.processingStatus = "SUCCESS"
            xsDataInputStoreAutoProc.setAutoProcContainer(
                xsDataAutoProcContainer)
            edPluginISPyBStoreAutoProc = EDFactoryPluginStatic.loadPlugin(
                "EDPluginISPyBStoreAutoProcv1_4")
            edPluginISPyBStoreAutoProc.setDataInput(xsDataInputStoreAutoProc)
            edPluginISPyBStoreAutoProc.executeSynchronous()
            if edPluginISPyBStoreAutoProc.isFailure():
                EDVerbose.ERROR("XML data not stored in ISPyB")
            else:
                xsDataResultISPyBStoreAutoProc = edPluginISPyBStoreAutoProc.dataOutput
                EDVerbose.screen("XML data sucessfully stored in ISPyB")
                if xsDataResultISPyBStoreAutoProc.autoProcScalingId is not None:
                    EDVerbose.screen(
                        "autoProcScalingId: %d" %
                        xsDataResultISPyBStoreAutoProc.autoProcScalingId.value)
                else:
                    EDVerbose.warning("No autoProcScalingId in results!")
from XSDataGridScreeningv1_0 import XSDataInputGridScreening


if __name__ == '__main__':
    strPathToTempDir = tempfile.mkdtemp(prefix="edna-image-quality-indicators_")
    os.chdir(strPathToTempDir)
    EDVerbose.setLogFileName(os.path.join(strPathToTempDir, "edna.log"))
    # Popolate input data
    EDVerbose.screen("Starting EDNA image quality indicators processing")
    EDVerbose.screen("Arguments: %r" % sys.argv)
    bVerbose = False
    bDebug = False
    listPaths = []
    for iIndex, strArg in enumerate(sys.argv[1:]):
        strarg = strArg.lower()
        if strarg == "--verbose":
            EDVerbose.setVerboseOn()
        elif strarg == "--debug":
            EDVerbose.setVerboseDebugOn()
        if os.path.exists(strArg):
            listPaths.append(os.path.abspath(strArg))
    for strPath in listPaths:
        xsDataInputGridScreening = XSDataInputGridScreening()
        xsDataFile = XSDataFile()
        xsDataFile.setPath(XSDataString(strPath))
        xsDataInputGridScreening.setImageFile(xsDataFile)
        xsDataInputGridScreening.setDoOnlyImageQualityIndicators(XSDataBoolean(True))
        xsDataInputGridScreening.setStoreImageQualityIndicatorsInISPyB(XSDataBoolean(True))
        edPluginGridScreening = EDFactoryPluginStatic.loadPlugin("EDPluginControlGridScreeningv1_0")
        edPluginGridScreening.setDataInput(xsDataInputGridScreening)
        edPluginGridScreening.executeSynchronous()
Beispiel #28
0
 def loadPlugin(cls, _strPluginName):
     EDVerbose.WARNING("The use of EDApplication.loadPlugin is deprecated. Please use EDFactoryPluginStatic.getFactoryPlugin instead.")
     return EDFactoryPluginStatic.loadPlugin(_strPluginName)
 strPathToTempDir = tempfile.mkdtemp(
     prefix="edna-image-quality-indicators_")
 os.chdir(strPathToTempDir)
 EDVerbose.setLogFileName(os.path.join(strPathToTempDir, "edna.log"))
 # Popolate input data
 EDVerbose.screen("Starting EDNA image quality indicators processing")
 EDVerbose.screen("Arguments: %r" % sys.argv)
 bVerbose = False
 bDebug = False
 listPaths = []
 for iIndex, strArg in enumerate(sys.argv[1:]):
     strarg = strArg.lower()
     if strarg == "--verbose":
         EDVerbose.setVerboseOn()
     elif strarg == "--debug":
         EDVerbose.setVerboseDebugOn()
     if os.path.exists(strArg):
         listPaths.append(os.path.abspath(strArg))
 for strPath in listPaths:
     xsDataInputGridScreening = XSDataInputGridScreening()
     xsDataFile = XSDataFile()
     xsDataFile.setPath(XSDataString(strPath))
     xsDataInputGridScreening.setImageFile(xsDataFile)
     xsDataInputGridScreening.setDoOnlyImageQualityIndicators(
         XSDataBoolean(True))
     xsDataInputGridScreening.setStoreImageQualityIndicatorsInISPyB(
         XSDataBoolean(True))
     edPluginGridScreening = EDFactoryPluginStatic.loadPlugin(
         "EDPluginControlGridScreeningv1_0")
     edPluginGridScreening.setDataInput(xsDataInputGridScreening)
     edPluginGridScreening.executeSynchronous()
 def preProcess(self,):
     self.edluginHDF5 = EDFactoryPluginStatic.loadPlugin("EDPluginHDF5")
def runMXv1Pipeline():
    strLogFileName = os.path.join(returnWorkingDirectory(), "wsgi-server.log")
    EDVerbose.setLogFileName(strLogFileName)
    strInput = str(request['wsgi.input'].read(int(request['CONTENT_LENGTH'])))
    if strInput:
        # Take the parameters string, split off the title and run the bash script to generate the input char. XML
        listParams = shlex.split(strInput)
        strComments = listParams[0]  # the 1st item
        strShortComments = listParams[1]  # the 2nd item
        strWorkingDir = listParams[2]  # the 3rd item
        strHTMLResultDir = listParams[3]  # the 4th item

        os.chdir(strWorkingDir)

        strParamString = " ".join(
            listParams[4:])  # all but the first four items
        edPluginMxv1ParamsToXML = EDFactoryPluginStatic.loadPlugin(
            'EDPluginMxv1ParamsToXMLv1_0')
        edPluginMxv1ParamsToXML.setDataInput(XSDataString(strParamString),
                                             "paramString")
        edPluginMxv1ParamsToXML.executeSynchronous()
        xsDataFile = edPluginMxv1ParamsToXML.getDataOutput()

        # Read the XML and parse it into an object hierarchy
        strXMLFile = xsDataFile.getPath().getValue()
        f = open(strXMLFile, 'r')
        xml = f.read()
        f.close()
        xsDataInputCharacterisation = XSDataInputCharacterisation.parseString(
            xml)

        # Run the MXv1 application pipeline
        edApplicationMXv1Characterisation = EDApplicationMXv1Characterisation(_strPluginName="EDPluginControlInterfacev1_2", \
                               _strConfigurationFileName=strConfigurationFilePath, \
                               _xsDataInputCharacterisation=xsDataInputCharacterisation, \
                               _strComments=strComments, \
                               _strShortComments=strShortComments)
        edApplicationMXv1Characterisation.execute()

        # Run the EDNA2HTML generator on the output from the MXv1 application
        edPluginExecOutputHTML = EDFactoryPluginStatic.loadPlugin(
            'EDPluginExecOutputHTMLv1_0')
        edPluginExecOutputHTML.setDataInput(XSDataString(strComments), "title")
        strWorkingDir = os.path.join(
            strWorkingDir, edApplicationMXv1Characterisation.getWorkingDir())
        edPluginExecOutputHTML.setDataInput(XSDataString(strWorkingDir),
                                            "workingDir")
        #strBaseDir = os.path.join(strHTMLResultDir, "edna")
        #edPluginExecOutputHTML.setDataInput(XSDataString(strBaseDir), "basename")
        edPluginExecOutputHTML.setDataInput(XSDataString(strHTMLResultDir),
                                            "basename")

        edPluginExecOutputHTML.executeSynchronous()

        strPathToHTMLFile = ""
        if (edPluginExecOutputHTML.hasDataOutput("htmlFile")):
            strPathToHTMLFile = edPluginExecOutputHTML.getDataOutput(
                "htmlFile")[0].getPath().getValue()
        else:
            EDVerbose.ERROR(
                "edna-mxv1-wsgi-server: edPluginExecOutputHTML has no dataOutput htmlFile!"
            )

        if strPathToHTMLFile == "":
            EDVerbose.ERROR("edna-mxv1-wsgi-server: Returning empty string")
        return strPathToHTMLFile
    else:
        return strInput
Beispiel #32
0
 def initPlugin(self, strPluginName):
     plugin = EDFactoryPluginStatic.loadPlugin(strPluginName)
     if plugin is None:
         return "Plugin not found: %s" % strPluginName
     else:
         return "Plugin loaded: %s" % strPluginName