Package Biskit :: Package Mod :: Module ModelSlave
[hide private]
[frames] | no frames]

Source Code for Module Biskit.Mod.ModelSlave

  1  ## 
  2  ## Biskit, a toolkit for the manipulation of macromolecular structures 
  3  ## Copyright (C) 2004-2005 Raik Gruenberg & Johan Leckner 
  4  ## 
  5  ## This program is free software; you can redistribute it and/or 
  6  ## modify it under the terms of the GNU General Public License as 
  7  ## published by the Free Software Foundation; either version 2 of the 
  8  ## License, or any later version. 
  9  ## 
 10  ## This program is distributed in the hope that it will be useful, 
 11  ## but WITHOUT ANY WARRANTY; without even the implied warranty of 
 12  ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 
 13  ## General Public License for more details. 
 14  ## 
 15  ## You find a copy of the GNU General Public License in the file 
 16  ## license.txt along with this program; if not, write to the Free 
 17  ## Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 
 18   
 19  ## Contributions: Olivier PERIN, Raik Gruenberg 
 20  ## last $Author: graik $ 
 21  ## last $Date: 2006/12/22 14:27:30 $ 
 22  ## $Revision: 2.3 $ 
 23  """ 
 24  Parallelize Modeller runs 
 25  """ 
 26   
 27  from Biskit.PVM import JobSlave 
 28  import Biskit.tools as T 
 29   
 30  from Biskit.Mod import Modeller as M 
 31   
 32  from Biskit import LogFile 
 33  import os 
 34  import subprocess 
 35  import settings 
 36  import socket 
 37   
 38   
39 -class ModelSlave(JobSlave):
40
41 - def initialize(self, params):
42 """ 43 Initialize AlignerSlave. 44 45 @param params: dictionary with init parameters 46 @type params: {param:value} 47 """ 48 self.__dict__.update( params ) 49 self.params = params 50 51 self.errorLog = LogFile( self.ferror, mode='a' )
52 53 54
55 - def reportError(self, msg, d ):
56 """ 57 Report error. 58 59 @param msg: error message 60 @type msg: str 61 @param d: error data 62 @type d: any 63 """ 64 try: 65 s = '%s on %s, job %r\n' % (msg, os.uname()[1], d) 66 s += '\nErrorTrace:\n' + T.lastErrorTrace() + '\n' 67 68 self.errorLog.add( s ) 69 70 try: 71 print msg 72 except: 73 pass 74 except Exception, why: 75 f = open('ErrorReportError_XRefineSlave','a') 76 f.write( str(why) ) 77 try: 78 f.write( t.lastErrorTrace() ) 79 except: 80 pass 81 f.close()
82 83
84 - def go(self, dict):
85 """ 86 Run Modeller job. 87 88 @param dict: dictionary with run parameters 89 @type dict: {param:value} 90 """ 91 d = {} 92 val = None 93 94 try: 95 96 T.flushPrint( self.params['progress_str'] ) 97 for id, val in dict.items(): 98 99 modeller_log = LogFile( '%s/Modeller.log' %val["outFolder"] ) 100 101 d[id] = val 102 103 104 m = M( outFolder= val["outFolder"], 105 log=modeller_log, 106 fasta_target=val["fastaTarget"], 107 f_pir=val["f_pir"], 108 template_folder=val["template_folder"], 109 starting_model=val["starting_model"], 110 ending_model=val["ending_model"] ) 111 112 m.run() 113 114 115 except Exception, why: 116 self.reportError( 'ERROR '+str(why), val ) 117 118 print "Done." 119 120 return d
121 122 123 if __name__ == '__main__': 124 125 slave = ModelSlave() 126 slave.start() 127