comparison calc_vina_box_params.py @ 1:4f7c5cad3377 draft

planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/autodock_vina commit ed9b6859de648aa5f7cde483732f5df20aaff90e
author bgruening
date Tue, 07 May 2019 13:31:59 -0400
parents 761762031eee
children 73c2c9774c2d
comparison
equal deleted inserted replaced
0:761762031eee 1:4f7c5cad3377
1 import numpy as np 1 import numpy as np
2 from rdkit import Chem 2 from rdkit import Chem
3 from rdkit.Chem import rdShapeHelpers 3 from rdkit.Chem import rdShapeHelpers
4 import argparse 4 import argparse
5 from random import randint
5 6
6 7
7 def get_params(options): 8 def get_params(options):
8 # make sure we have a mol file by initiating rdkit mol object from input 9 # make sure we have a mol file by initiating rdkit mol object from input
9 mol = Chem.MolFromMolFile(options.ligand_path) 10 mol = Chem.MolFromMolFile(options.ligand_path)
25 dims = np.abs(coords1 - coords2) 26 dims = np.abs(coords1 - coords2)
26 27
27 # optionally add buffers in each direction - expansion 28 # optionally add buffers in each direction - expansion
28 box_dims = [dims[0] + options.bufx, dims[1] + options.bufy, dims[2] + options.bufz] 29 box_dims = [dims[0] + options.bufx, dims[1] + options.bufy, dims[2] + options.bufz]
29 30
31 # if no seed set, then randomly generate one between 0 and 2**31
32 if options.seed == None:
33 options.seed = randint(0, 2147483647)
34
30 with open(options.output, 'w') as f: 35 with open(options.output, 'w') as f:
31 f.write( 36 f.write(
32 """ 37 """
33 size_x = {} 38 size_x = {}
34 size_y = {} 39 size_y = {}
38 center_z = {} 43 center_z = {}
39 num_modes = 9999 44 num_modes = 9999
40 energy_range = 9999 45 energy_range = 9999
41 exhaustiveness = {} 46 exhaustiveness = {}
42 cpu = 4 47 cpu = 4
43 seed = 1 48 seed = {}
44 """.format(box_dims[0], box_dims[1], box_dims[2], center[0], center[1], center[2], options.exhaustiveness) 49 """.format(box_dims[0], box_dims[1], box_dims[2], center[0], center[1], center[2], options.exhaustiveness, options.seed)
45 ) 50 )
46 51
47 52
48 if __name__ == "__main__": 53 if __name__ == "__main__":
49 parser = argparse.ArgumentParser(description=""" 54 parser = argparse.ArgumentParser(description="""
50 This tool calculates a confounding box around an input ligand (mol file), and uses it to 55 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 56 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. 57 the autodock vina tool as an alternative to creating the parameter file manually.
53 58
54 Optionally, you can include a 'buffer' in each of the x,y and z directions (in angstroms), 59 Optionally, you can include a 'buffer' in each of the x,y and z directions (in Å),
55 which will be added to the confounding box in the appropriate direction. 60 which will be added to the confounding box in the appropriate direction.
56 """) 61 """)
57 parser.add_argument('--ligand', dest='ligand_path', help='The input ligand (mol file)') 62 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)') 63 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 ' 64 parser.add_argument('--exh', dest='exhaustiveness', default=10, type=int, help='The number of poses '
62 '(float - in angs.)') 67 '(float - in angs.)')
63 parser.add_argument('--bufy', dest='bufy', default=0, type=float, help='the buffer in the y direction ' 68 parser.add_argument('--bufy', dest='bufy', default=0, type=float, help='the buffer in the y direction '
64 '(float - in angs.)') 69 '(float - in angs.)')
65 parser.add_argument('--bufz', dest='bufz', default=0, type=float, help='the buffer in the z direction ' 70 parser.add_argument('--bufz', dest='bufz', default=0, type=float, help='the buffer in the z direction '
66 '(float - in angs.)') 71 '(float - in angs.)')
72 parser.add_argument('--seed', dest='seed', default=None, type=int, help='Random seed for reproducibility')
67 73
68 options = parser.parse_args() 74 options = parser.parse_args()
69 get_params(options) 75 get_params(options)