annotate rbdock.py @ 5:e4b7d1507a75 draft

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