1
- """
1
+ '''
2
2
(c) 2011-2012 Thomas Holder, MPI for Developmental Biology
3
- """
3
+ '''
4
4
5
5
from __future__ import print_function
6
- from pymol import cmd , CmdException
7
6
8
7
__author__ = 'Thomas Holder'
9
8
__version__ = '1.1'
10
9
__license__ = 'BSD-2-Clause'
11
10
11
+ from pymol import cmd , CmdException
12
+
12
13
13
14
def save_pdb_without_ter (filename , selection , ** kwargs ):
14
- """
15
- DESCRIPTION
15
+ '''
16
+ DESCRIPTION
16
17
17
- Save PDB file without TER records. External applications like TMalign and
18
- DynDom stop reading PDB files at TER records, which might be undesired in
19
- case of missing loops.
20
- """
18
+ Save PDB file without TER records. External applications like TMalign and
19
+ DynDom stop reading PDB files at TER records, which might be undesired in
20
+ case of missing loops.
21
+ '''
21
22
v = cmd .get_setting_boolean ('pdb_use_ter_records' )
22
23
if v :
23
24
cmd .unset ('pdb_use_ter_records' )
@@ -28,34 +29,34 @@ def save_pdb_without_ter(filename, selection, **kwargs):
28
29
29
30
def alignwithanymethod (mobile , target , methods = 'align super cealign tmalign' ,
30
31
async = 1 , quiet = 1 ):
31
- """
32
- DESCRIPTION
32
+ '''
33
+ DESCRIPTION
33
34
34
- Align copies of mobile to target with several alignment methods
35
+ Align copies of mobile to target with several alignment methods
35
36
36
- ARGUMENTS
37
+ ARGUMENTS
37
38
38
- mobile = string: atom selection
39
+ mobile = string: atom selection
39
40
40
- target = string: atom selection
41
+ target = string: atom selection
41
42
42
- methods = string: space separated list of PyMOL commands which take
43
- arguments "mobile" and "target" (in any order) {default: align super
44
- cealign tmalign}
45
- """
43
+ methods = string: space separated list of PyMOL commands which take
44
+ arguments "mobile" and "target" (in any order) {default: align super
45
+ cealign tmalign}
46
+ '''
46
47
import threading
47
48
import time
48
49
methods = methods .split ()
49
50
async , quiet = int (async ), int (quiet )
50
51
mobile_obj = cmd .get_object_list ('first (' + mobile + ')' )[0 ]
51
52
52
- def myalign (method_ ):
53
- newmobile = cmd .get_unused_name (mobile_obj + '_' + method_ )
53
+ def myalign (method ):
54
+ newmobile = cmd .get_unused_name (mobile_obj + '_' + method )
54
55
cmd .create (newmobile , mobile_obj )
55
56
start = time .time ()
56
- cmd .do ('%s mobile=%s in %s, target=%s' % (method_ , newmobile , mobile , target ))
57
+ cmd .do ('%s mobile=%s in %s, target=%s' % (method , newmobile , mobile , target ))
57
58
if not quiet :
58
- print ('Finished: %s (%.2f sec)' % (method_ , time .time () - start ))
59
+ print ('Finished: %s (%.2f sec)' % (method , time .time () - start ))
59
60
60
61
for method in methods :
61
62
if async :
@@ -66,34 +67,34 @@ def myalign(method_):
66
67
myalign (method )
67
68
68
69
69
- def tmalign (mobile , target , args = '' , exe = 'TMalign' , ter = 0 , transform = 1 , object_ = None , quiet = 0 ):
70
- """
71
- DESCRIPTION
70
+ def tmalign (mobile , target , args = '' , exe = 'TMalign' , ter = 0 , transform = 1 , object = None , quiet = 0 ):
71
+ '''
72
+ DESCRIPTION
72
73
73
- TMalign wrapper
74
+ TMalign wrapper
74
75
75
- Reference: Y. Zhang and J. Skolnick, Nucl. Acids Res. 2005 33, 2302-9
76
- http://zhanglab.ccmb.med.umich.edu/TM-align/
76
+ Reference: Y. Zhang and J. Skolnick, Nucl. Acids Res. 2005 33, 2302-9
77
+ http://zhanglab.ccmb.med.umich.edu/TM-align/
77
78
78
- USAGE
79
+ USAGE
79
80
80
- tmalign mobile, target [, args [, exe ]]
81
+ tmalign mobile, target [, args [, exe ]]
81
82
82
- ARGUMENTS
83
+ ARGUMENTS
83
84
84
- mobile, target = string: atom selections
85
+ mobile, target = string: atom selections
85
86
86
- args = string: Extra arguments like -d0 5 -L 100
87
+ args = string: Extra arguments like -d0 5 -L 100
87
88
88
- exe = string: Path to TMalign executable {default: TMalign}
89
+ exe = string: Path to TMalign executable {default: TMalign}
89
90
90
- ter = 0/1: If ter=0, then ignore chain breaks because TMalign will stop
91
- at first TER record {default: 0}
91
+ ter = 0/1: If ter=0, then ignore chain breaks because TMalign will stop
92
+ at first TER record {default: 0}
92
93
93
- SEE ALSO
94
+ SEE ALSO
94
95
95
- tmscore, mmalign
96
- """
96
+ tmscore, mmalign
97
+ '''
97
98
import subprocess
98
99
import tempfile
99
100
import os
@@ -104,8 +105,8 @@ def tmalign(mobile, target, args='', exe='TMalign', ter=0, transform=1, object_=
104
105
mobile_filename = tempfile .mktemp ('.pdb' , 'mobile' )
105
106
target_filename = tempfile .mktemp ('.pdb' , 'target' )
106
107
matrix_filename = tempfile .mktemp ('.txt' , 'matrix' )
107
- mobile_ca_sele = '(%s) and (not hetatm) and name CA and alt +A' % mobile
108
- target_ca_sele = '(%s) and (not hetatm) and name CA and alt +A' % target
108
+ mobile_ca_sele = '(%s) and (not hetatm) and name CA and alt +A' % ( mobile )
109
+ target_ca_sele = '(%s) and (not hetatm) and name CA and alt +A' % ( target )
109
110
110
111
if ter :
111
112
save = cmd .save
@@ -121,7 +122,7 @@ def tmalign(mobile, target, args='', exe='TMalign', ter=0, transform=1, object_=
121
122
process = subprocess .Popen (args , stdout = subprocess .PIPE )
122
123
lines = process .stdout .readlines ()
123
124
except OSError :
124
- print ('Cannot execute "%s", please provide full path to TMscore or TMalign executable' % exe )
125
+ print ('Cannot execute "%s", please provide full path to TMscore or TMalign executable' % ( exe ) )
125
126
raise CmdException
126
127
finally :
127
128
os .remove (mobile_filename )
@@ -148,7 +149,7 @@ def tmalign(mobile, target, args='', exe='TMalign', ter=0, transform=1, object_=
148
149
elif line .lower ().startswith (' -------- rotation matrix' ):
149
150
rowcount = 1
150
151
elif line .startswith ('(":" denotes' ):
151
- alignment = [line_it .next ().rstrip () for _ in range (3 )]
152
+ alignment = [line_it .next ().rstrip () for i in range (3 )]
152
153
else :
153
154
match = re_score .search (line )
154
155
if match is not None :
@@ -166,10 +167,10 @@ def tmalign(mobile, target, args='', exe='TMalign', ter=0, transform=1, object_=
166
167
matrix .extend ([0 , 0 , 0 , 1 ])
167
168
168
169
if int (transform ):
169
- cmd .transform_selection ('byobject (%s)' % mobile , matrix , homogenous = 1 )
170
+ cmd .transform_selection ('byobject (%s)' % ( mobile ) , matrix , homogenous = 1 )
170
171
171
172
# alignment object
172
- if object_ is not None :
173
+ if object is not None :
173
174
mobile_idx , target_idx = [], []
174
175
space = {'mobile_idx' : mobile_idx , 'target_idx' : target_idx }
175
176
cmd .iterate (mobile_ca_sele , 'mobile_idx.append("%s`%d" % (model, index))' , space = space )
@@ -180,61 +181,61 @@ def tmalign(mobile, target, args='', exe='TMalign', ter=0, transform=1, object_=
180
181
for i , aa in enumerate (alignment [2 ]):
181
182
if aa == '-' :
182
183
target_idx .insert (i , None )
183
- if len (mobile_idx ) == len (target_idx ) == len (alignment [2 ]):
184
+ if ( len (mobile_idx ) == len (target_idx ) == len (alignment [2 ]) ):
184
185
cmd .rms_cur (
185
186
' ' .join (idx for (idx , m ) in zip (mobile_idx , alignment [1 ]) if m in ':.' ),
186
187
' ' .join (idx for (idx , m ) in zip (target_idx , alignment [1 ]) if m in ':.' ),
187
- cycles = 0 , matchmaker = 4 , object = object_ )
188
+ cycles = 0 , matchmaker = 4 , object = object )
188
189
else :
189
190
print ('Could not load alignment object' )
190
191
191
192
if not quiet and r is not None :
192
- print ('Found in output TM-score = %.4f' % r )
193
+ print ('Found in output TM-score = %.4f' % ( r ) )
193
194
194
195
return r
195
196
196
197
197
198
def tmscore (mobile , target , args = '' , exe = 'TMscore' , quiet = 0 , ** kwargs ):
198
- """
199
- DESCRIPTION
199
+ '''
200
+ DESCRIPTION
200
201
201
- TMscore wrapper
202
+ TMscore wrapper
202
203
203
- Reference: Yang Zhang and Jeffrey Skolnick, Proteins 2004 57: 702-710
204
- http://zhanglab.ccmb.med.umich.edu/TM-score/
204
+ Reference: Yang Zhang and Jeffrey Skolnick, Proteins 2004 57: 702-710
205
+ http://zhanglab.ccmb.med.umich.edu/TM-score/
205
206
206
- ARGUMENTS
207
+ ARGUMENTS
207
208
208
- mobile, target = string: atom selections
209
+ mobile, target = string: atom selections
209
210
210
- args = string: Extra arguments like -d 5
211
+ args = string: Extra arguments like -d 5
211
212
212
- exe = string: Path to TMscore executable {default: TMscore}
213
+ exe = string: Path to TMscore executable {default: TMscore}
213
214
214
- ter = 0/1: If ter=0, then ignore chain breaks because TMscore will stop
215
- at first TER record {default: 0}
215
+ ter = 0/1: If ter=0, then ignore chain breaks because TMscore will stop
216
+ at first TER record {default: 0}
216
217
217
- SEE ALSO
218
+ SEE ALSO
218
219
219
- tmalign, mmalign
220
- """
220
+ tmalign, mmalign
221
+ '''
221
222
kwargs .pop ('_self' , None )
222
223
return tmalign (mobile , target , args , exe , quiet = quiet , ** kwargs )
223
224
224
225
225
226
def mmalign (mobile , target , args = '' , exe = 'MMalign' , ter = 0 , transform = 1 , quiet = 0 ):
226
- """
227
- DESCRIPTION
227
+ '''
228
+ DESCRIPTION
228
229
229
- MMalign wrapper
230
+ MMalign wrapper
230
231
231
- Reference: S. Mukherjee and Y. Zhang, Nucleic Acids Research 2009; 37: e83
232
- http://zhanglab.ccmb.med.umich.edu/MM-align/
232
+ Reference: S. Mukherjee and Y. Zhang, Nucleic Acids Research 2009; 37: e83
233
+ http://zhanglab.ccmb.med.umich.edu/MM-align/
233
234
234
- SEE ALSO
235
+ SEE ALSO
235
236
236
- tmalign, tmscore
237
- """
237
+ tmalign, tmscore
238
+ '''
238
239
return tmalign (mobile , target , args , exe , ter , transform , quiet = quiet )
239
240
240
241
# pymol commands
0 commit comments