Mercurial > repos > bgruening > rdock_sort_filter
annotate rbdock.py @ 2:a6ec6c55267e draft
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/rdock commit db76c3bc4ced257e2f622fcf8fcc6d2e28de3577"
author | bgruening |
---|---|
date | Tue, 14 Apr 2020 06:35:35 -0400 |
parents | 4812dc209abd |
children |
rev | line source |
---|---|
1
4812dc209abd
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/rdock commit db567a29443284f2cec1444ec9db9aa6bd913fad"
bgruening
parents:
diff
changeset
|
1 import subprocess |
4812dc209abd
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/rdock commit db567a29443284f2cec1444ec9db9aa6bd913fad"
bgruening
parents:
diff
changeset
|
2 import argparse |
4812dc209abd
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/rdock commit db567a29443284f2cec1444ec9db9aa6bd913fad"
bgruening
parents:
diff
changeset
|
3 |
4812dc209abd
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/rdock commit db567a29443284f2cec1444ec9db9aa6bd913fad"
bgruening
parents:
diff
changeset
|
4 def main(): |
4812dc209abd
"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') |
4812dc209abd
"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') |
4812dc209abd
"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') |
4812dc209abd
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/rdock commit db567a29443284f2cec1444ec9db9aa6bd913fad"
bgruening
parents:
diff
changeset
|
8 args = parser.parse_args() |
4812dc209abd
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/rdock commit db567a29443284f2cec1444ec9db9aa6bd913fad"
bgruening
parents:
diff
changeset
|
9 |
4812dc209abd
"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'] |
4812dc209abd
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/rdock commit db567a29443284f2cec1444ec9db9aa6bd913fad"
bgruening
parents:
diff
changeset
|
11 if args.seed != None: |
4812dc209abd
"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)] |
4812dc209abd
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/rdock commit db567a29443284f2cec1444ec9db9aa6bd913fad"
bgruening
parents:
diff
changeset
|
13 |
4812dc209abd
"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) |
4812dc209abd
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/rdock commit db567a29443284f2cec1444ec9db9aa6bd913fad"
bgruening
parents:
diff
changeset
|
15 |
4812dc209abd
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/rdock commit db567a29443284f2cec1444ec9db9aa6bd913fad"
bgruening
parents:
diff
changeset
|
16 error_counter = 0 |
4812dc209abd
"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, ''): |
4812dc209abd
"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): |
4812dc209abd
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/rdock commit db567a29443284f2cec1444ec9db9aa6bd913fad"
bgruening
parents:
diff
changeset
|
19 error_counter += 1 |
4812dc209abd
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/rdock commit db567a29443284f2cec1444ec9db9aa6bd913fad"
bgruening
parents:
diff
changeset
|
20 if error_counter == 10: |
4812dc209abd
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/rdock commit db567a29443284f2cec1444ec9db9aa6bd913fad"
bgruening
parents:
diff
changeset
|
21 print(ps.stdout) |
4812dc209abd
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/rdock commit db567a29443284f2cec1444ec9db9aa6bd913fad"
bgruening
parents:
diff
changeset
|
22 exit(23) |
4812dc209abd
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/rdock commit db567a29443284f2cec1444ec9db9aa6bd913fad"
bgruening
parents:
diff
changeset
|
23 if ps.poll() != None: |
4812dc209abd
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/rdock commit db567a29443284f2cec1444ec9db9aa6bd913fad"
bgruening
parents:
diff
changeset
|
24 print(ps.stdout) |
4812dc209abd
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/rdock commit db567a29443284f2cec1444ec9db9aa6bd913fad"
bgruening
parents:
diff
changeset
|
25 exit(int(ps.poll())) |
4812dc209abd
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/rdock commit db567a29443284f2cec1444ec9db9aa6bd913fad"
bgruening
parents:
diff
changeset
|
26 |
4812dc209abd
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/rdock commit db567a29443284f2cec1444ec9db9aa6bd913fad"
bgruening
parents:
diff
changeset
|
27 if __name__ == "__main__": |
4812dc209abd
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/rdock commit db567a29443284f2cec1444ec9db9aa6bd913fad"
bgruening
parents:
diff
changeset
|
28 main() |