annotate rbdock.py @ 1:8e214e52e461 draft

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