diff 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
line wrap: on
line diff
--- a/calc_vina_box_params.py	Wed Oct 02 12:49:11 2019 -0400
+++ b/calc_vina_box_params.py	Fri Oct 18 04:57:34 2019 -0400
@@ -4,12 +4,21 @@
 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)
+    else:
+        raise IOError
+    if not mol:
+        raise IOError
+    return mol
 
 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
+    mol = get_mol_from_file(options.ligand_path, options.ftype)
 
     # get rdkit conformer and compute x,y,z of top and bottom corner of confounding cuboid
     conf = mol.GetConformer()
@@ -51,14 +60,15 @@
 
 if __name__ == "__main__":
     parser = argparse.ArgumentParser(description="""
-    This tool calculates a confounding box around an input ligand (mol file), and uses it to
+    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. 
     
     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 (mol file)')
+    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 '