예제 #1
0
def real_database(database_name, institute_obj, user_obj, genes, panel_info):
    """Setup a real database with populated data"""
    mongo_client = pymongo.MongoClient()
    mongo_client.drop_database(database_name)

    database = mongo_client[database_name]
    adapter = MongoAdapter(database)

    # Populate the database
    adapter.add_institute(institute_obj)
    adapter.add_user(user_obj)

    load_hgnc_genes(adapter, genes)
    adapter.hgnc_collection.create_index([('build', pymongo.ASCENDING),
                                          ('hgnc_symbol', pymongo.ASCENDING)])
    load_panel(adapter=adapter, panel_info=panel_info)

    # load_hpo(adapter=gene_database, hpo_lines=hpo_terms_handle, disease_lines=genemap_handle)
    # adapter.add_case(case_obj)

    # for variant in variant_objs:
    #     adapter.load_variant(variant)

    yield adapter

    mongo_client.drop_database(database_name)
예제 #2
0
def real_database(request, database_name, institute_obj, user_obj, genes,
                  panel_info):
    """Setup a real database with populated data"""
    mongo_client = pymongo.MongoClient()
    mongo_client.drop_database(database_name)

    database = mongo_client[database_name]
    adapter = MongoAdapter(database)

    # Populate the database
    adapter.add_institute(institute_obj)
    adapter.add_user(user_obj)

    load_hgnc_genes(adapter, genes)
    adapter.hgnc_collection.create_index([('build', pymongo.ASCENDING),
                                          ('hgnc_symbol', pymongo.ASCENDING)])
    adapter.load_panel(path=panel_info['file'],
                       institute=panel_info['institute'],
                       panel_id=panel_info['panel_name'],
                       date=panel_info['date'],
                       panel_type=panel_info['type'],
                       version=panel_info['version'],
                       display_name=panel_info['full_name'])

    # load_hpo(adapter=gene_database, hpo_lines=hpo_terms_handle, disease_lines=genemap_handle)
    # adapter.add_case(case_obj)

    # for variant in variant_objs:
    #     adapter.load_variant(variant)

    def teardown():
        mongo_client.drop_database(database_name)

    request.addfinalizer(teardown)

    return adapter