Ejemplo n.º 1
0
def test_project_deletion(testing_db: RagsProjectDB):
    reset_db(testing_db)
    testing_db.create_project('Testing Project')
    new_project_id = testing_db.get_project_by_name('Testing Project').id
    testing_db.delete_project(new_project_id)
    assert testing_db.project_exists_by_id(new_project_id) is False
    assert testing_db.get_project_by_name('Testing Project') is None
Ejemplo n.º 2
0
def test_get_projects(testing_db: RagsProjectDB):
    reset_db(testing_db)
    testing_db.create_project('Testing Project')
    testing_db.create_project('Testing Project 2')
    testing_db.create_project('Testing Project 3')
    projects = testing_db.get_projects()
    assert len(projects) == 3

    for p in projects:
        assert type(p) == rags_db_models.RAGsProject
        assert 'Test' in p.name
Ejemplo n.º 3
0
def create_project_with_rags(testing_db: RagsProjectDB):
    testing_db.create_project('Testing Project')
    project_id = testing_db.get_project_by_name('Testing Project').id
    testing_db.create_study(project_id=project_id,
                            file_path=f'sample_sugen.gz',
                            study_name="Testing GWAS 1",
                            study_type=GWAS,
                            original_trait_id='MONDO:0011122',
                            original_trait_type=DISEASE,
                            original_trait_label='Obesity',
                            p_value_cutoff=0.005,
                            max_p_value=1,
                            has_tabix=True)
    testing_db.create_study(project_id=project_id,
                            file_path=f'sample_sugen2.gz',
                            study_name="Testing GWAS 2",
                            study_type=GWAS,
                            original_trait_id='MONDO:0011122',
                            original_trait_type=DISEASE,
                            original_trait_label='Obesity',
                            p_value_cutoff=0.005,
                            max_p_value=1,
                            has_tabix=True)
    testing_db.create_study(project_id=project_id,
                            file_path=f'sample_sugen3.gz',
                            study_name="Testing GWAS 3",
                            study_type=GWAS,
                            original_trait_id='MONDO:0011122',
                            original_trait_type=DISEASE,
                            original_trait_label='Obesity',
                            p_value_cutoff=0.005,
                            max_p_value=1,
                            has_tabix=True)
    testing_db.create_study(project_id=project_id,
                            file_path=f'sample_sugen4.gz',
                            study_name="Testing GWAS 4",
                            study_type=GWAS,
                            original_trait_id='MONDO:0011122',
                            original_trait_type=DISEASE,
                            original_trait_label='Obesity',
                            p_value_cutoff=0.005,
                            max_p_value=1,
                            has_tabix=True)
    testing_db.create_study(project_id=project_id,
                            file_path=f'sample_mwas',
                            study_name="Testing MWAS",
                            study_type=MWAS,
                            original_trait_id='MONDO:0011122',
                            original_trait_type=DISEASE,
                            original_trait_label='Obesity',
                            p_value_cutoff=0.005,
                            max_p_value=1)
    return project_id
Ejemplo n.º 4
0
def add_project(request: Request,
                new_project_name: str = Form(...),
                rags_project_db: RagsProjectDB = Depends(get_db)):
    template_context = init_template_context(request)
    if rags_project_db.project_exists_by_name(new_project_name):
        show_error_message(
            template_context,
            f'A project with that name already exists. ({new_project_name})')
    else:
        if rags_project_db.create_project(new_project_name):
            show_success_message(
                template_context,
                f'A new project was added. ({new_project_name})')
        else:
            show_error_message(template_context,
                               f'Error adding project. ({new_project_name})')

    set_up_projects_for_display(template_context, rags_project_db)
    return templates.TemplateResponse("projects.html.jinja", template_context)