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
27 """
28 Convert a PDB file to a pickled PDBModel object.
29 """
30
31 from PDBModel import PDBModel
32 import tools as T
33
34
35 from Biskit.PVM import JobSlave
36
37
39 """
40 Convert a PDB file to a pickled PDBModel object.
41 """
42
44 """
45 Copy the parameters that Master is passing in as dict into
46 fields of this class.
47
48 @param params: defined in Master
49 @type params: dict
50 """
51 self.params = params
52
53
55 """
56 Rename special residues (from Amber) back into standard
57 names (i.e CYX S{->} CYS).
58
59 @param model: model
60 @type model: PDBModel
61 """
62 for a in model.getAtoms():
63 if a['residue_name'] == 'CYX':
64 a['residue_name'] = 'CYS'
65 if a['residue_name'] in ['HIE','HID','HIP']:
66 a['residue_name'] = 'HIS'
67
68
70 """
71 ptraj puts last letter/number of 4-letter atom names first. Undo.
72
73 @param model: model
74 @type model: PDBModel
75
76 @note: could be avoided if ptraj would be told:
77 trajout |file| pdb nowrap
78 """
79 numbers = map( str, range(10) )
80
81 for a in model.getAtoms():
82 if len(a['name'])==4 and a['name'][0] in numbers:
83 a['name'] = a['name'][1:] + a['name'][0]
84
85
87 """
88 Calculate rmsd values for trajectory and plot them.
89
90 @param dict: dictionary with path to pdb files as keys
91 @type dict: dict
92
93 @return: dictionary mapping input:output names
94 @rtype: dict
95 """
96 d = {}
97
98 print "working on :",
99 for pdbIn, out in dict.items():
100
101 print T.stripFilename( pdbIn )
102
103
104 dir = os.path.dirname( pdbIn )
105 if self.params['out'] <> None:
106 dir = self.params['out']
107
108 out = dir + '/' + T.stripFilename( pdbIn) + '.model'
109
110 try:
111 m = PDBModel( pdbIn, skipRes=self.params['skipRes'] )
112
113 if self.params['amber']:
114 self.renameAmberRes( m )
115 self.renameToAmberAtoms( m )
116
117 if self.params['sort']:
118 m = m.sort()
119
120 m.saveAs( out )
121
122 except:
123 if self.params.has_key('report') and self.params['report']:
124 f = open( out[:-6] + '.error', 'w' )
125 f.write( T.lastError() )
126 f.close()
127 else:
128 T.errWriteln("Error" + T.lastError() )
129
130
131 out = ''
132
133 d[pdbIn] = out
134
135 print "Done."
136 return d
137
138 if __name__ == '__main__':
139
140 import os, sys
141
142 if len(sys.argv) == 2:
143
144 niceness = int(sys.argv[1])
145 os.nice(niceness)
146
147 slave = StructureSlave()
148 slave.start()
149