comparison calc_vina_box_params.py @ 0:761762031eee draft

planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/autodock_vina commit a657ca32e9a470d710e483e9c3c2706726bec9a3
author bgruening
date Wed, 17 Apr 2019 09:11:01 -0400
parents
children 4f7c5cad3377
comparison
equal deleted inserted replaced
-1:000000000000 0:761762031eee
1 import numpy as np
2 from rdkit import Chem
3 from rdkit.Chem import rdShapeHelpers
4 import argparse
5
6
7 def get_params(options):
8 # make sure we have a mol file by initiating rdkit mol object from input
9 mol = Chem.MolFromMolFile(options.ligand_path)
10 if not mol:
11 raise IOError
12
13 # get rdkit conformer and compute x,y,z of top and bottom corner of confounding cuboid
14 conf = mol.GetConformer()
15 params = rdShapeHelpers.ComputeConfBox(conf)
16
17 # change tuples to arrays
18 coords1 = np.array(params[0])
19 coords2 = np.array(params[1])
20
21 # get the centre of the box
22 center = np.mean((coords1, coords2), axis=0)
23
24 # calculate box dimensions
25 dims = np.abs(coords1 - coords2)
26
27 # optionally add buffers in each direction - expansion
28 box_dims = [dims[0] + options.bufx, dims[1] + options.bufy, dims[2] + options.bufz]
29
30 with open(options.output, 'w') as f:
31 f.write(
32 """
33 size_x = {}
34 size_y = {}
35 size_z = {}
36 center_x = {}
37 center_y = {}
38 center_z = {}
39 num_modes = 9999
40 energy_range = 9999
41 exhaustiveness = {}
42 cpu = 4
43 seed = 1
44 """.format(box_dims[0], box_dims[1], box_dims[2], center[0], center[1], center[2], options.exhaustiveness)
45 )
46
47
48 if __name__ == "__main__":
49 parser = argparse.ArgumentParser(description="""
50 This tool calculates a confounding box around an input ligand (mol file), and uses it to
51 generate the input parameters for an autodock vina job. The output file can be fed into
52 the autodock vina tool as an alternative to creating the parameter file manually.
53
54 Optionally, you can include a 'buffer' in each of the x,y and z directions (in angstroms),
55 which will be added to the confounding box in the appropriate direction.
56 """)
57 parser.add_argument('--ligand', dest='ligand_path', help='The input ligand (mol file)')
58 parser.add_argument('--config', dest='output', help='The output file containing calculated params (txt)')
59 parser.add_argument('--exh', dest='exhaustiveness', default=10, type=int, help='The number of poses '
60 'to return from docking job')
61 parser.add_argument('--bufx', dest='bufx', default=0, type=float, help='the buffer in the x direction '
62 '(float - in angs.)')
63 parser.add_argument('--bufy', dest='bufy', default=0, type=float, help='the buffer in the y direction '
64 '(float - in angs.)')
65 parser.add_argument('--bufz', dest='bufz', default=0, type=float, help='the buffer in the z direction '
66 '(float - in angs.)')
67
68 options = parser.parse_args()
69 get_params(options)