#!/bin/bash -Ceuo pipefail
cat << 'EOF' > manifest.json
{"pairs":[{"pair_id":"HCC1395_tumor_vs_HCC1395_BL","tumor_sample":"HCC1395_tumor","normal_sample":"HCC1395_BL"},{"pair_id":"custom_Sig_18_tumor_normal","tumor_sample":"Sig_18_tissue","normal_sample":"Sig_18_Blood"}],"qc_files":[{"scope":"pair","sample_id":"HCC1395_tumor_vs_HCC1395_BL","qc_type":"contamination","tool":"conpair","label":"concordance","filename":"HCC1395_tumor_vs_HCC1395_BL.conpair.contamination.txt","staged_path":"1/HCC1395_tumor_vs_HCC1395_BL.conpair.contamination.txt"},{"scope":"batch","sample_id":"all","qc_type":"identity","tool":"ngscheckmate","label":"all_txt","filename":"ngscheckmate_all.txt","staged_path":"2/ngscheckmate_all.txt"},{"scope":"pair","sample_id":"Sig_18_tissue_vs_Sig_18_Blood","qc_type":"contamination","tool":"conpair","label":"concordance","filename":"Sig_18_tissue_vs_Sig_18_Blood.conpair.contamination.txt","staged_path":"3/Sig_18_tissue_vs_Sig_18_Blood.conpair.contamination.txt"},{"scope":"sample","sample_id":"HCC1395_BL","qc_type":"germline_cnv","tool":"germline_cnv","label":"vcf","filename":"HCC1395_BL.vcf.gz","staged_path":"4/HCC1395_BL.vcf.gz"},{"scope":"sample","sample_id":"Sig_18_Blood","qc_type":"germline_cnv","tool":"germline_cnv","label":"vcf","filename":"Sig_18_Blood.vcf.gz","staged_path":"5/Sig_18_Blood.vcf.gz"},{"scope":"pair","sample_id":"HCC1395_tumor_vs_HCC1395_BL","qc_type":"tmb","tool":"tmb","label":"csv","filename":"HCC1395_tumor_vs_HCC1395_BL.tnseq.filtered_snpEff.ann.tmb.csv","staged_path":"6/HCC1395_tumor_vs_HCC1395_BL.tnseq.filtered_snpEff.ann.tmb.csv"},{"scope":"pair","sample_id":"custom_Sig_18_tumor_normal","qc_type":"tmb","tool":"tmb","label":"csv","filename":"custom_Sig_18_tumor_normal.tnseq.filtered_snpEff.ann.tmb.csv","staged_path":"7/custom_Sig_18_tumor_normal.tnseq.filtered_snpEff.ann.tmb.csv"},{"scope":"pair","sample_id":"HCC1395_tumor_vs_HCC1395_BL","qc_type":"bcftools_stats","tool":"strelka","label":"stats_snvs","filename":"HCC1395_tumor_vs_HCC1395_BL.strelka.somatic_snvs.bcftools_stats.txt","staged_path":"8/HCC1395_tumor_vs_HCC1395_BL.strelka.somatic_snvs.bcftools_stats.txt"},{"scope":"pair","sample_id":"HCC1395_tumor_vs_HCC1395_BL","qc_type":"bcftools_stats","tool":"strelka","label":"stats_indels","filename":"HCC1395_tumor_vs_HCC1395_BL.strelka.somatic_indels.bcftools_stats.txt","staged_path":"9/HCC1395_tumor_vs_HCC1395_BL.strelka.somatic_indels.bcftools_stats.txt"},{"scope":"pair","sample_id":"custom_Sig_18_tumor_normal","qc_type":"bcftools_stats","tool":"strelka","label":"stats_snvs","filename":"custom_Sig_18_tumor_normal.strelka.somatic_snvs.bcftools_stats.txt","staged_path":"10/custom_Sig_18_tumor_normal.strelka.somatic_snvs.bcftools_stats.txt"},{"scope":"pair","sample_id":"custom_Sig_18_tumor_normal","qc_type":"bcftools_stats","tool":"strelka","label":"stats_indels","filename":"custom_Sig_18_tumor_normal.strelka.somatic_indels.bcftools_stats.txt","staged_path":"11/custom_Sig_18_tumor_normal.strelka.somatic_indels.bcftools_stats.txt"},{"scope":"sample","sample_id":"Sig_18_Blood","qc_type":"deconfliction_audit","tool":"deconflict","label":"tsv","filename":"Sig_18_Blood.deconfliction_audit.tsv","staged_path":"12/Sig_18_Blood.deconfliction_audit.tsv"},{"scope":"sample","sample_id":"HCC1395_BL","qc_type":"deconfliction_audit","tool":"deconflict","label":"tsv","filename":"HCC1395_BL.deconfliction_audit.tsv","staged_path":"13/HCC1395_BL.deconfliction_audit.tsv"}]}
EOF
aggregate_qc_metrics.py \
--manifest manifest.json \
--files-dir . \
--output variant_qc.json
cat <<-END_VERSIONS > versions.yml
"NFCORE_SAREK:SAREK:AGGREGATE_VARIANT_QC":
python: $(python --version | sed 's/Python //g')
aggregate_qc_metrics: 2.0.0
END_VERSIONS