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

Update lofreq somatic and callparallel #5931

Merged
merged 23 commits into from
Jul 11, 2024
Merged
Show file tree
Hide file tree
Changes from 17 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
35 changes: 31 additions & 4 deletions modules/nf-core/lofreq/callparallel/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ process LOFREQ_CALLPARALLEL {
'biocontainers/lofreq:2.1.5--py38h588ecb2_4' }"

input:
tuple val(meta), path(bam), path(bai), path(intervals)
path fasta
path fai
tuple val(meta) , path(bam), path(bai), path(intervals)
tuple val(meta2), path(fasta)
tuple val(meta3), path(fai)

output:
tuple val(meta), path("*.vcf.gz"), emit: vcf
Expand All @@ -23,15 +23,42 @@ process LOFREQ_CALLPARALLEL {
def args = task.ext.args ?: ''
def prefix = task.ext.prefix ?: "${meta.id}"
def options_intervals = intervals ? "-l ${intervals}" : ""

def alignment_cram = bam.Extension == "cram" ? true : false
def alignment_bam = bam.Extension == "bam" ? true : false
def alignment_out = alignment_cram ? bam.BaseName + ".bam" : "${bam}"

def samtools_cram_convert = ''
SPPearce marked this conversation as resolved.
Show resolved Hide resolved
samtools_cram_convert += alignment_cram ? " samtools view -T ${fasta} ${bam} -@ $task.cpus -o ${alignment_out}\n" : ''
samtools_cram_convert += alignment_cram ? " samtools index ${alignment_out}\n" : ''

def samtools_cram_remove = ''
samtools_cram_remove += alignment_cram ? " rm ${alignment_out}\n" : ''
samtools_cram_remove += alignment_cram ? " rm ${alignment_out}.bai\n " : ''
"""
$samtools_cram_convert
SPPearce marked this conversation as resolved.
Show resolved Hide resolved

lofreq \\
call-parallel \\
--pp-threads $task.cpus \\
$args \\
$options_intervals \\
-f $fasta \\
-o ${prefix}.vcf.gz \\
$bam
$alignment_out

$samtools_cram_remove

cat <<-END_VERSIONS > versions.yml
"${task.process}":
lofreq: \$(echo \$(lofreq version 2>&1) | sed 's/^version: //; s/ *commit.*\$//')
END_VERSIONS
"""

stub:
def prefix = task.ext.prefix ?: "${meta.id}"
"""
echo "" | gzip > ${prefix}.vcf.gz

cat <<-END_VERSIONS > versions.yml
"${task.process}":
Expand Down
16 changes: 14 additions & 2 deletions modules/nf-core/lofreq/callparallel/meta.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,30 @@ input:
e.g. [ id:'test' ]
- bam:
type: file
description: Sorted BAM file
description: Tumor sample sorted BAM file
pattern: "*.{bam}"
- bai:
type: file
description: BAM index file
pattern: "*.{bai}"
pattern: "*.{bam.bai}"
- intervals:
type: file
description: BED file containing target regions for variant calling
pattern: "*.{bed}"
- meta2:
type: map
description: |
Groovy Map containing sample information about the reference fasta
e.g. [ id:'reference' ]
- fasta:
type: file
description: Reference genome FASTA file
pattern: "*.{fasta}"
- meta3:
type: map
description: |
Groovy Map containing sample information about the reference fasta fai
e.g. [ id:'reference' ]
- fai:
type: file
description: Reference genome FASTA index file
Expand All @@ -58,3 +68,5 @@ authors:
maintainers:
- "@kaurravneet4123"
- "@bjohnnyd"
- "@nevinwu"
- "@AitorPeseta"
103 changes: 103 additions & 0 deletions modules/nf-core/lofreq/callparallel/tests/main.nf.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
nextflow_process {

name "Test Process LOFREQ_CALLPARALLEL"
script "../main.nf"
process "LOFREQ_CALLPARALLEL"

tag "modules"
tag "modules_nfcore"
tag "lofreq"
tag "lofreq/callparallel"

test("sarscov2 - bam") {

when {
process {
"""
input[0] = [ [ id:'test' ], // meta map
file(params.modules_testdata_base_path + 'genomics/sarscov2/illumina/bam/test.paired_end.sorted.bam', checkIfExists: true),
file(params.modules_testdata_base_path + 'genomics/sarscov2/illumina/bam/test.paired_end.sorted.bam.bai', checkIfExists: true),
[]
]
input[1] = [ [ id:'fasta' ], // meta map
file(params.modules_testdata_base_path + 'genomics/sarscov2/genome/genome.fasta', checkIfExists: true)
]
input[2] = [ [ id:'fai' ], // meta map
file(params.modules_testdata_base_path + 'genomics/sarscov2/genome/genome.fasta.fai', checkIfExists: true)
]
"""
}
}

then {
assertAll(
{ assert process.success },
{ assert snapshot(process.out.versions).match() },
{ assert path(process.out.vcf.get(0).get(1)).linesGzip.contains('##INFO=<ID=CONSVAR,Number=0,Type=Flag,Description="Indicates that the variant is a consensus variant (as opposed to a low frequency variant).">') }
)
}

}

test("sarscov2 - bam - bed") {

when {
process {
"""
input[0] = [ [ id:'test' ], // meta map
file(params.modules_testdata_base_path + 'genomics/sarscov2/illumina/bam/test.paired_end.sorted.bam', checkIfExists: true),
file(params.modules_testdata_base_path + 'genomics/sarscov2/illumina/bam/test.paired_end.sorted.bam.bai', checkIfExists: true),
file(params.modules_testdata_base_path + 'genomics/sarscov2/genome/bed/test.bed', checkIfExists: true)
]
input[1] = [ [ id:'fasta' ], // meta map
file(params.modules_testdata_base_path + 'genomics/sarscov2/genome/genome.fasta', checkIfExists: true)
]
input[2] = [ [ id:'fai' ], // meta map
file(params.modules_testdata_base_path + 'genomics/sarscov2/genome/genome.fasta.fai', checkIfExists: true)
]
"""
}
}

then {
assertAll(
{ assert process.success },
{ assert snapshot(process.out.versions).match() },
{ assert path(process.out.vcf.get(0).get(1)).linesGzip.contains('##INFO=<ID=CONSVAR,Number=0,Type=Flag,Description="Indicates that the variant is a consensus variant (as opposed to a low frequency variant).">') }
)
}

}

test("sarscov2 - bam - stub") {

options "-stub"

when {
process {
"""
input[0] = [ [ id:'test' ], // meta map
file(params.modules_testdata_base_path + 'genomics/sarscov2/illumina/bam/test.paired_end.sorted.bam', checkIfExists: true),
file(params.modules_testdata_base_path + 'genomics/sarscov2/illumina/bam/test.paired_end.sorted.bam.bai', checkIfExists: true),
[]
]
input[1] = [ [ id:'fasta' ], // meta map
file(params.modules_testdata_base_path + 'genomics/sarscov2/genome/genome.fasta', checkIfExists: true)
]
input[2] = [ [ id:'fai' ], // meta map
file(params.modules_testdata_base_path + 'genomics/sarscov2/genome/genome.fasta.fai', checkIfExists: true)
]
"""
}
}

then {
assertAll(
{ assert process.success },
{ assert snapshot(process.out).match() }
)
}

}

}
59 changes: 59 additions & 0 deletions modules/nf-core/lofreq/callparallel/tests/main.nf.test.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
{
"sarscov2 - bam - stub": {
"content": [
{
"0": [
[
{
"id": "test"
},
"test.vcf.gz:md5,68b329da9893e34099c7d8ad5cb9c940"
]
],
"1": [
"versions.yml:md5,56d45e0015add277b2689f071a4fe3e4"
],
"vcf": [
[
{
"id": "test"
},
"test.vcf.gz:md5,68b329da9893e34099c7d8ad5cb9c940"
]
],
"versions": [
"versions.yml:md5,56d45e0015add277b2689f071a4fe3e4"
]
}
],
"meta": {
"nf-test": "0.8.4",
"nextflow": "24.04.2"
},
"timestamp": "2024-07-10T12:57:00.731035"
},
"sarscov2 - bam": {
"content": [
[
"versions.yml:md5,56d45e0015add277b2689f071a4fe3e4"
]
],
"meta": {
"nf-test": "0.8.4",
"nextflow": "24.04.2"
},
"timestamp": "2024-07-10T12:59:23.105421"
},
"sarscov2 - bam - bed": {
"content": [
[
"versions.yml:md5,56d45e0015add277b2689f071a4fe3e4"
]
],
"meta": {
"nf-test": "0.8.4",
"nextflow": "24.04.2"
},
"timestamp": "2024-07-10T12:59:28.355632"
}
}
2 changes: 2 additions & 0 deletions modules/nf-core/lofreq/callparallel/tests/tags.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
lofreq/callparallel:
- "modules/nf-core/lofreq/callparallel/**"
33 changes: 27 additions & 6 deletions modules/nf-core/lofreq/somatic/main.nf
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
process LOFREQ_SOMATIC {
tag "$meta.id"
label "process_high"
label 'process_high'

conda "${moduleDir}/environment.yml"
container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ?
'https://depot.galaxyproject.org/singularity/lofreq:2.1.5--py38h588ecb2_4' :
'biocontainers/lofreq:2.1.5--py38h588ecb2_4' }"

input:
tuple val(meta), path(tumor_bam), path(tumor_bai), path(normal_bam), path(normal_bai), path(target_bed)
tuple val(meta), path(tumor), path(tumor_index), path(normal), path(normal_index), path(target_bed)
tuple val(meta2), path(fasta)
tuple val(meta3), path(fai)

Expand All @@ -23,17 +22,39 @@ process LOFREQ_SOMATIC {
def args = task.ext.args ?: ""
def prefix = task.ext.prefix ?: "${meta.id}"
def options_target_bed = target_bed ? "-l ${target_bed}" : ""

def tumor_cram = tumor.Extension == "cram" ? true : false
def normal_cram = normal.Extension == "cram" ? true : false

def tumor_out = tumor_cram ? tumor.BaseName + ".bam" : "${tumor}"
def normal_out = normal_cram ? normal.BaseName + ".bam" : "${normal}"

def samtools_cram_convert = ''
samtools_cram_convert += normal_cram ? " samtools view -T $fasta $normal -@ $task.cpus -o $normal_out\n" : ''
samtools_cram_convert += normal_cram ? " samtools index $normal_out\n" : ''
samtools_cram_convert += tumor_cram ? " samtools view -T ${fasta} $tumor -@ $task.cpus -o $tumor_out\n" : ''
samtools_cram_convert += tumor_cram ? " samtools index ${tumor_out}\n" : ''

def samtools_cram_remove = ''
samtools_cram_remove += tumor_cram ? " rm $tumor_out\n" : ''
samtools_cram_remove += tumor_cram ? " rm ${tumor_out}.bai\n " : ''
samtools_cram_remove += normal_cram ? " rm $normal_out\n" : ''
samtools_cram_remove += normal_cram ? " rm ${normal_out}.bai\n " : ''
"""
$samtools_cram_convert

lofreq \\
somatic \\
--threads $task.cpus \\
$args \\
-f $fasta \\
-t $tumor_bam \\
-n $normal_bam \\
-t $tumor_out \\
-n $normal_out \\
${options_target_bed} \\
-o ${prefix}

$samtools_cram_remove

cat <<-END_VERSIONS > versions.yml
"${task.process}":
lofreq: \$(echo \$(lofreq version 2>&1) | sed 's/^version: //; s/ *commit.*\$//')
Expand All @@ -43,7 +64,7 @@ process LOFREQ_SOMATIC {
stub:
def prefix = task.ext.prefix ?: "${meta.id}"
"""
touch ${prefix}.vcf.gz
echo "" | gzip > ${prefix}.vcf.gz

cat <<-END_VERSIONS > versions.yml
"${task.process}":
Expand Down
15 changes: 8 additions & 7 deletions modules/nf-core/lofreq/somatic/meta.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ tools:
homepage: https://csb5.github.io/lofreq/
documentation: https://csb5.github.io/lofreq/commands/
doi: 10.1093/nar/gks918
licence: "['MIT']"
licence: ["MIT"]
input:
- meta:
type: map
Expand All @@ -23,22 +23,22 @@ input:
- meta3:
type: map
description: Groovy Map containing reference information
- tumor_bam:
- tumor:
type: file
description: tumor sample input BAM file
pattern: "*.{bam}"
- tumor_bai:
- tumor_index:
type: file
description: tumor sample BAM index file
pattern: "*.{bai}"
- normal_bam:
pattern: "*.{bam.bai}"
- normal:
type: file
description: normal sample input BAM file
pattern: "*.{bam}"
- normal_bai:
- normal_index:
type: file
description: normal sample BAM index file
pattern: "*.{bai}"
pattern: "*.{bam.bai}"
- fasta:
type: file
description: Reference genome FASTA file
Expand Down Expand Up @@ -69,3 +69,4 @@ authors:
- "@nevinwu"
maintainers:
- "@nevinwu"
- "@AitorPeseta"
Loading
Loading