Skip to content

Commit

Permalink
begin metadata madness
Browse files Browse the repository at this point in the history
  • Loading branch information
KateSakharova committed May 29, 2024
1 parent 5f6e1dd commit 5156e43
Show file tree
Hide file tree
Showing 9 changed files with 176 additions and 82 deletions.
116 changes: 38 additions & 78 deletions conf/modules.config
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@ process {

withName: 'SAMPLESHEET_CHECK' {
publishDir = [
path: { "${params.outdir}/pipeline_info" },
mode: params.publish_dir_mode,
saveAs: { filename -> filename.equals('versions.yml') ? null : filename }
[
path: "${params.outdir}/pipeline_info",
mode: params.publish_dir_mode,
saveAs: { filename -> filename.equals('versions.yml') ? null : filename }
]
]
}

Expand All @@ -34,22 +36,28 @@ process {
time = { check_max( 8.h * task.attempt, 'time' ) }
publishDir = [
[
path: "${params.outdir}/qc/fastp",
mode: params.publish_dir_mode,
failOnError: true,
pattern: "*fastp.log"
],
[
path: "${params.outdir}/qc/fastp",
mode: params.publish_dir_mode,
failOnError: true,
pattern: "*fastp.html"
],
[
path: "${params.outdir}/qc/fastp",
path: "${params.outdir}",
mode: params.publish_dir_mode,
failOnError: true,
pattern: "*fastp.json"
saveAs: {
filename -> {
if ( filename.equals('versions.yml') ) {
return null;
}
def studyAccessionPrefix = params.study_accession.substring(0, 7);
def readsAccessionPrefix = params.reads_accession.substring(0, 7);
def file_patterns_to_publish = [
'fastp.log',
'fastp.html',
'fastp.json'
]
def output_file = new File(filename);
if ( file_patterns_to_publish.any { output_file.name.contains(it) } ) {
return "${studyAccessionPrefix}/${params.study_accession}/${readsAccessionPrefix}/${params.reads_accession}/qc/fastp/${output_file.name}";
}
return null;
}
}
]
]
}
Expand All @@ -59,9 +67,20 @@ process {
time = { check_max( 8.h * task.attempt, 'time' ) }
publishDir = [
[
path: "${params.outdir}/qc/fastqc",
path: "${params.outdir}",
mode: params.publish_dir_mode,
failOnError: true
failOnError: true,
saveAs: {
filename -> {
if ( filename.equals('versions.yml') ) {
return null;
}
def studyAccessionPrefix = params.study_accession.substring(0, 7);
def readsAccessionPrefix = params.reads_accession.substring(0, 7);
def output_file = new File(filename);
return "${studyAccessionPrefix}/${params.study_accession}/${readsAccessionPrefix}/${params.reads_accession}/qc/fastqc/${output_file.name}";
}
}
]
]
}
Expand Down Expand Up @@ -93,53 +112,12 @@ process {

memory = { "$params.assembly_memory" + ".GB" * task.attempt }
cpus = 32
publishDir = [
[
path: "${params.outdir}/assembly/spades/${params.spades_version}",
mode: params.publish_dir_mode,
failOnError: true,
pattern: "params.txt*"

],
[
path: "${params.outdir}/assembly/spades/${params.spades_version}",
mode: params.publish_dir_mode,
failOnError: true,
pattern: "*graph.fastg*"
],
[
path: "${params.outdir}/assembly/spades/${params.spades_version}",
mode: params.publish_dir_mode,
failOnError: true,
pattern: "*contigs.fa.gz"
],
[
path: "${params.outdir}/assembly/spades/${params.spades_version}",
mode: params.publish_dir_mode,
failOnError: true,
pattern: "*scaffolds.fa.gz"
],
[
path: "${params.outdir}/assembly/spades/${params.spades_version}",
mode: params.publish_dir_mode,
failOnError: true,
pattern: "*graph_with_scaffolds.gfa.gz"
]
]
}

withName: 'MEGAHIT' {
cpus = { check_max( 12 * task.attempt, 'cpus' ) }
memory = { check_max( 72.GB * task.attempt, 'memory' ) }
time = { check_max( 16.h * task.attempt, 'time' ) }
publishDir = [
[
path: "${params.outdir}/assembly/megahit/${params.megahit_version}",
mode: params.publish_dir_mode,
failOnError: true,
pattern: "*.fa*.gz"
],
]
}

withName: 'SEQKIT_SEQ' {
Expand Down Expand Up @@ -201,14 +179,6 @@ process {
cpus = { check_max( 6 * task.attempt, 'cpus' ) }
memory = { check_max( 36.GB * task.attempt, 'memory' ) }
time = { check_max( 8.h * task.attempt, 'time' ) }
publishDir = [
[
path: "${params.outdir}/assembly/coverage",
mode: params.publish_dir_mode,
failOnError: true,
pattern: "*.txt.gz"
],
]
}

withName: 'SAMTOOLS_IDXSTATS' {
Expand All @@ -235,21 +205,11 @@ process {
time = { check_max( 4.h * task.attempt, 'time' ) }

ext.args = { params.multiqc_title ? "--title \"$params.multiqc_title\"" : '' }
publishDir = [
path: { "${params.outdir}/assembly/qc/multiqc" },
mode: params.publish_dir_mode,
saveAs: { filename -> filename.equals('versions.yml') ? null : filename }
]
}

withName: 'QUAST' {
cpus = { check_max( 1 , 'cpus' ) }
memory = { check_max( 6.GB * task.attempt, 'memory' ) }
time = { check_max( 4.h * task.attempt, 'time' ) }

publishDir = [
path: { "${params.outdir}/assembly/qc/quast" },
mode: params.publish_dir_mode
]
}
}
16 changes: 16 additions & 0 deletions modules/local/publish_file.nf
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
process PUBLISH_FILE {

publishDir(
path: "${params.outdir}/$output_dir",
mode: params.publish_dir_mode
)

input:
path(contigs)
val(output_dir)

script:
"""
echo "$output_dir"
"""
}
24 changes: 24 additions & 0 deletions modules/nf-core/megahit/main.nf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions modules/nf-core/metabat2/jgisummarizebamcontigdepths/main.nf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 18 additions & 0 deletions modules/nf-core/multiqc/main.nf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions modules/nf-core/quast/main.nf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 27 additions & 0 deletions modules/nf-core/spades/main.nf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion subworkflows/local/assembly_qc.nf
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ include { BLAST_BLASTN as BLAST_BLASTN_HUMAN_PHIX } from '../../modules/nf-core/
include { BLAST_BLASTN as BLAST_BLASTN_HOST } from '../../modules/nf-core/blast/blastn/main'
include { SEQKIT_GREP } from '../../modules/nf-core/seqkit/grep/main'
include { SEQKIT_SEQ } from '../../modules/nf-core/seqkit/seq/main'
include { PUBLISH_FILE } from '../../modules/local/publish_file'

workflow ASSEMBLY_QC {

Expand Down Expand Up @@ -59,7 +60,9 @@ workflow ASSEMBLY_QC {
contaminated_contigs = BLAST_BLASTN_HUMAN_PHIX.out.txt
}

contaminated_contigs.map { _, hits_txt -> hits_txt }.collectFile(storeDir: "${params.outdir}/assembly/decontamination", newLine: true)
collected_contigs = contaminated_contigs.map { meta, hits_txt -> hits_txt }.collectFile(name: "decontaminated.txt", newLine: true)
output_path = contaminated_contigs.map { meta, _ -> "assembly/$meta.assembler/$meta.assembler_version/decontamination/"}
PUBLISH_FILE(collected_contigs, output_path)

SEQKIT_GREP(
SEQKIT_SEQ.out.fastx,
Expand Down
Loading

0 comments on commit 5156e43

Please sign in to comment.