@click.command('exons', short_help='Load exons')
@click.option('-e', '--exons-file', type=click.Path(exists=True), help='Path to file with ensembl exons')
@click.option('-b', '--build', type=click.Choice(['37', '38']), default='37', show_default=True)
@with_appcontext
def exons(build, exons_file):
    'Load exons into the scout database. If no file, fetch exons from ensembl biomart'
    adapter = store
    LOG.info('Running scout load exons')
    start = datetime.now()
    existing_exon = adapter.exon(build=build)
    if existing_exon:
        LOG.warning('Dropping all exons ')
        adapter.drop_exons(build=build)
        LOG.info('Exons dropped')
    nr_exons = 0
    if exons_file:
        ensembl_exons = get_file_handle(exons_file)
        for (nr_exons, line) in enumerate(ensembl_exons, 1):
            pass
        ensembl_exons = get_file_handle(exons_file)
    else:
        ensembl_exons = fetch_ensembl_exons(build=build)
        nr_exons = 1360000
    try:
        load_exons(adapter, ensembl_exons, build, nr_exons=nr_exons)
    except Exception as err:
        LOG.warning('Something went wrong with ensembl biomart')
        LOG.info('Please download a mart dump manually, see instructions in user guide for admins')
        return
    LOG.info('Time to load exons: {0}'.format((datetime.now() - start)))
Load exons into the scout database. If no file, fetch exons from ensembl biomart
@click.command('exons', short_help='Load exons')
@click.option('-e', '--exons-file', type=click.Path(exists=True), help='Path to file with ensembl exons')
@click.option('-b', '--build', type=click.Choice(['37', '38']), default='37', show_default=True)
@with_appcontext
def exons(build, exons_file):
    
    adapter = store
    LOG.info('Running scout load exons')
    start = datetime.now()
    existing_exon = adapter.exon(build=build)
    if existing_exon:
        LOG.warning('Dropping all exons ')
        adapter.drop_exons(build=build)
        LOG.info('Exons dropped')
    nr_exons = 0
    if exons_file:
        ensembl_exons = get_file_handle(exons_file)
        for (nr_exons, line) in enumerate(ensembl_exons, 1):
            pass
        ensembl_exons = get_file_handle(exons_file)
    else:
        ensembl_exons = fetch_ensembl_exons(build=build)
        nr_exons = 1360000
    try:
        load_exons(adapter, ensembl_exons, build, nr_exons=nr_exons)
    except Exception as err:
        LOG.warning('Something went wrong with ensembl biomart')
        LOG.info('Please download a mart dump manually, see instructions in user guide for admins')
        return
    LOG.info('Time to load exons: {0}'.format((datetime.now() - start)))