How to execute a program through a script

From EdnaWiki
Jump to: navigation, search

Script Plugins

One of the ways to interact with tasks in EDNA is to execute them through shell scripts, using for example the bash interpreter. This is achieved by inheriting from the EDPluginExecProcessScript exec plugin, thus:

 class EDPluginExecDIMPLETRUNCATEv10(EDPluginExecProcessScript):
     An EDNA plugin for the CCP4 program truncate.
 
     def __init__(self):
         EDPluginExecProcessScript.__init__(self)

As described elsewhere, the plugin needs to be executed in three steps, preProcess, process, postProcess, and in these steps the corresponding parent class methods also need to be called:

   def preProcess(self, _edObject = None):
       EDPluginExecProcessScript.preProcess(self)
       EDVerbose.DEBUG('*** EDPluginExecDIMPLETRUNCATEv10.preProcess')
   
       self.write_my_script_method()
   
       return
       
   def process(self, _edObject = None):
       EDPluginExecProcessScript.process(self)
       EDVerbose.DEBUG('*** EDPluginExecDIMPLETRUNCATEv10.process')
   
       return
       
   def postProcess(self, _edObject = None):
       EDPluginExecProcessScript.postProcess(self)

(though I have no idea why) - the main work is done in your write_my_script_method(), which may look a little like:

   def write_my_script_method(self):
       self.setScriptCommandline('this is my command line %s' % parameter)
       self.addListCommandExecution('input record %s' % another_parameter)
   
       return

And... that's about it.