diff --git a/flowcraft/generator/components/metagenomics.py b/flowcraft/generator/components/metagenomics.py index 3fcaf3d7..b773bf5e 100644 --- a/flowcraft/generator/components/metagenomics.py +++ b/flowcraft/generator/components/metagenomics.py @@ -139,6 +139,12 @@ def __init__(self, **kwargs): "'default', megahit will use the default k-mer lengths. " "(default: $params.megahitKmers)" }, + "fastg": { + "default": "false", + "description": + "Converts megahit intermediate contigs to fastg" + + }, "clearInput": { "default": "false", "description": @@ -155,7 +161,17 @@ def __init__(self, **kwargs): "container": "flowcraft/megahit", "version": "1.1.3-0.1", "scratch": "true" - }} + }, + "megahit_fastg": { + "container": "flowcraft/megahit", + "version": "1.1.3-0.1", + } + } + + self.status_channels = [ + "megahit", + "megahit_fastg" + ] class Metaspades(Process): diff --git a/flowcraft/generator/templates/megahit.nf b/flowcraft/generator/templates/megahit.nf index 8a5d7a7d..4938297e 100644 --- a/flowcraft/generator/templates/megahit.nf +++ b/flowcraft/generator/templates/megahit.nf @@ -23,6 +23,7 @@ process megahit_{{ pid }} { output: set sample_id, file('*megahit*.fasta') into {{ output_channel }} + set sample_id, file('megahit/intermediate_contigs/k*.contigs.fa') into IN_fastg{{ pid }} {% with task_name="megahit" %} {%- include "compiler_channels.txt" ignore missing -%} {% endwith %} @@ -31,8 +32,38 @@ process megahit_{{ pid }} { template "megahit.py" } +IN_fastg = Channel.create() -{{ forks }} +fastg = params.fastg{{ param_id }} ? "true" : "false" +if (fastg) { + process megahit_fastg_{{ pid }}{ + // Send POST request to platform + {% include "post.txt" ignore missing %} + tag { sample_id } + publishDir "results/assembly/megahit_{{ pid }}/$sample_id", pattern: "*.fastg" + input: + set sample_id, file(kmer_files) from IN_fastg{{ pid }} + + output: + file "*.fastg" + {% with task_name="megahit_fastg" %} + {%- include "compiler_channels.txt" ignore missing -%} + {% endwith %} + + script: + """ + for kmer_file in ${kmer_files}; + do + echo \$kmer_file + k=\$(echo \$kmer_file | cut -d '.' -f 1); + echo \$k + megahit_toolkit contig2fastg \$k \$kmer_file > \$kmer_file'.fastg'; + done + """ + } +} + +{{ forks }} \ No newline at end of file diff --git a/flowcraft/generator/templates/spades.nf b/flowcraft/generator/templates/spades.nf index 64b6e4c8..4c61f3c6 100644 --- a/flowcraft/generator/templates/spades.nf +++ b/flowcraft/generator/templates/spades.nf @@ -24,6 +24,8 @@ process spades_{{ pid }} { tag { sample_id } publishDir 'results/assembly/spades_{{ pid }}/', pattern: '*_spades*.fasta', mode: 'copy' + publishDir "reports/assembly/spades_{{ pid }}/$sample_id", pattern: "*.gfa", mode: "copy" + publishDir "reports/assembly/spades_{{ pid }}/$sample_id", pattern: "*.fastg", mode: "copy" input: set sample_id, file(fastq_pair), max_len from {{ input_channel }}.join(SIDE_max_len_{{ pid }}) @@ -33,6 +35,8 @@ process spades_{{ pid }} { output: set sample_id, file('*_spades*.fasta') into {{ output_channel }} + file "*.fastg" + file "*.gfa" {% with task_name="spades" %} {%- include "compiler_channels.txt" ignore missing -%} {% endwith %}