changeset 5:668c60aa4799 draft

"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/autodock_vina commit 26e9f1627e91a4be6bdc7e71cd44f1ea1701ee6f"
author bgruening
date Thu, 22 Jul 2021 14:04:57 +0000
parents ad35eaa204ea
children 8f766d9652a2
files calc_vina_box_params.py prepare_box.xml
diffstat 2 files changed, 74 insertions(+), 30 deletions(-) [+]
line wrap: on
line diff
--- a/calc_vina_box_params.py	Tue Jul 28 08:16:17 2020 -0400
+++ b/calc_vina_box_params.py	Thu Jul 22 14:04:57 2021 +0000
@@ -1,22 +1,24 @@
+import argparse
+
 import numpy as np
 from rdkit import Chem
 from rdkit.Chem import rdShapeHelpers
-import argparse
-from random import randint
+
 
 def get_mol_from_file(fname, ftype):
-    if ftype in ['mol', 'sdf']:
-        mol = Chem.MolFromMolFile(options.ligand_path)
-    elif ftype == 'pdb':
-        mol = Chem.MolFromPDBFile(options.ligand_path)
-    elif ftype == 'mol2':
-        mol = Chem.MolFromMol2File(options.ligand_path)
+    if ftype in ["mol", "sdf"]:
+        mol = Chem.MolFromMolFile(options.ligand_path, strictParsing=False, sanitize=False)
+    elif ftype == "pdb":
+        mol = Chem.MolFromPDBFile(options.ligand_path, sanitize=False)
+    elif ftype == "mol2":
+        mol = Chem.MolFromMol2File(options.ligand_path, sanitize=False)
     else:
         raise IOError
     if not mol:
         raise IOError
     return mol
 
+
 def get_params(options):
     mol = get_mol_from_file(options.ligand_path, options.ftype)
 
@@ -39,13 +41,12 @@
 
     optionalvals = ""
 
-
-    if options.seed != None:
+    if options.seed is not None:
         optionalvals += "seed = " + str(options.seed) + "\n"
-    if options.exhaustiveness != None:
+    if options.exhaustiveness is not None:
         optionalvals += "exhaustiveness = " + str(options.exhaustiveness) + "\n"
 
-    with open(options.output, 'w') as f:
+    with open(options.output, "w") as f:
         f.write(
             """
 size_x =  {}
@@ -54,30 +55,73 @@
 center_x =  {}
 center_y =  {}
 center_z =  {}
-{}""".format(box_dims[0], box_dims[1], box_dims[2], center[0], center[1], center[2], optionalvals)
+{}""".format(
+                box_dims[0],
+                box_dims[1],
+                box_dims[2],
+                center[0],
+                center[1],
+                center[2],
+                optionalvals,
+            )
         )
 
 
 if __name__ == "__main__":
-    parser = argparse.ArgumentParser(description="""
+    parser = argparse.ArgumentParser(
+        description="""
     This tool calculates a confounding box around an input ligand, 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. 
-    
+    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 Å),
     which will be added to the confounding box in the appropriate direction.
-    """)
-    parser.add_argument('--ligand', dest='ligand_path', help='The input ligand filepath.')
-    parser.add_argument('--ftype', dest='ftype', help='Filetype of the input ligand (mol, sdf, pdb, mol2)')
-    parser.add_argument('--config', dest='output', help='The output file containing calculated params (txt)')
-    parser.add_argument('--exh', dest='exhaustiveness', type=int, help='Exhaustiveness of global search')
-    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.)')
-    parser.add_argument('--seed', dest='seed', default=None, type=int, help='Random seed for reproducibility')
+    """
+    )
+    parser.add_argument(
+        "--ligand", dest="ligand_path", help="The input ligand filepath."
+    )
+    parser.add_argument(
+        "--ftype",
+        dest="ftype",
+        help="Filetype of the input ligand (mol, sdf, pdb, mol2)",
+    )
+    parser.add_argument(
+        "--config",
+        dest="output",
+        help="The output file containing calculated params (txt)",
+    )
+    parser.add_argument(
+        "--exh", dest="exhaustiveness", type=int, help="Exhaustiveness of global search"
+    )
+    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.)",
+    )
+    parser.add_argument(
+        "--seed",
+        dest="seed",
+        default=None,
+        type=int,
+        help="Random seed for reproducibility",
+    )
 
     options = parser.parse_args()
     get_params(options)
--- a/prepare_box.xml	Tue Jul 28 08:16:17 2020 -0400
+++ b/prepare_box.xml	Thu Jul 22 14:04:57 2021 +0000
@@ -1,6 +1,6 @@
 <tool id="prepare_box" name="Calculate the box parameters using RDKit" version="@TOOL_VERSION@+galaxy@GALAXY_VERSION@">
     <macros>
-        <token name="@TOOL_VERSION@">2020.03.4</token>
+        <token name="@TOOL_VERSION@">2021.03.4</token>
         <token name="@GALAXY_VERSION@">0</token>
     </macros>
     <description>for an AutoDock Vina job from a ligand input file (confounding box)</description>
@@ -82,7 +82,7 @@
 **Description**
 
 This tool calculates a confounding box around an input ligand and
-uses it to generate the input parameters for an autodock vina job.
+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.