diff rbdock.py @ 0:7a4306d69801 draft

"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/rdock commit 6037a8c8d53839daad1b183e1ae0329862ac2c2c"
author bgruening
date Mon, 04 May 2020 07:41:13 -0400
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/rbdock.py	Mon May 04 07:41:13 2020 -0400
@@ -0,0 +1,28 @@
+import subprocess
+import argparse
+
+def main():
+    parser = argparse.ArgumentParser(description='Simple wrapper for rbdock')
+    parser.add_argument('-n', '--num', type=int, help='Number of docking poses to generate')
+    parser.add_argument('-s', '--seed', type=int, help='Random seed')
+    args = parser.parse_args()
+
+    cmd = ['rbdock', '-i', 'ligands.sdf', '-r', 'receptor.prm', '-p', 'dock.prm', '-n', str(args.num), '-o', 'rdock_output']
+    if args.seed != None:
+        cmd += ['-s', str(args.seed)]
+
+    ps = subprocess.Popen(cmd, stdout=subprocess.PIPE)
+
+    error_counter = 0
+    for stdout_line in iter(ps.stdout.readline, ''):
+        if 'RBT_DOCKING_ERROR' in str(stdout_line):
+                error_counter += 1
+                if error_counter == 10:
+                    print(ps.stdout)
+                    exit(23)
+        if ps.poll() != None:
+            print(ps.stdout)
+            exit(int(ps.poll()))
+
+if __name__ == "__main__":
+    main()