def configure( self ): EDPluginExec.configure( self ) EDVerbose.DEBUG( "*** EDPluginExecICATIngesterv10.configure" ) xsPluginItem = self.getConfiguration() if ( xsPluginItem == None ): EDVerbose.warning( "EDPluginExecICATIngesterv10.configure: No DLS Archiver plugin item defined." ) xsPluginItem = XSPluginItem()
def ingestXML(self, xml): """ Connect to the ICAT and ingest an XML string using the existing sessionID if the sessionID is invalid or has expired get a new one using refreshSessionID() """ EDVerbose.DEBUG( strftime("%Y-%m-%d %H:%M:%S") + " *** EDPluginExecICATRegisterv10.ingestXML...") icat = Client( "https://facilities02.esc.rl.ac.uk:8181/ICATService/ICAT?wsdl") try: icat.service.ingestMetadata(self.sessionID, xml) except Exception as e: EDVerbose.DEBUG('An error occurred: %s\n' % e.message) # record the error and the info about the file being ingested, i.e. visit_id, #self.recordFailedIngest( self.sessionID, xml, e.message ) if e.message.lower().find('session') == -1: print 'Not a sessionId issue!' #return raise e self.refreshSessionID() try: icat.service.ingestMetadata(self.sessionID, xml) except Exception as ee: EDVerbose.DEBUG('An error occurred: %s\n' % ee.message) raise ee
def preProcess( self, _edObject = None ): EDPluginExecProcessScript.preProcess( self ) EDVerbose.DEBUG( "*** EDPluginExecDIMPLEMTZDUMPv10.preProcess") self.generateDIMPLEMTZDUMPCommands() if self.getDataInput().getOutputLogFile() != None: self.setScriptLogFileName(self.getDataInput().getOutputLogFile().getPath().getValue()) EDVerbose.DEBUG( "*** EDPluginExecDIMPLEPDBSETv10.preProcess - setting log file to: " \ + self.getScriptLogFileName())
def preProcess(self, _edObject=None): EDPluginExec.preProcess(self) EDVerbose.DEBUG('*** EDPluginExecDIMPLEPDBDUMPv10.preProcess') self.set_xyzin(self.getDataInput().getXYZIN().getPath().getValue()) EDVerbose.DEBUG('Obtained PDB file: %s' % self._xyzin) return
def configure(self): EDPluginExec.configure(self) EDVerbose.DEBUG("*** EDPluginExecICATIngesterv10.configure") xsPluginItem = self.getConfiguration() if (xsPluginItem == None): EDVerbose.warning( "EDPluginExecICATIngesterv10.configure: No DLS Archiver plugin item defined." ) xsPluginItem = XSPluginItem()
def configure( self ): """ Configure the plugin, mainly boiler plate code to get things going """ EDPluginExec.configure( self ) EDVerbose.DEBUG( "*** EDPluginExecSRBRegisterv10.configure" ) xsPluginItem = self.getConfiguration() if ( xsPluginItem == None ): EDVerbose.warning( "EDPluginExecSRBRegisterv10.configure: No DLS Archiver plugin item defined." ) xsPluginItem = XSPluginItem()
def configure( self ): """ configure the plugin, mainly boiler plate code in here, to make sure the underlying code is being run """ EDPluginControl.configure( self ) EDVerbose.DEBUG( strftime("%Y-%m-%d %H:%M:%S") + " *** EDPluginControlDLSArchiverv10.configure" ) xsPluginItem = self.getConfiguration() if ( xsPluginItem == None ): EDVerbose.warning( "EDPluginControlDLSArchiverv10.configure: No DLS Archiver plugin item defined." ) xsPluginItem = XSPluginItem()
def configure(self): """ Configure the plugin, mainly boiler plate code to get things going """ EDPluginExec.configure(self) EDVerbose.DEBUG("*** EDPluginExecSRBRegisterv10.configure") xsPluginItem = self.getConfiguration() if (xsPluginItem == None): EDVerbose.warning( "EDPluginExecSRBRegisterv10.configure: No DLS Archiver plugin item defined." ) xsPluginItem = XSPluginItem()
def testExecute(self): self.run() plugin = self.getPlugin() EDVerbose.DEBUG('Checking error messages...') EDAssert.equal(self.m_iNoErrorMessages, self.getErrorMessages().getNumberObjects()) EDVerbose.DEBUG('Checking warning messages...') EDAssert.equal(self.m_iNoWarningMessages, self.getWarningMessages().getNumberObjects())
def process(self, _oalObject=None): """ This is the guts of the plugin, where all the hard work is done, in this case the plugin is a server, and is therefore repeating this process forever """ EDVerbose.DEBUG( strftime("%Y-%m-%d %H:%M:%S") + " *** EDPluginControlDLSArchiverv10.process...") EDPluginControl.process(self) # Actually run the plugin #Set up the main loop to run continuously self.serverActive = True edRound = 0 edSleeptime = self.getDataInput().getPollTime().getValue() while self.serverActive: start = datetime.datetime.now() self.checkDelayedFiles() time1 = datetime.datetime.now() self.cleanAllFiles() time2 = datetime.datetime.now() self.processAllSRBFiles() time3 = datetime.datetime.now() self.processAllICATFiles() end = datetime.datetime.now() #print '================= archiving report =================' #print 'Round: ' + str( edRound ) #print 'Total number of drop files: ' + str( self.numberOfFiles ) #print 'Total archiving time: ' + str( end - start ) #print 'checkDelayedFiles() execution time: ' + str( time1 - start ) #print 'cleanAllFiles() execution time: ' + str( time2 - time1 ) #print 'processAllSRBFiles() execution time: ' + str( time3 - time2 ) #print 'processAllICATFiles() execution time: ' + str( end - time3 ) ##print 'darc running since: ' + str( start ) #print '======================================================' edRound += 1 EDVerbose.DEBUG( strftime("%Y-%m-%d %H:%M:%S") + " *** EDPluginControlDLSArchiverv10.Sleeping") if (edSleeptime > 0): time.sleep(edSleeptime) else: self.serverActive = False
def preProcess(self, _edObject=None): EDPluginExecProcessScript.preProcess(self) EDVerbose.DEBUG("*** EDPluginExecTomographyv10.postProcess") xsDataInputTomography = self.getDataInput() args = {} args["-w"] = str(xsDataInputTomography.getImageWidth().getValue()) args["-l"] = str(xsDataInputTomography.getChunkHeight().getValue()) args["-J"] = str(xsDataInputTomography.getJobName().getValue()) args["-s"] = str( xsDataInputTomography.getNumberOfSegments().getValue()) args["-p"] = str(xsDataInputTomography. getNumberOfProjectionsPerSegment().getValue()) args["-G"] = "" args["-z"] = str( int(xsDataInputTomography.getTimeoutPollingInterval().getValue())) args["-Z"] = str( int(xsDataInputTomography.getTimeoutLength().getValue())) args["-b"] = str( xsDataInputTomography.getByteDepthOfImage().getValue()) args["-U"] = str(xsDataInputTomography.getUniqueName().getValue()) args["-v"] = "" args["-n"] = str(xsDataInputTomography.getNumberOfChunks().getValue()) args["-I"] = xsDataInputTomography.getSettingsFileName().getPath( ).getValue() argString = " ".join(["%s %s" % (k, v) for k, v in args.items()]) EDVerbose.DEBUG("Argument list is = %s" % argString) self.addListCommandPreExecution( "cd %s" % xsDataInputTomography.getImageDirectory().getPath().getValue()) self.setScriptCommandline(argString) self.addListCommandExecution("END") # finaly get some parameters ready for when to stop the job strFinishFileName = "finish_r%s%s.txt" % ( self.getDataInput().getJobName().getValue(), xsDataInputTomography.getUniqueName().getValue()) self.strFinishPathName = os.path.join( self.getDataInput().getImageDirectory().getPath().getValue(), strFinishFileName) EDVerbose.DEBUG("finish job string name = %s" % self.strFinishPathName) # and then in fact remove it, if this is a second go at the reconstruction for example # however it may not exist try: os.remove(self.strFinishPathName) except: pass
def configure(self): """ configure the plugin, mainly boiler plate code in here, to make sure the underlying code is being run """ EDPluginControl.configure(self) EDVerbose.DEBUG( strftime("%Y-%m-%d %H:%M:%S") + " *** EDPluginControlDLSArchiverv10.configure") xsPluginItem = self.getConfiguration() if (xsPluginItem == None): EDVerbose.warning( "EDPluginControlDLSArchiverv10.configure: No DLS Archiver plugin item defined." ) xsPluginItem = XSPluginItem()
def testExecute( self ): """ """ self.run() # Checks that there are no error messages plugin = self.getPlugin() EDVerbose.DEBUG("Checking error messages...") EDAssert.equal( self.m_iNoErrorMessages, self.getErrorMessages().getNumberObjects() ) EDVerbose.DEBUG("Checking warning messages...") EDAssert.equal( self.m_iNoWarningMessages, self.getWarningMessages().getNumberObjects() )
def testExecute(self): """ """ self.run() # Checks that there are no error messages plugin = self.getPlugin() EDVerbose.DEBUG("Checking error messages...") EDAssert.equal(self.m_iNoErrorMessages, self.getErrorMessages().getNumberObjects()) EDVerbose.DEBUG("Checking warning messages...") EDAssert.equal(self.m_iNoWarningMessages, self.getWarningMessages().getNumberObjects()) # Checking obtained results # For the moment, just check if the output file exists xsDataResultsFIT2DCake = plugin.getDataOutput() strPathToOutputFile = xsDataResultsFIT2DCake.getResultFile().getPath().getValue() strDataObtained = EDUtilsFile.readFile(strPathToOutputFile) strDataReference = EDUtilsFile.readFile(os.path.join(self.getPluginTestsDataHome(), \ "EDPluginFIT2DCakev1_1.chi")) EDAssert.equal(strDataReference, strDataObtained) EDAssert.equal(True, os.path.exists(strPathToOutputFile)) bEqual = (strDataReference == strDataObtained) if not bEqual: lstDataReference = strDataReference.split() lstDataObtained = strDataObtained.split() if len(lstDataReference) == len(lstDataObtained): EDVerbose.DEBUG("Checking for small numerical error...Relative:%s Absolute: %s" % (self.EPSILON_REL, self.EPSILON_ABS)) bEqual = True for i in xrange(len(lstDataReference)): if lstDataReference[i] != lstDataObtained[i]: try: r = float(lstDataReference[i]) o = float(lstDataObtained[i]) except Exception: bEqual = False break if (2 * abs(r - o) / (o + r) > self.EPSILON_REL) and abs(r - o) > self.EPSILON_ABS: # EDVerbose.setVerboseDebugOn() EDVerbose.DEBUG("MisMatch: %s,%s" % (r, o)) bEqual = False break EDAssert.equal(bEqual, True)
def generateExecutiveSummary(self, _oedPlugin): """ This should probably have some extra information in here about the number of calls etc, which were made, however, as this is a server plugin, i dont think this will ever get called properly """ EDVerbose.DEBUG( strftime("%Y-%m-%d %H:%M:%S") + " *** EDPluginControlDLSArchiverv10.generateExecutiveSummary")
def doSuccess_PDBSET(self, _edPlugin=None): EDVerbose.DEBUG("*** doSuccess_PDBSET") ccp4DataResult_CopyUnitCellMTZtoPDB = CCP4DataResultControlCopyUnitCellMTZtoPDB( ) ccp4DataResult_CopyUnitCellMTZtoPDB.setXYZOUT( self.edPluginPDBSET.getDataOutput().getXYZOUT()) self.setDataOutput(ccp4DataResult_CopyUnitCellMTZtoPDB)
def postProcess(self, _edObject = None): EDPluginExecProcessScript.postProcess(self) EDVerbose.DEBUG( '*** EDPluginExecDIMPLEREFMACRestrainedRefinementv10.postProcess') init_r, init_r_free, final_r, final_r_free = self.parse_refmac_log() xsDataResult = CCP4DataResultREFMACRestrainedRefinement( HKLOUT = HKL(self._hklout), XYZOUT = XYZ(self._xyzout), initialR = XSDataFloat(init_r), initialRFree = XSDataFloat(init_r_free), finalR = XSDataFloat(final_r), finalRFree = XSDataFloat(final_r_free), returnStatus = CCP4ReturnStatus()) self.setDataOutput(xsDataResult) if not os.path.isfile(self.getDataOutput().getHKLOUT().getPath().getValue()): raise RuntimeError, 'File %s does not exist' % self.getDataOutput().getHKLOUT().getPath().getValue() if not os.path.isfile(self.getDataOutput().getXYZOUT().getPath().getValue()): raise RuntimeError, 'File %s does not exist' % self.getDataOutput().getXYZOUT().getPath().getValue() return
def checkParameters(self): """ Checks the mandatory parameters. """ EDVerbose.DEBUG("*** EDPluginExecTomographyv10.checkParameters") self.checkMandatoryParameters(self.getDataInput(), "Data Input is None")
def generateExecutiveSummary(self, _edPlugin): """ Generates a summary of the execution of the plugin. """ #EDPluginExecDIMPLEPDBSETv10.generateExecutiveSummary(self, _edPlugin) EDVerbose.DEBUG( "*** EDPluginExecDIMPLEREFMACRigidBodyv10.generateExecutiveSummary" ) self.addExecutiveSummaryLine("") self.addExecutiveSummaryLine( "############################################################") self.addExecutiveSummaryLine( "### REFMAC (rigid body refinement) Output Log ###") self.addExecutiveSummaryLine( "############################################################") self.addExecutiveSummaryLine("") self.addExecutiveSummaryLine(self.readProcessLogFile()) self.addExecutiveSummaryLine("") self.addExecutiveSummaryLine( "############################################################") self.addExecutiveSummaryLine( "### End REFMAC Output Log ###") self.addExecutiveSummaryLine( "############################################################") self.addExecutiveSummaryLine("") self.verboseScreenExecutiveSummary()
def preProcess(self, _edObject=None): EDPluginControl.preProcess(self) EDVerbose.DEBUG('*** PrepareMTZFileForRefinementv10.preProcess') # control plugins I will use self._copy_spacegroup_plugin = self.loadPlugin( 'EDPluginControlDIMPLECopySpaceGroupPDBtoMTZv10') # read in the column labels self._ColLabels = self.getDataInput().getColLabels() # execute plugins I will use self._pdbdump_plugin = self.loadPlugin('EDPluginExecDIMPLEPDBDUMPv10') self._mtzdump_plugin = self.loadPlugin('EDPluginExecDIMPLEMTZDUMPv10') self._unique_plugin = self.loadPlugin('EDPluginExecDIMPLEUNIQUEv10') self._freerflag_plugin = self.loadPlugin( 'EDPluginExecDIMPLEFREERFLAGv10') self._cad_plugin = self.loadPlugin('EDPluginExecDIMPLECADv10') self._truncate_plugin = self.loadPlugin( 'EDPluginExecDIMPLETRUNCATEv10') self.set_xyzin(self.getDataInput().getXYZIN().getPath().getValue()) self.set_hklin(self.getDataInput().getHKLIN().getPath().getValue()) self.set_hklout(self.getDataInput().getHKLOUT().getPath().getValue()) return
def generateExecutiveSummary(self, _edPlugin): """ Generates a summary of the execution of the plugin. """ #EDPluginExecDIMPLEPDBSETv10.generateExecutiveSummary(self, _edPlugin) EDVerbose.DEBUG( "*** EDPluginExecDIMPLETRUNCATETESTv10.generateExecutiveSummary") self.addExecutiveSummaryLine("") self.addExecutiveSummaryLine( "############################################################") self.addExecutiveSummaryLine( "### TRUNCATE Output Log ###") self.addExecutiveSummaryLine( "############################################################") self.addExecutiveSummaryLine("") self.addExecutiveSummaryLine(self.readProcessLogFile()) self.addExecutiveSummaryLine("") self.addExecutiveSummaryLine( "############################################################") self.addExecutiveSummaryLine( "### End TRUNCATE Output Log ###") self.addExecutiveSummaryLine( "############################################################") self.addExecutiveSummaryLine("") self.verboseScreenExecutiveSummary()
def postProcess(self, _edObject=None): EDPluginControl.postProcess(self) EDVerbose.DEBUG( "*** EDPluginControlDIMPLECopyUnitCellMTZtoPDBv10.postProcess") # Create some output data xsDataResult = CCP4DataResultControlCopyUnitCellMTZtoPDB() self.setDataOutput(xsDataResult)
def openXMLTree(self, edFileName): """ Opens the xml file and places the tree in the object """ # get the filename to load try: self.localedTree = minidom.parse(edFileName) except Exception: EDVerbose.DEBUG( strftime("%Y-%m-%d %H:%M:%S") + " *** EDPluginControlDLSArchiverv10.openXMLTree Failed to parse file '%s' renaming it." % edFileName) edNewName = edFileName + ".invalid" #os.rename( edFileName, edNewName ) shutil.move(edFileName, edNewName) pathSplit = os.path.split(edNewName) newFolder = os.path.join( pathSplit[0], 'invalid' ) # folder name should be extracted from input xml file individualFile = pathSplit[1] print '\nmoving ' + str(edNewName) + ' into ' + str( os.path.join(newFolder, individualFile)) #os.rename( edNewName, os.path.join( newFolder, individualFile ) ) shutil.move(edNewName, os.path.join(newFolder, individualFile)) #os.rename( edFileName, edFileName + '.invalid' ) return self.localedTree
def postProcess(self, _edObject=None): EDPluginExecProcessScript.postProcess(self) EDVerbose.DEBUG("*** EDPluginExecDIMPLEPDBSETv10.postProcess") self.programTermination() # Create some output data # xsDataResult = CCP4DataResultPDBSET() # self.setDataOutput( xsDataResult ) strLog = self.readProcessLogFile() ccp4ReturnStatus = self.getPDBSETReturnStatus(strLog) ccp4DataResultPDBSET = CCP4DataResultPDBSET() # Set the output PDB file ccp4DataResultPDBSET.setXYZOUT( XSDataString(self.getDataInput().getXYZOUT().getPath().getValue())) # Set the output log file ccp4DataResultPDBSET.setOutputLogFile( XSDataString(self.getScriptLogFileName())) # Set the return status ccp4DataResultPDBSET.setReturnStatus(ccp4ReturnStatus) # Set the data output for the job self.setDataOutput(ccp4DataResultPDBSET) if not os.path.isfile(self.getDataOutput().getXYZOUT().getValue()): raise RuntimeError, 'File %s does not exist' % self.getDataOutput( ).getXYZOUT().getValue()
def checkParameters( self ): """ Checks the mandatory parameters. """ EDVerbose.DEBUG( "*** EDPluginExecDIMPLEMTZDUMPv10.checkParameters") self.checkMandatoryParameters( self.getDataInput(),"Data Input is None" ) self.checkMandatoryParameters( self.getDataInput().getHKLIN(),"No input MTZ file" )
def openXMLTree(self): """ Opens the xml file and places the tree in the object """ # get the filename to load # get the data from the plugin xsDataInputPluginExecSRBRegister = self.getDataInput() # get the string of the path xsDataInputPluginExecSRBRegister.getXmlIngestFileName().getPath( ).getValue() edFileName = EDString(xsDataInputPluginExecSRBRegister. getXmlIngestFileName().getPath().getValue()) #print '\nedFileName= ' + str( edFileName ) try: self.edTree = minidom.parse(edFileName) except Exception: # This is to make the tests pass, and it is during the postprocess step where the data is returned from the plugin. EDVerbose.DEBUG( strftime("%Y-%m-%d %H:%M:%S") + " *** EDPluginExecSRBRegisterv10.openXMLTree Failed to parse file '%s' renaming it." % edFileName) #os.rename( edFileName, edFileName + '.invalid' ) shutil.move(edFileName, edFileName + '.invalid')
def _failure_reindex(self, _edPlugin=None): EDVerbose.DEBUG('*** CopySpaceGroupPDBtoMTZv10._failure_reindex') self.retrieveFailureMessages( _edPlugin, 'CopySpaceGroupPDBtoMTZv10._failure_reindex') raise RuntimeError, 'reindex failed' return
def _success_reindex(self, _edPlugin=None): EDVerbose.DEBUG('*** CopySpaceGroupPDBtoMTZv10._success_reindex') self.retrieveSuccessMessages( _edPlugin, 'CopySpaceGroupPDBtoMTZv10._success_reindex') # all good... return
def preProcess(self, _edObject=None): """ This is for before the process occurs, in this case just calling the super method really, but you could add additional methods in here """ EDVerbose.DEBUG( strftime("%Y-%m-%d %H:%M:%S") + " *** EDPluginControlDLSArchiverv10.preProcess...") EDPluginControl.preProcess(self)
def postProcess(self, _edObject = None): EDPluginControl.postProcess(self) EDVerbose.DEBUG('*** PipelineCalcDiffMapv10.postProcess') results = self._restrained_plugin.getDataOutput() xsDataResult = CCP4DataResultControlPipelineCalcDiffMap( HKLOUT = HKL(self._hklout), XYZOUT = XYZ(self._xyzout), initialR = results.getInitialR(), initialRFree = results.getInitialRFree(), finalR = results.getFinalR(), finalRFree = results.getFinalRFree(), returnStatus = CCP4ReturnStatus()) self.setDataOutput(xsDataResult) # and also produce a summary file? - first pull out the residuals refmac_out = self._restrained_plugin.readProcessLogFile().split('\n') residuals = { } collect_residuals = False for record in refmac_out: if '$TABLE: Rfactor analysis, stats vs cycle' in record: collect_residuals = True continue if not collect_residuals: continue if record.strip()[0] in '0123456789': tokens = record.split() cycle = int(tokens[0]) r_rfree_fom = map(float, tokens[1:4]) residuals[cycle] = r_rfree_fom if 'Final results' in record: collect_residuals = False # now need to write this someplace... summary = open(os.path.join(self.getWorkingDirectory(), 'summary.log'), 'w') for c in sorted(residuals): summary.write('%2d %.4f %.4f %.3f\n' % (c, residuals[c][0], residuals[c][1], residuals[c][2])) summary.close() # Create a Coot script launcher self.createCootLauncher() return
def setDataInput( self, _dataInput ): """ Sets the Plugin Input Data _dataInput could be either an String XML or an XSData The XML String should be parsed as an Output Object by the final Plugin """ EDVerbose.DEBUG( "EDPluginSTACv10Alignment.setDataInput" ) # Check the type if( isinstance( _dataInput, EDString ) ): EDVerbose.DEBUG( "EDPluginSTACv10.setDataInput: Input Data is of EDString " ) self.m_xsDataInput = XSDataInputBest.parseString( _dataInput ) elif ( isinstance( _dataInput, XSDataInputBest ) ): self.m_xsDataInput = _dataInput else: errorMessage = EDMessage.ERROR_WRONG_DATA_TYPE_02 % ('EDPluginSTACv10.setDataInput', "XMLString or XSDataBestv01Input expected" ) EDVerbose.error( errorMessage ) self.addErrorMessage( errorMessage ) raise RuntimeError, errorMessage
def process(self, _edObject=None): EDPluginExec.process(self) EDVerbose.DEBUG('*** EDPluginExecDIMPLEPDBDUMPv10.process') self.parse_pdb_get_sequence() self.parse_pdb_get_unit_cell_symmetry() self.programTermination() return
def postProcess(self, _edObject=None): EDPluginControl.postProcess(self) EDVerbose.DEBUG('*** CopySpaceGroupPDBtoMTZv10.postProcess') xsDataResult = CCP4DataResultControlCopySpaceGroupPDBtoMTZ( HKLOUT=HKL(self._hklout), returnStatus=CCP4ReturnStatus()) self.setDataOutput(xsDataResult) return
def refreshSessionID(self): """ Connect to the ICAT and return the new sessionID """ EDVerbose.DEBUG( strftime("%Y-%m-%d %H:%M:%S") + " *** EDPluginExecICATRegisterv10.refreshSessionID...") url = "https://facilities02.esc.rl.ac.uk:8181/ICATAdminService/ICATAdmin?wsdl" client = Client(url) client.options.username = "******" client.options.password = "******" self.sessionID = client.service.loginAdmin("GUARDIAN") EDVerbose.DEBUG( strftime("%Y-%m-%d %H:%M:%S") + " *** EDPluginExecICATRegisterv10.refreshSessionID : New sessionID = " + str(self.sessionID))