Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
144 changes: 70 additions & 74 deletions eva_sub_cli/jinja_templates/html/file_validation.html
Original file line number Diff line number Diff line change
@@ -1,93 +1,89 @@

{% macro file_validation_report(validation_results, file_name) -%}
{% for check_type, check_per_file in validation_results.items() if check_type not in ["trim_down", "version"] %}
{% set result = check_per_file.get(file_name, {}) %}
{% if check_type == "assembly_check" %}
{{ assembly_check(result) }}
{% elif check_type == "vcf_check" %}
{{ vcf_check(result) }}

{% macro vcf_check_report(vcf_check_result_per_file, vcf_file_names) -%}
{% for file_name in vcf_file_names %}
{% set vcf_check_result = vcf_check_result_per_file.get(file_name, {}) %}
{% set critical_count = vcf_check_result.get("critical_count", 0) %}
{% set error_count = vcf_check_result.get("error_count", 0) %}
{% set expand_icon = "" %}
{% if critical_count > 0 %}
{% set expand_icon = "▶" %}
{% set icon = "❌" %}
{% set row_class = "report-section fail collapsible" %}
{% elif error_count > 0 %}
{% set expand_icon = "▶" %}
{% set icon = "❗" %}
{% set row_class = "report-section warn collapsible" %}
{% else %}
{% set icon = "✔" %}
{% set row_class = "report-section pass" %}
{% endif %}
<div class='{{ row_class }}'><span class="expand_icon">{{ expand_icon }}</span> {{ icon }} {{ file_name }}: {{ critical_count }} critical errors, {{ error_count }} non-critical errors </div>
{% set critical_list = vcf_check_result.get("critical_list") %}
{% set error_list = vcf_check_result.get("error_list") %}

{% if critical_list or error_list%}
<div class="error-list">
<div class="error-description">First 10 errors per category are below. <strong>Full report:</strong> {{ vcf_check_result.get('report_path', '') }}</div>
<table>
<tr>
<th>Category</th><th>Error</th>
</tr>
{% for error in critical_list[:10] %}
<tr>
<td><strong>critical error</strong></td><td> {{ error }}</td>
</tr>
{% endfor %}
{% for error in error_list[:10] %}
<tr>
<td><strong>non-critical error</strong></td><td> {{ error }}</td>
</tr>
{% endfor %}
</table>
</div>
{% endif %}
{% endfor %}
{%- endmacro %}

{% macro vcf_check(vcf_check_result) %}
{% set critical_count = vcf_check_result.get("critical_count", 0) %}
{% set error_count = vcf_check_result.get("error_count", 0) %}
{% set expand_icon = "" %}
{% if critical_count > 0 %}
{% set expand_icon = "&#9654;" %}
{% set icon = "&#10060;" %}
{% set row_class = "report-section fail collapsible" %}
{% elif error_count > 0 %}
{% set expand_icon = "&#9654;" %}
{% set icon = "&#10071;" %}
{% set row_class = "report-section warn collapsible" %}
{% else %}
{% set icon = "&#10004;" %}
{% set row_class = "report-section pass" %}
{% endif %}
<div class='{{ row_class }}'><span class="expand_icon">{{ expand_icon }}</span> {{ icon }} VCF check: {{ critical_count }} critical errors, {{ error_count }} non-critical errors </div>
{% set critical_list = vcf_check_result.get("critical_list") %}
{% set error_list = vcf_check_result.get("error_list") %}

{% if critical_list or error_list%}
<div class="error-list">
<div class="error-description">First 10 errors per category are below. <strong>Full report:</strong> {{ vcf_check_result.get('report_path', '') }}</div>
{% macro assembly_check_report(assembly_check_result_per_file, vcf_file_names) -%}
{% for file_name in vcf_file_names %}
{% set assembly_check_result = assembly_check_result_per_file.get(file_name, {}) %}
{% set nb_match = assembly_check_result.get("match", 0) %}
{% set nb_total = assembly_check_result.get("total", 0) %}
{% set match_percentage = nb_match / nb_total * 100 if nb_total else 0 %}
{% set expand_icon = "" %}
{% if assembly_check_result.get("nb_mismatch", 0) > 0 or nb_total == 0 %}
{% set expand_icon = "&#9654;" %}
{% set icon = "&#10060;" %}
{% set row_class = "report-section fail collapsible" %}
{% else %}
{% set icon = "&#10004;" %}
{% set row_class = "report-section pass" %}
{% endif %}
<div class='{{ row_class }}'><span class="expand_icon">{{ expand_icon }}</span> {{ icon }} {{ file_name }}: {{ nb_match }}/{{ nb_total }} ({{ match_percentage|round(2) }}%)</div>
{% set mismatch_list = assembly_check_result.get("mismatch_list") %}
{% set error_list = assembly_check_result.get("error_list") %}
{% if mismatch_list or error_list %}
<div class="error-list">
<div class="error-description">First 10 errors per category are below. <strong>Full report:</strong> {{ assembly_check_result.get('report_path', '') }}</div>
<table>
<tr>
<th>Category</th><th>Error</th>
</tr>
{% for error in critical_list[:10] %}
{% for error in error_list[:10] %}
<tr>
<td><strong>critical error</strong></td><td> {{ error }}</td>
<td><strong>Parsing Error</strong></td><td> {{ error }}</td>
</tr>
{% endfor %}
{% for error in error_list[:10] %}
{% for error in mismatch_list[:10] %}
<tr>
<td><strong>non-critical error</strong></td><td> {{ error }}</td>
<td><strong>mismatch error</strong></td><td> {{ error }}</td>
</tr>
{% endfor %}
</table>
</div>
{% endif %}
{%- endmacro %}

{% macro assembly_check(assembly_check_result) %}
{% set nb_match = assembly_check_result.get("match", 0) %}
{% set nb_total = assembly_check_result.get("total", 0) %}
{% set match_percentage = nb_match / nb_total * 100 if nb_total else 0 %}
{% set expand_icon = "" %}
{% if assembly_check_result.get("nb_mismatch", 0) > 0 or nb_total == 0 %}
{% set expand_icon = "&#9654;" %}
{% set icon = "&#10060;" %}
{% set row_class = "report-section fail collapsible" %}
{% else %}
{% set icon = "&#10004;" %}
{% set row_class = "report-section pass" %}
{% endif %}
<div class='{{ row_class }}'><span class="expand_icon">{{ expand_icon }}</span> {{ icon }} Assembly check: {{ nb_match }}/{{ nb_total }} ({{ match_percentage|round(2) }}%)</div>
{% set mismatch_list = assembly_check_result.get("mismatch_list") %}
{% set error_list = assembly_check_result.get("error_list") %}
{% if mismatch_list or error_list %}
<div class="error-list">
<div class="error-description">First 10 errors per category are below. <strong>Full report:</strong> {{ assembly_check_result.get('report_path', '') }}</div>
<table>
<tr>
<th>Category</th><th>Error</th>
</tr>
{% for error in error_list[:10] %}
<tr>
<td><strong>Parsing Error</strong></td><td> {{ error }}</td>
</tr>
{% endfor %}
{% for error in mismatch_list[:10] %}
<tr>
<td><strong>mismatch error</strong></td><td> {{ error }}</td>
</tr>
{% endfor %}
</table>
</div>
{% endif %}
</div>
{% endif %}
{% endfor %}
{%- endmacro %}


42 changes: 31 additions & 11 deletions eva_sub_cli/jinja_templates/html/report.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<!DOCTYPE html>
{% from 'project_details.html' import project_details_report %}
{% from 'file_validation.html' import file_validation_report %}
{% from 'file_validation.html' import assembly_check_report, vcf_check_report %}
{% from 'sample_name_check.html' import sample_name_check_report %}
{% from 'fasta_check.html' import fasta_check_report %}
{% from 'metadata_validation.html' import metadata_validation_report %}
Expand All @@ -13,6 +13,13 @@
<div class='{{ row_class }}'><span class="expand_icon">{{ expand_icon }}</span> {{ icon }} {{ text }}</div>
{% endmacro %}

{% macro report_crashed_task(task_name) %}
{% set icon = "&#10071;" %} {# exclamation point ❗#}
{% set row_class = "report-section info" %}
{% set expand_icon = "" %}
<div class='{{ row_class }}'><span class="expand_icon">{{ expand_icon }}</span> {{ icon }} {{ task_name }} did not complete successfully. Check the logs for more information.</div>
{% endmacro %}

<html lang="EN">
<head>
<meta charset="UTF-8">
Expand Down Expand Up @@ -73,8 +80,10 @@ <h2>Metadata validation results</h2>
For requirements, please refer to the <a href="https://www.ebi.ac.uk/eva/?Submit-Data" target=”_blank”>EVA website</a>.
</div>
{% set run_status = validation_results.get('metadata_check', {}).get('run_status', '') %}
{% if run_status %}
{% if run_status == 'success' %}
{{ metadata_validation_report(validation_results) }}
{% elif run_status == 'crashed' %}
{{ report_crashed_task('Metadata check') }}
{% else %}
{{ validation_not_run_yet_message() }}
{% endif %}
Expand All @@ -86,14 +95,21 @@ <h2>VCF validation results</h2>
Checks whether each file is compliant with the <a href="http://samtools.github.io/hts-specs/VCFv4.4.pdf" target=”_blank”>VCF specification</a>.
Also checks whether the variants' reference alleles match against the reference assembly.
</div>
<h3>Assembly check</h3>
{% set run_status = validation_results.get('assembly_check', {}).get('run_status', '') %}
{% if run_status == 'success' %}
{{ assembly_check_report(validation_results.get('assembly_check', {}), vcf_files) }}
{% elif run_status == 'crashed' %}
{{ report_crashed_task('Assembly check') }}
{% else %}
{{ validation_not_run_yet_message() }}
{% endif %}
<h3>VCF check</h3>
{% set run_status = validation_results.get('vcf_check', {}).get('run_status', '') %}
{% if run_status %}
{% for file_name in vcf_files %}
{% if file_name != "pass"%}
<h3>{{ file_name }}</h3>
{{ file_validation_report(validation_results, file_name) }}
{% endif %}
{% endfor %}
{% if run_status == 'success' %}
{{ vcf_check_report(validation_results.get('vcf_check', {}), vcf_files) }}
{% elif run_status == 'crashed' %}
{{ report_crashed_task('VCF check') }}
{% else %}
{{ validation_not_run_yet_message() }}
{% endif %}
Expand All @@ -105,8 +121,10 @@ <h2>Sample name concordance check</h2>
Checks whether information in the metadata is concordant with that contained in the VCF files, in particular sample names.
</div>
{% set run_status = validation_results.get('sample_check', {}).get('run_status', '') %}
{% if run_status %}
{% if run_status == 'success' %}
{{ sample_name_check_report(validation_results)}}
{% elif run_status == 'crashed' %}
{{ report_crashed_task('Sample name concordance') }}
{% else %}
{{ validation_not_run_yet_message() }}

Expand All @@ -120,13 +138,15 @@ <h2>Reference genome INSDC check</h2>
Also checks if the reference assembly accession in the metadata matches the one determined from the FASTA file.
</div>
{% set run_status = validation_results.get('fasta_check', {}).get('run_status', '') %}
{% if run_status %}
{% if run_status == 'success' %}
{% for file_name in fasta_files %}
{% if file_name != "pass"%}
<h3>{{ file_name }}</h3>
{{ fasta_check_report(validation_results, file_name) }}
{% endif %}
{% endfor %}
{% elif run_status == 'crashed' %}
{{ report_crashed_task('INSDC check') }}
{% else %}
{{ validation_not_run_yet_message() }}
{% endif %}
Expand Down
101 changes: 48 additions & 53 deletions eva_sub_cli/jinja_templates/text/file_validation.txt
Original file line number Diff line number Diff line change
@@ -1,60 +1,55 @@

{% macro file_validation_report(validation_results, file_name) -%}
{% for check_type, check_per_file in validation_results.items() if check_type not in ["trim_down", "version"] %}
{% set result = check_per_file.get(file_name, {}) %}
{% if check_type == "assembly_check" %}
{{ assembly_check(result) }}
{% elif check_type == "vcf_check" %}
{{ vcf_check(result) }}
{% macro vcf_check_report(vcf_check_result_per_file, vcf_file_names) -%}
{% for file_name in vcf_file_names %}
{% set vcf_check_result = vcf_check_result_per_file.get(file_name, {}) %}
{% set critical_count = vcf_check_result.get("critical_count", 0) %}
{% set error_count = vcf_check_result.get("error_count", 0) %}
{% if critical_count > 0 %}
{% set icon = "\u274C" %}
{% elif error_count > 0 %}
{% set icon = "\u26A0" %}
{% else %}
{% set icon = "\u2714" %}
{% endif %}
{% endfor %}
{%- endmacro %}
{{ icon }} {{ file_name }}: {{ critical_count }} critical errors, {{ error_count }} non-critical errors

{% macro vcf_check(vcf_check_result) %}
{% set critical_count = vcf_check_result.get("critical_count", 0) %}
{% set error_count = vcf_check_result.get("error_count", 0) %}
{% if critical_count > 0 %}
{% set icon = "\u274C" %}
{% elif error_count > 0 %}
{% set icon = "\u26A0" %}
{% else %}
{% set icon = "\u2714" %}
{% endif %}
{{ icon }} VCF check: {{ critical_count }} critical errors, {{ error_count }} non-critical errors

{% set critical_list = vcf_check_result.get("critical_list") %}
{% set error_list = vcf_check_result.get("error_list") %}
{% if critical_list or error_list%}
First 10 errors per category are below. Full report: {{ vcf_check_result.get('report_path', '') }}
{% for error in critical_list[:10] %}
Critical error: {{ error }}
{% endfor %}
{% for error in error_list[:10] %}
Non-critical error: {{ error }}
{% endfor %}
{% endif %}
{% set critical_list = vcf_check_result.get("critical_list") %}
{% set error_list = vcf_check_result.get("error_list") %}
{% if critical_list or error_list%}
First 10 errors per category are below. Full report: {{ vcf_check_result.get('report_path', '') }}
{% for error in critical_list[:10] %}
Critical error: {{ error }}
{% endfor %}
{% for error in error_list[:10] %}
Non-critical error: {{ error }}
{% endfor %}
{% endif %}
{% endfor %}
{%- endmacro %}

{% macro assembly_check(assembly_check_result) %}
{% set nb_match = assembly_check_result.get("match", 0) %}
{% set nb_total = assembly_check_result.get("total", 0) %}
{% set match_percentage = nb_match / nb_total * 100 if nb_total else 0 %}
{% if assembly_check_result.get("nb_mismatch", 0) > 0 or nb_total == 0 %}
{% set icon = "\u274C" %}
{% else %}
{% set icon = "\u2714" %}
{% endif %}
{{ icon }} Assembly check: {{ nb_match }}/{{ nb_total }} ({{ match_percentage|round(2) }}%)
{% macro assembly_check_report(assembly_check_result_per_file, vcf_file_names) -%}
{% for file_name in vcf_file_names %}
{% set assembly_check_result = assembly_check_result_per_file.get(file_name, {}) %}
{% set nb_match = assembly_check_result.get("match", 0) %}
{% set nb_total = assembly_check_result.get("total", 0) %}
{% set match_percentage = nb_match / nb_total * 100 if nb_total else 0 %}
{% if assembly_check_result.get("nb_mismatch", 0) > 0 or nb_total == 0 %}
{% set icon = "\u274C" %}
{% else %}
{% set icon = "\u2714" %}
{% endif %}
{{ icon }} {{ file_name }}: {{ nb_match }}/{{ nb_total }} ({{ match_percentage|round(2) }}%)

{% set mismatch_list = assembly_check_result.get("mismatch_list") %}
{% set error_list = assembly_check_result.get("error_list") %}
{% if mismatch_list or error_list %}
First 10 errors per category are below. Full report: {{ assembly_check_result.get('report_path', '') }}
{% for error in error_list[:10] %}
Parsing error: {{ error }}
{% endfor %}
{% for error in mismatch_list[:10] %}
Mismatch error: {{ error }}
{% endfor %}
{% endif %}
{% set mismatch_list = assembly_check_result.get("mismatch_list") %}
{% set error_list = assembly_check_result.get("error_list") %}
{% if mismatch_list or error_list %}
First 10 errors per category are below. Full report: {{ assembly_check_result.get('report_path', '') }}
{% for error in error_list[:10] %}
Parsing error: {{ error }}
{% endfor %}
{% for error in mismatch_list[:10] %}
Mismatch error: {{ error }}
{% endfor %}
{% endif %}
{% endfor %}
{%- endmacro %}
Loading
Loading