def storeResultsInISPyB(self, _strSubject, _strMessage): strSubject = _strSubject strMessage = _strMessage xsDataResultCharacterisation = self.edPluginControlInterface.getDataOutput( ).getResultCharacterisation() self.xsDataResultMXCuBE.setCharacterisationResult( xsDataResultCharacterisation) xsDataResultControlISPyB = self.edPluginControlInterface.getDataOutput( ).getResultControlISPyB() if xsDataResultControlISPyB != None: self.xsDataResultMXCuBE.setScreeningId( xsDataResultControlISPyB.getScreeningId()) if xsDataResultCharacterisation != None: self.xsDataResultMXCuBE.characterisationResult = xsDataResultCharacterisation strPathCharacterisationResult = os.path.join( self.getWorkingDirectory(), "CharacterisationResult.xml") xsDataResultCharacterisation.exportToFile( strPathCharacterisationResult) self.xsDataResultMXCuBE.setListOfOutputFiles( XSDataString(strPathCharacterisationResult)) # For the moment, create "DNA" style output directory strPathToDNAFileDirectory = self.createDNAFileDirectoryPath( xsDataResultCharacterisation) xsDataDictionaryLogFile = None if not EDUtilsPath.isALBA: if (self.createDNAFileDirectory(strPathToDNAFileDirectory)): xsDataDictionaryLogFile = self.createOutputFileDictionary( xsDataResultCharacterisation, strPathToDNAFileDirectory) strPyArchPathToDNAFileDirectory = EDHandlerESRFPyarchv1_0.createPyarchFilePath( strPathToDNAFileDirectory) if (self.createDNAFileDirectory(strPyArchPathToDNAFileDirectory)): xsDataDictionaryLogFile = self.createOutputFileDictionary( xsDataResultCharacterisation, strPyArchPathToDNAFileDirectory) self.xsDataResultMXCuBE.setOutputFileDictionary( xsDataDictionaryLogFile) if xsDataResultCharacterisation.getStatusMessage(): strMessage += "\n\n" strMessage += xsDataResultCharacterisation.getStatusMessage( ).getValue() if xsDataResultCharacterisation.getShortSummary(): strMessage += "\n\n" strMessage += xsDataResultCharacterisation.getShortSummary( ).getValue() self.sendEmail(strSubject, strMessage) # Fix for bug EDNA-55 : If burning strategy EDNA2html shouldn't be run bRunExecOutputHTML = False xsDataInputMXCuBE = self.getDataInput() xsDataDiffractionPlan = xsDataInputMXCuBE.getDiffractionPlan() if xsDataDiffractionPlan.getStrategyOption() is not None: strStrategyOption = xsDataDiffractionPlan.getStrategyOption( ).getValue() if strStrategyOption.find("-DamPar") != -1: bRunExecOutputHTML = False if (self.edPluginExecOutputHTML is not None) and bRunExecOutputHTML: self.edPluginExecOutputHTML.setDataInput( XSDataFile(XSDataString(strPathToDNAFileDirectory)), "dnaFileDirectory") self.edPluginExecOutputHTML.execute() # Fix for bug MXSUP-251: Put the BEST .par file in the EDNA characterisation root directory xsDataIntegrationResult = xsDataResultCharacterisation.getIntegrationResult( ) if xsDataIntegrationResult: listXSDataIntegrationSubWedgeResult = xsDataIntegrationResult.getIntegrationSubWedgeResult( ) for xsDataIntegrationSubWedgeResult in listXSDataIntegrationSubWedgeResult: if xsDataIntegrationSubWedgeResult.getBestfilePar( ) is not None: strBestfilePar = xsDataIntegrationSubWedgeResult.getBestfilePar( ).getValue() # Put the file one directory above the mxCuBE v1.3 plugin working directory: strDir = os.path.dirname(self.getWorkingDirectory()) strPath = os.path.join(strDir, "bestfile.par") EDUtilsFile.writeFile(strPath, strBestfilePar) break # Execute plugin which creates a simple HTML page self.executeSimpleHTML(xsDataResultCharacterisation) # Upload the best wilson plot path to ISPyB strBestWilsonPlotPath = EDHandlerXSDataISPyBv1_4.getBestWilsonPlotPath( xsDataResultCharacterisation) if strBestWilsonPlotPath is not None and strPyArchPathToDNAFileDirectory is not None: # Copy wilson path to Pyarch strBestWilsonPlotPyarchPath = os.path.join( strPyArchPathToDNAFileDirectory, os.path.basename(strBestWilsonPlotPath)) if not os.path.exists(strBestWilsonPlotPyarchPath): if not os.path.exists( os.path.dirname(strBestWilsonPlotPyarchPath)): os.makedirs( os.path.dirname(strBestWilsonPlotPyarchPath), 755) shutil.copy(strBestWilsonPlotPath, strBestWilsonPlotPyarchPath) self.DEBUG("Best wilson pyarch path: %s " % strBestWilsonPlotPyarchPath) if self.edPluginControlInterface.dataOutput.resultControlISPyB is not None: xsDataInputISPyBSetBestWilsonPlotPath = XSDataInputISPyBSetBestWilsonPlotPath( ) xsDataInputISPyBSetBestWilsonPlotPath.dataCollectionId = self.edPluginControlInterface.dataOutput.resultControlISPyB.dataCollectionId xsDataInputISPyBSetBestWilsonPlotPath.bestWilsonPlotPath = XSDataString( strBestWilsonPlotPyarchPath) edPluginSetBestWilsonPlotPath = self.loadPlugin( "EDPluginISPyBSetBestWilsonPlotPathv1_4", "ISPyBSetBestWilsonPlotPath") edPluginSetBestWilsonPlotPath.dataInput = xsDataInputISPyBSetBestWilsonPlotPath edPluginSetBestWilsonPlotPath.executeSynchronous()
def storeResultsInISPyB(self, _strSubject, _strMessage): strSubject = _strSubject strMessage = _strMessage xsDataResultCharacterisation = self.edPluginControlInterface.getDataOutput().getResultCharacterisation() if self.bIsEigerDetector: xsDataResultCharacterisation = self.makeNumberOfImagesMultipleOf100(xsDataResultCharacterisation) self.xsDataResultMXCuBE.setCharacterisationResult(xsDataResultCharacterisation) xsDataResultControlISPyB = self.edPluginControlInterface.getDataOutput().getResultControlISPyB() if xsDataResultControlISPyB != None: self.xsDataResultMXCuBE.setScreeningId(xsDataResultControlISPyB.getScreeningId()) if xsDataResultCharacterisation != None: self.xsDataResultMXCuBE.characterisationResult = xsDataResultCharacterisation strPathCharacterisationResult = os.path.join(self.getWorkingDirectory(), "CharacterisationResult.xml") xsDataResultCharacterisation.exportToFile(strPathCharacterisationResult) self.xsDataResultMXCuBE.setListOfOutputFiles(XSDataString(strPathCharacterisationResult)) # For the moment, create "DNA" style output directory strPathToDNAFileDirectory = self.createDNAFileDirectoryPath(xsDataResultCharacterisation) xsDataDictionaryLogFile = None if self.createDNAFileDirectory(strPathToDNAFileDirectory): xsDataDictionaryLogFile = self.createOutputFileDictionary( xsDataResultCharacterisation, strPathToDNAFileDirectory ) strPyArchPathToDNAFileDirectory = EDHandlerESRFPyarchv1_0.createPyarchFilePath(strPathToDNAFileDirectory) if self.createDNAFileDirectory(strPyArchPathToDNAFileDirectory): xsDataDictionaryLogFile = self.createOutputFileDictionary( xsDataResultCharacterisation, strPyArchPathToDNAFileDirectory ) self.xsDataResultMXCuBE.setOutputFileDictionary(xsDataDictionaryLogFile) if xsDataResultCharacterisation.getStatusMessage(): strMessage += "\n\n" strMessage += xsDataResultCharacterisation.getStatusMessage().getValue() if xsDataResultCharacterisation.getShortSummary(): strMessage += "\n\n" strMessage += xsDataResultCharacterisation.getShortSummary().getValue() self.sendEmail(strSubject, strMessage) # Fix for bug EDNA-55 : If burning strategy EDNA2html shouldn't be run bRunExecOutputHTML = False xsDataInputMXCuBE = self.getDataInput() xsDataDiffractionPlan = xsDataInputMXCuBE.getDiffractionPlan() if xsDataDiffractionPlan is not None and xsDataDiffractionPlan.getStrategyOption() is not None: strStrategyOption = xsDataDiffractionPlan.getStrategyOption().getValue() if strStrategyOption.find("-DamPar") != -1: bRunExecOutputHTML = False if (self.edPluginExecOutputHTML is not None) and bRunExecOutputHTML: self.edPluginExecOutputHTML.setDataInput( XSDataFile(XSDataString(strPathToDNAFileDirectory)), "dnaFileDirectory" ) self.edPluginExecOutputHTML.execute() # Fix for bug MXSUP-251: Put the BEST .par file in the EDNA characterisation root directory xsDataIntegrationResult = xsDataResultCharacterisation.getIntegrationResult() if xsDataIntegrationResult: listXSDataIntegrationSubWedgeResult = xsDataIntegrationResult.getIntegrationSubWedgeResult() for xsDataIntegrationSubWedgeResult in listXSDataIntegrationSubWedgeResult: if xsDataIntegrationSubWedgeResult.getBestfilePar() is not None: strBestfilePar = xsDataIntegrationSubWedgeResult.getBestfilePar().getValue() # Put the file one directory above the mxCuBE v1.3 plugin working directory: strDir = os.path.dirname(self.getWorkingDirectory()) strPath = os.path.join(strDir, "bestfile.par") EDUtilsFile.writeFile(strPath, strBestfilePar) break # Execute plugin which creates a simple HTML page self.executeSimpleHTML(xsDataResultCharacterisation) # Upload the best wilson plot path to ISPyB strBestWilsonPlotPath = EDHandlerXSDataISPyBv1_4.getBestWilsonPlotPath(xsDataResultCharacterisation) strBestWilsonPlotPyarchPath = None if strBestWilsonPlotPath is not None and strPyArchPathToDNAFileDirectory is not None: # Copy wilson path to Pyarch strBestWilsonPlotPyarchPath = os.path.join( strPyArchPathToDNAFileDirectory, os.path.basename(strBestWilsonPlotPath) ) if not os.path.exists(strBestWilsonPlotPyarchPath): if not os.path.exists(os.path.dirname(strBestWilsonPlotPyarchPath)): os.makedirs(os.path.dirname(strBestWilsonPlotPyarchPath), 755) shutil.copy(strBestWilsonPlotPath, strBestWilsonPlotPyarchPath) self.DEBUG("Best wilson pyarch path: %s " % strBestWilsonPlotPyarchPath) if self.edPluginControlInterface.dataOutput.resultControlISPyB is not None: xsDataInputISPyBSetBestWilsonPlotPath = XSDataInputISPyBSetBestWilsonPlotPath() xsDataInputISPyBSetBestWilsonPlotPath.dataCollectionId = ( self.edPluginControlInterface.dataOutput.resultControlISPyB.dataCollectionId ) xsDataInputISPyBSetBestWilsonPlotPath.bestWilsonPlotPath = XSDataString(strBestWilsonPlotPyarchPath) edPluginSetBestWilsonPlotPath = self.loadPlugin( "EDPluginISPyBSetBestWilsonPlotPathv1_4", "ISPyBSetBestWilsonPlotPath" ) edPluginSetBestWilsonPlotPath.dataInput = xsDataInputISPyBSetBestWilsonPlotPath edPluginSetBestWilsonPlotPath.executeSynchronous() # Only for the ESRF: if EDUtilsPath.isESRF(): # For EXI: create workflow entry with one workflow step self.edPluginStoreWorkflow = self.loadPlugin(self.strPluginStoreWorkflow) self.edPluginStoreWorkflowStep = self.loadPlugin(self.strPluginStoreWorkflowStep) self.edPluginUpdateDataCollectionGroupWorkflowId = self.loadPlugin( self.strUpdateDataCollectionGroupWorkflowId ) xsDataISPyBWorkflow = XSDataISPyBWorkflow() xsDataISPyBWorkflow.workflowType = XSDataString("Characterisation") xsDataISPyBWorkflow.workflowTitle = XSDataString("Characterisation") xsDataInputISPyBStoreWorkflow = XSDataInputISPyBStoreWorkflow() xsDataInputISPyBStoreWorkflow.workflow = xsDataISPyBWorkflow self.edPluginStoreWorkflow.dataInput = xsDataInputISPyBStoreWorkflow self.edPluginStoreWorkflow.executeSynchronous() if ( self.edPluginStoreWorkflow.dataOutput is not None and self.edPluginStoreWorkflow.dataOutput.workflowId is not None ): workflowId = self.edPluginStoreWorkflow.dataOutput.workflowId.value # Update data collection group xsDataInputISPyBUpdateDataCollectionGroupWorkflowId = ( XSDataInputISPyBUpdateDataCollectionGroupWorkflowId() ) xsDataInputISPyBUpdateDataCollectionGroupWorkflowId.workflowId = XSDataInteger(workflowId) xsDataInputISPyBUpdateDataCollectionGroupWorkflowId.fileLocation = XSDataString( os.path.dirname(self.xsDataFirstImage.path.value) ) xsDataInputISPyBUpdateDataCollectionGroupWorkflowId.fileName = XSDataString( os.path.basename(self.xsDataFirstImage.path.value) ) self.edPluginUpdateDataCollectionGroupWorkflowId.dataInput = ( xsDataInputISPyBUpdateDataCollectionGroupWorkflowId ) self.edPluginUpdateDataCollectionGroupWorkflowId.executeSynchronous() xsDataInputISPyBStoreWorkflowStep = XSDataInputISPyBStoreWorkflowStep() xsDataInputISPyBStoreWorkflowStep.workflowId = XSDataInteger(workflowId) xsDataInputISPyBStoreWorkflowStep.workflowStepType = XSDataString("Characterisation") xsDataInputISPyBStoreWorkflowStep.status = XSDataString("Success") if strBestWilsonPlotPyarchPath is not None: xsDataInputISPyBStoreWorkflowStep.imageResultFilePath = XSDataString( strBestWilsonPlotPyarchPath ) xsDataInputISPyBStoreWorkflowStep.htmlResultFilePath = XSDataString(strPyArchPathToDNAFileDirectory) if self.edPluginExecSimpleHTML.dataOutput is not None: strResultFilePath = self.edPluginExecSimpleHTML.dataOutput.pathToJsonFile.path.value # strPyarchResultFilePath = EDHandlerESRFPyarchv1_0.createPyarchFilePath(strResultFilePath) xsDataInputISPyBStoreWorkflowStep.resultFilePath = XSDataString(strResultFilePath) self.edPluginStoreWorkflowStep.dataInput = xsDataInputISPyBStoreWorkflowStep self.edPluginStoreWorkflowStep.executeSynchronous()
def storeResultsInISPyB(self, _strSubject, _strMessage): strSubject = _strSubject strMessage = _strMessage xsDataResultCharacterisation = self.edPluginControlInterface.getDataOutput().getResultCharacterisation() self.xsDataResultMXCuBE.setCharacterisationResult(xsDataResultCharacterisation) xsDataResultControlISPyB = self.edPluginControlInterface.getDataOutput().getResultControlISPyB() if xsDataResultControlISPyB != None: self.xsDataResultMXCuBE.setScreeningId(xsDataResultControlISPyB.getScreeningId()) if xsDataResultCharacterisation != None: self.xsDataResultMXCuBE.characterisationResult = xsDataResultCharacterisation strPathCharacterisationResult = os.path.join(self.getWorkingDirectory(), "CharacterisationResult.xml") xsDataResultCharacterisation.exportToFile(strPathCharacterisationResult) self.xsDataResultMXCuBE.setListOfOutputFiles(XSDataString(strPathCharacterisationResult)) # For the moment, create "DNA" style output directory strPathToDNAFileDirectory = self.createDNAFileDirectoryPath(xsDataResultCharacterisation) xsDataDictionaryLogFile = None if (self.createDNAFileDirectory(strPathToDNAFileDirectory)): xsDataDictionaryLogFile = self.createOutputFileDictionary(xsDataResultCharacterisation, strPathToDNAFileDirectory) strPyArchPathToDNAFileDirectory = EDHandlerESRFPyarchv1_0.createPyarchFilePath(strPathToDNAFileDirectory) if (self.createDNAFileDirectory(strPyArchPathToDNAFileDirectory)): xsDataDictionaryLogFile = self.createOutputFileDictionary(xsDataResultCharacterisation, strPyArchPathToDNAFileDirectory) self.xsDataResultMXCuBE.setOutputFileDictionary(xsDataDictionaryLogFile) if xsDataResultCharacterisation.getStatusMessage(): strMessage += "\n\n" strMessage += xsDataResultCharacterisation.getStatusMessage().getValue() if xsDataResultCharacterisation.getShortSummary(): strMessage += "\n\n" strMessage += xsDataResultCharacterisation.getShortSummary().getValue() self.sendEmail(strSubject, strMessage) # Fix for bug EDNA-55 : If burning strategy EDNA2html shouldn't be run bRunExecOutputHTML = False xsDataInputMXCuBE = self.getDataInput() xsDataDiffractionPlan = xsDataInputMXCuBE.getDiffractionPlan() if xsDataDiffractionPlan.getStrategyOption() is not None: strStrategyOption = xsDataDiffractionPlan.getStrategyOption().getValue() if strStrategyOption.find("-DamPar") != -1: bRunExecOutputHTML = False if (self.edPluginExecOutputHTML is not None) and bRunExecOutputHTML: self.edPluginExecOutputHTML.setDataInput(XSDataFile(XSDataString(strPathToDNAFileDirectory)), "dnaFileDirectory") self.edPluginExecOutputHTML.execute() # Fix for bug MXSUP-251: Put the BEST .par file in the EDNA characterisation root directory xsDataIntegrationResult = xsDataResultCharacterisation.getIntegrationResult() if xsDataIntegrationResult: listXSDataIntegrationSubWedgeResult = xsDataIntegrationResult.getIntegrationSubWedgeResult() for xsDataIntegrationSubWedgeResult in listXSDataIntegrationSubWedgeResult: if xsDataIntegrationSubWedgeResult.getBestfilePar() is not None: strBestfilePar = xsDataIntegrationSubWedgeResult.getBestfilePar().getValue() # Put the file one directory above the mxCuBE v1.3 plugin working directory: strDir = os.path.dirname(self.getWorkingDirectory()) strPath = os.path.join(strDir, "bestfile.par") EDUtilsFile.writeFile(strPath, strBestfilePar) break # Execute plugin which creates a simple HTML page self.executeSimpleHTML(xsDataResultCharacterisation) # Upload the best wilson plot path to ISPyB strBestWilsonPlotPath = EDHandlerXSDataISPyBv1_4.getBestWilsonPlotPath(xsDataResultCharacterisation) if strBestWilsonPlotPath is not None and strPyArchPathToDNAFileDirectory is not None: # Copy wilson path to Pyarch strBestWilsonPlotPyarchPath = os.path.join(strPyArchPathToDNAFileDirectory, os.path.basename(strBestWilsonPlotPath)) if not os.path.exists(strBestWilsonPlotPyarchPath): if not os.path.exists(os.path.dirname(strBestWilsonPlotPyarchPath)): os.makedirs(os.path.dirname(strBestWilsonPlotPyarchPath), 755) shutil.copy(strBestWilsonPlotPath, strBestWilsonPlotPyarchPath) self.DEBUG("Best wilson pyarch path: %s " % strBestWilsonPlotPyarchPath) if self.edPluginControlInterface.dataOutput.resultControlISPyB is not None: xsDataInputISPyBSetBestWilsonPlotPath = XSDataInputISPyBSetBestWilsonPlotPath() xsDataInputISPyBSetBestWilsonPlotPath.dataCollectionId = self.edPluginControlInterface.dataOutput.resultControlISPyB.dataCollectionId xsDataInputISPyBSetBestWilsonPlotPath.bestWilsonPlotPath = XSDataString(strBestWilsonPlotPyarchPath) edPluginSetBestWilsonPlotPath = self.loadPlugin("EDPluginISPyBSetBestWilsonPlotPathv1_4", "ISPyBSetBestWilsonPlotPath") edPluginSetBestWilsonPlotPath.dataInput = xsDataInputISPyBSetBestWilsonPlotPath edPluginSetBestWilsonPlotPath.executeSynchronous()