changeset 0:255b6b88be7c 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:10:38 -0400
parents
children d965076a0cd2
files calc_vina_box_params.py prepare_box.xml test-data/NUDT5A-x0114_2.mol test-data/box_params.txt
diffstat 4 files changed, 218 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/calc_vina_box_params.py	Wed Apr 17 09:10:38 2019 -0400
@@ -0,0 +1,69 @@
+import numpy as np
+from rdkit import Chem
+from rdkit.Chem import rdShapeHelpers
+import argparse
+
+
+def get_params(options):
+    # make sure we have a mol file by initiating rdkit mol object from input
+    mol = Chem.MolFromMolFile(options.ligand_path)
+    if not mol:
+        raise IOError
+
+    # get rdkit conformer and compute x,y,z of top and bottom corner of confounding cuboid
+    conf = mol.GetConformer()
+    params = rdShapeHelpers.ComputeConfBox(conf)
+
+    # change tuples to arrays
+    coords1 = np.array(params[0])
+    coords2 = np.array(params[1])
+
+    # get the centre of the box
+    center = np.mean((coords1, coords2), axis=0)
+
+    # calculate box dimensions
+    dims = np.abs(coords1 - coords2)
+
+    # optionally add buffers in each direction - expansion
+    box_dims = [dims[0] + options.bufx, dims[1] + options.bufy, dims[2] + options.bufz]
+
+    with open(options.output, 'w') as f:
+        f.write(
+            """
+size_x =  {}
+size_y =  {}
+size_z =  {}
+center_x =  {}
+center_y =  {}
+center_z =  {}
+num_modes = 9999
+energy_range = 9999
+exhaustiveness = {}
+cpu = 4
+seed = 1
+            """.format(box_dims[0], box_dims[1], box_dims[2], center[0], center[1], center[2], options.exhaustiveness)
+        )
+
+
+if __name__ == "__main__":
+    parser = argparse.ArgumentParser(description="""
+    This tool calculates a confounding box around an input ligand (mol file), and uses it to
+    generate the input parameters for an autodock vina job. The output file can be fed into
+    the autodock vina tool as an alternative to creating the parameter file manually. 
+    
+    Optionally, you can include a 'buffer' in each of the x,y and z directions (in angstroms),
+    which will be added to the confounding box in the appropriate direction.
+    """)
+    parser.add_argument('--ligand', dest='ligand_path', help='The input ligand (mol file)')
+    parser.add_argument('--config', dest='output', help='The output file containing calculated params (txt)')
+    parser.add_argument('--exh', dest='exhaustiveness', default=10, type=int, help='The number of poses '
+                                                                                     'to return from docking job')
+    parser.add_argument('--bufx', dest='bufx', default=0, type=float, help='the buffer in the x direction '
+                                                                           '(float - in angs.)')
+    parser.add_argument('--bufy', dest='bufy', default=0, type=float, help='the buffer in the y direction '
+                                                                           '(float - in angs.)')
+    parser.add_argument('--bufz', dest='bufz', default=0, type=float, help='the buffer in the z direction '
+                                                                           '(float - in angs.)')
+
+    options = parser.parse_args()
+    get_params(options)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/prepare_box.xml	Wed Apr 17 09:10:38 2019 -0400
@@ -0,0 +1,102 @@
+<tool id="prepare_box" name="Calculate the box parameters for an AutoDock Vina" version="0.1.0">
+    <description>job from an input mol file (confounding box)</description>
+    <requirements>
+        <requirement type="package" version="2019.03.1.0">rdkit</requirement>
+        <requirement type="package" version="1.16.2">numpy</requirement>
+    </requirements>
+    <command detect_errors="exit_code"><![CDATA[
+        python '$__tool_directory__/calc_vina_box_params.py'
+        --ligand '$input1'
+        --config '$output1'
+        --bufx '$bufx'
+        --bufy '$bufy'
+        --bufz '$bufz'
+        --exh '$exh'
+    ]]></command>
+    <inputs>
+        <param type="data" name="input1" format="mol" label="input ligand mol file"
+            help="The input ligand (mol file)"/>
+        <param name="bufx" type="float" value="0" label="x-axis buffer"
+            help="the buffer in the x direction (in angs.)"/>
+        <param name="bufy" type="float" value="0" label="y-axis buffer"
+            help="the buffer in the y direction (in angs.)"/>
+        <param name="bufz" type="float" value="0" label="z-axis buffer"
+            help="the buffer in the z direction (in angs.)"/>
+        <param name="exh" type="integer" value="0" label="exhaustiveness"
+            help="The number of poses to return from docking job"/>
+    </inputs>
+    <outputs>
+        <data name="output1" format="txt" />
+    </outputs>
+    <tests>
+        <test>
+            <param name="input1" value="NUDT5A-x0114_2.mol" />
+            <param name="bufx" value="1" />
+            <param name="bufy" value="2" />
+            <param name="bufz" value="3" />
+            <param name="exh" value="10" />
+            <output name="output1" file="box_params.txt" />
+        </test>
+    </tests>
+    <help><![CDATA[
+
+.. class:: infomark
+
+**Description:**
+
+This tool calculates a confounding box around an input ligand (mol file), and
+uses it to generate the input parameters for an autodock vina job.
+
+The output file can be fed into the autodock vina tool as an alternative to creating the
+parameter file manually.
+
+-----
+.. class:: infomark
+
+**Inputs:**
+
+This tool requires:
+* An input ligand - This should be a mol file representing the ligand you wish to dock.
+This should be derived from the file you use to prepare the ligand for the docking job
+(see prepare ligand tool).
+
+* OPTIONAL Buffers for each direction (x,y,z), which defaults to 0 angstroms. This value
+will be added to the confounding box that the tool generates in each respective direction.
+We recommend that you visualise the calculated box from an initial run of this tool, and
+calculate the expansion needed in each direction to cover the area of the binding site
+you wish to explore.
+
+-----
+.. class:: infomark
+
+**Output:**
+
+The output for this tool is a txt file containing the parameters needed to run an autodock
+vina docking calculation with the docking tool. For example:
+
+size_x =  12.443000000000001
+size_y =  11.888
+size_z =  9.290999999999997
+center_x =  -29.8395
+center_y =  4.364
+center_z =  -64.5925
+num_modes = 9999
+energy_range = 9999
+exhaustiveness = 10
+cpu = 4
+seed = 1
+
+The values for num_modes, energy range, cpu and seed are set to default values here.
+
+This file can be used as the box parameter for the docking tool.
+
+    ]]></help>
+    <citations>
+        <citation type="bibtex">
+            @article{rdkit,
+                author = {Greg Landrum},
+                title = {RDKit: Open-source cheminformatics},
+                url ={http://www.rdkit.org}
+            }</citation>
+    </citations>
+</tool>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test-data/NUDT5A-x0114_2.mol	Wed Apr 17 09:10:38 2019 -0400
@@ -0,0 +1,34 @@
+
+     RDKit          3D
+
+ 14 15  0  0  0  0  0  0  0  0999 V2000
+  -29.7210    5.1080  -63.9440 N   0  0  0  0  0  0  0  0  0  0  0  0
+  -32.1200    1.4200  -65.7380 C   0  0  0  0  0  0  0  0  0  0  0  0
+  -32.3550    4.2720  -63.4470 O   0  0  0  0  0  0  0  0  0  0  0  0
+  -32.1450    2.9190  -65.4240 C   0  0  1  0  0  0  0  0  0  0  0  0
+  -33.5610    3.5680  -65.3800 C   0  0  0  0  0  0  0  0  0  0  0  0
+  -33.4090    4.6780  -64.3250 C   0  0  0  0  0  0  0  0  0  0  0  0
+  -31.5300    3.2840  -64.0390 C   0  0  1  0  0  0  0  0  0  0  0  0
+  -30.0640    3.7560  -64.2700 C   0  0  0  0  0  0  0  0  0  0  0  0
+  -28.4710    5.7300  -64.0910 C   0  0  0  0  0  0  0  0  0  0  0  0
+  -28.1090    7.0310  -63.7420 C   0  0  0  0  0  0  0  0  0  0  0  0
+  -26.7490    7.3080  -64.0480 N   0  0  0  0  0  0  0  0  0  0  0  0
+  -26.1180    6.3750  -64.5730 N   0  0  0  0  0  0  0  0  0  0  0  0
+  -29.2560    2.9400  -64.7040 O   0  0  0  0  0  0  0  0  0  0  0  0
+  -27.0620    4.9230  -64.8090 S   0  0  0  0  0  0  0  0  0  0  0  0
+  1  8  1  0
+  1  9  1  0
+  3  6  1  0
+  3  7  1  0
+  4  2  1  1
+  4  5  1  0
+  4  7  1  0
+  5  6  1  0
+  7  8  1  6
+  8 13  2  0
+  9 10  2  0
+  9 14  1  0
+ 10 11  1  0
+ 11 12  2  0
+ 12 14  1  0
+M  END
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test-data/box_params.txt	Wed Apr 17 09:10:38 2019 -0400
@@ -0,0 +1,13 @@
+
+size_x =  12.443000000000001
+size_y =  11.888
+size_z =  9.290999999999997
+center_x =  -29.8395
+center_y =  4.364
+center_z =  -64.5925
+num_modes = 9999
+energy_range = 9999
+exhaustiveness = 10
+cpu = 4
+seed = 1
+            
\ No newline at end of file