def testCheckParameters(self): xsDataInputControlISPyB = XSDataInputControlISPyB() xsDataResultCharacterisation = XSDataResultCharacterisation() xsDataInputControlISPyB.setCharacterisationResult(xsDataResultCharacterisation) edPluginControlISPyB = self.createPlugin() edPluginControlISPyB.setDataInput(xsDataInputControlISPyB) edPluginControlISPyB.checkParameters()
def testCheckParameters(self): xsDataInputControlISPyB = XSDataInputControlISPyB() xsDataResultCharacterisation = XSDataResultCharacterisation xsDataInputControlISPyB.setCharacterisationResult( xsDataResultCharacterisation) edPluginControlISPyB = self.createPlugin() edPluginControlISPyB.setDataInput(xsDataInputControlISPyB) edPluginControlISPyB.checkParameters()
def testGenerateXSDataInputISPyB(self): """ This method is testing the generation of the XSDataInputISPyB object given a XSDataIndexingInput object. """ strReferenceInputControlISPyBFile = EDUtilsPath.mergePath( self.strDataPath, "XSDataInputControlISPyB_reference.xml") strPath = os.path.join(self.strDataPath, strReferenceInputControlISPyBFile) strXMLIndexingInput = self.readAndParseFile(strPath) from XSDataMXv1 import XSDataInputControlISPyB xsDataInputControlISPyB = XSDataInputControlISPyB.parseString( strXMLIndexingInput) from EDHandlerXSDataISPyBv1_1 import EDHandlerXSDataISPyBv1_1 xsDataInputISPyB = EDHandlerXSDataISPyBv1_1.generateXSDataInputISPyB( xsDataInputControlISPyB) strReferenceInputISPyBFile = EDUtilsPath.mergePath( self.strDataPath, "XSDataInputISPyB_reference.xml") strReferencePath = os.path.join(self.strDataPath, strReferenceInputISPyBFile) strXMLInputISPyBReference = self.readAndParseFile(strReferencePath) EDFactoryPluginStatic.loadModule("XSDataISPyBv1_1") from XSDataISPyBv1_1 import XSDataInputISPyB xsDataInputISPyBReference = XSDataInputISPyB.parseString( strXMLInputISPyBReference) # Remove the time strings since they otherwise make the test fail xsDataInputISPyBReference.getScreening().setTimeStamp(None) xsDataInputISPyB.getScreening().setTimeStamp(None) EDAssert.equal(xsDataInputISPyBReference.marshal(), xsDataInputISPyB.marshal())
def testGetBestWilsonPlotPath(self): strReferenceInputControlISPyBFile = EDUtilsPath.mergePath(self.strDataPath, "XSDataInputControlISPyB_reference.xml") strPath = os.path.join(self.strDataPath, strReferenceInputControlISPyBFile) strXMLIndexingInput = EDUtilsFile.readFileAndParseVariables(strPath, self.dictReplace) xsDataInputControlISPyB = XSDataInputControlISPyB.parseString(strXMLIndexingInput) xsDataCharacterisationResult = xsDataInputControlISPyB.characterisationResult strPath = EDHandlerXSDataISPyBv1_4.getBestWilsonPlotPath(xsDataCharacterisationResult) EDAssert.equal(True, strPath.endswith("B.jpg"), "Wilson plot path extracted from characterisation results")
def storeResultsInISPyB(self, _edPlugin=None): self.DEBUG("EDPluginControlInterfacev1_3.storeResultsInISPyB") if (self.edPluginControlISPyB is not None): # Execute the ISPyB control plugin xsDataInputControlISPyB = XSDataInputControlISPyB() xsDataInputControlISPyB.setCharacterisationResult(self.edPluginControlCharacterisation.getDataOutput()) if (not self.iDataCollectionId is None): dataCollectionGroupId = self.getDataCollectionGroupId(self.iDataCollectionId) xsDataInputControlISPyB.setDataCollectionGroupId(XSDataInteger(dataCollectionGroupId)) if (not self.strShortComments is None): self.edPluginControlISPyB.setDataInput(XSDataString(self.strShortComments), "shortComments") if (not self.strComments is None): self.edPluginControlISPyB.setDataInput(XSDataString(self.strComments), "comments") if (not self.strStatusMessage is None): self.edPluginControlISPyB.setDataInput(XSDataString(self.strStatusMessage), "statusMessage") self.edPluginControlISPyB.setDataInput(xsDataInputControlISPyB) self.edPluginControlISPyB.executeSynchronous() self.checkDozorScores(self.edPluginControlCharacterisation.getDataOutput())
def storeResultsInISPyB(self, _edPlugin=None): self.DEBUG("EDPluginControlInterfacev1_3.storeResultsInISPyB") if (self.edPluginControlISPyB is not None): # Execute the ISPyB control plugin xsDataInputControlISPyB = XSDataInputControlISPyB() xsDataInputControlISPyB.setCharacterisationResult( self.edPluginControlCharacterisation.getDataOutput()) if (not self.iDataCollectionId is None): dataCollectionGroupId = self.getDataCollectionGroupId( self.iDataCollectionId) xsDataInputControlISPyB.setDataCollectionGroupId( XSDataInteger(dataCollectionGroupId)) if (not self.strShortComments is None): self.edPluginControlISPyB.setDataInput( XSDataString(self.strShortComments), "shortComments") if (not self.strComments is None): self.edPluginControlISPyB.setDataInput( XSDataString(self.strComments), "comments") if (not self.strStatusMessage is None): self.edPluginControlISPyB.setDataInput( XSDataString(self.strStatusMessage), "statusMessage") self.edPluginControlISPyB.setDataInput(xsDataInputControlISPyB) self.edPluginControlISPyB.executeSynchronous() self.checkDozorScores( self.edPluginControlCharacterisation.getDataOutput())
def testGenerateXSDataInputISPyB(self): """ This method is testing the generation of the XSDataInputISPyB object given a XSDataIndexingInput object. """ strReferenceInputControlISPyBFile = EDUtilsPath.mergePath(self.strDataPath, "XSDataInputControlISPyB_reference.xml") strPath = os.path.join(self.strDataPath, strReferenceInputControlISPyBFile) strXMLIndexingInput = EDUtilsFile.readFileAndParseVariables(strPath, self.dictReplace) xsDataInputControlISPyB = XSDataInputControlISPyB.parseString(strXMLIndexingInput) xsDataInputISPyB = EDHandlerXSDataISPyBv1_4.generateXSDataInputISPyBStoreScreening(xsDataInputControlISPyB) strReferenceInputISPyBFile = EDUtilsPath.mergePath(self.strDataPath, "XSDataInputISPyB_reference.xml") strReferencePath = os.path.join(self.strDataPath, strReferenceInputISPyBFile) strXMLInputISPyBReference = EDUtilsFile.readFileAndParseVariables(strReferencePath, self.dictReplace) EDFactoryPluginStatic.loadModule("XSDataISPyBv1_4")
def testGenerateXSDataInputISPyB(self): """ This method is testing the generation of the XSDataInputISPyB object given a XSDataIndexingInput object. """ strReferenceInputControlISPyBFile = EDUtilsPath.mergePath(self.strDataPath, "XSDataInputControlISPyB_reference.xml") strPath = os.path.join(self.strDataPath, strReferenceInputControlISPyBFile) strXMLIndexingInput = EDUtilsFile.readFileAndParseVariables(strPath, self.dictReplace) xsDataInputControlISPyB = XSDataInputControlISPyB.parseString(strXMLIndexingInput) xsDataInputISPyB = EDHandlerXSDataISPyBv1_3.generateXSDataInputISPyBStoreScreening(xsDataInputControlISPyB) print xsDataInputISPyB.marshal() strReferenceInputISPyBFile = EDUtilsPath.mergePath(self.strDataPath, "XSDataInputISPyB_reference.xml") strReferencePath = os.path.join(self.strDataPath, strReferenceInputISPyBFile) strXMLInputISPyBReference = EDUtilsFile.readFileAndParseVariables(strReferencePath, self.dictReplace) EDFactoryPluginStatic.loadModule("XSDataISPyBv1_3")
def testGetBestWilsonPlotPath(self): strReferenceInputControlISPyBFile = EDUtilsPath.mergePath( self.strDataPath, "XSDataInputControlISPyB_reference.xml") strPath = os.path.join(self.strDataPath, strReferenceInputControlISPyBFile) strXMLIndexingInput = EDUtilsFile.readFileAndParseVariables( strPath, self.dictReplace) xsDataInputControlISPyB = XSDataInputControlISPyB.parseString( strXMLIndexingInput) xsDataCharacterisationResult = xsDataInputControlISPyB.characterisationResult strPath = EDHandlerXSDataISPyBv1_4.getBestWilsonPlotPath( xsDataCharacterisationResult) EDAssert.equal( True, strPath.endswith("B.jpg"), "Wilson plot path extracted from characterisation results")
def storeResultsInISPyB(self, _edPlugin=None): self.DEBUG("EDPluginControlInterfacev2_0.storeResultsInISPyB") if (self.edPluginControlISPyB is not None): # Execute the ISPyB control plugin xsDataInputControlISPyB = XSDataInputControlISPyB() xsDataInputControlISPyB.setCharacterisationResult(self.edPluginControlCharacterisation.getDataOutput().getMxv1ResultCharacterisation()) if (not self.iDataCollectionId is None): xsDataInputControlISPyB.setDataCollectionId(XSDataInteger(self.iDataCollectionId)) if (not self.strShortComments is None): self.edPluginControlISPyB.setDataInput(XSDataString(self.strShortComments), "shortComments") if (not self.strComments is None): self.edPluginControlISPyB.setDataInput(XSDataString(self.strComments), "comments") self.edPluginControlISPyB.setDataInput(xsDataInputControlISPyB) self.edPluginControlISPyB.executeSynchronous()
def testGenerateXSDataInputISPyB(self): """ This method is testing the generation of the XSDataInputISPyB object given a XSDataIndexingInput object. """ strReferenceInputControlISPyBFile = EDUtilsPath.mergePath(self.strDataPath, "XSDataInputControlISPyB_reference.xml") strPath = os.path.join(self.strDataPath, strReferenceInputControlISPyBFile) strXMLIndexingInput = self.readAndParseFile(strPath) from XSDataMXv1 import XSDataInputControlISPyB xsDataInputControlISPyB = XSDataInputControlISPyB.parseString(strXMLIndexingInput) from EDHandlerXSDataISPyBv1_1 import EDHandlerXSDataISPyBv1_1 xsDataInputISPyB = EDHandlerXSDataISPyBv1_1.generateXSDataInputISPyB(xsDataInputControlISPyB) strReferenceInputISPyBFile = EDUtilsPath.mergePath(self.strDataPath, "XSDataInputISPyB_reference.xml") strReferencePath = os.path.join(self.strDataPath, strReferenceInputISPyBFile) strXMLInputISPyBReference = self.readAndParseFile(strReferencePath) EDFactoryPluginStatic.loadModule("XSDataISPyBv1_1") from XSDataISPyBv1_1 import XSDataInputISPyB xsDataInputISPyBReference = XSDataInputISPyB.parseString(strXMLInputISPyBReference) # Remove the time strings since they otherwise make the test fail xsDataInputISPyBReference.getScreening().setTimeStamp(None) xsDataInputISPyB.getScreening().setTimeStamp(None) EDAssert.equal(xsDataInputISPyBReference.marshal(), xsDataInputISPyB.marshal())
def testCheckParameters(self): xsDataInput = XSDataInputControlISPyB() edPluginExecISPyB = self.createPlugin() edPluginExecISPyB.setDataInput(xsDataInput) edPluginExecISPyB.checkParameters()
class EDPluginControlInterfaceToMXCuBEv1_2(EDPluginControl): """ This is the plugin interface to launch the MXv1 characterisation from an MXCuBE gui. It is for the moment a wrapper for the EDPluginControlCCP4iv1_1 plugin, which also runs the ISPyB control plugin if a data collection id is available. """ __EDNA_CONTACT_EMAIL = "contactEmail" __EDNA_EMAIL_SENDER = "emailSender" def __init__ (self): """ Initialisation of EDPluginControlInterfaceToMXCuBEv1_2: - Input data type class : XSDataInputMXCuBE - Name of default characterisation plugin : EDPluginControlCharacterisationv1_1 """ EDPluginControl.__init__(self) self.setXSDataInputClass(XSDataInputMXCuBE) self.__strPluginControlCCP4i = "EDPluginControlCCP4iv1_1" self.__edPluginControlCCP4i = None self.__strPluginControlISPyB = "EDPluginControlISPyBv1_0" self.__edPluginControlISPyB = None self.__xsDataResultMXCuBE = None self.__xsDataIntegerDataCollectionId = None self.__strPluginExecOutputHTMLName = "EDPluginExecOutputHTMLv1_0" self.__edPluginExecOutputHTML = None self.__strEDNAContactEmail = None self.__strEDNAEmailSender = "*****@*****.**" def checkParameters(self): """ Checks the mandatory input parameters : - dataSet - outputFileDirectory """ self.verboseDebug("EDPluginControlInterfaceToMXCuBEv1_2.checkParameters") self.checkMandatoryParameters(self.getDataInput(), "Data Input is None") self.checkMandatoryParameters(self.getDataInput().getDataSet(), "dataSet") #self.checkMandatoryParameters( self.getDataInput().getOutputFileDirectory(), "outputFileDirectory" ) def configure(self): EDPluginControl.configure(self) EDVerbose.DEBUG("EDPluginControlInterfaceToMXCuBEv1_2.configure") xsPluginItem = self.getConfiguration() if xsPluginItem == None: EDVerbose.DEBUG("EDPluginControlInterfaceToMXCuBEv1_2.configure: No plugin item defined.") else: self.__strEDNAContactEmail = EDConfiguration.getStringParamValue(xsPluginItem, EDPluginControlInterfaceToMXCuBEv1_2.__EDNA_CONTACT_EMAIL) EDVerbose.DEBUG("EDPluginControlInterfaceToMXCuBEv1_2.configure: EDNAContactEmail = %s" % self.__strEDNAContactEmail) strEDNAEmailSender = EDConfiguration.getStringParamValue(xsPluginItem, self.__EDNA_EMAIL_SENDER) if strEDNAEmailSender: self.__strEDNAEmailSender = strEDNAEmailSender def preProcess(self, _edPlugin=None): """ This method prepares the input for the CCP4i plugin and loads it. """ EDPluginControl.preProcess(self, _edPlugin) EDVerbose.DEBUG("EDPluginControlInterfaceToMXCuBEv1_2.preProcess...") EDFactoryPluginStatic.loadModule("XSDataCCP4iv1_1") from XSDataCCP4iv1_1 import XSDataInputCCP4i xsDataInputCCP4i = XSDataInputCCP4i() xsDataInputMXCuBE = self.getDataInput() xsDataInputCCP4i.setDataSet(xsDataInputMXCuBE.getDataSet()) #xsDataInputCCP4i.setDataFile( xsDataInputMXCuBE.getDataFile() ) xsDataInputCCP4i.setExperimentalCondition(xsDataInputMXCuBE.getExperimentalCondition()) xsDataInputCCP4i.setDiffractionPlan(xsDataInputMXCuBE.getDiffractionPlan()) xsDataInputCCP4i.setSample(xsDataInputMXCuBE.getSample()) self.__edPluginControlCCP4i = self.loadPlugin(self.__strPluginControlCCP4i, "CCP4i") self.__edPluginControlCCP4i.setDataInput(xsDataInputCCP4i) self.__xsDataIntegerDataCollectionId = xsDataInputMXCuBE.getDataCollectionId() if (self.__xsDataIntegerDataCollectionId is not None): self.__edPluginControlISPyB = self.loadPlugin(self.__strPluginControlISPyB, "ISPyB") self.__edPluginExecOutputHTML = self.loadPlugin(self.__strPluginExecOutputHTMLName, "OutputHTML") def process(self, _edPlugin=None): EDPluginControl.process(self, _edPlugin) EDVerbose.DEBUG("EDPluginControlInterfaceToMXCuBEv1_2.process...") if self.__edPluginControlCCP4i is not None: self.connectProcess(self.__edPluginControlCCP4i.executeSynchronous) self.__edPluginControlCCP4i.connectSUCCESS(self.doSuccessActionCCP4i) self.__edPluginControlCCP4i.connectFAILURE(self.doFailureActionCCP4i) if self.__edPluginControlISPyB is not None: self.__edPluginControlISPyB.connectSUCCESS(self.doSuccessActionISPyB) self.__edPluginControlISPyB.connectFAILURE(self.doFailureActionISPyB) def postProcess(self, _edPlugin=None): EDPluginControl.postProcess(self, _edPlugin) EDVerbose.DEBUG("EDPluginControlInterfaceToMXCuBEv1_2.postProcess...") self.setDataOutput(self.__xsDataResultMXCuBE) def doSuccessActionCCP4i(self, _edPlugin=None): EDVerbose.DEBUG("EDPluginControlInterfaceToMXCuBEv1_2.doSuccessActionCCP4i...") self.retrieveSuccessMessages(self.__edPluginControlCCP4i, "EDPluginControlInterfaceToMXCuBEv1_2.doSuccessActionCCP4i") # Retrieve the results from the CCP4 plugin execution xsDataResultCCP4i = self.__edPluginControlCCP4i.getDataOutput() self.__xsDataResultMXCuBE = XSDataResultMXCuBE() xsDataStringListOfOutputFiles = xsDataResultCCP4i.getListOfOutputFiles() self.__xsDataResultMXCuBE.setListOfOutputFiles(xsDataStringListOfOutputFiles) # Retrieve the characterisation output object xsDataResultCharacterisation = self.getXSDataResultCharacterisation(xsDataStringListOfOutputFiles.getValue()) # For the moment, create "DNA" style output directory strPathToDNAFileDirectory = self.createDNAFileDirectoryPath(xsDataResultCharacterisation) xsDataDictionaryLogFile = None if (self.createDNAFileDirectory(strPathToDNAFileDirectory)): xsDataDictionaryLogFile = self.createOutputFileDictionary(xsDataStringListOfOutputFiles, xsDataResultCharacterisation, strPathToDNAFileDirectory) strPyArchPathToDNAFileDirectory = self.createPyArchDNAFilePath(strPathToDNAFileDirectory) if (self.createDNAFileDirectory(strPyArchPathToDNAFileDirectory)): xsDataDictionaryLogFile = self.createOutputFileDictionary(xsDataStringListOfOutputFiles, xsDataResultCharacterisation, strPyArchPathToDNAFileDirectory) self.__xsDataResultMXCuBE.setOutputFileDictionary(xsDataDictionaryLogFile) # Send success email message (MXSUP-183): strSubject = "%s : SUCCESS!" % EDUtilsPath.getEdnaSite() strMessage = "Success!" if xsDataDictionaryLogFile != None: for xsDataKeyValuePair in xsDataDictionaryLogFile.getKeyValuePair(): strKey = xsDataKeyValuePair.getKey().getValue() if strKey == "executiveSummary": strPathToExecutiveSummary = xsDataKeyValuePair.getValue().getValue() strMessage = EDUtilsFile.readFile(strPathToExecutiveSummary) self.sendEmail(strSubject, strMessage) # Fix for bug EDNA-55 : If burning strategy EDNA2html shouldn't be run bRunExecOutputHTML = True 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.executeSynchronous() if not self.__edPluginExecOutputHTML.isFailure() and self.__edPluginExecOutputHTML.hasDataOutput("htmlFile"): strPathToHTMLFile = self.__edPluginExecOutputHTML.getDataOutput("htmlFile")[0].getPath().getValue() strPathToHTMLDir = self.__edPluginExecOutputHTML.getDataOutput("htmlDir")[0].getPath().getValue() strPathToDNAIndexDirectory = os.path.join(strPathToDNAFileDirectory, "index") if os.path.exists(strPathToHTMLFile): try: os.mkdir(strPathToDNAIndexDirectory) shutil.copy(strPathToHTMLFile, os.path.join(strPathToDNAIndexDirectory, "index.html")) shutil.copytree(strPathToHTMLDir, os.path.join(strPathToDNAIndexDirectory, os.path.basename(strPathToHTMLDir))) if strPyArchPathToDNAFileDirectory is not None: strPathToPyArchIndexDirectory = os.path.join(strPyArchPathToDNAFileDirectory, "index") os.mkdir(strPathToPyArchIndexDirectory) shutil.copy(strPathToHTMLFile, os.path.join(strPathToPyArchIndexDirectory, "index.html")) shutil.copytree(strPathToHTMLDir, os.path.join(strPathToPyArchIndexDirectory, os.path.basename(strPathToHTMLDir))) except Exception, e: EDVerbose.DEBUG("Exception caught: %r" % e) if (self.__edPluginControlISPyB is not None): # Execute the ISPyB control plugin xsDataInputControlISPyB = XSDataInputControlISPyB() xsDataInputControlISPyB.setCharacterisationResult(xsDataResultCharacterisation) xsDataInputControlISPyB.setDataCollectionId(self.__xsDataIntegerDataCollectionId) self.__edPluginControlISPyB.setDataInput(xsDataInputControlISPyB) self.__edPluginControlISPyB.executeSynchronous()