Mercurial > repos > bgruening > rdock_rbdock
annotate rbdock.py @ 9:c362398df83b 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 08:43:58 -0400 |
parents | a428230b38f6 |
children |
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() |