Debian Codegraph @

bowtie2-inspect

raw ◀ ▶
2 Debian patches touch this file
•1 #!/usr/bin/python3
2
3 """
4 Copyright 2014, Ben Langmead <[email protected]>
5
6 This file is part of Bowtie 2.
7
8 Bowtie 2 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 Bowtie 2 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 Bowtie 2. If not, see <http://www.gnu.org/licenses/>.
20 """
21
22
23 import os
24 import sys
25 import inspect
26 import logging
27 import argparse
28 import subprocess
29 import platform
30 from collections import deque
31
32 def main():
33 parser = argparse.ArgumentParser(add_help = False)
34
35 group = parser.add_mutually_exclusive_group()
36 group.add_argument('--debug', action='store_true')
37
38 parser.add_argument('--verbose', action='store_true')
39 parser.add_argument('--large-index', action='store_true')
40
41 logging.basicConfig(level=logging.ERROR,
42 format='%(levelname)s: %(message)s'
43 )
44 inspect_bin_name = 'bowtie-inspect'
45 inspect_bin_s = 'bowtie2-inspect-s'
46 inspect_bin_l = 'bowtie2-inspect-l'
47 idx_ext_l = '.1.bt2l'
48 idx_ext_s = '.1.bt2'
49 curr_script = os.path.realpath(inspect.getsourcefile(main))
50 ex_path = os.path.dirname(curr_script)
51 inspect_bin_spec = os.path.join(ex_path,inspect_bin_s)
52
53 script_options, argv = parser.parse_known_args()
54 argv = deque(argv)
55
56 if script_options.verbose:
57 logging.getLogger().setLevel(logging.INFO)
58
59 if script_options.debug:
60 inspect_bin_spec += '-debug'
61 inspect_bin_l += '-debug'
62
63 if script_options.large_index:
64 inspect_bin_spec = os.path.join(ex_path,inspect_bin_l)
65 elif len(argv) >= 1:
66 idx_basename = argv[-1]
67 large_idx_exists = os.path.exists(idx_basename + idx_ext_l)
68 small_idx_exists = os.path.exists(idx_basename + idx_ext_s)
69 if large_idx_exists and not small_idx_exists:
70 inspect_bin_spec = os.path.join(ex_path,inspect_bin_l)
71
72 if "Windows" in platform.platform():
73 inspect_bin_spec += '.exe'
74
75 argv.appendleft('basic-0')
76 argv.appendleft('--wrapper')
77 argv.appendleft(inspect_bin_spec)
78 logging.info('Command: %s' % ' '.join(argv))
79 sys.exit(subprocess.call(list(argv)))
80
81 if __name__ == '__main__':
82 main()