Mercurial > repos > bgruening > autodock_vina_prepare_box
comparison calc_vina_box_params.py @ 3:908880455b2d draft
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/autodock_vina commit deb7ad38cefd13df312431b1138054a68381efdf"
author | bgruening |
---|---|
date | Fri, 18 Oct 2019 04:57:34 -0400 |
parents | 73c2c9774c2d |
children | 668c60aa4799 |
comparison
equal
deleted
inserted
replaced
2:73c2c9774c2d | 3:908880455b2d |
---|---|
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 from random import randint |
6 | 6 |
7 def get_mol_from_file(fname, ftype): | |
8 if ftype in ['mol', 'sdf']: | |
9 mol = Chem.MolFromMolFile(options.ligand_path) | |
10 elif ftype == 'pdb': | |
11 mol = Chem.MolFromPDBFile(options.ligand_path) | |
12 elif ftype == 'mol2': | |
13 mol = Chem.MolFromMol2File(options.ligand_path) | |
14 else: | |
15 raise IOError | |
16 if not mol: | |
17 raise IOError | |
18 return mol | |
7 | 19 |
8 def get_params(options): | 20 def get_params(options): |
9 # make sure we have a mol file by initiating rdkit mol object from input | 21 mol = get_mol_from_file(options.ligand_path, options.ftype) |
10 mol = Chem.MolFromMolFile(options.ligand_path) | |
11 if not mol: | |
12 raise IOError | |
13 | 22 |
14 # get rdkit conformer and compute x,y,z of top and bottom corner of confounding cuboid | 23 # get rdkit conformer and compute x,y,z of top and bottom corner of confounding cuboid |
15 conf = mol.GetConformer() | 24 conf = mol.GetConformer() |
16 params = rdShapeHelpers.ComputeConfBox(conf) | 25 params = rdShapeHelpers.ComputeConfBox(conf) |
17 | 26 |
49 ) | 58 ) |
50 | 59 |
51 | 60 |
52 if __name__ == "__main__": | 61 if __name__ == "__main__": |
53 parser = argparse.ArgumentParser(description=""" | 62 parser = argparse.ArgumentParser(description=""" |
54 This tool calculates a confounding box around an input ligand (mol file), and uses it to | 63 This tool calculates a confounding box around an input ligand, and uses it to |
55 generate the input parameters for an autodock vina job. The output file can be fed into | 64 generate the input parameters for an autodock vina job. The output file can be fed into |
56 the autodock vina tool as an alternative to creating the parameter file manually. | 65 the autodock vina tool as an alternative to creating the parameter file manually. |
57 | 66 |
58 Optionally, you can include a 'buffer' in each of the x,y and z directions (in Å), | 67 Optionally, you can include a 'buffer' in each of the x,y and z directions (in Å), |
59 which will be added to the confounding box in the appropriate direction. | 68 which will be added to the confounding box in the appropriate direction. |
60 """) | 69 """) |
61 parser.add_argument('--ligand', dest='ligand_path', help='The input ligand (mol file)') | 70 parser.add_argument('--ligand', dest='ligand_path', help='The input ligand filepath.') |
71 parser.add_argument('--ftype', dest='ftype', help='Filetype of the input ligand (mol, sdf, pdb, mol2)') | |
62 parser.add_argument('--config', dest='output', help='The output file containing calculated params (txt)') | 72 parser.add_argument('--config', dest='output', help='The output file containing calculated params (txt)') |
63 parser.add_argument('--exh', dest='exhaustiveness', type=int, help='Exhaustiveness of global search') | 73 parser.add_argument('--exh', dest='exhaustiveness', type=int, help='Exhaustiveness of global search') |
64 parser.add_argument('--bufx', dest='bufx', default=0, type=float, help='the buffer in the x direction ' | 74 parser.add_argument('--bufx', dest='bufx', default=0, type=float, help='the buffer in the x direction ' |
65 '(float - in angs.)') | 75 '(float - in angs.)') |
66 parser.add_argument('--bufy', dest='bufy', default=0, type=float, help='the buffer in the y direction ' | 76 parser.add_argument('--bufy', dest='bufy', default=0, type=float, help='the buffer in the y direction ' |