From 1353ce0afa474bf6b8f0372072ff624f882fba26 Mon Sep 17 00:00:00 2001 From: Erin Young Date: Wed, 12 Jul 2023 09:33:37 -0600 Subject: [PATCH] added more metrics --- modules/snp-dists.nf | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/modules/snp-dists.nf b/modules/snp-dists.nf index 186e663..3728298 100644 --- a/modules/snp-dists.nf +++ b/modules/snp-dists.nf @@ -10,10 +10,12 @@ process snp_dists { //#UPHLICA time '24h' input: - file(contigs) + tuple file(contigs), val(num_samples), val(num_core_genes) output: path "snp-dists/snp_matrix.txt" , emit: snp_matrix + path "snp-dists/snp_matrix_with_qc.txt" + path "snp-dists/roary_metrics_mqc.csv" , emit: for_multiqc path "logs/${task.process}/${task.process}.${workflow.sessionId}.log", emit: log_files shell: @@ -31,5 +33,12 @@ process snp_dists { snp-dists !{params.snp_dists_options} \ !{contigs} \ > snp-dists/snp_matrix.txt + + genome_length=$(cat !{contigs} | tr "\n" ";" | sed 's/>[^>]*//2g' | tr ";" "\n" | grep -v ">" | wc -c ) + + sed '0,/,/s/,/num_samples=!{num_samples};num_core_genes=!{num_core_genes};core_genome_length=$genome_length,/' snp-dists/snp_matrix.txt > snp-dists/snp_matrix_with_qc.txt + + echo "num_samples,num_core_genes,core_genome_length" > snp-dists/roary_metrics_mqc.csv + echo "!{num_samples},!{num_core_genes},$genome_length" >> snp-dists/roary_metrics_mqc.csv ''' }