Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Increase submodule usability #10

Merged
merged 4 commits into from
Feb 6, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -78,25 +78,25 @@ workflow {

// alignment
if (params.algorithm == "aln" && !params.inception) {
BWA_ALN(trimmed_fastqs.map {name, fq1, fq2 -> tuple(name, fq1)})
BWA_ALN_2(trimmed_fastqs.map {name, fq1, fq2 -> tuple(name, fq2)})
BWA_SAMPE(BWA_ALN.out.alignment_output.join(BWA_ALN_2.out.alignment_output))
BWA_ALN(trimmed_fastqs.map {name, fq1, fq2 -> tuple(name, fq1)},params.reference)
BWA_ALN_2(trimmed_fastqs.map {name, fq1, fq2 -> tuple(name, fq2)},params.reference)
BWA_SAMPE(BWA_ALN.out.alignment_output.join(BWA_ALN_2.out.alignment_output),params.reference)
output_bams = BWA_SAMPE.out.bams
}
else if (params.algorithm == "aln" && params.inception) {
BWA_ALN_INCEPTION(trimmed_fastqs)
BWA_ALN_INCEPTION(trimmed_fastqs,params.reference)
output_bams = BWA_ALN_INCEPTION.out.bams
}
else if (params.algorithm == "mem") {
BWA_MEM(trimmed_fastqs)
BWA_MEM(trimmed_fastqs,params.reference)
output_bams = BWA_MEM.out.bams
}
else if (params.algorithm == "mem2") {
BWA_MEM_2(trimmed_fastqs)
BWA_MEM_2(trimmed_fastqs,params.reference)
output_bams = BWA_MEM_2.out.bams
}
else if (params.algorithm == "star") {
STAR(trimmed_fastqs)
STAR(trimmed_fastqs,params.reference)
output_bams = STAR.out.bams
}
else {
Expand All @@ -112,20 +112,20 @@ workflow {
trimmed_fastqs = FASTP_SINGLE.out.trimmed_fastqs
}
if (params.algorithm == "aln" && !params.inception) {
BWA_ALN(trimmed_fastqs)
BWA_SAMSE(BWA_ALN.out.alignment_output)
BWA_ALN(trimmed_fastqs,params.reference)
BWA_SAMSE(BWA_ALN.out.alignment_output,params.reference)
output_bams = BWA_SAMSE.out.bams
}
else if (params.algorithm == "mem") {
BWA_MEM_SE(trimmed_fastqs)
BWA_MEM_SE(trimmed_fastqs,params.reference)
output_bams = BWA_MEM_SE.out.bams
}
else if (params.algorithm == "mem2") {
BWA_MEM_2_SE(trimmed_fastqs)
BWA_MEM_2_SE(trimmed_fastqs,params.reference)
output_bams = BWA_MEM_2_SE.out.bams
}
else if (params.algorithm == "star") {
STAR_SE(trimmed_fastqs)
STAR_SE(trimmed_fastqs,params.reference)
output_bams = STAR_SE.out.bams
}
else {
Expand Down
12 changes: 6 additions & 6 deletions modules/01_fastp.nf
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ process FASTP_PAIRED {
file("${fastq2.baseName}.trimmed.fq.gz"), emit: trimmed_fastqs
file("${name}.fastp_stats.json")
file("${name}.fastp_stats.html")
file("software_versions.${task.process}.txt")
file("software_versions.FASTP_PAIRED.txt")

"""
# --input_files needs to be forced, otherwise it is inherited from profile in tests
Expand All @@ -29,8 +29,8 @@ process FASTP_PAIRED {
--html ${name}.fastp_stats.html \
--thread ${params.cpus}

echo ${params.manifest} >> software_versions.${task.process}.txt
fastp --version 2>> software_versions.${task.process}.txt
echo ${params.manifest} >> software_versions.FASTP_PAIRED.txt
fastp --version 2>> software_versions.FASTP_PAIRED.txt
"""
}

Expand All @@ -50,7 +50,7 @@ process FASTP_SINGLE {
tuple val(name), file("${fastq1.baseName}.trimmed.fq.gz"), emit: trimmed_fastqs
file("${name}.fastp_stats.json")
file("${name}.fastp_stats.html")
file("software_versions.${task.process}.txt")
file("software_versions.FASTP_SINGLE.txt")

"""
# --input_files needs to be forced, otherwise it is inherited from profile in tests
Expand All @@ -61,7 +61,7 @@ process FASTP_SINGLE {
--html ${name}.fastp_stats.html \
--thread ${params.cpus}

echo ${params.manifest} >> software_versions.${task.process}.txt
fastp --version 2>> software_versions.${task.process}.txt
echo ${params.manifest} >> software_versions.FASTP_SINGLE.txt
fastp --version 2>> software_versions.FASTP_SINGLE.txt
"""
}
42 changes: 23 additions & 19 deletions modules/02_bwa_aln.nf
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,17 @@ process BWA_ALN {

input:
tuple val(name), file(fastq)
val(reference)

output:
tuple val("${name}"), file("${fastq}"), file("${fastq.baseName}.sai"), emit: alignment_output
file("software_versions.${task.process}.txt")
file("software_versions.BWA_ALN.txt")

"""
bwa aln -t ${task.cpus} ${params.reference} ${fastq} > ${fastq.baseName}.sai
bwa aln -t ${task.cpus} ${reference} ${fastq} > ${fastq.baseName}.sai

echo ${params.manifest} >> software_versions.${task.process}.txt
echo "bwa=0.7.17" >> software_versions.${task.process}.txt
echo ${params.manifest} >> software_versions.BWA_ALN.txt
echo "bwa=0.7.17" >> software_versions.BWA_ALN.txt
"""
}

Expand All @@ -34,17 +35,18 @@ process BWA_SAMPE {
input:
// joins both channels by key using the first element in the tuple, the name
tuple val(name), file(fastq1), file(sai1), file(fastq2), file(sai2)
val(reference)

output:
tuple val("${name}"), file("${name}.bam"), emit: bams
file("software_versions.${task.process}.txt")
file("software_versions.BWA_SAMPE.txt")

"""
bwa sampe ${params.reference} ${sai1} ${sai2} ${fastq1} ${fastq2} | samtools view -uS - | samtools sort - > ${name}.bam
bwa sampe ${reference} ${sai1} ${sai2} ${fastq1} ${fastq2} | samtools view -uS - | samtools sort - > ${name}.bam

echo ${params.manifest} >> software_versions.${task.process}.txt
echo "bwa=0.7.17" >> software_versions.${task.process}.txt
samtools --version >> software_versions.${task.process}.txt
echo ${params.manifest} >> software_versions.BWA_SAMPE.txt
echo "bwa=0.7.17" >> software_versions.BWA_SAMPE.txt
samtools --version >> software_versions.BWA_SAMPE.txt
"""
}

Expand All @@ -60,16 +62,17 @@ process BWA_SAMSE {
input:
// joins both channels by key using the first element in the tuple, the name
tuple val(name), file(fastq), file(sai)
val(reference)

output:
tuple val("${name}"), file("${name}.bam"), emit: bams
file("software_versions.${task.process}.txt")
file("software_versions.BWA_SAMSE.txt")

"""
bwa samse ${params.reference} ${sai} ${fastq} | samtools view -uS - | samtools sort - > ${name}.bam
bwa samse ${reference} ${sai} ${fastq} | samtools view -uS - | samtools sort - > ${name}.bam

echo ${params.manifest} >> software_versions.${task.process}.txt
echo "bwa=0.7.17" >> software_versions.${task.process}.txt
echo ${params.manifest} >> software_versions.BWA_SAMSE.txt
echo "bwa=0.7.17" >> software_versions.BWA_SAMSE.txt
"""
}

Expand All @@ -86,18 +89,19 @@ process BWA_ALN_INCEPTION {
input:
// joins both channels by key using the first element in the tuple, the name
tuple val(name), file(fastq1), file(fastq2)
val(reference)

output:
tuple val("${name}"), file("${name}.bam"), emit: bams
file("software_versions.${task.process}.txt")
file("software_versions.BWA_ALN_INCEPTION.txt")

"""
bwa sampe ${params.reference} <( bwa aln -t ${params.cpus} ${params.reference} ${fastq1} ) \
<( bwa aln -t ${params.cpus} ${params.reference} ${fastq2} ) ${fastq1} ${fastq2} \
bwa sampe ${reference} <( bwa aln -t ${params.cpus} ${reference} ${fastq1} ) \
<( bwa aln -t ${params.cpus} ${reference} ${fastq2} ) ${fastq1} ${fastq2} \
| samtools view -uS - | samtools sort - > ${name}.bam

echo ${params.manifest} >> software_versions.${task.process}.txt
echo "bwa=0.7.17" >> software_versions.${task.process}.txt
samtools --version >> software_versions.${task.process}.txt
echo ${params.manifest} >> software_versions.BWA_ALN_INCEPTION.txt
echo "bwa=0.7.17" >> software_versions.BWA_ALN_INCEPTION.txt
samtools --version >> software_versions.BWA_ALN_INCEPTION.txt
"""
}
22 changes: 12 additions & 10 deletions modules/02_bwa_mem.nf
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,18 @@ process BWA_MEM {

input:
tuple val(name), file(fastq1), file(fastq2)
val(reference)

output:
tuple val("${name}"), file("${name}.bam"), emit: bams
file("software_versions.${task.process}.txt")
file("software_versions.BWA_MEM.txt")

"""
bwa mem ${params.additional_args} -t ${task.cpus} ${params.reference} ${fastq1} ${fastq2} | samtools view -uS - | samtools sort - > ${name}.bam
bwa mem ${params.additional_args} -t ${task.cpus} ${reference} ${fastq1} ${fastq2} | samtools view -uS - | samtools sort - > ${name}.bam

echo ${params.manifest} >> software_versions.${task.process}.txt
echo "bwa=0.7.17" >> software_versions.${task.process}.txt
samtools --version >> software_versions.${task.process}.txt
echo ${params.manifest} >> software_versions.BWA_MEM.txt
echo "bwa=0.7.17" >> software_versions.BWA_MEM.txt
samtools --version >> software_versions.BWA_MEM.txt
"""
}

Expand All @@ -36,16 +37,17 @@ process BWA_MEM_SE {
input:
// joins both channels by key using the first element in the tuple, the name
tuple val(name), file(fastq)
val(reference)

output:
tuple val("${name}"), file("${name}.bam"), emit: bams
file("software_versions.${task.process}.txt")
file("software_versions.BWA_MEM_SE.txt")

"""
bwa mem ${params.additional_args} -t ${task.cpus} ${params.reference} ${fastq} | samtools view -uS - | samtools sort - > ${name}.bam
bwa mem ${params.additional_args} -t ${task.cpus} ${reference} ${fastq} | samtools view -uS - | samtools sort - > ${name}.bam

echo ${params.manifest} >> software_versions.${task.process}.txt
echo "bwa=0.7.17" >> software_versions.${task.process}.txt
samtools --version >> software_versions.${task.process}.txt
echo ${params.manifest} >> software_versions.BWA_MEM_SE.txt
echo "bwa=0.7.17" >> software_versions.BWA_MEM_SE.txt
samtools --version >> software_versions.BWA_MEM_SE.txt
"""
}
22 changes: 12 additions & 10 deletions modules/02_bwa_mem_2.nf
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,18 @@ process BWA_MEM_2 {

input:
tuple val(name), file(fastq1), file(fastq2)
val(reference)

output:
tuple val("${name}"), file("${name}.bam"), emit: bams
file("software_versions.${task.process}.txt")
file("software_versions.BWA_MEM_2.txt")

"""
bwa-mem2 mem ${params.additional_args} -t ${task.cpus} ${params.reference} ${fastq1} ${fastq2} | samtools view -uS - | samtools sort - > ${name}.bam
bwa-mem2 mem ${params.additional_args} -t ${task.cpus} ${reference} ${fastq1} ${fastq2} | samtools view -uS - | samtools sort - > ${name}.bam

echo ${params.manifest} >> software_versions.${task.process}.txt
bwa-mem2 version >> software_versions.${task.process}.txt
samtools --version >> software_versions.${task.process}.txt
echo ${params.manifest} >> software_versions.BWA_MEM_2.txt
bwa-mem2 version >> software_versions.BWA_MEM_2.txt
samtools --version >> software_versions.BWA_MEM_2.txt
"""
}

Expand All @@ -36,16 +37,17 @@ process BWA_MEM_2_SE {
input:
// joins both channels by key using the first element in the tuple, the name
tuple val(name), file(fastq)
val(reference)

output:
tuple val("${name}"), file("${name}.bam"), emit: bams
file("software_versions.${task.process}.txt")
file("software_versions.BWA_MEM_2_SE.txt")

"""
bwa-mem2 mem ${params.additional_args} -t ${task.cpus} ${params.reference} ${fastq} | samtools view -uS - | samtools sort - > ${name}.bam
bwa-mem2 mem ${params.additional_args} -t ${task.cpus} ${reference} ${fastq} | samtools view -uS - | samtools sort - > ${name}.bam

echo ${params.manifest} >> software_versions.${task.process}.txt
bwa-mem2 version >> software_versions.${task.process}.txt
samtools --version >> software_versions.${task.process}.txt
echo ${params.manifest} >> software_versions.BWA_MEM_2_SE.txt
bwa-mem2 version >> software_versions.BWA_MEM_2_SE.txt
samtools --version >> software_versions.BWA_MEM_2_SE.txt
"""
}
17 changes: 9 additions & 8 deletions modules/02_star.nf
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ process STAR {

output:
tuple val("${name}"), file("${name}.bam"), emit: bams
file("software_versions.${task.process}.txt")
file("software_versions.STAR.txt")

script:
two_pass_mode_param = params.star_two_pass_mode ? "--twopassMode Basic" : ""
"""
STAR --genomeDir ${params.reference} ${two_pass_mode_param} ${params.additional_args} \
STAR --genomeDir ${reference} ${two_pass_mode_param} ${params.additional_args} \
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you are missing the definition of input parameter val(reference)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added missing input parameter in latest commit

--readFilesCommand "gzip -d -c -f" \
--readFilesIn ${fastq1} ${fastq2} \
--outSAMmode Full \
Expand All @@ -32,8 +32,8 @@ process STAR {

mv ${name}.Aligned.sortedByCoord.out.bam ${name}.bam

echo ${params.manifest} >> software_versions.${task.process}.txt
STAR --version >> software_versions.${task.process}.txt
echo ${params.manifest} >> software_versions.STAR.txt
STAR --version >> software_versions.STAR.txt
"""
}

Expand All @@ -48,15 +48,16 @@ process STAR_SE {

input:
tuple val(name), file(fastq)
val(reference)

output:
tuple val("${name}"), file("${name}.bam"), emit: bams
file("software_versions.${task.process}.txt")
file("software_versions.STAR_SE.txt")

script:
two_pass_mode_param = params.star_two_pass_mode ? "--twopassMode Basic" : ""
"""
STAR --genomeDir ${params.reference} ${two_pass_mode_param} ${params.additional_args} \
STAR --genomeDir ${reference} ${two_pass_mode_param} ${params.additional_args} \
--readFilesCommand "gzip -d -c -f" \
--readFilesIn ${fastq} \
--outSAMmode Full \
Expand All @@ -70,7 +71,7 @@ process STAR_SE {

mv ${name}.Aligned.sortedByCoord.out.bam ${name}.bam

echo ${params.manifest} >> software_versions.${task.process}.txt
STAR --version >> software_versions.${task.process}.txt
echo ${params.manifest} >> software_versions.STAR_SE.txt
STAR --version >> software_versions.STAR_SE.txt
"""
}
6 changes: 3 additions & 3 deletions modules/03_index.nf
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ process INDEX_BAM {

output:
file("${name}.bam.bai")
file("software_versions.${task.process}.txt")
file("software_versions.INDEX_BAM.txt")

"""
samtools index -@ ${task.cpus} ${bam}

echo ${params.manifest} >> software_versions.${task.process}.txt
samtools --version >> software_versions.${task.process}.txt
echo ${params.manifest} >> software_versions.INDEX_BAM.txt
samtools --version >> software_versions.INDEX_BAM.txt
"""
}
Loading