1#!/usr/local/bin/python3.8 2 3""" 4 Copyright 2014, Ben Langmead <langmea@cs.jhu.edu> 5 6 This file is part of Bowtie. 7 8 Bowtie 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 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. If not, see <http://www.gnu.org/licenses/>. 20""" 21 22 23import os 24import inspect 25from importlib.machinery import SourceFileLoader 26import logging 27 28def main(): 29 logging.basicConfig(level=logging.ERROR, 30 format='%(levelname)s: %(message)s' 31 ) 32 inspect_bin_name = "bowtie-inspect" 33 inspect_bin_s = "bowtie-inspect-s" 34 inspect_bin_l = "bowtie-inspect-l" 35 idx_ext_l = '.1.ebwtl' 36 idx_ext_s = '.1.ebwt' 37 curr_script = os.path.realpath(inspect.getsourcefile(main)) 38 ex_path = os.path.dirname(curr_script) 39 inspect_bin_spec = os.path.join(ex_path,inspect_bin_s) 40 bld = SourceFileLoader('bowtie-build',os.path.join(ex_path,'bowtie-build')).load_module() 41 options,arguments = bld.build_args() 42 43 if '--verbose' in options: 44 arguments.append('--verbose') 45 logging.getLogger().setLevel(logging.INFO) 46 47 if '--debug' in options: 48 inspect_bin_spec += '-debug' 49 inspect_bin_l += '-debug' 50 51 if '--large-index' in options: 52 inspect_bin_spec = os.path.join(ex_path,inspect_bin_l) 53 elif len(arguments) >= 1: 54 idx_basename = arguments[-1] 55 large_idx_exists = os.path.exists(idx_basename + idx_ext_l) 56 small_idx_exists = os.path.exists(idx_basename + idx_ext_s) 57 if large_idx_exists and not small_idx_exists: 58 logging.info("No small index but a large one is present. Inspecting the large index.") 59 inspect_bin_spec = os.path.join(ex_path,inspect_bin_l) 60 61 arguments[0] = inspect_bin_name 62 arguments.insert(1, 'basic-0') 63 arguments.insert(1, '--wrapper') 64 logging.info('Command: %s %s' % (inspect_bin_spec,' '.join(arguments[1:]))) 65 os.execv(inspect_bin_spec, arguments) 66 67 68if __name__ == "__main__": 69 main() 70