code: def get_bams():
      
      for size, md5, url in bams:
          bam = os.path.join(
              args.data_dir,
              os.path.basename(url).replace('.bam', '_%s.bam' % CHROM))
          if not _up_to_date(md5, bam):
              logger.info(
                  'Downloading reads on chromosome %s from %s to %s'
                  % (CHROM, url, bam))
              cmds = ['samtools', 'view', '-b', url, COORD, '>', bam]
              logged_command(cmds)
          bai = bam + '.bai'
          if not os.path.exists(bai):
              logger.info('indexing %s' % bam)
              logger.info(' '.join(cmds))
              cmds = [
                  'samtools',
                  'index',
                  bam]
              logged_command(cmds)
          if os.path.exists(os.path.basename(url) + '.bai'):
              os.unlink(os.path.basename(url) + '.bai')
  
      for size, md5, fn in bais:
          if not _up_to_date(md5, fn):
              cmds = [
                  'samtools', 'index', bai.replace('.bai', '')]
              logged_command(cmds)
docs: Download BAM files if needed, extract only chr17 reads, and regenerate .bai