<commit_before>#!/usr/bin/env python3
from database import db
from database import bdb
from database import bdb_refseq
import import_data
import argparse


def restet_relational_db():

    print('Removing relational database...')
    db.reflect()
    db.drop_all()
    print('Removing relational database completed.')

    print('Recreating relational database...')
    db.create_all()
    print('Recreating relational database completed.')


def reset_mappings_db():
    print('Removing mappigns database...')
    bdb.reset()
    bdb_refseq.reset()
    print('Removing mapings database completed.')

if __name__ == '__main__':

    parser = argparse.ArgumentParser()
    parser.add_argument(
        '-i',
        '--import_mappings',
        action='store_true',
        help='Should mappings be (re)imported'
    )
    parser.add_argument(
        '-r',
        '--reload_relational',
        action='store_true',
        help='Should relational database be (re)imported'
    )
    parser.add_argument(
        '-m',
        '--only_mutations',
        action='store_true',
        help='Should mutations be loaded without db restart?'
    )

    args = parser.parse_args()

    if args.only_mutations:
        print('Importing mutations')
        with app.app_context():
            proteins = import_data.get_proteins()
            mutations = import_data.load_mutations(proteins, set())
    else:
        if args.reload_relational:
            restet_relational_db()
            print('Importing data')
            import_data.import_data()

        if args.import_mappings:
            reset_mappings_db()
            with app.app_context():
                proteins = get_proteins()
                import_data.import_mappings(proteins)

    print('Done, all tasks completed.')

else:
    print('This script should be run from command line')<commit_msg>Fix namespace bugs in db create<commit_after>#!/usr/bin/env python3
from database import db
from database import bdb
from database import bdb_refseq
import import_data
import argparse


def restet_relational_db():

    print('Removing relational database...')
    db.reflect()
    db.drop_all()
    print('Removing relational database completed.')

    print('Recreating relational database...')
    db.create_all()
    print('Recreating relational database completed.')


def reset_mappings_db():
    print('Removing mappigns database...')
    bdb.reset()
    bdb_refseq.reset()
    print('Removing mapings database completed.')

if __name__ == '__main__':

    parser = argparse.ArgumentParser()
    parser.add_argument(
        '-i',
        '--import_mappings',
        action='store_true',
        help='Should mappings be (re)imported'
    )
    parser.add_argument(
        '-r',
        '--reload_relational',
        action='store_true',
        help='Should relational database be (re)imported'
    )
    parser.add_argument(
        '-m',
        '--only_mutations',
        action='store_true',
        help='Should mutations be loaded without db restart?'
    )

    args = parser.parse_args()

    if args.only_mutations:
        print('Importing mutations')
        with import_data.app.app_context():
            proteins = import_data.get_proteins()
            mutations = import_data.load_mutations(proteins, set())
    else:
        if args.reload_relational:
            restet_relational_db()
            print('Importing data')
            import_data.import_data()

        if args.import_mappings:
            reset_mappings_db()
            print('Importing mappings')
            with import_data.app.app_context():
                proteins = import_data.get_proteins()
                import_data.import_mappings(proteins)

    print('Done, all tasks completed.')

else:
    print('This script should be run from command line')
{'fraction_non_alphanumeric': 0.10560796645702306, 'fraction_numerical': 0.0005241090146750524, 'mean_word_length': 2.570626753975678, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2718127', 'n_tokens_mistral': 1121, 'n_tokens_neox': 1079, 'n_words': 250}