Skip to content

Commit 7691977

Browse files
committed
Initial commit with base structure in place
1 parent 457d320 commit 7691977

File tree

14 files changed

+761
-59
lines changed

14 files changed

+761
-59
lines changed

assets/blastdb.fasta

+376
Large diffs are not rendered by default.

main.nf

+3-5
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,14 @@ WorkflowMain.initialise(workflow, params, log)
2727
// TODO: Rename this and the file under lib/ to something matching this pipeline (e.g. WorkflowAmplicons)
2828
WorkflowPipeline.initialise(params, log)
2929

30-
// TODO: Rename this to something matching this pipeline, e.g. "AMPLICONS"
31-
include { MAIN } from './workflows/main'
30+
include { GMO } from './workflows/gmo'
3231

3332
multiqc_report = Channel.from([])
3433

3534
workflow {
36-
// TODO: Rename to something matching this pipeline (see above)
37-
MAIN()
35+
GMO()
3836

39-
multiqc_report = multiqc_report.mix(MAIN.out.qc).toList()
37+
multiqc_report = multiqc_report.mix(GMO.out.qc).toList()
4038
}
4139

4240
workflow.onComplete {

modules/blast/blastn/main.nf

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
process BLAST_BLASTN {
2+
3+
publishDir "${params.outdir}/BlastN", mode: 'copy'
4+
5+
label 'short_parallel'
6+
7+
conda 'bioconda::blast=2.15'
8+
container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ?
9+
'https://depot.galaxyproject.org/singularity/blast:2.15.0--pl5321h6f7f691_1' :
10+
'quay.io/biocontainers/blast:2.15.0--pl5321h6f7f691_1' }"
11+
12+
input:
13+
tuple val(meta),path(fasta)
14+
tuple path(db)
15+
16+
output:
17+
tuple val(meta),path(result), emit: blastout
18+
19+
script:
20+
blastout = meta.sample_id + ".blast.txt"
21+
22+
"""
23+
DB=`find -L ./ -name "*.nal" | sed 's/\\.nal\$//'`
24+
if [ -z "\$DB" ]; then
25+
DB=`find -L ./ -name "*.nin" | sed 's/\\.nin\$//'`
26+
fi
27+
echo Using \$DB
28+
29+
blastn -num_threads ${task.cpus} \
30+
-db \$DB \
31+
-outfmt 6 \
32+
-query $fasta \
33+
-out $blastout
34+
35+
cat <<-END_VERSIONS > versions.yml
36+
"${task.process}":
37+
blast: \$(blastn -version 2>&1 | sed 's/^.*blastn: //; s/ .*\$//')
38+
END_VERSIONS
39+
40+
"""
41+
}

modules/blast/makeblastdb/main.nf

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
process BLAST_MAKEBLASTDB {
2+
3+
publishDir "${params.outdir}/BlastDB", mode: 'copy'
4+
5+
label 'short_parallel'
6+
7+
conda 'bioconda::blast=2.15'
8+
container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ?
9+
'https://depot.galaxyproject.org/singularity/blast:2.15.0--pl5321h6f7f691_1' :
10+
'quay.io/biocontainers/blast:2.15.0--pl5321h6f7f691_1' }"
11+
12+
input:
13+
path(fasta)
14+
15+
output:
16+
path('*.n*'), emit: db
17+
18+
script:
19+
def is_compressed = fasta.getExtension() == "gz" ? true : false
20+
def fasta_name = is_compressed ? fasta.getBaseName() : fasta
21+
22+
"""
23+
if [ "${is_compressed}" == "true" ]; then
24+
gzip -c -d ${fasta} > ${fasta_name}
25+
fi
26+
27+
makeblastdb \
28+
-in $fasta \
29+
-dbtype nucl \
30+
-out $fasta_name
31+
32+
cat <<-END_VERSIONS > versions.yml
33+
"${task.process}":
34+
blast: \$(makeblastdb -version 2>&1 | sed 's/^.*makeblastdb: //; s/ .*\$//')
35+
END_VERSIONS
36+
37+
"""
38+
}

modules/bwamem2/mem/main.nf

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
process BWAMEM2_MEM {
2+
3+
tag "${meta.sample_id}"
4+
5+
container 'quay.io/biocontainers/mulled-v2-e5d375990341c5aef3c9aff74f96f66f65375ef6:2cdf6bf1e92acbeb9b2834b1c58754167173a410-0'
6+
7+
label 'medium_parallel'
8+
9+
input:
10+
tuple val(meta), path(left),path(right)
11+
val(bwa_index)
12+
13+
output:
14+
tuple val(meta), path(bam), emit: bam
15+
path("versions.yml"), emit: versions
16+
17+
script:
18+
bam = "${meta.sample_id}_${meta.library_id}_${meta.readgroup_id}_bwa2-aligned.fm.bam"
19+
20+
"""
21+
bwa-mem2 mem -K 1000000 -H ${params.dict} -M -R "@RG\\tID:${meta.readgroup_id}\\tPL:ILLUMINA\\tPU:${meta.platform_unit}\\tSM:${meta.sample_id}\\tLB:${meta.library_id}\\tDS:${bwa_index}\\tCN:${meta.center}" \
22+
-t ${task.cpus} ${bwa_index} $left $right \
23+
| samtools fixmate -@ ${task.cpus} -m - - \
24+
| samtools sort -@ ${task.cpus} -m 2G -O bam -o $bam -
25+
26+
cat <<-END_VERSIONS > versions.yml
27+
"${task.process}":
28+
bwamem2: \$(echo \$(bwa-mem2 version 2>&1) | sed 's/.* //')
29+
samtools: \$(echo \$(samtools --version 2>&1) | sed 's/^.*samtools //; s/Using.*\$//')
30+
END_VERSIONS
31+
"""
32+
}

modules/freebayes/main.nf

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
process FREEBAYES {
2+
3+
publishDir "${params.outdir}/Freebayes", mode: 'copy'
4+
5+
label 'medium_serial'
6+
7+
conda 'bioconda::freebayes=1.3.6'
8+
container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ?
9+
'https://depot.galaxyproject.org/singularity/freebayes:1.3.6--hb0f3ef8_7' :
10+
'quay.io/biocontainers/freebayes:1.3.6--hb0f3ef8_7' }"
11+
12+
13+
}

modules/vsearch/fastqfilter/main.nf

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
process VSEARCH_FASTQFILTER {
2+
3+
publishDir "${params.outdir}/VSEARCH", mode: 'copy'
4+
5+
label 'short_serial'
6+
7+
conda 'bioconda::vsearch=2.27.0'
8+
container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ?
9+
'https://depot.galaxyproject.org/singularity/vsearch:2.27.0--h6a68c12_0 :
10+
'quay.io/biocontainers/vsearch:2.27.0--h6a68c12_0' }"
11+
12+
input:
13+
tuple val(meta),path(fq)
14+
15+
output:
16+
tuple val(meta),path(filtered), emit: fasta
17+
18+
script:
19+
filtered = fq.getBaseName() + ".filtered.fasta"
20+
21+
"""
22+
vsearch -fastq_filter $fq -fastq_maxee 1.0 -relabel Filtered -fastaout $fasta
23+
24+
cat <<-END_VERSIONS > versions.yml
25+
"${task.process}":
26+
vsearch: \$(vsearch --version 2>&1 | sed -e "s/vsearch //g" -e "s/,.*//")
27+
END_VERSIONS
28+
"""
29+
}

modules/vsearch/fastqmerge/main.nf

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
process VSEARCH_FASTQMERGE {
2+
3+
publishDir "${params.outdir}/VSEARCH", mode: 'copy'
4+
5+
label 'short_serial'
6+
7+
conda 'bioconda::vsearch=2.27.0'
8+
container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ?
9+
'https://depot.galaxyproject.org/singularity/vsearch:2.27.0--h6a68c12_0 :
10+
'quay.io/biocontainers/vsearch:2.27.0--h6a68c12_0' }"
11+
12+
input:
13+
tuple val(meta),path(fwd),path(rev)
14+
15+
output:
16+
tuple val(meta),path(merged), emit: fastq
17+
18+
script:
19+
merged = meta.sample_id + ".merged.fastq"
20+
21+
"""
22+
vsearch --fastq_merge $fwd --reverse $rev --fastqout $merged
23+
24+
cat <<-END_VERSIONS > versions.yml
25+
"${task.process}":
26+
vsearch: \$(vsearch --version 2>&1 | sed -e "s/vsearch //g" -e "s/,.*//")
27+
END_VERSIONS
28+
"""
29+
}

modules/vsearch/fastxuniques/main.nf

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
process VSEARCH_FASTXUNIQUES {
2+
3+
publishDir "${params.outdir}/VSEARCH", mode: 'copy'
4+
5+
label 'short_serial'
6+
7+
conda 'bioconda::vsearch=2.27.0'
8+
container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ?
9+
'https://depot.galaxyproject.org/singularity/vsearch:2.27.0--h6a68c12_0 :
10+
'quay.io/biocontainers/vsearch:2.27.0--h6a68c12_0' }"
11+
12+
input:
13+
tuple val(meta),path(fa)
14+
15+
output:
16+
tuple val(meta),path(derep), emit: fasta
17+
18+
script:
19+
derep = fa.getBaseName() + ".unique.fasta"
20+
21+
"""
22+
vsearch -fastq_uniques $fa -sizeout -relabel Unique -fastaout $derep
23+
24+
cat <<-END_VERSIONS > versions.yml
25+
"${task.process}":
26+
vsearch: \$(vsearch --version 2>&1 | sed -e "s/vsearch //g" -e "s/,.*//")
27+
END_VERSIONS
28+
"""
29+
}

nextflow.config

+7-9
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ params {
44
input = null
55
outdir = "results"
66

7+
tools = "vsearch"
8+
79
help = false
810

911
logo = "${baseDir}/assets/pipelinelogo.png"
@@ -24,13 +26,12 @@ params {
2426

2527
}
2628

27-
// TODO: update name and version of pipeline, author name and URL
2829
manifest {
29-
name = "marchoeppner/pipeline"
30-
version = "0.0"
31-
description = "Pipeline"
32-
author = "Author Name"
33-
homePage = "https://github.com/marchoeppner/pipeline"
30+
name = "marchoeppner/gmo-check"
31+
version = "0.1"
32+
description = "Pipeline to check for genetically modified food stuff"
33+
author = "Marc Hoeppner"
34+
homePage = "https://github.com/marchoeppner/gmo-check"
3435
nextflowVersion = "23.10.0"
3536
}
3637

@@ -57,9 +58,6 @@ dag {
5758
file = "${params.outdir}/pipeline_info/pipeline_dag.svg"
5859
}
5960

60-
// TODO: Update name of container, if any - else remove
61-
process.container = 'user/xxx:dev'
62-
6361
profiles {
6462

6563
standard {

subworkflows/bwamem2/main.nf

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
include { BWAMEM2_MEM } from "./../modules/bwamem2/mem/main"
2+
include { SAMTOOLS_MERGE } from "./../modules/samtools/merge/main"
3+
include { SAMTOOLS_MARKDUP } from "./../modules/samtools/markdup/main"
4+
include { SAMTOOLS_INDEX } from "./../modules/samtools/index/main"
5+
6+
ch_versions = Channel.from([])
7+
8+
workflow BWAMEM2_WORKFLOW {
9+
10+
take:
11+
reads
12+
reference
13+
14+
main:
15+
16+
BWAMEM2_MEM(
17+
reads,
18+
reference
19+
)
20+
21+
ch_versions = ch_versions.mix(BWAMEM2_MEM.out.versions)
22+
23+
bam_mapped = BWAMEM2_MEM.out.bam.map { meta, bam ->
24+
new_meta = [:]
25+
new_meta.sample_id = meta.sample_id
26+
def groupKey = meta.sample_id
27+
tuple( groupKey, new_meta, bam)
28+
}.groupTuple(by: [0,1]).map { g ,new_meta ,bam -> [ new_meta, bam ] }
29+
30+
bam_mapped.branch {
31+
single: it[1].size() == 1
32+
multiple: it[1].size() > 1
33+
}.set { bam_to_merge }
34+
35+
SAMTOOLS_MERGE( bam_to_merge.multiple )
36+
37+
ch_versions = ch_versions.mix(SAMTOOLS_MERGE.out.versions)
38+
39+
SAMTOOLS_INDEX(SAMTOOLS_MERGE.out.bam.mix( bam_to_merge.single ))
40+
41+
ch_versions = ch_versions.mix(SAMTOOLS_INDEX.out.versions)
42+
43+
SAMTOOLS_MARKDUP(
44+
SAMTOOLS_INDEX.out.bam
45+
)
46+
ch_versions = ch_versions.mix(SAMTOOLS_MARKDUP.out.versions)
47+
48+
FREEBAYES(
49+
SAMTOOLS_MARKDUP.out.bam,
50+
reference
51+
)
52+
ch_versions = ch_versions.mix(FREEBAYES.out.versions)
53+
54+
emit:
55+
versions = ch_versions
56+
vcf = FREEBAYES.out.vcf
57+
58+
}

subworkflows/vsearch/main.nf

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
include { VSEARCH_FASTQMERGE } from "./../modules/vsearch/fastqmerge"
2+
include { VSEARCH_FASTXUNIQUES } from "./../modules/vsearch/fastxuniques"
3+
include { VSEARCH_FASTQFILTER } from "./../modules/vsearch/fastqfilter"
4+
include { BLAST_BLASTN } from "./../modules/blast/blastn"
5+
6+
ch_versions = Channel.from([])
7+
8+
workflow VSEARCH_WORKFLOW {
9+
10+
take:
11+
reads
12+
db
13+
14+
main:
15+
16+
VSEARCH_FASTQMERGE(
17+
reads
18+
)
19+
ch_versions = ch_versions.mix(VSEARCH_FASTQMERGE.out.versions)
20+
21+
VSEARCH_FASTQFILTER(
22+
VSEARCH_FASTQMERGE.out.fastq
23+
)
24+
ch_versions = ch_versions.mix(VSEARCH_FASTQFILTER.out.versions)
25+
26+
VSEARCH_FASTXUNIQUES(
27+
VSEARCH_FASTQFILTER.out.fasta
28+
)
29+
ch_versions = ch_versions.mix(VSEARCH_FASTXUNIQUES.out.versions)
30+
31+
BLAST_BLASTN(
32+
VSEARCH_FASTXUNIQUES.out.fasta,
33+
db
34+
)
35+
36+
emit:
37+
versions = ch_versions
38+
results = BLAST_BLASTN.out.blastout
39+
40+
}

0 commit comments

Comments
 (0)