Mercurial > repos > sanbi-uwc > build_ctb_gene
annotate build_ctb_gene.py @ 9:9cc174f0fb9f draft
planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit 2b6755be1c76f3e4209f9723e7f50f945939244f
author | sanbi-uwc |
---|---|
date | Mon, 16 May 2016 05:45:10 -0400 |
parents | 56555326a056 |
children | cb322069c7bc |
rev | line source |
---|---|
4
714cbeae0b96
planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit 43f091b6ac53f9754906c0be9ab6ced467cb3535
sanbi-uwc
parents:
diff
changeset
|
1 #!/usr/bin/env python |
714cbeae0b96
planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit 43f091b6ac53f9754906c0be9ab6ced467cb3535
sanbi-uwc
parents:
diff
changeset
|
2 from __future__ import print_function |
714cbeae0b96
planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit 43f091b6ac53f9754906c0be9ab6ced467cb3535
sanbi-uwc
parents:
diff
changeset
|
3 import argparse |
714cbeae0b96
planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit 43f091b6ac53f9754906c0be9ab6ced467cb3535
sanbi-uwc
parents:
diff
changeset
|
4 import os |
714cbeae0b96
planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit 43f091b6ac53f9754906c0be9ab6ced467cb3535
sanbi-uwc
parents:
diff
changeset
|
5 import sys |
714cbeae0b96
planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit 43f091b6ac53f9754906c0be9ab6ced467cb3535
sanbi-uwc
parents:
diff
changeset
|
6 import glob |
714cbeae0b96
planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit 43f091b6ac53f9754906c0be9ab6ced467cb3535
sanbi-uwc
parents:
diff
changeset
|
7 |
714cbeae0b96
planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit 43f091b6ac53f9754906c0be9ab6ced467cb3535
sanbi-uwc
parents:
diff
changeset
|
8 import logging |
7
d89a58d00a92
planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit 74c1cc58782b9960175753e731dfdd120f234b4c
sanbi-uwc
parents:
6
diff
changeset
|
9 |
d89a58d00a92
planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit 74c1cc58782b9960175753e731dfdd120f234b4c
sanbi-uwc
parents:
6
diff
changeset
|
10 log = logging.getLogger(__name__) |
4
714cbeae0b96
planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit 43f091b6ac53f9754906c0be9ab6ced467cb3535
sanbi-uwc
parents:
diff
changeset
|
11 |
7
d89a58d00a92
planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit 74c1cc58782b9960175753e731dfdd120f234b4c
sanbi-uwc
parents:
6
diff
changeset
|
12 |
d89a58d00a92
planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit 74c1cc58782b9960175753e731dfdd120f234b4c
sanbi-uwc
parents:
6
diff
changeset
|
13 def build_ctb_gene(output_file1, output_dir, input_file, mount_point): |
d89a58d00a92
planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit 74c1cc58782b9960175753e731dfdd120f234b4c
sanbi-uwc
parents:
6
diff
changeset
|
14 # cmdline_str = "build_ctb_gene goterms ${}".format(input_file) |
9
9cc174f0fb9f
planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit 2b6755be1c76f3e4209f9723e7f50f945939244f
sanbi-uwc
parents:
8
diff
changeset
|
15 cmdline_str = "echo %s" % input_file |
9cc174f0fb9f
planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit 2b6755be1c76f3e4209f9723e7f50f945939244f
sanbi-uwc
parents:
8
diff
changeset
|
16 output_dir = mount_point |
4
714cbeae0b96
planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit 43f091b6ac53f9754906c0be9ab6ced467cb3535
sanbi-uwc
parents:
diff
changeset
|
17 build_ctb = False |
714cbeae0b96
planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit 43f091b6ac53f9754906c0be9ab6ced467cb3535
sanbi-uwc
parents:
diff
changeset
|
18 try: |
714cbeae0b96
planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit 43f091b6ac53f9754906c0be9ab6ced467cb3535
sanbi-uwc
parents:
diff
changeset
|
19 os.system(cmdline_str) |
714cbeae0b96
planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit 43f091b6ac53f9754906c0be9ab6ced467cb3535
sanbi-uwc
parents:
diff
changeset
|
20 build_ctb = True |
714cbeae0b96
planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit 43f091b6ac53f9754906c0be9ab6ced467cb3535
sanbi-uwc
parents:
diff
changeset
|
21 except: |
714cbeae0b96
planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit 43f091b6ac53f9754906c0be9ab6ced467cb3535
sanbi-uwc
parents:
diff
changeset
|
22 log.debug("Error running the build_ctb_gene goterms", file=sys.stderr) |
714cbeae0b96
planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit 43f091b6ac53f9754906c0be9ab6ced467cb3535
sanbi-uwc
parents:
diff
changeset
|
23 |
714cbeae0b96
planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit 43f091b6ac53f9754906c0be9ab6ced467cb3535
sanbi-uwc
parents:
diff
changeset
|
24 # Read the files at the mount point and load the html file |
7
d89a58d00a92
planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit 74c1cc58782b9960175753e731dfdd120f234b4c
sanbi-uwc
parents:
6
diff
changeset
|
25 if build_ctb: |
d89a58d00a92
planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit 74c1cc58782b9960175753e731dfdd120f234b4c
sanbi-uwc
parents:
6
diff
changeset
|
26 files = glob.glob(mount_point) |
d89a58d00a92
planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit 74c1cc58782b9960175753e731dfdd120f234b4c
sanbi-uwc
parents:
6
diff
changeset
|
27 output_file1 = """<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
4
714cbeae0b96
planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit 43f091b6ac53f9754906c0be9ab6ced467cb3535
sanbi-uwc
parents:
diff
changeset
|
28 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> |
714cbeae0b96
planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit 43f091b6ac53f9754906c0be9ab6ced467cb3535
sanbi-uwc
parents:
diff
changeset
|
29 <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> |
714cbeae0b96
planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit 43f091b6ac53f9754906c0be9ab6ced467cb3535
sanbi-uwc
parents:
diff
changeset
|
30 <meta name="generator" content="Galaxy %s tool output - see http://g2.trac.bx.psu.edu/" /> |
714cbeae0b96
planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit 43f091b6ac53f9754906c0be9ab6ced467cb3535
sanbi-uwc
parents:
diff
changeset
|
31 <title></title> |
714cbeae0b96
planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit 43f091b6ac53f9754906c0be9ab6ced467cb3535
sanbi-uwc
parents:
diff
changeset
|
32 <link rel="stylesheet" href="/static/style/base.css" type="text/css" /> |
714cbeae0b96
planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit 43f091b6ac53f9754906c0be9ab6ced467cb3535
sanbi-uwc
parents:
diff
changeset
|
33 </head> |
714cbeae0b96
planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit 43f091b6ac53f9754906c0be9ab6ced467cb3535
sanbi-uwc
parents:
diff
changeset
|
34 <body> |
714cbeae0b96
planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit 43f091b6ac53f9754906c0be9ab6ced467cb3535
sanbi-uwc
parents:
diff
changeset
|
35 <div class="toolFormBody"> |
714cbeae0b96
planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit 43f091b6ac53f9754906c0be9ab6ced467cb3535
sanbi-uwc
parents:
diff
changeset
|
36 <table> |
714cbeae0b96
planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit 43f091b6ac53f9754906c0be9ab6ced467cb3535
sanbi-uwc
parents:
diff
changeset
|
37 <th>Files</th> |
714cbeae0b96
planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit 43f091b6ac53f9754906c0be9ab6ced467cb3535
sanbi-uwc
parents:
diff
changeset
|
38 """ |
7
d89a58d00a92
planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit 74c1cc58782b9960175753e731dfdd120f234b4c
sanbi-uwc
parents:
6
diff
changeset
|
39 for f in files: |
d89a58d00a92
planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit 74c1cc58782b9960175753e731dfdd120f234b4c
sanbi-uwc
parents:
6
diff
changeset
|
40 output_file1 += "<tr><td>" + f + "</td></tr>" |
d89a58d00a92
planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit 74c1cc58782b9960175753e731dfdd120f234b4c
sanbi-uwc
parents:
6
diff
changeset
|
41 output_file1 += """</table></div></body></html>\n""" |
4
714cbeae0b96
planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit 43f091b6ac53f9754906c0be9ab6ced467cb3535
sanbi-uwc
parents:
diff
changeset
|
42 |
714cbeae0b96
planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit 43f091b6ac53f9754906c0be9ab6ced467cb3535
sanbi-uwc
parents:
diff
changeset
|
43 |
714cbeae0b96
planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit 43f091b6ac53f9754906c0be9ab6ced467cb3535
sanbi-uwc
parents:
diff
changeset
|
44 def main(): |
714cbeae0b96
planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit 43f091b6ac53f9754906c0be9ab6ced467cb3535
sanbi-uwc
parents:
diff
changeset
|
45 parser = argparse.ArgumentParser(description="Generate a BAM file from the Novo Align tool") |
714cbeae0b96
planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit 43f091b6ac53f9754906c0be9ab6ced467cb3535
sanbi-uwc
parents:
diff
changeset
|
46 parser.add_argument('output_file1') |
8
56555326a056
planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit 333add5fa185ac676c1a09b9b62e4d6c07b3bafa
sanbi-uwc
parents:
7
diff
changeset
|
47 parser.add_argument('--outputdir') |
4
714cbeae0b96
planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit 43f091b6ac53f9754906c0be9ab6ced467cb3535
sanbi-uwc
parents:
diff
changeset
|
48 parser.add_argument('--input_file') |
714cbeae0b96
planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit 43f091b6ac53f9754906c0be9ab6ced467cb3535
sanbi-uwc
parents:
diff
changeset
|
49 parser.add_argument('--mount_point') |
714cbeae0b96
planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit 43f091b6ac53f9754906c0be9ab6ced467cb3535
sanbi-uwc
parents:
diff
changeset
|
50 parser.add_argument('--username') |
714cbeae0b96
planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit 43f091b6ac53f9754906c0be9ab6ced467cb3535
sanbi-uwc
parents:
diff
changeset
|
51 parser.add_argument('--password') |
714cbeae0b96
planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit 43f091b6ac53f9754906c0be9ab6ced467cb3535
sanbi-uwc
parents:
diff
changeset
|
52 parser.add_argument('--url') |
714cbeae0b96
planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit 43f091b6ac53f9754906c0be9ab6ced467cb3535
sanbi-uwc
parents:
diff
changeset
|
53 parser.add_argument('--port') |
714cbeae0b96
planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit 43f091b6ac53f9754906c0be9ab6ced467cb3535
sanbi-uwc
parents:
diff
changeset
|
54 args = parser.parse_args() |
714cbeae0b96
planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit 43f091b6ac53f9754906c0be9ab6ced467cb3535
sanbi-uwc
parents:
diff
changeset
|
55 |
5
6098213127d7
planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit 225901c2aced445746de69c7e8733cfa59681869
sanbi-uwc
parents:
4
diff
changeset
|
56 export_cmd = "export NEO4J_REST_URL=http://${args.username}:${args.password}@${args.url}:${args.port}/db/data/" |
4
714cbeae0b96
planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit 43f091b6ac53f9754906c0be9ab6ced467cb3535
sanbi-uwc
parents:
diff
changeset
|
57 try: |
714cbeae0b96
planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit 43f091b6ac53f9754906c0be9ab6ced467cb3535
sanbi-uwc
parents:
diff
changeset
|
58 os.system(export_cmd) |
714cbeae0b96
planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit 43f091b6ac53f9754906c0be9ab6ced467cb3535
sanbi-uwc
parents:
diff
changeset
|
59 except: |
714cbeae0b96
planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit 43f091b6ac53f9754906c0be9ab6ced467cb3535
sanbi-uwc
parents:
diff
changeset
|
60 log.debug("Error exporting the NEO4J db environmental values") |
714cbeae0b96
planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit 43f091b6ac53f9754906c0be9ab6ced467cb3535
sanbi-uwc
parents:
diff
changeset
|
61 |
8
56555326a056
planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit 333add5fa185ac676c1a09b9b62e4d6c07b3bafa
sanbi-uwc
parents:
7
diff
changeset
|
62 build_ctb_gene(args.output_file1, args.outputdir, args.input_file, args.mount_point) |
4
714cbeae0b96
planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit 43f091b6ac53f9754906c0be9ab6ced467cb3535
sanbi-uwc
parents:
diff
changeset
|
63 |
7
d89a58d00a92
planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit 74c1cc58782b9960175753e731dfdd120f234b4c
sanbi-uwc
parents:
6
diff
changeset
|
64 |
4
714cbeae0b96
planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit 43f091b6ac53f9754906c0be9ab6ced467cb3535
sanbi-uwc
parents:
diff
changeset
|
65 if __name__ == "__main__": main() |