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