{% from 'project_details.txt' import project_details_report %}
{% from 'file_validation.txt' import file_validation_report %}
{% from 'sample_name_check.txt' import sample_name_check_report %}
{% from 'fasta_check.txt' import fasta_check_report %}
{% from 'metadata_validation.txt' import metadata_validation_report %}
{% from 'shallow_validation.txt' import optional_shallow_validation_report %}

{% macro validation_not_run_yet_message(text="Process not run yet") -%}
{% set icon = "\u23F8" %}
{{ icon }} {{ text }}
{%- endmacro %}

VALIDATION REPORT
eva-sub-cli v{{cli_version}}

{{ optional_shallow_validation_report(validation_results) }}

-

PROJECT SUMMARY
General details about the project

{{ project_details_report(validation_results, project_title, validation_date, submission_dir, consent_statement_required, vcf_fasta_analysis_mapping) }}

-

METADATA VALIDATION RESULTS
Ensures that required fields are present and values are formatted correctly.
For requirements, please refer to the EVA website (https://www.ebi.ac.uk/eva/?Submit-Data).

{% set run_status = validation_results.get('metadata_check', {}).get('run_status', '') %}
{% if run_status %}
    {{ metadata_validation_report(validation_results) }}
{% else %}
    {{ validation_not_run_yet_message() }}
{% endif %}
-

VCF VALIDATION RESULTS
Checks whether each file is compliant with the VCF specification (http://samtools.github.io/hts-specs/VCFv4.4.pdf).
Also checks whether the variants' reference alleles match against the reference assembly.

{% set run_status = validation_results.get('vcf_check', {}).get('run_status', '') %}
{% if run_status %}
{% for file_name in vcf_files %}
{% if file_name != "pass"%}
    {{ file_name }}
    {{ file_validation_report(validation_results, file_name) }}
{% endif %}
{% endfor %}
{% else %}
    {{ validation_not_run_yet_message() }}
{% endif %}

-

SAMPLE NAME CONCORDANCE CHECK
Checks whether information in the metadata is concordant with that contained in the VCF files, in particular sample names.

{% set run_status = validation_results.get('sample_check', {}).get('run_status', '') %}
{% if run_status %}
    {{ sample_name_check_report(validation_results) }}
{% else %}
    {{ validation_not_run_yet_message() }}
{% endif %}

-

REFERENCE GENOME INSDC CHECK
Checks that the reference sequences in the FASTA file used to call the variants are accessioned in INSDC.
Also checks if the reference assembly accession in the metadata matches the one determined from the FASTA file.

{% set run_status = validation_results.get('fasta_check', {}).get('run_status', '') %}
{% if run_status %}
{% for file_name in fasta_files %}
{% if file_name != "pass"%}
    {{ file_name }}
    {{ fasta_check_report(validation_results, file_name) }}
{% endif %}
{% endfor %}
{% else %}
    {{ validation_not_run_yet_message() }}
{% endif %}
