Skip to content

Commit

Permalink
Igv js (nf-core#2846)
Browse files Browse the repository at this point in the history
* add igv/js module

* add documentation in meta.yml

* create test.yml according to new version of the library

* fix browser description and pattern
  • Loading branch information
mirpedrol authored and samfulcrum committed Feb 27, 2023
1 parent 9c64b56 commit fb922bd
Show file tree
Hide file tree
Showing 6 changed files with 180 additions and 0 deletions.
66 changes: 66 additions & 0 deletions modules/nf-core/igv/js/main.nf
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@

process IGV_JS {
tag "$meta.id"
label 'process_single'

conda "conda-forge::sed=4.7"
container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ?
'https://depot.galaxyproject.org/singularity/ubuntu:20.04' :
'ubuntu:20.04' }"

input:
tuple val(meta), path(alignment), path(index)

output:
tuple val(meta), path("*_genome-browser.html") , emit: browser
tuple val(meta), path(alignment) , emit: align_files
tuple val(meta), path(index) , emit: index_files
path "versions.yml" , emit: versions

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

script:
def browser_args = task.ext.args ?: ''
def track_args = task.ext.args2 ?: ''
def prefix = task.ext.prefix ?: "${meta.id}"
"""
cat <<IGV > ${prefix}_genome-browser.html
<html>
<head>
<script src="https://cdn.jsdelivr.net/npm/igv@2.13.9/dist/igv.min.js"></script> <!-- https://github.com/igvteam/igv.js/ -->
</head>
<body>
<div id="igv-div"></div>
<script>
var igvDiv = document.getElementById("igv-div");
var options =
{
$browser_args,
tracks: [
{
"name": "$prefix",
"url": "$alignment",
"indexURL": "$index",
$track_args
}
]
};
igv.removeAllBrowsers();
igv.createBrowser(igvDiv, options)
.then(function(browser){
igv.browser = browser;
})
</script>
</body>
</html>
IGV
cat <<-END_VERSIONS > versions.yml
"${task.process}":
cat: \$(echo \$(cat --version 2>&1) | sed 's/^.*coreutils) //; s/ .*\$//')
END_VERSIONS
"""
}
67 changes: 67 additions & 0 deletions modules/nf-core/igv/js/meta.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: "igv_js"
description: igv.js is an embeddable interactive genome visualization component
keywords:
- igv
- igv.js
- js
- genome browser
tools:
- "igv":
description: |
Create an embeddable interactive genome browser component.
Output files are expected to be present in the same directory as teh genome browser html file.
To visualise it, files have to be served. Check the documentation at:
https://github.com/igvteam/igv-webapp for an example and
https://github.com/igvteam/igv.js/wiki/Data-Server-Requirements for server requirements
homepage: https://github.com/igvteam/igv.js
documentation: https://github.com/igvteam/igv.js/wiki
tool_dev_url: https://github.com/igvteam/igv.js
doi: https://doi.org/10.1093/bioinformatics/btac830
licence: "['MIT']"

input:
- meta:
type: map
description: |
Groovy Map containing sample information
e.g. [ id:'test', single_end:false ]
- alignment:
type: file
description: Sorted BAM/CRAM file
pattern: "*.{bam,cram}"

- index:
type: file
description: Index of sorted BAM/CRAM file
pattern: "*.{bai,crai}"

output:
- meta:
type: map
description: |
Groovy Map containing sample information
e.g. [ id:'test', single_end:false ]
- browser:
type: file
description: Genome browser HTML file
pattern: "*.{html}"

- align_files:
type: file
description: Copy of the input sorted BAM/CRAM file
pattern: "*.{bam,cram}"

- index_files:
type: file
description: Copy of the input index of sorted BAM/CRAM file
pattern: "*.{bai,crai}"

- versions:
type: file
description: File containing software versions
pattern: "versions.yml"

authors:
- "@mirpedrol"
4 changes: 4 additions & 0 deletions tests/config/pytest_modules.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1629,6 +1629,10 @@ idr:
- modules/nf-core/idr/**
- tests/modules/nf-core/idr/**

igv/js:
- modules/nf-core/igv/js/**
- tests/modules/nf-core/igv/js/**

imputeme/vcftoprs:
- modules/nf-core/imputeme/vcftoprs/**
- tests/modules/nf-core/imputeme/vcftoprs/**
Expand Down
16 changes: 16 additions & 0 deletions tests/modules/nf-core/igv/js/main.nf
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/usr/bin/env nextflow

nextflow.enable.dsl = 2

include { IGV_JS } from '../../../../../modules/nf-core/igv/js/main.nf'

workflow test_igv_js {

input = [
[ id:'test', single_end:false ], // meta map
file(params.test_data['homo_sapiens']['illumina']['test_paired_end_sorted_bam'], checkIfExists: true),
file(params.test_data['homo_sapiens']['illumina']['test_paired_end_sorted_bam_bai'], checkIfExists: true)
]

IGV_JS ( input )
}
14 changes: 14 additions & 0 deletions tests/modules/nf-core/igv/js/nextflow.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
process {

publishDir = [
mode: "copy",
path: { "${params.outdir}/${task.process.tokenize(':')[-1].tokenize('_')[0].toLowerCase()}" },
]
withName: 'IGV_JS' {
ext.args = """genome: "hg38",
locus: "chr22:4,514-4,554""""
ext.args2 = """"format": "bam",
"type": "alignment""""
}
}
13 changes: 13 additions & 0 deletions tests/modules/nf-core/igv/js/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
- name: igv js test_igv_js
command: nextflow run ./tests/modules/nf-core/igv/js -entry test_igv_js -c ./tests/config/nextflow.config -c ./tests/modules/nf-core/igv/js/nextflow.config
tags:
- igv
- igv/js
files:
- path: output/igv/test.paired_end.sorted.bam
md5sum: 76396678f283516b159a1e9b538fc64c
- path: output/igv/test.paired_end.sorted.bam.bai
md5sum: 9ac6ecb9435822c44b37765f111e9013
- path: output/igv/test_genome-browser.html
md5sum: 99f4962da2703eceaba71fd68f9be7e6
- path: output/igv/versions.yml

0 comments on commit fb922bd

Please sign in to comment.