Skip to content

Commit

Permalink
Igv reports (nf-core#5263)
Browse files Browse the repository at this point in the history
* add inital igvreports module

* add full input and tests

---------

Co-authored-by: Andrea Telatin <15690844+telatin@users.noreply.github.com>
  • Loading branch information
2 people authored and jennylsmith committed Mar 20, 2024
1 parent fba9a17 commit e10debf
Show file tree
Hide file tree
Showing 7 changed files with 258 additions and 0 deletions.
9 changes: 9 additions & 0 deletions modules/nf-core/igvreports/environment.yml
@@ -0,0 +1,9 @@
---
# yaml-language-server: $schema=https://raw.githubusercontent.com/nf-core/modules/master/modules/environment-schema.json
name: "igvreports"
channels:
- conda-forge
- bioconda
- defaults
dependencies:
- "bioconda::igv-reports=1.12.0"
48 changes: 48 additions & 0 deletions modules/nf-core/igvreports/main.nf
@@ -0,0 +1,48 @@
process IGVREPORTS {
tag "$meta.id"
label 'process_low'

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

input:
tuple val(meta), path(sites)
path genomeFasta //optional genome fasta file

output:
tuple val(meta), path("*.html") , emit: report
path "versions.yml" , emit: versions

when:
task.ext.when == null || task.ext.when

script:
def args = task.ext.args ?: ''
def prefix = task.ext.prefix ?: "${meta.id}"
def fasta = genomeFasta ? "--fasta ${genomeFasta}" : ""
"""
create_report $sites \
$args \
$fasta \
--output ${meta.id}_report.html
cat <<-END_VERSIONS > versions.yml
"${task.process}":
igvreports: \$(python -c "import igv_reports; print(igv_reports.__version__)")
END_VERSIONS
"""

stub:
def args = task.ext.args ?: ''
def prefix = task.ext.prefix ?: "${meta.id}"
"""
touch ${meta.id}_report.html
cat <<-END_VERSIONS > versions.yml
"${task.process}":
igvreports: \$(python -c "import igv_reports; print(igv_reports.__version__)")
END_VERSIONS
"""
}
47 changes: 47 additions & 0 deletions modules/nf-core/igvreports/meta.yml
@@ -0,0 +1,47 @@
---
# yaml-language-server: $schema=https://raw.githubusercontent.com/nf-core/modules/master/modules/meta-schema.json
name: "igvreports"
description: A Python application to generate self-contained HTML reports for variant review and other genomic applications
keywords:
- vcf
- variant
- genomics
tools:
- "igvreports":
description: "Creates self-contained html pages for visual variant review with IGV (igv.js)."
homepage: "https://github.com/igvteam/igv-reports"
documentation: "https://github.com/igvteam/igv-reports"
tool_dev_url: "https://github.com/igvteam/igv-reports"
doi: "10.1093/bioinformatics/btac830"
licence: ["MIT"]

input:
# Only when we have meta
- meta:
type: map
description: |
Groovy Map containing sample information
e.g. [ id:'test', single_end:false ]
- sites:
type: file
description: VCF, BED, MAF, BEDPE, or generic tab delimited file of genomic variant sites
- genomeFasta:
type: file
description: Reference fasta file
pattern: "*.{fasta,fa}"

output:
- versions:
type: file
description: File containing software versions
pattern: "versions.yml"
- report:
type: file
description: html report with a table of genomic sites and an embedded IGV genome browser for viewing data for each site
pattern: "*.{html}"

authors:
- "@souljamie"
maintainers:
- "@souljamie"
107 changes: 107 additions & 0 deletions modules/nf-core/igvreports/tests/main.nf.test
@@ -0,0 +1,107 @@
nextflow_process {

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

tag "modules"
tag "modules_nfcore"
tag "igvreports"

test("testvariantsWithFasta - vcf") {

when {
process {
"""
input[0] = [ [ id:'test'], // meta map
file(params.test_data['sarscov2']['illumina']['test_vcf'], checkIfExists: true)
]
input[1] = file(params.test_data['sarscov2']['genome']['genome_fasta'], checkIfExists: true)
"""
}
}

then {
assertAll(
{ assert process.success },
{ assert snapshot(process.out.versions).match()},
{
with(process.out.report) {
with(get(0)) {
assert get(1).endsWith("_report.html")
}
}
}
)
}

}



test("testvariantsWithGenome - vcf") {
config "./nextflow_genome.config"

when {
process {
"""
input[0] = [
[ id:'test'], // meta map
file("https://raw.githubusercontent.com/igvteam/igv-reports/master/test/data/variants/variants.vcf")
]
// Need to specify the empty optional fasta input
input[1] = []
"""
}
}

then {
assertAll(
{ assert process.success },
{ assert snapshot(process.out.versions).match()},
{
with(process.out.report) {
with(get(0)) {
assert get(1).endsWith("_report.html")
}
}
}
)
}

}

test("testvariantWithGenome - vcf - stub") {
config "./nextflow_genome.config"

options "-stub"

when {
process {
"""
input[0] = [
[ id:'test'], // meta map
file("https://raw.githubusercontent.com/igvteam/igv-reports/master/test/data/variants/variants.vcf")
]
input[1] = []
"""
}
}

then {
assertAll(
{ assert process.success },
{ assert snapshot(process.out.versions).match()},
{
with(process.out.report) {
with(get(0)) {
assert get(1).endsWith("_report.html")
}
}
}
)
}

}

}
38 changes: 38 additions & 0 deletions modules/nf-core/igvreports/tests/main.nf.test.snap

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

7 changes: 7 additions & 0 deletions modules/nf-core/igvreports/tests/nextflow_genome.config
@@ -0,0 +1,7 @@
process {

withName: IGVREPORTS {
ext.args = '--genome hg38'
}

}
2 changes: 2 additions & 0 deletions modules/nf-core/igvreports/tests/tags.yml
@@ -0,0 +1,2 @@
igvreports:
- "modules/nf-core/igvreports/**"

0 comments on commit e10debf

Please sign in to comment.