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