annotate build_ctb_gene.py @ 27:3995dfb6b497 draft

planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit 03cbaf9b605624fc4f6fbad4ccfbbe984d54e990
author sanbi-uwc
date Sun, 22 May 2016 15:34:49 -0400
parents 51a48982f643
children 4864d5866418
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
3995dfb6b497 planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit 03cbaf9b605624fc4f6fbad4ccfbbe984d54e990
sanbi-uwc
parents: 26
diff changeset
11 import random
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
10
cb322069c7bc planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit f3af88f047a6081a46925bdbb50161ad1244b4f1
sanbi-uwc
parents: 9
diff changeset
19 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
20 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
21 '''
cb322069c7bc planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit f3af88f047a6081a46925bdbb50161ad1244b4f1
sanbi-uwc
parents: 9
diff changeset
22 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
23 '''
cb322069c7bc planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit f3af88f047a6081a46925bdbb50161ad1244b4f1
sanbi-uwc
parents: 9
diff changeset
24 # 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
25 # 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
26 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
27 self.mount_point = None
10
cb322069c7bc planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit f3af88f047a6081a46925bdbb50161ad1244b4f1
sanbi-uwc
parents: 9
diff changeset
28
12
7d49ea27d9f6 planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit 9ba2424793e47546990c750ac5f1129bd1e3a77c
sanbi-uwc
parents: 11
diff changeset
29 def build_ctb_gene(self):
27
3995dfb6b497 planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit 03cbaf9b605624fc4f6fbad4ccfbbe984d54e990
sanbi-uwc
parents: 26
diff changeset
30 # cmdline_str = "build_ctb_gene goterms {}".format(self.args.input_file)
3995dfb6b497 planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit 03cbaf9b605624fc4f6fbad4ccfbbe984d54e990
sanbi-uwc
parents: 26
diff changeset
31 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
32 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
33 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
34 try:
cb322069c7bc planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit f3af88f047a6081a46925bdbb50161ad1244b4f1
sanbi-uwc
parents: 9
diff changeset
35 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
36 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
37 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
38 print("Error running the build_ctb_gene goterms", file=sys.stderr)
4caf3e2d10e8 planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit 63871d62b7acd851ff2d50dc08520c17bdf834f6
sanbi-uwc
parents: 13
diff changeset
39 if build_ctb_run:
4caf3e2d10e8 planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit 63871d62b7acd851ff2d50dc08520c17bdf834f6
sanbi-uwc
parents: 13
diff changeset
40 self.copy_output_file_to_dataset()
19
d60316b849a1 planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit c995ab52e8a43df67dc18c70aa70830f7568fc8b
sanbi-uwc
parents: 18
diff changeset
41 print("Building a new DB, current time: %s" % str(datetime.date.today()))
27
3995dfb6b497 planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit 03cbaf9b605624fc4f6fbad4ccfbbe984d54e990
sanbi-uwc
parents: 26
diff changeset
42 # print("Noe4j Database Name: http://%s:%s@%s:%s/db/data/" % (
3995dfb6b497 planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit 03cbaf9b605624fc4f6fbad4ccfbbe984d54e990
sanbi-uwc
parents: 26
diff changeset
43 # self.args.username, self.args.password, self.args.url, self.args.port))
19
d60316b849a1 planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit c995ab52e8a43df67dc18c70aa70830f7568fc8b
sanbi-uwc
parents: 18
diff changeset
44 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
45
11
517691812452 planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit 3f5361a7226127ec8b8d6cb5591b5bb4f52bb6fe
sanbi-uwc
parents: 10
diff changeset
46 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
47 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
48 lex.quotes = '"'
cb322069c7bc planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit f3af88f047a6081a46925bdbb50161ad1244b4f1
sanbi-uwc
parents: 9
diff changeset
49 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
50 lex.commenters = ''
cb322069c7bc planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit f3af88f047a6081a46925bdbb50161ad1244b4f1
sanbi-uwc
parents: 9
diff changeset
51 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
52
cb322069c7bc planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit f3af88f047a6081a46925bdbb50161ad1244b4f1
sanbi-uwc
parents: 9
diff changeset
53 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
54 '''
cb322069c7bc planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit f3af88f047a6081a46925bdbb50161ad1244b4f1
sanbi-uwc
parents: 9
diff changeset
55 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
56 '''
cb322069c7bc planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit f3af88f047a6081a46925bdbb50161ad1244b4f1
sanbi-uwc
parents: 9
diff changeset
57 # 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
58 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
59 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
60 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
61 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
62 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
63 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
64 # 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
65 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
66 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
67
27
3995dfb6b497 planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit 03cbaf9b605624fc4f6fbad4ccfbbe984d54e990
sanbi-uwc
parents: 26
diff changeset
68 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
69 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
70 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
71 try:
3995dfb6b497 planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit 03cbaf9b605624fc4f6fbad4ccfbbe984d54e990
sanbi-uwc
parents: 26
diff changeset
72 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
73 except CalledProcessError:
3995dfb6b497 planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit 03cbaf9b605624fc4f6fbad4ccfbbe984d54e990
sanbi-uwc
parents: 26
diff changeset
74 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
75
3995dfb6b497 planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit 03cbaf9b605624fc4f6fbad4ccfbbe984d54e990
sanbi-uwc
parents: 26
diff changeset
76 def docker_rm(self):
3995dfb6b497 planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit 03cbaf9b605624fc4f6fbad4ccfbbe984d54e990
sanbi-uwc
parents: 26
diff changeset
77 cmd_str = 'docker rm 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
78 cmd = self.newSplit(cmd_str)
26
51a48982f643 planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit a8d49944fccca430c0d79782f01e8e8758161cb8
sanbi-uwc
parents: 25
diff changeset
79 check_call(cmd)
4
714cbeae0b96 planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit 43f091b6ac53f9754906c0be9ab6ced467cb3535
sanbi-uwc
parents:
diff changeset
80
27
3995dfb6b497 planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit 03cbaf9b605624fc4f6fbad4ccfbbe984d54e990
sanbi-uwc
parents: 26
diff changeset
81 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
82 self.mount_point = "{}/neo4j/data".format(os.getcwd())
3995dfb6b497 planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit 03cbaf9b605624fc4f6fbad4ccfbbe984d54e990
sanbi-uwc
parents: 26
diff changeset
83 cmd_str = "docker run -d -p 7474:7474 -v {}:/data -e NEO4J_AUTH=none --name build_ctb_gene neo4j:2.3".format(
3995dfb6b497 planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit 03cbaf9b605624fc4f6fbad4ccfbbe984d54e990
sanbi-uwc
parents: 26
diff changeset
84 self.mount_point)
3995dfb6b497 planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit 03cbaf9b605624fc4f6fbad4ccfbbe984d54e990
sanbi-uwc
parents: 26
diff changeset
85 cmd = self.newSplit(cmd_str)
3995dfb6b497 planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit 03cbaf9b605624fc4f6fbad4ccfbbe984d54e990
sanbi-uwc
parents: 26
diff changeset
86 check_call(cmd)
3995dfb6b497 planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit 03cbaf9b605624fc4f6fbad4ccfbbe984d54e990
sanbi-uwc
parents: 26
diff changeset
87
3995dfb6b497 planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit 03cbaf9b605624fc4f6fbad4ccfbbe984d54e990
sanbi-uwc
parents: 26
diff changeset
88 def docker_container_check(self):
3995dfb6b497 planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit 03cbaf9b605624fc4f6fbad4ccfbbe984d54e990
sanbi-uwc
parents: 26
diff changeset
89 cmd_str = 'docker ps -a -f name=build_ctb_gene | grep 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
90 output = False
3995dfb6b497 planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit 03cbaf9b605624fc4f6fbad4ccfbbe984d54e990
sanbi-uwc
parents: 26
diff changeset
91 try:
3995dfb6b497 planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit 03cbaf9b605624fc4f6fbad4ccfbbe984d54e990
sanbi-uwc
parents: 26
diff changeset
92 output = check_output(cmd_str, shell=True)
3995dfb6b497 planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit 03cbaf9b605624fc4f6fbad4ccfbbe984d54e990
sanbi-uwc
parents: 26
diff changeset
93 except CalledProcessError:
3995dfb6b497 planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit 03cbaf9b605624fc4f6fbad4ccfbbe984d54e990
sanbi-uwc
parents: 26
diff changeset
94 print("Error running docker container check", 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
95 if output:
3995dfb6b497 planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit 03cbaf9b605624fc4f6fbad4ccfbbe984d54e990
sanbi-uwc
parents: 26
diff changeset
96 return True
3995dfb6b497 planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit 03cbaf9b605624fc4f6fbad4ccfbbe984d54e990
sanbi-uwc
parents: 26
diff changeset
97 return False
3995dfb6b497 planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit 03cbaf9b605624fc4f6fbad4ccfbbe984d54e990
sanbi-uwc
parents: 26
diff changeset
98
3995dfb6b497 planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit 03cbaf9b605624fc4f6fbad4ccfbbe984d54e990
sanbi-uwc
parents: 26
diff changeset
99
4
714cbeae0b96 planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit 43f091b6ac53f9754906c0be9ab6ced467cb3535
sanbi-uwc
parents:
diff changeset
100 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
101 parser = argparse.ArgumentParser(description="Tool used to extract data about genes using locus_tags")
27
3995dfb6b497 planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit 03cbaf9b605624fc4f6fbad4ccfbbe984d54e990
sanbi-uwc
parents: 26
diff changeset
102 # parser.add_argument('--outputfile')
8
56555326a056 planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit 333add5fa185ac676c1a09b9b62e4d6c07b3bafa
sanbi-uwc
parents: 7
diff changeset
103 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
104 parser.add_argument('--input_file')
27
3995dfb6b497 planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit 03cbaf9b605624fc4f6fbad4ccfbbe984d54e990
sanbi-uwc
parents: 26
diff changeset
105 # parser.add_argument('--mount_point')
3995dfb6b497 planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit 03cbaf9b605624fc4f6fbad4ccfbbe984d54e990
sanbi-uwc
parents: 26
diff changeset
106 # parser.add_argument('--username')
3995dfb6b497 planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit 03cbaf9b605624fc4f6fbad4ccfbbe984d54e990
sanbi-uwc
parents: 26
diff changeset
107 # parser.add_argument('--password')
3995dfb6b497 planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit 03cbaf9b605624fc4f6fbad4ccfbbe984d54e990
sanbi-uwc
parents: 26
diff changeset
108 # parser.add_argument('--url')
3995dfb6b497 planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit 03cbaf9b605624fc4f6fbad4ccfbbe984d54e990
sanbi-uwc
parents: 26
diff changeset
109 # parser.add_argument('--port')
4
714cbeae0b96 planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit 43f091b6ac53f9754906c0be9ab6ced467cb3535
sanbi-uwc
parents:
diff changeset
110 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
111
26
51a48982f643 planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit a8d49944fccca430c0d79782f01e8e8758161cb8
sanbi-uwc
parents: 25
diff changeset
112 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
113
51a48982f643 planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit a8d49944fccca430c0d79782f01e8e8758161cb8
sanbi-uwc
parents: 25
diff changeset
114 # 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
115 if ctb_gene_runner.docker_container_check():
3995dfb6b497 planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit 03cbaf9b605624fc4f6fbad4ccfbbe984d54e990
sanbi-uwc
parents: 26
diff changeset
116 ctb_gene_runner.docker_stop()
3995dfb6b497 planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit 03cbaf9b605624fc4f6fbad4ccfbbe984d54e990
sanbi-uwc
parents: 26
diff changeset
117 ctb_gene_runner.docker_rm()
3995dfb6b497 planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit 03cbaf9b605624fc4f6fbad4ccfbbe984d54e990
sanbi-uwc
parents: 26
diff changeset
118 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
119
27
3995dfb6b497 planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit 03cbaf9b605624fc4f6fbad4ccfbbe984d54e990
sanbi-uwc
parents: 26
diff changeset
120 # TODO: randomise the ports/names/mount_point and use the autokill image
3995dfb6b497 planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit 03cbaf9b605624fc4f6fbad4ccfbbe984d54e990
sanbi-uwc
parents: 26
diff changeset
121 export_cmd = "export NEO4J_REST_URL=http://localhost:7474/db/data/"
4
714cbeae0b96 planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit 43f091b6ac53f9754906c0be9ab6ced467cb3535
sanbi-uwc
parents:
diff changeset
122 try:
714cbeae0b96 planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit 43f091b6ac53f9754906c0be9ab6ced467cb3535
sanbi-uwc
parents:
diff changeset
123 os.system(export_cmd)
14
4caf3e2d10e8 planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit 63871d62b7acd851ff2d50dc08520c17bdf834f6
sanbi-uwc
parents: 13
diff changeset
124 except (OSError, ValueError), e:
4caf3e2d10e8 planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit 63871d62b7acd851ff2d50dc08520c17bdf834f6
sanbi-uwc
parents: 13
diff changeset
125 print("Error exporting 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
126
10
cb322069c7bc planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit f3af88f047a6081a46925bdbb50161ad1244b4f1
sanbi-uwc
parents: 9
diff changeset
127 # 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
128 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
129 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
130 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
131 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
132
11
517691812452 planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit 3f5361a7226127ec8b8d6cb5591b5bb4f52bb6fe
sanbi-uwc
parents: 10
diff changeset
133
14
4caf3e2d10e8 planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit 63871d62b7acd851ff2d50dc08520c17bdf834f6
sanbi-uwc
parents: 13
diff changeset
134 if __name__ == "__main__": main()