1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
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
40
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
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
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