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