| 1 |
#!/usr/bin/env 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 |
group.add_argument('--sanitized', action='store_true') |
| 38 |
|
| 39 |
parser.add_argument('--verbose', action='store_true') |
| 40 |
parser.add_argument('--large-index', action='store_true') |
| 41 |
|
| 42 |
logging.basicConfig(level=logging.ERROR, |
| 43 |
format='%(levelname)s: %(message)s' |
| 44 |
) |
| 45 |
inspect_bin_name = 'bowtie-inspect' |
| 46 |
inspect_bin_s = 'bowtie2-inspect-s' |
| 47 |
inspect_bin_l = 'bowtie2-inspect-l' |
| 48 |
idx_ext_l = '.1.bt2l' |
| 49 |
idx_ext_s = '.1.bt2' |
| 50 |
curr_script = os.path.realpath(inspect.getsourcefile(main)) |
| 51 |
ex_path = os.path.dirname(curr_script) |
| 52 |
inspect_bin_spec = os.path.join(ex_path,inspect_bin_s) |
| 53 |
|
| 54 |
script_options, argv = parser.parse_known_args() |
| 55 |
argv = deque(argv) |
| 56 |
|
| 57 |
if script_options.verbose: |
| 58 |
logging.getLogger().setLevel(logging.INFO) |
| 59 |
|
| 60 |
if script_options.debug: |
| 61 |
inspect_bin_spec += '-debug' |
| 62 |
inspect_bin_l += '-debug' |
| 63 |
|
| 64 |
if script_options.sanitized: |
| 65 |
inspect_bin_spec += '-sanitized' |
| 66 |
inspect_bin_l += '-sanitized' |
| 67 |
|
| 68 |
if script_options.large_index: |
| 69 |
inspect_bin_spec = os.path.join(ex_path,inspect_bin_l) |
| 70 |
elif len(argv) >= 1: |
| 71 |
idx_basename = argv[-1] |
| 72 |
large_idx_exists = os.path.exists(idx_basename + idx_ext_l) |
| 73 |
small_idx_exists = os.path.exists(idx_basename + idx_ext_s) |
| 74 |
if large_idx_exists and not small_idx_exists: |
| 75 |
inspect_bin_spec = os.path.join(ex_path,inspect_bin_l) |
| 76 |
|
| 77 |
if "Windows" in platform.platform(): |
| 78 |
inspect_bin_spec += '.exe' |
| 79 |
|
| 80 |
argv.appendleft('basic-0') |
| 81 |
argv.appendleft('--wrapper') |
| 82 |
argv.appendleft(inspect_bin_spec) |
| 83 |
logging.info('Command: %s' % ' '.join(argv)) |
| 84 |
sys.exit(subprocess.call(list(argv))) |
| 85 |
|
| 86 |
if __name__ == '__main__': |
| 87 |
main() |