Skip to content

Commit

Permalink
Clean up bowtie script
Browse files Browse the repository at this point in the history
  • Loading branch information
ch4rr0 committed Jul 22, 2020
1 parent d20447f commit e9d67f1
Showing 1 changed file with 8 additions and 36 deletions.
44 changes: 8 additions & 36 deletions bowtie
Original file line number Diff line number Diff line change
Expand Up @@ -38,31 +38,19 @@ def main():

parser = argparse.ArgumentParser()

group = parser.add_mutually_exclusive_group()
group.add_argument('-b', '--build', action='store_true')
group.add_argument('-i', '--inspect', action='store_true')

parser.add_argument('--verbose', action='store_true')
parser.add_argument('--debug', action='store_true')
parser.add_argument('--large-index', action='store_true')
parser.add_argument('--index', type=str)

# parse the args specific to the wrapper script
# all other args will be passed verbatim to bowtie
args, bowtie_args = parser.parse_known_args()

action = 'align'
if args.inspect:
action = 'inspect'
elif args.build:
action = 'build'

logging.basicConfig(level=logging.ERROR,
format='%(levelname)s: %(message)s'
)
bin_name = 'bowtie' + '-' + action
bin_s = 'bowtie-%s-s' % action
bin_l = 'bowtie-%s-l' % action
bin_s = 'bowtie-align-s'
bin_l = 'bowtie-align-l'
idx_ext_l = '.1.ebwtl'
idx_ext_s = '.1.ebwt'
ex_path = os.path.dirname(os.path.realpath(__file__))
Expand All @@ -75,28 +63,12 @@ def main():
if args.large_index:
bin_spec = os.path.join(ex_path, bin_l)

if args.index:
if args.build:
delta = 200
small_index_max_size = 4 * 1024 ** 3 - delta
tot_size = sum([os.stat(fn).st_size
for fn in args.index.split(',')
if os.path.exists(fn)])

if tot_size > small_index_max_size:
bin_spec = os.path.join(ex_path, bin_l)
else:
if not os.path.exists(arg + idx_ext_s)\
and os.path.exists(args.index + idx_ext_l):
bin_spec = os.path.join(ex_path, bin_l)
bowtie_args.insert(0, args.index)
else:
for arg in bowtie_args:
if arg[0] == '-':
continue
if not os.path.exists(arg + idx_ext_s)\
and os.path.exists(arg + idx_ext_l):
bin_spec = os.path.join(ex_path, bin_l)
for arg in bowtie_args:
if arg[0] == '-':
continue
if not os.path.exists(arg + idx_ext_s)\
and os.path.exists(arg + idx_ext_l):
bin_spec = os.path.join(ex_path, bin_l)

if args.debug:
bin_spec += '-debug'
Expand Down

0 comments on commit e9d67f1

Please sign in to comment.