annotate rbdock.py @ 2:1421c93f9385 draft default tip

"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/rdock commit 944ea4bb8a9cd4244152a4a4fecd0485fabc2ad0"
author bgruening
date Tue, 28 Jul 2020 12:07:08 +0000
parents 355c1759835c
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
355c1759835c "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/rdock commit 6037a8c8d53839daad1b183e1ae0329862ac2c2c"
bgruening
parents:
diff changeset
1 import subprocess
355c1759835c "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/rdock commit 6037a8c8d53839daad1b183e1ae0329862ac2c2c"
bgruening
parents:
diff changeset
2 import argparse
355c1759835c "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/rdock commit 6037a8c8d53839daad1b183e1ae0329862ac2c2c"
bgruening
parents:
diff changeset
3
355c1759835c "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/rdock commit 6037a8c8d53839daad1b183e1ae0329862ac2c2c"
bgruening
parents:
diff changeset
4 def main():
355c1759835c "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')
355c1759835c "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')
355c1759835c "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')
355c1759835c "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/rdock commit 6037a8c8d53839daad1b183e1ae0329862ac2c2c"
bgruening
parents:
diff changeset
8 args = parser.parse_args()
355c1759835c "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/rdock commit 6037a8c8d53839daad1b183e1ae0329862ac2c2c"
bgruening
parents:
diff changeset
9
355c1759835c "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']
355c1759835c "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/rdock commit 6037a8c8d53839daad1b183e1ae0329862ac2c2c"
bgruening
parents:
diff changeset
11 if args.seed != None:
355c1759835c "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)]
355c1759835c "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/rdock commit 6037a8c8d53839daad1b183e1ae0329862ac2c2c"
bgruening
parents:
diff changeset
13
355c1759835c "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)
355c1759835c "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/rdock commit 6037a8c8d53839daad1b183e1ae0329862ac2c2c"
bgruening
parents:
diff changeset
15
355c1759835c "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/rdock commit 6037a8c8d53839daad1b183e1ae0329862ac2c2c"
bgruening
parents:
diff changeset
16 error_counter = 0
355c1759835c "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, ''):
355c1759835c "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):
355c1759835c "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/rdock commit 6037a8c8d53839daad1b183e1ae0329862ac2c2c"
bgruening
parents:
diff changeset
19 error_counter += 1
355c1759835c "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/rdock commit 6037a8c8d53839daad1b183e1ae0329862ac2c2c"
bgruening
parents:
diff changeset
20 if error_counter == 10:
355c1759835c "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/rdock commit 6037a8c8d53839daad1b183e1ae0329862ac2c2c"
bgruening
parents:
diff changeset
21 print(ps.stdout)
355c1759835c "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/rdock commit 6037a8c8d53839daad1b183e1ae0329862ac2c2c"
bgruening
parents:
diff changeset
22 exit(23)
355c1759835c "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/rdock commit 6037a8c8d53839daad1b183e1ae0329862ac2c2c"
bgruening
parents:
diff changeset
23 if ps.poll() != None:
355c1759835c "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/rdock commit 6037a8c8d53839daad1b183e1ae0329862ac2c2c"
bgruening
parents:
diff changeset
24 print(ps.stdout)
355c1759835c "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/rdock commit 6037a8c8d53839daad1b183e1ae0329862ac2c2c"
bgruening
parents:
diff changeset
25 exit(int(ps.poll()))
355c1759835c "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/rdock commit 6037a8c8d53839daad1b183e1ae0329862ac2c2c"
bgruening
parents:
diff changeset
26
355c1759835c "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/rdock commit 6037a8c8d53839daad1b183e1ae0329862ac2c2c"
bgruening
parents:
diff changeset
27 if __name__ == "__main__":
355c1759835c "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/rdock commit 6037a8c8d53839daad1b183e1ae0329862ac2c2c"
bgruening
parents:
diff changeset
28 main()