annotate rbdock.py @ 0:e99f861ba68a draft

"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/rxdock commit bb19570293b920983b6856b30b42203a09543bc5"
author bgruening
date Sat, 04 Apr 2020 15:04:13 -0400
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
e99f861ba68a "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/rxdock commit bb19570293b920983b6856b30b42203a09543bc5"
bgruening
parents:
diff changeset
1 import subprocess
e99f861ba68a "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/rxdock commit bb19570293b920983b6856b30b42203a09543bc5"
bgruening
parents:
diff changeset
2 import argparse
e99f861ba68a "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/rxdock commit bb19570293b920983b6856b30b42203a09543bc5"
bgruening
parents:
diff changeset
3
e99f861ba68a "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/rxdock commit bb19570293b920983b6856b30b42203a09543bc5"
bgruening
parents:
diff changeset
4 def main():
e99f861ba68a "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/rxdock commit bb19570293b920983b6856b30b42203a09543bc5"
bgruening
parents:
diff changeset
5 parser = argparse.ArgumentParser(description='Simple wrapper for rbdock')
e99f861ba68a "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/rxdock commit bb19570293b920983b6856b30b42203a09543bc5"
bgruening
parents:
diff changeset
6 parser.add_argument('-n', '--num', type=int, help='Number of docking poses to generate')
e99f861ba68a "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/rxdock commit bb19570293b920983b6856b30b42203a09543bc5"
bgruening
parents:
diff changeset
7 parser.add_argument('-s', '--seed', type=int, help='Random seed')
e99f861ba68a "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/rxdock commit bb19570293b920983b6856b30b42203a09543bc5"
bgruening
parents:
diff changeset
8 args = parser.parse_args()
e99f861ba68a "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/rxdock commit bb19570293b920983b6856b30b42203a09543bc5"
bgruening
parents:
diff changeset
9
e99f861ba68a "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/rxdock commit bb19570293b920983b6856b30b42203a09543bc5"
bgruening
parents:
diff changeset
10 cmd = ['rbdock', '-i', 'ligands.sdf', '-r', 'receptor.prm', '-p', 'dock.prm', '-n', str(args.num), '-o', 'rdock_output']
e99f861ba68a "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/rxdock commit bb19570293b920983b6856b30b42203a09543bc5"
bgruening
parents:
diff changeset
11 if args.seed != None:
e99f861ba68a "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/rxdock commit bb19570293b920983b6856b30b42203a09543bc5"
bgruening
parents:
diff changeset
12 cmd += ['-s', str(args.seed)]
e99f861ba68a "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/rxdock commit bb19570293b920983b6856b30b42203a09543bc5"
bgruening
parents:
diff changeset
13
e99f861ba68a "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/rxdock commit bb19570293b920983b6856b30b42203a09543bc5"
bgruening
parents:
diff changeset
14 ps = subprocess.Popen(cmd, stdout=subprocess.PIPE)
e99f861ba68a "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/rxdock commit bb19570293b920983b6856b30b42203a09543bc5"
bgruening
parents:
diff changeset
15
e99f861ba68a "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/rxdock commit bb19570293b920983b6856b30b42203a09543bc5"
bgruening
parents:
diff changeset
16 error_counter = 0
e99f861ba68a "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/rxdock commit bb19570293b920983b6856b30b42203a09543bc5"
bgruening
parents:
diff changeset
17 for stdout_line in iter(ps.stdout.readline, ''):
e99f861ba68a "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/rxdock commit bb19570293b920983b6856b30b42203a09543bc5"
bgruening
parents:
diff changeset
18 if 'RBT_DOCKING_ERROR' in str(stdout_line):
e99f861ba68a "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/rxdock commit bb19570293b920983b6856b30b42203a09543bc5"
bgruening
parents:
diff changeset
19 error_counter += 1
e99f861ba68a "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/rxdock commit bb19570293b920983b6856b30b42203a09543bc5"
bgruening
parents:
diff changeset
20 if error_counter == 10:
e99f861ba68a "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/rxdock commit bb19570293b920983b6856b30b42203a09543bc5"
bgruening
parents:
diff changeset
21 print(ps.stdout)
e99f861ba68a "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/rxdock commit bb19570293b920983b6856b30b42203a09543bc5"
bgruening
parents:
diff changeset
22 exit(23)
e99f861ba68a "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/rxdock commit bb19570293b920983b6856b30b42203a09543bc5"
bgruening
parents:
diff changeset
23 if ps.poll() != None:
e99f861ba68a "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/rxdock commit bb19570293b920983b6856b30b42203a09543bc5"
bgruening
parents:
diff changeset
24 print(ps.stdout)
e99f861ba68a "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/rxdock commit bb19570293b920983b6856b30b42203a09543bc5"
bgruening
parents:
diff changeset
25 exit(int(ps.poll()))
e99f861ba68a "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/rxdock commit bb19570293b920983b6856b30b42203a09543bc5"
bgruening
parents:
diff changeset
26
e99f861ba68a "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/rxdock commit bb19570293b920983b6856b30b42203a09543bc5"
bgruening
parents:
diff changeset
27 if __name__ == "__main__":
e99f861ba68a "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/rxdock commit bb19570293b920983b6856b30b42203a09543bc5"
bgruening
parents:
diff changeset
28 main()