Skip to content

Commit

Permalink
Merge pull request #11 from TRON-Bioinformatics/develop
Browse files Browse the repository at this point in the history
Merge Gianna's work into master + change CI environment requirements and conda/mamba setup
  • Loading branch information
Pablo Riesgo-Ferreiro authored May 23, 2024
2 parents 24e23fb + a9e8dd6 commit b47efca
Show file tree
Hide file tree
Showing 22 changed files with 98 additions and 85 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/automated_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
with:
distribution: 'zulu' # See 'Supported distributions' for available options
java-version: '11'
- uses: conda-incubator/setup-miniconda@v2
- uses: mamba-org/setup-micromamba@v1
- name: Install dependencies
run: |
apt-get update && apt-get --assume-yes install wget make procps software-properties-common
Expand Down
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
"""
}
18 changes: 10 additions & 8 deletions modules/02_star.nf
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,16 @@ process STAR {

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.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} \
--readFilesCommand "gzip -d -c -f" \
--readFilesIn ${fastq1} ${fastq2} \
--outSAMmode Full \
Expand All @@ -32,8 +33,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 +49,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 +72,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
"""
}
9 changes: 6 additions & 3 deletions nextflow.config
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,21 @@ params.additional_args = ""
profiles {
conda {
params.enable_conda = true
conda.enabled = true
}
debug { process.beforeScript = 'echo $HOSTNAME' }
test {
params.input_files = "test_data/test_input_paired.txt"
params.reference = "$baseDir/test_data/ucsc.hg19.minimal.fasta"
ci {
params.cpus = 1
params.memory = "3g"
timeline.enabled = false
report.enabled = false
trace.enabled = false
dag.enabled = false
}
test {
params.input_files = "test_data/test_input_paired.txt"
params.reference = "$baseDir/test_data/ucsc.hg19.minimal.fasta"
}
}

// Export this variable to prevent local Python libraries from conflicting with those in the container
Expand Down
Loading

0 comments on commit b47efca

Please sign in to comment.