1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25 """
26 Parallizes the convertion of PDB files into pickled PDBModel objects.
27 """
28
29 import Biskit.hosts as hosts
30 import Biskit.tools as T
31
32 from Biskit.PVM import TrackingJobMaster
33
34
36
37 - def __init__(self, dat, chunk, hosts, outFolder, skipWat=0, amber=0,
38 sort=0, add_hosts=1, **kw):
39 """
40 @param dat: data dictionary
41 @type dat: dict
42 @param chunk: chunk size passed to slave
43 @type chunk: int
44 @param hosts: list of host-names
45 @type hosts: [str]
46 @param outFolder: alternative output folder
47 @type outFolder: str
48 """
49 niceness = {'default': 0}
50 slave_script = T.projectRoot() + '/Biskit/StructureSlave.py'
51
52 TrackingJobMaster.__init__(self, dat, chunk, hosts, niceness,
53 slave_script, **kw)
54
55 self.options = {}
56 self.options['out'] = outFolder
57
58 self.options['skipRes'] = None
59 if skipWat:
60 self.options['skipRes'] = ['WAT','TIP3','H2O','WWW','Na+','Cl-']
61
62 if kw.has_key('show_output'):
63 self.options['report'] = not kw['show_output']
64
65 self.options['amber'] = amber
66
67 self.options['sort'] = sort
68
69
71 """
72 hand over parameters to slave once.
73
74 @param slave_tid: slave task id
75 @type slave_tid: int
76
77 @return: dictionary with init parameters
78 @rtype: {param:value}
79 """
80 return self.options
81
82
86
87
88
89
90
91
92
94 """
95 Test class
96 """
97
98 - def run( self, local=0 ):
99 """
100 run function test
101
102 @param local: transfer local variables to global and perform
103 other tasks only when run locally
104 @type local: 1|0
105
106 @return: 1
107 @rtype: int
108 """
109 import tempfile
110 out_folder = tempfile.mkdtemp( '_test_StructureMaster' )
111
112 pdbs = {T.testRoot() + '/lig/1A19.pdb':'',
113 T.testRoot() + '/rec/1A2P.pdb':'',
114 T.testRoot() + '/com/1BGS.pdb':''}
115
116 master = StructMaster( pdbs,
117 2,
118 hosts=hosts.cpus_all,
119 outFolder=out_folder,
120 show_output=local,
121 verbose=local,
122 add_hosts=1 )
123
124
125 r = master.calculateResult()
126
127 if local:
128 print 'The converted pdb files has been written to %s'%out_folder
129 globals().update( locals() )
130
131
132 T.tryRemove( out_folder, tree=1 )
133
134 return 1
135
136
138 """
139 Precalculated result to check for consistent performance.
140
141 @return: 1
142 @rtype: int
143 """
144 return 1
145
146
147 if __name__ == '__main__':
148
149 test = Test()
150
151 assert test.run( local=1 ) == test.expected_result()
152