From 94f88adbfdb3a74c40557a2b1e974f143597b1ea Mon Sep 17 00:00:00 2001 From: taranewman <69013600+taranewman@users.noreply.github.com> Date: Wed, 10 Apr 2024 09:09:46 -0700 Subject: [PATCH] Matrix table fix (#7) * fix gubbins error with 2 isolates * clean spaces * use run gubbins boolean * clean white space --- main.nf | 13 ++++++++++--- modules/gubbins.nf | 6 ++++++ modules/snippy_core.nf | 13 ++++++++++++- 3 files changed, 28 insertions(+), 4 deletions(-) diff --git a/main.nf b/main.nf index 43f4ea6..ee30ed6 100644 --- a/main.nf +++ b/main.nf @@ -26,17 +26,24 @@ workflow { ch_mask = Channel.fromPath(params.mask) } + + main: snippy_core(ch_snippy_dirs.collect().combine(ch_ref).map{ it -> [it[0..-2], it[-1]] }.combine(ch_mask)) + if (!params.skip_gubbins) { - gubbins(snippy_core.out.clean_full_alignment) - ch_alignment = gubbins.out.filtered_polymorphic_sites + gubbins(snippy_core.out.clean_full_alignment, snippy_core.out.run_gubbins) + if (snippy_core.out.run_gubbins == "true") { + ch_alignment = gubbins.out.filtered_polymorphic_sites + } else { + ch_alignment = snippy_core.out.clean_full_alignment + } } else { ch_alignment = snippy_core.out.clean_full_alignment } - + snp_sites(ch_alignment) iqtree(snp_sites.out) diff --git a/modules/gubbins.nf b/modules/gubbins.nf index ce4cb30..b1de688 100644 --- a/modules/gubbins.nf +++ b/modules/gubbins.nf @@ -1,15 +1,21 @@ process gubbins { + + errorStrategy 'ignore' publishDir "${params.outdir}", mode: 'copy', pattern: "gubbins.*" input: path(alignment) + val(run_gubbins) output: path('gubbins.filtered_polymorphic_sites.fasta'), emit: filtered_polymorphic_sites path('gubbins.recombination_predictions.gff'), emit: recombination_predictions_gff path('gubbins.per_branch_statistics.tsv'), emit: per_branch_statistics + when: + run_gubbins == "true" + script: """ run_gubbins.py \ diff --git a/modules/snippy_core.nf b/modules/snippy_core.nf index 2e17642..b521c6d 100644 --- a/modules/snippy_core.nf +++ b/modules/snippy_core.nf @@ -12,6 +12,8 @@ process snippy_core { path('core.tsv'), emit: core_stats path('core.full.aln'), emit: full_alignment path('clean.full.aln'), emit: clean_full_alignment + val('run_gubbins'), emit: run_gubbins + script: """ @@ -23,5 +25,14 @@ process snippy_core { snippy-clean_full_aln core.full.aln > clean.full.aln add_percent_used.py core.txt > core.tsv + + num_isolates=\$(echo "\$snippy_dirs" | tr -s ' ' | wc -w) + if [ "\$num_isolates" -ge 3 ]; then + run_gubbins='true' + else + run_gubbins='false' + fi + """ -} \ No newline at end of file +} +