From 77740299b7bbec450f690ec8fe1ec2ee6fed0695 Mon Sep 17 00:00:00 2001 From: itrujnara Date: Tue, 24 Dec 2024 13:00:48 +0100 Subject: [PATCH] Update output paths in modules config --- conf/modules.config | 111 ++++++++++++++++++++++++++--------- modules/local/make_report.nf | 15 +++-- 2 files changed, 90 insertions(+), 36 deletions(-) diff --git a/conf/modules.config b/conf/modules.config index dc58598..5018cd8 100644 --- a/conf/modules.config +++ b/conf/modules.config @@ -24,7 +24,7 @@ process { withName: 'IDENTIFY_SEQ_ONLINE|WRITE_SEQINFO' { publishDir = [ - path: { "${params.outdir}/seqinfo" }, + path: { "${params.outdir}/seqinfo/${meta.id}" }, mode: params.publish_dir_mode, saveAs: { filename -> filename.equals('versions.yml') ? null : filename }, enabled: params.output_intermediates @@ -35,7 +35,7 @@ process { withName: 'FETCH_OMA_GROUP_LOCAL|FETCH_OMA_GROUP_ONLINE' { publishDir = [ - path: { "${params.outdir}/orthologs/oma" }, + path: { "${params.outdir}/orthologs/${meta.id}/oma" }, mode: params.publish_dir_mode, saveAs: { filename -> filename.equals('versions.yml') ? null : filename }, enabled: params.output_intermediates @@ -46,7 +46,7 @@ process { withName: 'FETCH_PANTHER_GROUP_LOCAL|FETCH_PANTHER_GROUP_ONLINE' { publishDir = [ - path: { "${params.outdir}/orthologs/panther" }, + path: { "${params.outdir}/orthologs/${meta.id}/panther" }, mode: params.publish_dir_mode, saveAs: { filename -> filename.equals('versions.yml') ? null : filename }, enabled: params.output_intermediates @@ -57,7 +57,7 @@ process { withName: 'FETCH_INSPECTOR_GROUP_ONLINE' { publishDir = [ - path: { "${params.outdir}/orthologs/orthoinspector" }, + path: { "${params.outdir}/orthologs/${meta.id}/orthoinspector" }, mode: params.publish_dir_mode, saveAs: { filename -> filename.equals('versions.yml') ? null : filename }, enabled: params.output_intermediates @@ -68,7 +68,7 @@ process { withName: 'FETCH_EGGNOG_GROUP_LOCAL|FETCH_EGGNOG_GROUP_ONLINE' { publishDir = [ - path: { "${params.outdir}/orthologs/eggnog" }, + path: { "${params.outdir}/orthologs/${meta.id}/eggnog" }, mode: params.publish_dir_mode, saveAs: { filename -> filename.equals('versions.yml') ? null : filename }, enabled: params.output_intermediates @@ -83,7 +83,7 @@ process { withName: 'SPLIT_ID_FORMAT' { publishDir = [ - path: { "${params.outdir}/sequences" }, + path: { "${params.outdir}/sequences/${meta.id}/" }, mode: params.publish_dir_mode, saveAs: { filename -> filename.equals('versions.yml') ? null : filename }, enabled: params.output_intermediates @@ -92,7 +92,7 @@ process { withName: 'FETCH_UNIPROT_SEQUENCES' { publishDir = [ - path: { "${params.outdir}/sequences" }, + path: { "${params.outdir}/sequences/${meta.id}/uniprot" }, mode: params.publish_dir_mode, saveAs: { filename -> filename.equals('versions.yml') ? null : filename }, enabled: params.output_intermediates @@ -110,7 +110,7 @@ process { withName: 'FETCH_ENSEMBL_SEQUENCES' { publishDir = [ - path: { "${params.outdir}/sequences" }, + path: { "${params.outdir}/sequences/${meta.id}/ensembl" }, mode: params.publish_dir_mode, saveAs: { filename -> filename.equals('versions.yml') ? null : filename }, enabled: params.output_intermediates @@ -119,7 +119,7 @@ process { withName: 'FETCH_REFSEQ_SEQUENCES' { publishDir = [ - path: { "${params.outdir}/sequences" }, + path: { "${params.outdir}/sequences/${meta.id}/refseq" }, mode: params.publish_dir_mode, saveAs: { filename -> filename.equals('versions.yml') ? null : filename }, enabled: params.output_intermediates @@ -128,7 +128,7 @@ process { withName: 'FETCH_OMA_SEQUENCES' { publishDir = [ - path: { "${params.outdir}/sequences" }, + path: { "${params.outdir}/sequences/${meta.id}/oma" }, mode: params.publish_dir_mode, saveAs: { filename -> filename.equals('versions.yml') ? null : filename }, enabled: params.output_intermediates @@ -136,8 +136,9 @@ process { } withName: 'CONCAT_FASTA' { + ext.prefix = { "${meta.id}_orthologs.txt" } publishDir = [ - path: { "${params.outdir}/sequences" }, + path: { "${params.outdir}/sequences/${meta.id}" }, mode: params.publish_dir_mode, saveAs: { filename -> filename.equals('versions.yml') ? null : filename } ] @@ -146,7 +147,7 @@ process { withName: 'CONCAT_HITS' { ext.prefix = {"${meta.id}_hits.txt"} publishDir = [ - path: { "${params.outdir}/sequences" }, + path: { "${params.outdir}/sequences/${meta.id}" }, mode: params.publish_dir_mode, saveAs: { filename -> filename.equals('versions.yml') ? null : filename }, enabled: params.output_intermediates @@ -156,7 +157,7 @@ process { withName: 'CONCAT_MISSES' { ext.prefix = {"${meta.id}_misses.txt"} publishDir = [ - path: { "${params.outdir}/sequences" }, + path: { "${params.outdir}/sequences/${meta.id}" }, mode: params.publish_dir_mode, saveAs: { filename -> filename.equals('versions.yml') ? null : filename }, enabled: params.output_intermediates @@ -168,7 +169,7 @@ process { ext.prefix = {"${meta.id}_ids"} ext.suffix = "txt" publishDir = [ - path: { "${params.outdir}/merge" }, + path: { "${params.outdir}/merge/${meta.id}" }, mode: params.publish_dir_mode, saveAs: { filename -> filename.equals('versions.yml') ? null : filename }, enabled: params.output_intermediates @@ -179,11 +180,40 @@ process { // ID merging // ---------------------- + withName: 'SPLIT_TAXIDS' { + publishDir = [ + path: { "${params.outdir}/merge/${meta.id}/taxids" }, + mode: params.publish_dir_mode, + saveAs: { filename -> filename.equals('versions.yml') ? null : filename }, + enabled: params.output_intermediates + ] + } + + withName: 'MERGE_FASTA_IDS' { + ext.prefix = { "${meta.id}_ids_raw" } + publishDir = [ + path: { "${params.outdir}/merge/${meta.id}/" }, + mode: params.publish_dir_mode, + saveAs: { filename -> filename.equals('versions.yml') ? null : filename }, + enabled: params.output_intermediates + ] + } + withName: 'DIAMOND_CLUSTER' { ext.args = "--approx-id 90" - ext.prefix = { "${meta.id}_${db.toString().tokenize(".")[0].tokenize("_")[-1]}" } + ext.prefix = { "${meta.id}_${db.toString().tokenize(".")[0].tokenize("_")[-1]}_clusters" } publishDir = [ - path: { "${params.outdir}/merge" }, + path: { "${params.outdir}/merge/${meta.id}/clusters" }, + mode: params.publish_dir_mode, + saveAs: { filename -> filename.equals('versions.yml') ? null : filename }, + enabled: params.output_intermediates + ] + } + + withName: 'MERGE_DIAMOND' { + ext.prefix = { "${meta.id}_pairs_raw.txt" } + publishDir = [ + path: { "${params.outdir}/merge/${meta.id}" }, mode: params.publish_dir_mode, saveAs: { filename -> filename.equals('versions.yml') ? null : filename }, enabled: params.output_intermediates @@ -201,10 +231,10 @@ process { print col1[1]; } }\'""" - ext.prefix = { "${meta.id}_ids_diamond" } + ext.prefix = { "${meta.id}_pairs_clean" } ext.suffix = "txt" publishDir = [ - path: { "${params.outdir}/merge" }, + path: { "${params.outdir}/merge/${meta.id}" }, mode: params.publish_dir_mode, saveAs: { filename -> filename.equals('versions.yml') ? null : filename }, enabled: params.output_intermediates @@ -216,7 +246,17 @@ process { ext.prefix = { "${meta.id}_clusters" } ext.suffix = "txt" publishDir = [ - path: { "${params.outdir}/merge" }, + path: { "${params.outdir}/merge/${meta.id}" }, + mode: params.publish_dir_mode, + saveAs: { filename -> filename.equals('versions.yml') ? null : filename }, + enabled: params.output_intermediates + ] + } + + withName: 'MERGE_ALL' { + ext.prefix = { "${meta.id}_idmap_raw.tsv" } + publishDir = [ + path: { "${params.outdir}/merge/${meta.id}" }, mode: params.publish_dir_mode, saveAs: { filename -> filename.equals('versions.yml') ? null : filename }, enabled: params.output_intermediates @@ -226,13 +266,19 @@ process { withName: 'REDUCE_IDMAP' { ext.args = "-F\'\t\'" ext.args2 = "\'NF >= 2\'" - ext.prefix = { "${meta.id}_idmap" } + ext.prefix = { "${meta.id}_idmap.tsv" } + publishDir = [ + path: { "${params.outdir}/merge/${meta.id}" }, + mode: params.publish_dir_mode, + saveAs: { filename -> filename.equals('versions.yml') ? null : filename }, + enabled: params.output_intermediates + ] } withName: 'MERGE_CSV' { ext.args = '-f 1 --outer-join --na 0' publishDir = [ - path: { "${params.outdir}/orthologs/merge_csv" }, + path: { "${params.outdir}/score/${meta.id}" }, mode: params.publish_dir_mode, saveAs: { filename -> filename.equals('versions.yml') ? null : filename }, enabled: params.output_intermediates @@ -245,7 +291,7 @@ process { withName: 'MAKE_SCORE_TABLE' { publishDir = [ - path: { "${params.outdir}/orthologs/score_table" }, + path: { "${params.outdir}/score/${meta.id}" }, mode: params.publish_dir_mode, saveAs: { filename -> filename.equals('versions.yml') ? null : filename } ] @@ -253,7 +299,7 @@ process { withName: 'FILTER_HITS' { publishDir = [ - path: { "${params.outdir}/orthologs/filter_hits" }, + path: { "${params.outdir}/score/${meta.id}" }, mode: params.publish_dir_mode, saveAs: { filename -> filename.equals('versions.yml') ? null : filename }, enabled: params.output_intermediates @@ -262,7 +308,7 @@ process { withName: 'PLOT_ORTHOLOGS' { publishDir = [ - path: { "${params.outdir}/orthologs/plots" }, + path: { "${params.outdir}/score/${meta.id}/plots" }, mode: params.publish_dir_mode, saveAs: { filename -> filename.equals('versions.yml') ? null : filename } ] @@ -270,7 +316,7 @@ process { withName: 'MAKE_HITS_TABLE' { publishDir = [ - path: { "${params.outdir}/orthologs/stats" }, + path: { "${params.outdir}/score/${meta.id}" }, mode: params.publish_dir_mode, saveAs: { filename -> filename.equals('versions.yml') ? null : filename }, enabled: params.output_intermediates @@ -281,7 +327,7 @@ process { ext.args = "-u 0 -k" ext.prefix = "aggregated_hits" publishDir = [ - path: { "${params.outdir}/orthologs/stats" }, + path: { "${params.outdir}/score" }, mode: params.publish_dir_mode, saveAs: { filename -> filename.equals('versions.yml') ? null : filename } ] @@ -289,7 +335,16 @@ process { withName: 'MAKE_STATS' { publishDir = [ - path: { "${params.outdir}/orthologs/stats" }, + path: { "${params.outdir}/score/${meta.id}" }, + mode: params.publish_dir_mode, + saveAs: { filename -> filename.equals('versions.yml') ? null : filename }, + enabled: params.output_intermediates + ] + } + + withName: 'STATS2CSV' { + publishDir = [ + path: { "${params.outdir}/score/${meta.id}" }, mode: params.publish_dir_mode, saveAs: { filename -> filename.equals('versions.yml') ? null : filename }, enabled: params.output_intermediates @@ -300,7 +355,7 @@ process { ext.args = "-u NA" ext.prefix = "aggregated_stats" publishDir = [ - path: { "${params.outdir}/orthologs/stats" }, + path: { "${params.outdir}/score" }, mode: params.publish_dir_mode, saveAs: { filename -> filename.equals('versions.yml') ? null : filename } ] diff --git a/modules/local/make_report.nf b/modules/local/make_report.nf index cfb7b95..38f0978 100644 --- a/modules/local/make_report.nf +++ b/modules/local/make_report.nf @@ -8,8 +8,8 @@ process MAKE_REPORT { tuple val(meta), path(id), path(taxid), path(exact), path(score_table), path(filtered_hits), path(support_plot), path(venn_plot), path(jaccard_plot), path(orthostats), path(seq_hits), path(seq_misses), path(params_file) output: - tuple val(meta), path("*dist/*"), emit: report_files - path "versions.yml" , emit: versions + tuple val(meta), path("${prefix}/*"), emit: report_files + path "versions.yml" , emit: versions when: task.ext.when == null || task.ext.when @@ -20,7 +20,7 @@ process MAKE_REPORT { error("Local MAKE_REPORT module does not support Conda. Please use Docker / Singularity / Podman instead.") } - def prefix = task.ext.prefix ?: meta.id + prefix = task.ext.prefix ?: meta.id seqhits_cmd = seq_hits ? "cp $seq_hits public/seq_hits.txt" : '' seqmisses_cmd = seq_misses ? "cp $seq_misses public/seq_misses.txt" : '' """ @@ -50,8 +50,8 @@ process MAKE_REPORT { echo "python3 -m http.server 0" > dist/run.sh chmod u+x dist/run.sh - # add prefix to directory name - mv dist ${prefix}_dist + # change output directory name + mv dist ${prefix} cat <<- END_VERSIONS > versions.yml "${task.process}": @@ -62,10 +62,9 @@ process MAKE_REPORT { """ stub: - def prefix = task.ext.prefix ?: "${meta.id}" """ - mkdir ${prefix}_dist - touch ${prefix}_dist/${prefix}_run.sh + mkdir ${prefix} + touch ${prefix}/run.sh cat <<- END_VERSIONS > versions.yml ${task.process}: