diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index ba1c5f68..385a527b 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -416,6 +416,8 @@ jobs: tags: salmon/quant - profile: "conda" tags: rediscoverte + - profile: "conda" + tags: igv/snapshot env: NXF_ANSI_LOG: false diff --git a/modules/msk/igv/snapshot/environment.yml b/modules/msk/igv/snapshot/environment.yml new file mode 100644 index 00000000..af717a89 --- /dev/null +++ b/modules/msk/igv/snapshot/environment.yml @@ -0,0 +1,9 @@ +--- +# yaml-language-server: $schema=https://raw.githubusercontent.com/nf-core/modules/master/modules/environment-schema.json +name: "igv_snapshot" +channels: + - conda-forge + - bioconda + - defaults +dependencies: + - "bioconda::igv=2.17.4" diff --git a/modules/msk/igv/snapshot/main.nf b/modules/msk/igv/snapshot/main.nf new file mode 100644 index 00000000..4cc8ef43 --- /dev/null +++ b/modules/msk/igv/snapshot/main.nf @@ -0,0 +1,57 @@ +process IGV_SNAPSHOT { + tag "$meta.id" + label 'process_single' + + conda "${moduleDir}/environment.yml" + container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ? + 'ghcr.io/msk-access/igv_snapshot:0.0.1': + 'ghcr.io/msk-access/igv_snapshot:0.0.1' }" + + input: + tuple val(meta), path(bam), path(bai), path(variant_file) + + output: + + tuple val(meta), path("**igv_output/*"), emit: igv_screenshots + 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 bed_name = prefix ? "${prefix}.bed": "variant.bed" + def out = prefix ? "${prefix}_igv_output": "igv_output" + def genome = task.ext.genome ? "-g ${task.ext.genome}" : "" + """ + igv run_screenshot \\ + --input-files $bam \\ + --annotated-variant-file $variant_file \\ + -t $prefix \\ + -o $out \\ + -r $bed_name \\ + $genome + + cat <<-END_VERSIONS > versions.yml + "${task.process}": + igv: \$(igv --version) + END_VERSIONS + """ + + stub: + def args = task.ext.args ?: "" + def prefix = task.ext.prefix ?: "${meta.id}" + def bed_name = prefix ? "${prefix}.bed": "variant.bed" + def out = prefix ? "${prefix}_igv_output": "igv_output" + """ + mkdir $out + touch $out/test.png + touch $out/test.bat + + cat <<-END_VERSIONS > versions.yml + "${task.process}": + igv: \$(igv --version) + END_VERSIONS + """ +} diff --git a/modules/msk/igv/snapshot/meta.yml b/modules/msk/igv/snapshot/meta.yml new file mode 100644 index 00000000..81d3ea90 --- /dev/null +++ b/modules/msk/igv/snapshot/meta.yml @@ -0,0 +1,62 @@ +--- +# yaml-language-server: $schema=https://raw.githubusercontent.com/nf-core/modules/master/modules/meta-schema.json +name: "igv_snapshot" +description: a module to run IGV screenshot +keywords: + - sort + - example + - genomics +tools: + - "igv": + description: "Integrative Genomics Viewer. Fast, efficient, scalable visualization tool for genomics data and annotations." + homepage: "https://igv.org/" + documentation: "https://igv.org/doc/desktop/#QuickStart/" + tool_dev_url: "https://github.com/igvteam/igv" + licence: ["MIT"] + - "igv snapshot": + description: "A python package to generate and execute IGV screenshot script." + documentation: "https://github.com/msk-access/igv_snapshot/blob/main/README.md" + tool_dev_url: "https://github.com/msk-access/igv_snapshot" + licence: ["MIT"] + +input: + # Only when we have meta + - meta: + type: map + description: | + Groovy Map containing sample information + e.g. `[ id:'sample1', single_end:false ]` + - bam: + type: file + description: BAM file with index. + pattern: "*.{bam,cram,sam}" + - bai: + type: file + description: BAM file index + pattern: "*.{bai}" + - variant_file: + type: file + description: Variant file of input BAM. + pattern: "*.{maf,vcf}" + +output: + #Only when we have meta + - meta: + type: map + description: | + Groovy Map containing sample information + e.g. `[ id:'sample1', single_end:false ]` + + - versions: + type: file + description: File containing software versions + pattern: "versions.yml" + - igv_screenshots: + type: directory + description: directory containing IGV screenshot for provided sample, and the bat script used to generate the screenshots. + pattern: "**igv_output/*" + +authors: + - "@buehlere" +maintainers: + - "@buehlere" diff --git a/modules/msk/igv/snapshot/tests/main.nf.test b/modules/msk/igv/snapshot/tests/main.nf.test new file mode 100644 index 00000000..d87a2cd7 --- /dev/null +++ b/modules/msk/igv/snapshot/tests/main.nf.test @@ -0,0 +1,64 @@ +nextflow_process { + + name "Test Process IGV_SNAPSHOT" + script "../main.nf" + process "IGV_SNAPSHOT" + + tag "modules" + tag "modules_nfcore" + tag "modules_msk" + tag "igv" + tag "igv/snapshot" + + test("chr22 - bam, vcf") { + + when { + process { + """ + input[0] = [ + [ id:'C-9M47TU-L001-d'], // meta map + file(params.test_data_mskcc['chr22']['chr22bam'], checkIfExists: true), + file(params.test_data_mskcc['chr22']['chr22bam_bai'], checkIfExists: true), + file(params.test_data_mskcc['chr22']['chr22vcf'], checkIfExists: true) + + ] + """ + } + } + + then { + assertAll( + { assert process.success }, + { assert snapshot(process.out).match() } + ) + } + + } + + test("chr22 - bam, vcf - stub") { + + options "-stub" + + when { + process { + """ + input[0] = [ + [ id:'C-9M47TU-L001-d'], // meta map + file(params.test_data_mskcc['chr22']['chr22bam'], checkIfExists: true), + file(params.test_data_mskcc['chr22']['chr22bam_bai'], checkIfExists: true), + file(params.test_data_mskcc['chr22']['chr22vcf'], checkIfExists: true) + ] + """ + } + } + + then { + assertAll( + { assert process.success }, + { assert snapshot(process.out).match() } + ) + } + + } + +} diff --git a/modules/msk/igv/snapshot/tests/main.nf.test.snap b/modules/msk/igv/snapshot/tests/main.nf.test.snap new file mode 100644 index 00000000..cac17abd --- /dev/null +++ b/modules/msk/igv/snapshot/tests/main.nf.test.snap @@ -0,0 +1,82 @@ +{ + "chr22 - bam, vcf - stub": { + "content": [ + { + "0": [ + [ + { + "id": "C-9M47TU-L001-d" + }, + [ + "test.bat:md5,d41d8cd98f00b204e9800998ecf8427e", + "test.png:md5,d41d8cd98f00b204e9800998ecf8427e" + ] + ] + ], + "1": [ + "versions.yml:md5,870a90d9f64f5a5f5ec4cd474d69027c" + ], + "igv_screenshots": [ + [ + { + "id": "C-9M47TU-L001-d" + }, + [ + "test.bat:md5,d41d8cd98f00b204e9800998ecf8427e", + "test.png:md5,d41d8cd98f00b204e9800998ecf8427e" + ] + ] + ], + "versions": [ + "versions.yml:md5,870a90d9f64f5a5f5ec4cd474d69027c" + ] + } + ], + "timestamp": "2024-08-06T17:08:44.477177" + }, + "chr22 - bam, vcf": { + "content": [ + { + "0": [ + [ + { + "id": "C-9M47TU-L001-d" + }, + [ + "22_22127176_22127176.png:md5,fd9de31a371db4523f8a0982df749a09", + "22_41565827_41565827.png:md5,1904ecf0b28baeee6e14e78543052a17", + "22_41566406_41566406.png:md5,c77c48716ed2272f45b49c7852a74705", + "22_41566413_41566413.png:md5,bfaf4189292aa0495e51c26ea33f64f7", + "22_41566595_41566595.png:md5,2fca6b6e75fd4c533fb512d0cd11941b", + "22_41566657_41566657.png:md5,fd49c1c6439206da9c15595921392d29", + "IGV_snapshots.bat:md5,d2eaf7a013f62e5fe07f8a0ddf459ace" + ] + ] + ], + "1": [ + "versions.yml:md5,870a90d9f64f5a5f5ec4cd474d69027c" + ], + "igv_screenshots": [ + [ + { + "id": "C-9M47TU-L001-d" + }, + [ + "22_22127176_22127176.png:md5,fd9de31a371db4523f8a0982df749a09", + "22_41565827_41565827.png:md5,1904ecf0b28baeee6e14e78543052a17", + "22_41566406_41566406.png:md5,c77c48716ed2272f45b49c7852a74705", + "22_41566413_41566413.png:md5,bfaf4189292aa0495e51c26ea33f64f7", + "22_41566595_41566595.png:md5,2fca6b6e75fd4c533fb512d0cd11941b", + "22_41566657_41566657.png:md5,fd49c1c6439206da9c15595921392d29", + "IGV_snapshots.bat:md5,d2eaf7a013f62e5fe07f8a0ddf459ace" + ] + ] + ], + "versions": [ + "versions.yml:md5,870a90d9f64f5a5f5ec4cd474d69027c" + ] + } + ], + "timestamp": "2024-08-06T17:08:31.32318" + } +} \ No newline at end of file diff --git a/modules/msk/igv/snapshot/tests/tags.yml b/modules/msk/igv/snapshot/tests/tags.yml new file mode 100644 index 00000000..a2856d2e --- /dev/null +++ b/modules/msk/igv/snapshot/tests/tags.yml @@ -0,0 +1,2 @@ +igv/snapshot: + - "modules/msk/igv/snapshot/**" diff --git a/tests/config/test_data.config b/tests/config/test_data.config index 1dd200c0..547696d0 100644 --- a/tests/config/test_data.config +++ b/tests/config/test_data.config @@ -725,6 +725,9 @@ params { dbsnp_138_b37_chr17_vcf_gz_tbi = "${params.test_data_base_msk}/hg37/genomic_reference/GRCH37/vcf/dbsnp_138.b37.chr17.vcf.gz.tbi" } 'chr22' { + chr22bam = "${params.test_data_base_msk}/chr22/chr22/chr22.bam" + chr22bam_bai = "${params.test_data_base_msk}/chr22/chr22/chr22.bam.bai" + chr22vcf = "${params.test_data_base_msk}/chr22/chr22/chr22.vcf" chr22maf = "${params.test_data_base_msk}/chr22/chr22/chr22.maf" chr22mafstandard = "${params.test_data_base_msk}/chr22/chr22/chr22_standard.maf" }