Mercurial > repos > sanbi-uwc > build_ctb_gene
annotate build_ctb_gene.py @ 32:9e33d452ad8c draft
planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit cca5de2166bbc2fbbab368415853e085d474b6b2
author | sanbi-uwc |
---|---|
date | Tue, 24 May 2016 04:19:03 -0400 |
parents | bcf4f741b94f |
children | f9ad7d3cd333 |
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 |
10
cb322069c7bc
planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit f3af88f047a6081a46925bdbb50161ad1244b4f1
sanbi-uwc
parents:
9
diff
changeset
|
7 import shlex |
cb322069c7bc
planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit f3af88f047a6081a46925bdbb50161ad1244b4f1
sanbi-uwc
parents:
9
diff
changeset
|
8 import shutil |
14
4caf3e2d10e8
planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit 63871d62b7acd851ff2d50dc08520c17bdf834f6
sanbi-uwc
parents:
13
diff
changeset
|
9 import datetime |
27
3995dfb6b497
planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit 03cbaf9b605624fc4f6fbad4ccfbbe984d54e990
sanbi-uwc
parents:
26
diff
changeset
|
10 import time |
29
b8ecf55d8987
planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit a97b08e4a7c05855b6409588ff50d3716071dd80
sanbi-uwc
parents:
28
diff
changeset
|
11 import random |
27
3995dfb6b497
planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit 03cbaf9b605624fc4f6fbad4ccfbbe984d54e990
sanbi-uwc
parents:
26
diff
changeset
|
12 from subprocess import check_call, check_output, CalledProcessError |
4
714cbeae0b96
planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit 43f091b6ac53f9754906c0be9ab6ced467cb3535
sanbi-uwc
parents:
diff
changeset
|
13 |
714cbeae0b96
planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit 43f091b6ac53f9754906c0be9ab6ced467cb3535
sanbi-uwc
parents:
diff
changeset
|
14 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
|
15 |
d89a58d00a92
planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit 74c1cc58782b9960175753e731dfdd120f234b4c
sanbi-uwc
parents:
6
diff
changeset
|
16 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
|
17 |
7
d89a58d00a92
planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit 74c1cc58782b9960175753e731dfdd120f234b4c
sanbi-uwc
parents:
6
diff
changeset
|
18 |
30
60aedbda386d
planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit 9dc41c2c903e6c9a26e70114f56680903671a669
sanbi-uwc
parents:
29
diff
changeset
|
19 def inspect_docker(cmd_str): |
60aedbda386d
planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit 9dc41c2c903e6c9a26e70114f56680903671a669
sanbi-uwc
parents:
29
diff
changeset
|
20 output = None |
60aedbda386d
planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit 9dc41c2c903e6c9a26e70114f56680903671a669
sanbi-uwc
parents:
29
diff
changeset
|
21 try: |
60aedbda386d
planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit 9dc41c2c903e6c9a26e70114f56680903671a669
sanbi-uwc
parents:
29
diff
changeset
|
22 output = check_output(cmd_str, shell=True) |
60aedbda386d
planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit 9dc41c2c903e6c9a26e70114f56680903671a669
sanbi-uwc
parents:
29
diff
changeset
|
23 except CalledProcessError: |
60aedbda386d
planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit 9dc41c2c903e6c9a26e70114f56680903671a669
sanbi-uwc
parents:
29
diff
changeset
|
24 print("Error running get_docker_port by build_ctb_gene", file=sys.stderr) |
60aedbda386d
planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit 9dc41c2c903e6c9a26e70114f56680903671a669
sanbi-uwc
parents:
29
diff
changeset
|
25 return output |
60aedbda386d
planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit 9dc41c2c903e6c9a26e70114f56680903671a669
sanbi-uwc
parents:
29
diff
changeset
|
26 |
60aedbda386d
planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit 9dc41c2c903e6c9a26e70114f56680903671a669
sanbi-uwc
parents:
29
diff
changeset
|
27 |
10
cb322069c7bc
planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit f3af88f047a6081a46925bdbb50161ad1244b4f1
sanbi-uwc
parents:
9
diff
changeset
|
28 class BuildCtbRunner(object): |
cb322069c7bc
planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit f3af88f047a6081a46925bdbb50161ad1244b4f1
sanbi-uwc
parents:
9
diff
changeset
|
29 def __init__(self, args=None): |
cb322069c7bc
planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit f3af88f047a6081a46925bdbb50161ad1244b4f1
sanbi-uwc
parents:
9
diff
changeset
|
30 ''' |
cb322069c7bc
planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit f3af88f047a6081a46925bdbb50161ad1244b4f1
sanbi-uwc
parents:
9
diff
changeset
|
31 Initializes an object to run CtbRunner in Galaxy. |
cb322069c7bc
planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit f3af88f047a6081a46925bdbb50161ad1244b4f1
sanbi-uwc
parents:
9
diff
changeset
|
32 ''' |
cb322069c7bc
planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit f3af88f047a6081a46925bdbb50161ad1244b4f1
sanbi-uwc
parents:
9
diff
changeset
|
33 # Check whether the options are specified and saves them into the object |
14
4caf3e2d10e8
planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit 63871d62b7acd851ff2d50dc08520c17bdf834f6
sanbi-uwc
parents:
13
diff
changeset
|
34 # assert args != None |
10
cb322069c7bc
planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit f3af88f047a6081a46925bdbb50161ad1244b4f1
sanbi-uwc
parents:
9
diff
changeset
|
35 self.args = args |
27
3995dfb6b497
planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit 03cbaf9b605624fc4f6fbad4ccfbbe984d54e990
sanbi-uwc
parents:
26
diff
changeset
|
36 self.mount_point = None |
29
b8ecf55d8987
planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit a97b08e4a7c05855b6409588ff50d3716071dd80
sanbi-uwc
parents:
28
diff
changeset
|
37 self.docker_instance_name = "build_ctb_gene_" + str(random.randrange(0, 1000, 2)) |
10
cb322069c7bc
planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit f3af88f047a6081a46925bdbb50161ad1244b4f1
sanbi-uwc
parents:
9
diff
changeset
|
38 |
12
7d49ea27d9f6
planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit 9ba2424793e47546990c750ac5f1129bd1e3a77c
sanbi-uwc
parents:
11
diff
changeset
|
39 def build_ctb_gene(self): |
32
9e33d452ad8c
planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit cca5de2166bbc2fbbab368415853e085d474b6b2
sanbi-uwc
parents:
31
diff
changeset
|
40 cmdline_str = "build_ctb_gene goterms {}".format(self.args.input_file) |
9e33d452ad8c
planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit cca5de2166bbc2fbbab368415853e085d474b6b2
sanbi-uwc
parents:
31
diff
changeset
|
41 #cmdline_str = "touch /tmp/foo.bar" |
10
cb322069c7bc
planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit f3af88f047a6081a46925bdbb50161ad1244b4f1
sanbi-uwc
parents:
9
diff
changeset
|
42 cmdline_str = self.newSplit(cmdline_str) |
18
71a3f4a25de3
planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit 79f3191bfc33e7bac3f31dc4ea519f99ffb09081
sanbi-uwc
parents:
17
diff
changeset
|
43 build_ctb_run = False |
10
cb322069c7bc
planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit f3af88f047a6081a46925bdbb50161ad1244b4f1
sanbi-uwc
parents:
9
diff
changeset
|
44 try: |
cb322069c7bc
planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit f3af88f047a6081a46925bdbb50161ad1244b4f1
sanbi-uwc
parents:
9
diff
changeset
|
45 check_call(cmdline_str) |
18
71a3f4a25de3
planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit 79f3191bfc33e7bac3f31dc4ea519f99ffb09081
sanbi-uwc
parents:
17
diff
changeset
|
46 build_ctb_run = True |
10
cb322069c7bc
planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit f3af88f047a6081a46925bdbb50161ad1244b4f1
sanbi-uwc
parents:
9
diff
changeset
|
47 except CalledProcessError: |
14
4caf3e2d10e8
planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit 63871d62b7acd851ff2d50dc08520c17bdf834f6
sanbi-uwc
parents:
13
diff
changeset
|
48 print("Error running the build_ctb_gene goterms", file=sys.stderr) |
32
9e33d452ad8c
planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit cca5de2166bbc2fbbab368415853e085d474b6b2
sanbi-uwc
parents:
31
diff
changeset
|
49 if build_ctb_run: |
9e33d452ad8c
planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit cca5de2166bbc2fbbab368415853e085d474b6b2
sanbi-uwc
parents:
31
diff
changeset
|
50 self.copy_output_file_to_dataset() |
9e33d452ad8c
planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit cca5de2166bbc2fbbab368415853e085d474b6b2
sanbi-uwc
parents:
31
diff
changeset
|
51 print("Building a new DB, current time: %s" % str(datetime.date.today())) |
9e33d452ad8c
planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit cca5de2166bbc2fbbab368415853e085d474b6b2
sanbi-uwc
parents:
31
diff
changeset
|
52 # print("Noe4j Database Name: http://%s:%s@%s:%s/db/data/" % ( |
9e33d452ad8c
planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit cca5de2166bbc2fbbab368415853e085d474b6b2
sanbi-uwc
parents:
31
diff
changeset
|
53 # self.args.username, self.args.password, self.args.url, self.args.port)) |
9e33d452ad8c
planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit cca5de2166bbc2fbbab368415853e085d474b6b2
sanbi-uwc
parents:
31
diff
changeset
|
54 print("GFF File - Input: %s" % str(self.args.input_file)) |
10
cb322069c7bc
planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit f3af88f047a6081a46925bdbb50161ad1244b4f1
sanbi-uwc
parents:
9
diff
changeset
|
55 |
11
517691812452
planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit 3f5361a7226127ec8b8d6cb5591b5bb4f52bb6fe
sanbi-uwc
parents:
10
diff
changeset
|
56 def newSplit(self, value): |
10
cb322069c7bc
planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit f3af88f047a6081a46925bdbb50161ad1244b4f1
sanbi-uwc
parents:
9
diff
changeset
|
57 lex = shlex.shlex(value) |
cb322069c7bc
planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit f3af88f047a6081a46925bdbb50161ad1244b4f1
sanbi-uwc
parents:
9
diff
changeset
|
58 lex.quotes = '"' |
cb322069c7bc
planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit f3af88f047a6081a46925bdbb50161ad1244b4f1
sanbi-uwc
parents:
9
diff
changeset
|
59 lex.whitespace_split = True |
cb322069c7bc
planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit f3af88f047a6081a46925bdbb50161ad1244b4f1
sanbi-uwc
parents:
9
diff
changeset
|
60 lex.commenters = '' |
cb322069c7bc
planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit f3af88f047a6081a46925bdbb50161ad1244b4f1
sanbi-uwc
parents:
9
diff
changeset
|
61 return list(lex) |
cb322069c7bc
planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit f3af88f047a6081a46925bdbb50161ad1244b4f1
sanbi-uwc
parents:
9
diff
changeset
|
62 |
cb322069c7bc
planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit f3af88f047a6081a46925bdbb50161ad1244b4f1
sanbi-uwc
parents:
9
diff
changeset
|
63 def copy_output_file_to_dataset(self): |
cb322069c7bc
planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit f3af88f047a6081a46925bdbb50161ad1244b4f1
sanbi-uwc
parents:
9
diff
changeset
|
64 ''' |
cb322069c7bc
planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit f3af88f047a6081a46925bdbb50161ad1244b4f1
sanbi-uwc
parents:
9
diff
changeset
|
65 Retrieves the output files from the output directory and copies them to the Galaxy output files |
cb322069c7bc
planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit f3af88f047a6081a46925bdbb50161ad1244b4f1
sanbi-uwc
parents:
9
diff
changeset
|
66 ''' |
cb322069c7bc
planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit f3af88f047a6081a46925bdbb50161ad1244b4f1
sanbi-uwc
parents:
9
diff
changeset
|
67 # retrieve neo4j files to the working gx directory |
27
3995dfb6b497
planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit 03cbaf9b605624fc4f6fbad4ccfbbe984d54e990
sanbi-uwc
parents:
26
diff
changeset
|
68 mp = self.mount_point + "/graph.db" |
3995dfb6b497
planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit 03cbaf9b605624fc4f6fbad4ccfbbe984d54e990
sanbi-uwc
parents:
26
diff
changeset
|
69 result_file = glob.glob(mp + '/*') |
11
517691812452
planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit 3f5361a7226127ec8b8d6cb5591b5bb4f52bb6fe
sanbi-uwc
parents:
10
diff
changeset
|
70 for file_name in result_file: |
23
9e9f1a97f97b
planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit 504dc929afd0bd35a5a5b90a2bcfb30ee007c481
sanbi-uwc
parents:
22
diff
changeset
|
71 if os.path.isfile(file_name): |
9e9f1a97f97b
planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit 504dc929afd0bd35a5a5b90a2bcfb30ee007c481
sanbi-uwc
parents:
22
diff
changeset
|
72 shutil.copy2(file_name, self.args.outputdir) |
9e9f1a97f97b
planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit 504dc929afd0bd35a5a5b90a2bcfb30ee007c481
sanbi-uwc
parents:
22
diff
changeset
|
73 elif os.path.isdir(file_name): |
24
dfc610c206af
planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit 54182d587632d9bf0577fbf89b3c90d3fdab863e
sanbi-uwc
parents:
23
diff
changeset
|
74 # create the parent dir before copytree |
dfc610c206af
planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit 54182d587632d9bf0577fbf89b3c90d3fdab863e
sanbi-uwc
parents:
23
diff
changeset
|
75 os.chdir(self.args.outputdir) |
dfc610c206af
planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit 54182d587632d9bf0577fbf89b3c90d3fdab863e
sanbi-uwc
parents:
23
diff
changeset
|
76 shutil.copytree(file_name, file_name.rsplit('/', 1)[-1]) |
11
517691812452
planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit 3f5361a7226127ec8b8d6cb5591b5bb4f52bb6fe
sanbi-uwc
parents:
10
diff
changeset
|
77 |
27
3995dfb6b497
planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit 03cbaf9b605624fc4f6fbad4ccfbbe984d54e990
sanbi-uwc
parents:
26
diff
changeset
|
78 def docker_stop(self): |
3995dfb6b497
planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit 03cbaf9b605624fc4f6fbad4ccfbbe984d54e990
sanbi-uwc
parents:
26
diff
changeset
|
79 stop_cmd = 'docker stop build_ctb_gene' |
3995dfb6b497
planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit 03cbaf9b605624fc4f6fbad4ccfbbe984d54e990
sanbi-uwc
parents:
26
diff
changeset
|
80 stop_cmd_str = self.newSplit(stop_cmd) |
3995dfb6b497
planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit 03cbaf9b605624fc4f6fbad4ccfbbe984d54e990
sanbi-uwc
parents:
26
diff
changeset
|
81 try: |
3995dfb6b497
planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit 03cbaf9b605624fc4f6fbad4ccfbbe984d54e990
sanbi-uwc
parents:
26
diff
changeset
|
82 check_call(stop_cmd_str) |
3995dfb6b497
planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit 03cbaf9b605624fc4f6fbad4ccfbbe984d54e990
sanbi-uwc
parents:
26
diff
changeset
|
83 except CalledProcessError: |
3995dfb6b497
planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit 03cbaf9b605624fc4f6fbad4ccfbbe984d54e990
sanbi-uwc
parents:
26
diff
changeset
|
84 print("Error running docker stop build_ctb_gene", file=sys.stderr) |
3995dfb6b497
planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit 03cbaf9b605624fc4f6fbad4ccfbbe984d54e990
sanbi-uwc
parents:
26
diff
changeset
|
85 |
3995dfb6b497
planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit 03cbaf9b605624fc4f6fbad4ccfbbe984d54e990
sanbi-uwc
parents:
26
diff
changeset
|
86 def docker_run(self): |
3995dfb6b497
planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit 03cbaf9b605624fc4f6fbad4ccfbbe984d54e990
sanbi-uwc
parents:
26
diff
changeset
|
87 self.mount_point = "{}/neo4j/data".format(os.getcwd()) |
29
b8ecf55d8987
planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit a97b08e4a7c05855b6409588ff50d3716071dd80
sanbi-uwc
parents:
28
diff
changeset
|
88 |
b8ecf55d8987
planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit a97b08e4a7c05855b6409588ff50d3716071dd80
sanbi-uwc
parents:
28
diff
changeset
|
89 cmd_str = "docker run -d -P -v {}:/data -e NEO4J_AUTH=none --name {} thoba/neo4j_galaxy_ie".format( |
b8ecf55d8987
planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit a97b08e4a7c05855b6409588ff50d3716071dd80
sanbi-uwc
parents:
28
diff
changeset
|
90 self.mount_point, self.docker_instance_name) |
27
3995dfb6b497
planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit 03cbaf9b605624fc4f6fbad4ccfbbe984d54e990
sanbi-uwc
parents:
26
diff
changeset
|
91 cmd = self.newSplit(cmd_str) |
29
b8ecf55d8987
planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit a97b08e4a7c05855b6409588ff50d3716071dd80
sanbi-uwc
parents:
28
diff
changeset
|
92 try: |
b8ecf55d8987
planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit a97b08e4a7c05855b6409588ff50d3716071dd80
sanbi-uwc
parents:
28
diff
changeset
|
93 check_call(cmd) |
b8ecf55d8987
planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit a97b08e4a7c05855b6409588ff50d3716071dd80
sanbi-uwc
parents:
28
diff
changeset
|
94 except CalledProcessError: |
b8ecf55d8987
planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit a97b08e4a7c05855b6409588ff50d3716071dd80
sanbi-uwc
parents:
28
diff
changeset
|
95 print("Error running docker run by build_ctb_gene", file=sys.stderr) |
27
3995dfb6b497
planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit 03cbaf9b605624fc4f6fbad4ccfbbe984d54e990
sanbi-uwc
parents:
26
diff
changeset
|
96 |
3995dfb6b497
planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit 03cbaf9b605624fc4f6fbad4ccfbbe984d54e990
sanbi-uwc
parents:
26
diff
changeset
|
97 |
4
714cbeae0b96
planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit 43f091b6ac53f9754906c0be9ab6ced467cb3535
sanbi-uwc
parents:
diff
changeset
|
98 def main(): |
10
cb322069c7bc
planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit f3af88f047a6081a46925bdbb50161ad1244b4f1
sanbi-uwc
parents:
9
diff
changeset
|
99 parser = argparse.ArgumentParser(description="Tool used to extract data about genes using locus_tags") |
8
56555326a056
planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit 333add5fa185ac676c1a09b9b62e4d6c07b3bafa
sanbi-uwc
parents:
7
diff
changeset
|
100 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
|
101 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
|
102 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
|
103 |
26
51a48982f643
planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit a8d49944fccca430c0d79782f01e8e8758161cb8
sanbi-uwc
parents:
25
diff
changeset
|
104 ctb_gene_runner = BuildCtbRunner(args) |
51a48982f643
planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit a8d49944fccca430c0d79782f01e8e8758161cb8
sanbi-uwc
parents:
25
diff
changeset
|
105 |
51a48982f643
planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit a8d49944fccca430c0d79782f01e8e8758161cb8
sanbi-uwc
parents:
25
diff
changeset
|
106 # boot up a neo4j docker container |
27
3995dfb6b497
planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit 03cbaf9b605624fc4f6fbad4ccfbbe984d54e990
sanbi-uwc
parents:
26
diff
changeset
|
107 ctb_gene_runner.docker_run() |
26
51a48982f643
planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit a8d49944fccca430c0d79782f01e8e8758161cb8
sanbi-uwc
parents:
25
diff
changeset
|
108 |
29
b8ecf55d8987
planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit a97b08e4a7c05855b6409588ff50d3716071dd80
sanbi-uwc
parents:
28
diff
changeset
|
109 # get the port of the docker container |
31
bcf4f741b94f
planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit ea7a94d6a0aa64dfc8f3a11ac977c39d57bba3e3
sanbi-uwc
parents:
30
diff
changeset
|
110 cmd_str = "docker inspect --format='{{(index (index .NetworkSettings.Ports \"7474/tcp\") 0).HostPort}}' %s" % ctb_gene_runner.docker_instance_name |
29
b8ecf55d8987
planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit a97b08e4a7c05855b6409588ff50d3716071dd80
sanbi-uwc
parents:
28
diff
changeset
|
111 |
27
3995dfb6b497
planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit 03cbaf9b605624fc4f6fbad4ccfbbe984d54e990
sanbi-uwc
parents:
26
diff
changeset
|
112 # TODO: randomise the ports/names/mount_point and use the autokill image |
32
9e33d452ad8c
planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit cca5de2166bbc2fbbab368415853e085d474b6b2
sanbi-uwc
parents:
31
diff
changeset
|
113 neo4j_url = 'http://localhost:{}/db/data/'.format( |
31
bcf4f741b94f
planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit ea7a94d6a0aa64dfc8f3a11ac977c39d57bba3e3
sanbi-uwc
parents:
30
diff
changeset
|
114 inspect_docker(cmd_str)[:-1]) |
4
714cbeae0b96
planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit 43f091b6ac53f9754906c0be9ab6ced467cb3535
sanbi-uwc
parents:
diff
changeset
|
115 try: |
32
9e33d452ad8c
planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit cca5de2166bbc2fbbab368415853e085d474b6b2
sanbi-uwc
parents:
31
diff
changeset
|
116 os.environ["NEO4J_REST_URL"] = neo4j_url |
14
4caf3e2d10e8
planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit 63871d62b7acd851ff2d50dc08520c17bdf834f6
sanbi-uwc
parents:
13
diff
changeset
|
117 except (OSError, ValueError), e: |
32
9e33d452ad8c
planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit cca5de2166bbc2fbbab368415853e085d474b6b2
sanbi-uwc
parents:
31
diff
changeset
|
118 print("Error setting the NEO4J db environmental values", e) |
4
714cbeae0b96
planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit 43f091b6ac53f9754906c0be9ab6ced467cb3535
sanbi-uwc
parents:
diff
changeset
|
119 |
10
cb322069c7bc
planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit f3af88f047a6081a46925bdbb50161ad1244b4f1
sanbi-uwc
parents:
9
diff
changeset
|
120 # make the output directory |
cb322069c7bc
planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit f3af88f047a6081a46925bdbb50161ad1244b4f1
sanbi-uwc
parents:
9
diff
changeset
|
121 if not os.path.exists(args.outputdir): |
cb322069c7bc
planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit f3af88f047a6081a46925bdbb50161ad1244b4f1
sanbi-uwc
parents:
9
diff
changeset
|
122 os.makedirs(args.outputdir) |
27
3995dfb6b497
planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit 03cbaf9b605624fc4f6fbad4ccfbbe984d54e990
sanbi-uwc
parents:
26
diff
changeset
|
123 time.sleep(60) |
3995dfb6b497
planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit 03cbaf9b605624fc4f6fbad4ccfbbe984d54e990
sanbi-uwc
parents:
26
diff
changeset
|
124 ctb_gene_runner.build_ctb_gene() |
7
d89a58d00a92
planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit 74c1cc58782b9960175753e731dfdd120f234b4c
sanbi-uwc
parents:
6
diff
changeset
|
125 |
11
517691812452
planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit 3f5361a7226127ec8b8d6cb5591b5bb4f52bb6fe
sanbi-uwc
parents:
10
diff
changeset
|
126 |
14
4caf3e2d10e8
planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit 63871d62b7acd851ff2d50dc08520c17bdf834f6
sanbi-uwc
parents:
13
diff
changeset
|
127 if __name__ == "__main__": main() |