Ejemplo n.º 1
0
def test_report_buttons():
    all_runs = path_processing.get_all_runs_names()
    run_id = all_runs[0]
    samples_for_given_run = path_processing.get_samples_from_run_name(run_id)
    sample_id = samples_for_given_run[0]

    download_path = path_processing.get_fastq_fq1_download_path(
        run_id, sample_id).replace(os.sep, '/')
    path = urllib.parse.urljoin(DOWNLOAD_PATH, download_path)
    assert check_status_code(path) == 200

    download_path = path_processing.get_fastq_fq2_download_path(
        run_id, sample_id).replace(os.sep, '/')
    path = urllib.parse.urljoin(DOWNLOAD_PATH, download_path)
    assert check_status_code(path) == 200

    download_path = path_processing.get_fastqc_report_path(
        run_id, sample_id, 1).replace(os.sep, '/')
    path = urllib.parse.urljoin(DOWNLOAD_PATH, download_path)
    assert check_status_code(path) == 200

    download_path = path_processing.get_fastqc_report_path(
        run_id, sample_id, 2).replace(os.sep, '/')
    path = urllib.parse.urljoin(DOWNLOAD_PATH, download_path)
    assert check_status_code(path) == 200
Ejemplo n.º 2
0
def test_specific_sample_page():
    all_runs = path_processing.get_all_runs_names()
    samples_for_given_run = path_processing.get_samples_from_run_name(
        all_runs[0])
    path = slash_join(BASE_LINK, 'runs', all_runs[0], samples_for_given_run[0])
    status_code = check_status_code(path)
    assert status_code == 200
Ejemplo n.º 3
0
def specific_run(run_id):
    runs = pp.get_all_runs_names()

    if run_id not in runs:
        logger.info('Redirected for incorrect run_id {}'.format(run_id))
        return redirect(url_for('runs'))

    # target coverage
    path = pp.get_sample_coverage_path(run_id)
    if pp.check_existence(path):
        sample_summary_table = data_preparation.get_summary(run_id)
    else:
        sample_summary_table = False

    # presenting plot
    path = pp.get_multisample_vcf_stats_path(run_id)
    if pp.check_existence(path):
        variants, variants_df = data_preparation.get_multisample_stats_df(run_id)
    else:
        variants, variants_df = False, False

    # variants annotations
    path = pp.get_annotated_variants_stats_path(run_id)
    if pp.check_existence(path):
        variants_annotations_df = pd.read_csv(path, delimiter='\t')
    else:
        variants_annotations_df = False

    graphs = [
        sample_summary_graph(sample_summary_table),
        variants_graph(variants_df),
        variants_annotations_graph(variants_annotations_df),
    ]

    graphJSON = json.dumps(graphs, cls=plotly.utils.PlotlyJSONEncoder)
    ids = ['graph-{}'.format(i) for i, _ in enumerate(graphs)]

    data = {'sample_summary_table': data_preparation.prepare_sample_summary_html_table(sample_summary_table, run_id),
            'graphJSON': graphJSON,
            'ids': ids,
            'variants': variants if variants else False,
            'variants_annotations': variants_annotations_df if variants_annotations_df is False else True,
            'coverage_sample_list': False,
            'run_id': run_id,
            'runs': runs,
            }

    # gene coverage
    summary_path = pp.get_sample_gene_coverage_path(run_id)
    if pp.check_existence(summary_path):
        data['coverage_sample_list_exists'] = True
        mean_cols_df = data_preparation.get_gene_summary(run_id)
        df = data_preparation.prepare_mean_columns_df(mean_cols_df)
        df.fillna(-1, inplace=True)
        data['coverage_sample_list'] = df.round(2).values.tolist()[:100]

    logger.info('Specific run_id page rendered correctly. {}'.format(run_id))
    return render_template('runs/run.html', **data)
Ejemplo n.º 4
0
def specific_sample(run_id, sample_id):
    if run_id not in pp.get_all_runs_names() or sample_id not in pp.get_samples_from_run_name(run_id):
        logger.info('Invalid sample_id or run_id.')
        return redirect(url_for('samples'))

    data = {'run_id': run_id,
            'sample_id': sample_id,
            'samples': pp.samples_paths(pp.get_all_runs_names()),
            'gene_coverage_exists': True,
            'sample_variants_exists': True,
            'coverage_sample_summary_exists': True}

    # update data dict with tables and other data information
    data.update(data_preparation.prepare_tables_for_sample_page(run_id, sample_id))

    # update dict with links to download files and reports
    data.update(data_preparation.links_to_external_download_data_and_reports(run_id, sample_id))

    logger.info('Specific sample loaded correctly. {} {}'.format(run_id, sample_id))
    return render_template('samples/sample.html', **data)
Ejemplo n.º 5
0
def runs():
    runs = pp.get_all_runs_names()
    logger.info("Runs page rendered.")
    return render_template('runs/runs.html', runs=runs)
Ejemplo n.º 6
0
def samples():
    runs = pp.get_all_runs_names()
    samples = pp.samples_paths(runs)
    logger.info('Samples page rendered.')
    return render_template('samples/samples.html', samples=samples)
Ejemplo n.º 7
0
def test_specific_run_page():
    all_runs = path_processing.get_all_runs_names()
    path = urllib.parse.urljoin(BASE_LINK, 'runs', all_runs[0])
    status_code = check_status_code(path)
    assert status_code == 200