Debian Codegraph @

centrifuge-build

raw ◀ ▶
1 Debian patch touch this file
•1 #!/usr/bin/python3
2
3 """
4 Copyright 2014, Daehwan Kim <[email protected]>
5
6 This file is part of Centrifuge, which is copied and modified from bowtie2 in the Bowtie2 package.
7
8 Centrifuge is free software: you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation, either version 3 of the License, or
11 (at your option) any later version.
12
13 Centrifuge is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with Centrifuge. If not, see <http://www.gnu.org/licenses/>.
20 """
21
22
23 import os
24 import sys
25 import inspect
26 import logging
27
28
29 def build_args():
30 """
31 Parse the wrapper arguments. Returns the options,<programm arguments> tuple.
32 """
33
34 parsed_args = {}
35 to_remove = []
36 argv = sys.argv[:]
37 for i, arg in enumerate(argv):
38 if arg == '--debug':
39 parsed_args[arg] = ""
40 to_remove.append(i)
41 elif arg == '--verbose':
42 parsed_args[arg] = ""
43 to_remove.append(i)
44
45 for i in reversed(to_remove):
46 del argv[i]
47
48 return parsed_args, argv
49
50
51 def main():
52 logging.basicConfig(level=logging.ERROR,
53 format='%(levelname)s: %(message)s'
54 )
55 delta = 200
56 small_index_max_size= 4 * 1024**3 - delta
57 build_bin_name = "centrifuge-build-bin"
58 build_bin_s = "centrifuge-build-bin"
59 curr_script = os.path.realpath(inspect.getsourcefile(main))
60 ex_path = os.path.dirname(curr_script)
61 build_bin_spec = os.path.join(ex_path,build_bin_s)
62
63 options, argv = build_args()
64
65 if '--verbose' in options:
66 logging.getLogger().setLevel(logging.INFO)
67
68 if '--debug' in options:
69 build_bin_spec += '-debug'
70 build_bin_l += '-debug'
71
72 argv[0] = build_bin_name
73 argv.insert(1, 'basic-0')
74 argv.insert(1, '--wrapper')
75 logging.info('Command: %s %s' % (build_bin_spec, ' '.join(argv[1:])))
76 os.execv(build_bin_spec, argv)
77
78 if __name__ == "__main__":
79 main()