@@ -51,7 +51,7 @@ def parse_residue_string(string):
51
51
err += "resnum could not be converted to integer, it was '%s' in '%s'" % (resnum , string ) + os_linesep
52
52
if ok :
53
53
res_id = (chain , resname , resnum )
54
- return res_id , ok , err
54
+ return res_id , ok , err
55
55
56
56
def parse_residue_string_and_name (string ):
57
57
"""
@@ -127,6 +127,8 @@ def get_args():
127
127
parser .add_argument ('--box_size' , help = "size of grid box (x, y, z) in Angstrom" , nargs = 3 , type = float )
128
128
parser .add_argument ('--box_center' , help = "center of grid box (x, y, z) in Angstrom" , nargs = 3 , type = float )
129
129
parser .add_argument ('--box_center_on_reactive_res' , help = "project center of grid box along CA-CB bond 5 A away from CB" , action = "store_true" )
130
+ parser .add_argument ('--ligand' , help = "PDBQT of reference ligand" )
131
+ parser .add_argument ('--padding' , help = "padding around reference ligand [A]" , type = float )
130
132
parser .add_argument ('--skip_gpf' , help = "do not write a GPF file for autogrid" , action = "store_true" )
131
133
parser .add_argument ('--r_eq_12' , default = 1.8 , type = float , help = "r_eq for reactive atoms (1-2 interaction)" )
132
134
parser .add_argument ('--eps_12' , default = 2.5 , type = float , help = "epsilon for reactive atoms (1-2 interaction)" )
@@ -142,21 +144,28 @@ def get_args():
142
144
msg = "can't use both --box_center and --box_center_on_reactive_res"
143
145
print ("Command line error: " + msg , file = sys .stderr )
144
146
sys .exit (2 )
145
- got_center = (args .box_center is not None ) or args .box_center_on_reactive_res
146
- if not args .skip_gpf and (args .box_size is None ) == got_center :
147
- msg = "missing center or size of grid box to write .gpf file for autogrid4" + os_linesep
148
- msg += "use --box_size and either --box_center or --box_center_on_reactive_res" + os_linesep
149
- msg += "Exactly one reactive residue required for --box_center_on_reactive_res" + os_linesep
150
- msg += "If a GPF file is not needed (e.g. docking with Vina scoring function) use option --skip_gpf"
151
- print ("Command line error: " + msg , file = sys .stderr )
152
- sys .exit (2 )
153
- if (args .box_size is None ) and not args .skip_gpf :
154
- msg = "grid box information is needed to dock with the AD4 scoring function." + os_linesep
155
- msg += "The grid box center and size will be used to write a GPF file for autogrid" + os_linesep
156
- msg += "If a GPF file is not needed (e.g. docking with Vina scoring function) use option --skip_gpf"
147
+ got_center = (args .box_center is not None ) or args .box_center_on_reactive_res or (args .ligand is not None )
148
+ if not args .skip_gpf :
149
+ if not got_center :
150
+ msg = "missing center or size of grid box to write .gpf file for autogrid4" + os_linesep
151
+ msg += "use --box_size and either --box_center or --box_center_on_reactive_res" + os_linesep
152
+ msg += "or --ligand and --padding" + os_linesep
153
+ msg += "Exactly one reactive residue required for --box_center_on_reactive_res" + os_linesep
154
+ msg += "If a GPF file is not needed (e.g. docking with Vina scoring function) use option --skip_gpf"
155
+ print ("Command line error: " + msg , file = sys .stderr )
156
+ sys .exit (2 )
157
+ if (args .box_size is None ) and (args .padding is None ):
158
+ msg = "grid box information is needed to dock with the AD4 scoring function." + os_linesep
159
+ msg += "The grid box center and size will be used to write a GPF file for autogrid" + os_linesep
160
+ msg += "If a GPF file is not needed (e.g. docking with Vina scoring function) use option --skip_gpf"
161
+ print ("Command line error: " + msg , file = sys .stderr )
162
+ sys .exit (2 )
163
+
164
+ if (args .box_center is not None ) + (args .ligand is not None ) + args .box_center_on_reactive_res > 1 :
165
+ msg = "--box_center, --box_center_on_reactive_res, and --ligand are mutually exclusive options"
157
166
print ("Command line error: " + msg , file = sys .stderr )
158
167
sys .exit (2 )
159
-
168
+
160
169
return args
161
170
162
171
args = get_args ()
@@ -183,34 +192,34 @@ def get_args():
183
192
all_ok = True
184
193
all_err = ""
185
194
for resid_string in args .reactive_flexres :
186
- res_id , ok , err = parse_residue_string (resid_string )
195
+ res_id , ok , err = parse_residue_string (resid_string )
187
196
if ok :
188
197
resname = res_id [1 ]
189
198
if resname in reactive_atom :
190
199
reactive_flexres [res_id ] = reactive_atom [resname ]
191
200
else :
192
201
all_ok = False
193
- all_err += "no default reactive name for %s, " % resname
202
+ all_err += "no default reactive name for %s, " % resname
194
203
all_err += "use --reactive_name or --reactive_name_specific" + os_linesep
195
204
all_ok &= ok
196
205
all_err += err
197
206
198
207
for string in args .reactive_name_specific :
199
- out , ok , err = parse_residue_string_and_name (string )
208
+ out , ok , err = parse_residue_string_and_name (string )
200
209
if ok :
201
210
# override name if res_id was also passed to --reactive_flexres
202
211
reactive_flexres [out ["res_id" ]] = out ["name" ]
203
212
all_ok &= ok
204
213
all_err += err
205
214
206
- if len (reactive_flexres ) > 8 :
215
+ if len (reactive_flexres ) > 8 :
207
216
msg = "got %d reactive_flexres but maximum is 8." % (len (args .reactive_flexres ))
208
217
print ("Command line error: " + msg , file = sys .stderr )
209
218
sys .exit (2 )
210
219
211
220
all_flexres = set ()
212
221
for resid_string in args .flexres :
213
- res_id , ok , err = parse_residue_string (resid_string )
222
+ res_id , ok , err = parse_residue_string (resid_string )
214
223
all_ok &= ok
215
224
all_err += err
216
225
if ok :
@@ -247,7 +256,7 @@ def get_args():
247
256
msg += "residue, but %d reactive residues are set" % len (reactive_flexres )
248
257
print ("Command line error:" + msg , file = sys .stderr )
249
258
sys .exit (2 )
250
-
259
+
251
260
if args .pdb is not None :
252
261
receptor = PDBQTReceptor (args .pdb , skip_typing = True )
253
262
ok , err = receptor .assign_types_charges ()
@@ -257,7 +266,7 @@ def get_args():
257
266
258
267
any_lig_base_types = ["HD" , "C" , "A" , "N" , "NA" , "OA" , "F" , "P" , "SA" ,
259
268
"S" , "Cl" , "CL" , "Br" , "BR" , "I" , "Si" , "B" ]
260
-
269
+
261
270
pdbqt , ok , err = receptor .write_pdbqt_string (flexres = all_flexres )
262
271
check (ok , err )
263
272
@@ -283,7 +292,7 @@ def get_args():
283
292
284
293
suffix = outpath .suffix
285
294
if outpath .suffix == "" :
286
- suffix = ".pdbqt"
295
+ suffix = ".pdbqt"
287
296
rigid_fn = str (outpath .with_suffix ("" )) + "_rigid" + suffix
288
297
flex_fn = str (outpath .with_suffix ("" )) + "_flex" + suffix
289
298
@@ -295,16 +304,17 @@ def get_args():
295
304
written_files_log ["filename" ].append (rigid_fn )
296
305
written_files_log ["description" ].append ("static (i.e., rigid) receptor input file" )
297
306
with open (rigid_fn , "w" ) as f :
298
- f .write (pdbqt ["rigid" ])
307
+ f .write (pdbqt ["rigid" ])
299
308
300
309
# GPF for autogrid4
301
310
if not args .skip_gpf :
302
311
if args .box_center is not None :
303
312
box_center = args .box_center
313
+ box_size = args .box_size
304
314
elif args .box_center_on_reactive_res :
305
315
# we have only one reactive residue and will set the box center
306
316
# to be 5 Angstromg away from CB along the CA->CB vector
307
- idxs = receptor .atom_idxs_by_res [list (reactive_flexres .keys ())[0 ]]
317
+ idxs = receptor .atom_idxs_by_res [list (reactive_flexres .keys ())[0 ]]
308
318
ca = None
309
319
cb = None
310
320
for atom in receptor .atoms (idxs ):
@@ -317,6 +327,9 @@ def get_args():
317
327
v = (cb - ca )
318
328
v /= math .sqrt (v [0 ]** 2 + v [1 ]** 2 + v [2 ]** 2 ) + 1e-8
319
329
box_center = ca + 5 * v
330
+ box_size = args .box_size
331
+ elif args .ligand is not None :
332
+ box_center , box_size = gridbox .calc_box (args .ligand , args .padding )
320
333
else :
321
334
print ("Error: No box center specified." , file = sys .stderr )
322
335
sys .exit (2 )
@@ -328,7 +341,7 @@ def get_args():
328
341
with open (ff_fn , "w" ) as f :
329
342
f .write (gridbox .boron_silicon_atompar )
330
343
rec_types = set (t for (i , t ) in enumerate (receptor .atoms ()["atom_type" ]) if i not in pdbqt ["flex_indices" ])
331
- gpf_string , npts = gridbox .get_gpf_string (box_center , args . box_size , rigid_fn , rec_types , any_lig_base_types ,
344
+ gpf_string , npts = gridbox .get_gpf_string (box_center , box_size , rigid_fn , rec_types , any_lig_base_types ,
332
345
ff_param_fname = ff_fn .name )
333
346
# write GPF
334
347
gpf_fn = pathlib .Path (rigid_fn ).with_suffix (".gpf" )
@@ -351,7 +364,7 @@ def get_args():
351
364
print ("WARNING: Flexible residue outside box." + os_linesep , file = sys .stderr )
352
365
print ("WARNING: Strongly recommended to use a box that encompasses flexible residues." + os_linesep , file = sys .stderr )
353
366
break # only need to warn once
354
-
367
+
355
368
# configuration info for AutoDock-GPU reactive docking
356
369
if len (reactive_flexres ) > 0 :
357
370
any_lig_reac_types = []
@@ -363,7 +376,7 @@ def get_args():
363
376
for line in all_flex_pdbqt .split (os_linesep ):
364
377
if line .startswith ("ATOM" ) or line .startswith ("HETATM" ):
365
378
atype = line [77 :].strip ()
366
- basetype , _ = reactive_typer .get_basetype_and_order (atype )
379
+ basetype , _ = reactive_typer .get_basetype_and_order (atype )
367
380
if basetype is not None : # is None if not reactive
368
381
rec_reac_types .append (line [77 :].strip ())
369
382
0 commit comments