Skip to content

Commit

Permalink
Add module and subworkflow mirtop (#6587)
Browse files Browse the repository at this point in the history
* add mirtop gff module

* add mirtop/counts module

* add mirtop/export module

* add mirtop/stats module

* update yml

* add bam_stats_mirna_mirtop subworkflow

* add required dependencies

* update test

* update subworkflow test

* update yml and output files

* fix tag linting issue?

* fix linting

* run prettier

* try to solve conda issue

* add a compatible pandas

* fix linting

* update failing ci mirtop/gff test
  • Loading branch information
atrigila authored Sep 6, 2024
1 parent c3e4418 commit 9897e69
Show file tree
Hide file tree
Showing 26 changed files with 1,344 additions and 0 deletions.
9 changes: 9 additions & 0 deletions modules/nf-core/mirtop/counts/environment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
# yaml-language-server: $schema=https://raw.githubusercontent.com/nf-core/modules/master/modules/environment-schema.json
channels:
- conda-forge
- bioconda
dependencies:
- "bioconda::mirtop=0.4.25"
- "conda-forge::r-base=4.1.1"
- "conda-forge::r-data.table=1.14.2"
53 changes: 53 additions & 0 deletions modules/nf-core/mirtop/counts/main.nf
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
process MIRTOP_COUNTS {
tag "$meta.id"
label 'process_single'

conda "${moduleDir}/environment.yml"
container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ?
'https://depot.galaxyproject.org/singularity/mulled-v2-0c13ef770dd7cc5c76c2ce23ba6669234cf03385:63be019f50581cc5dfe4fc0f73ae50f2d4d661f7-0' :
'biocontainers/mulled-v2-0c13ef770dd7cc5c76c2ce23ba6669234cf03385:63be019f50581cc5dfe4fc0f73ae50f2d4d661f7-0' }"

input:
tuple val(meta), path(mirtop_gff)
tuple val(meta2), path(hairpin)
tuple val(meta3), path(gtf), val(species)

output:
tuple val(meta), path("counts/*.tsv"), emit: tsv
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}"
"""
mirtop \\
counts \\
$args \\
--hairpin $hairpin \\
--gtf $gtf \\
--sps $species \\
--gff $mirtop_gff \\
-o counts
cat <<-END_VERSIONS > versions.yml
"${task.process}":
mirtop: \$(echo \$(mirtop --version 2>&1) | sed 's/^.*mirtop //')
END_VERSIONS
"""

stub:
def args = task.ext.args ?: ''
def prefix = task.ext.prefix ?: "${meta.id}"
"""
mkdir counts
touch counts/mirtop.tsv
cat <<-END_VERSIONS > versions.yml
"${task.process}":
mirtop: \$(echo \$(mirtop --version 2>&1) | sed 's/^.*mirtop //')
END_VERSIONS
"""
}
57 changes: 57 additions & 0 deletions modules/nf-core/mirtop/counts/meta.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
---
# yaml-language-server: $schema=https://raw.githubusercontent.com/nf-core/modules/master/modules/meta-schema.json
name: "mirtop_counts"
description: mirtop counts generates a file with the minimal information about each sequence and the count data in columns for each samples.
keywords:
- mirna
- isomir
- gff
tools:
- "mirtop":
description: "Small RNA-seq annotation"
homepage: "https://github.com/miRTop/mirtop"
documentation: "https://mirtop.readthedocs.io/en/latest/"
tool_dev_url: "https://github.com/miRTop/mirtop"
licence: ["MIT License"]

input:
- meta:
type: map
description: |
Groovy Map containing sample information
e.g. `[ id:'sample1', single_end:false ]`
- mirtop_gff:
type: file
description: GFF file
pattern: "*.{gff}"
- hairpin:
type: file
description: Hairpin file
pattern: "*.{fa,fasta}"
- gtf:
type: file
description: GTF file
pattern: "*.{gtf}"
- species:
type: string
description: Species name of the GTF file

output:
- 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"
- tsv:
type: file
description: TSV file
pattern: "*.{tsv}"

authors:
- "@atrigila"
maintainers:
- "@atrigila"
97 changes: 97 additions & 0 deletions modules/nf-core/mirtop/counts/tests/main.nf.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
nextflow_process {

name "Test Process MIRTOP_COUNTS"
script "../main.nf"
config "./nextflow.config"
process "MIRTOP_COUNTS"

tag "modules"
tag "modules_nfcore"
tag "mirtop"
tag "mirtop/gff"
tag "mirtop/counts"

setup {
run("MIRTOP_GFF") {
script "../../gff/main.nf"
process {
"""
input[0] = [
[ id:'sample_sim_isomir_bam'], // meta map
file("https://github.com/nf-core/test-datasets/raw/modules/data/delete_me/mirtop/sim_isomir_sort.bam", checkIfExists: true),
]
input[1] = [
[ id:'hairpin'], // meta map
file("https://github.com/nf-core/test-datasets/raw/modules/data/delete_me/mirtop/hairpin_mirtop.fa", checkIfExists: true),
]
input[2] = [
[ id:'hsa' ], // meta map
file("https://github.com/nf-core/test-datasets/raw/modules/data/delete_me/mirtop/hsa.gff3", checkIfExists: true),
"hsa"]
"""
}
}
}

test("isomir - bam") {

when {
process {
"""
input[0] = MIRTOP_GFF.out.mirtop_gff
input[1] = [
[ id:'hairpin'], // meta map
file("https://github.com/nf-core/test-datasets/raw/modules/data/delete_me/mirtop/hairpin_mirtop.fa", checkIfExists: true),
]
input[2] = [
[ id:'hsa' ], // meta map
file("https://github.com/nf-core/test-datasets/raw/modules/data/delete_me/mirtop/hsa.gff3", checkIfExists: true),
"hsa"]
"""
}
}

then {
assertAll(
{ assert process.success },
{ assert snapshot(
process.out.versions
).match()
},
// md5sum is not stable, order of elements in column "variant" change
{ assert file(process.out.tsv[0][1]).readLines().findAll { it.contains("iso-22-I0S21NSLN") }}
)
}

}

test("isomir - bam - stub") {

options "-stub"

when {
process {
"""
input[0] = MIRTOP_GFF.out.mirtop_gff
input[1] = [
[ id:'hairpin'], // meta map
file("https://github.com/nf-core/test-datasets/raw/modules/data/delete_me/mirtop/hairpin_mirtop.fa", checkIfExists: true),
]
input[2] = [
[ id:'hsa' ], // meta map
file("https://github.com/nf-core/test-datasets/raw/modules/data/delete_me/mirtop/hsa.gff3", checkIfExists: true),
"hsa"]
"""
}
}

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

}

}
47 changes: 47 additions & 0 deletions modules/nf-core/mirtop/counts/tests/main.nf.test.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{
"isomir - bam - stub": {
"content": [
{
"0": [
[
{
"id": "sample_sim_isomir_bam"
},
"mirtop.tsv:md5,d41d8cd98f00b204e9800998ecf8427e"
]
],
"1": [
"versions.yml:md5,16430682c2080d67387e7d5e9caf69a7"
],
"tsv": [
[
{
"id": "sample_sim_isomir_bam"
},
"mirtop.tsv:md5,d41d8cd98f00b204e9800998ecf8427e"
]
],
"versions": [
"versions.yml:md5,16430682c2080d67387e7d5e9caf69a7"
]
}
],
"meta": {
"nf-test": "0.9.0",
"nextflow": "24.04.4"
},
"timestamp": "2024-09-03T13:24:41.148536938"
},
"isomir - bam": {
"content": [
[
"versions.yml:md5,16430682c2080d67387e7d5e9caf69a7"
]
],
"meta": {
"nf-test": "0.9.0",
"nextflow": "24.04.4"
},
"timestamp": "2024-09-04T18:39:50.607483472"
}
}
5 changes: 5 additions & 0 deletions modules/nf-core/mirtop/counts/tests/nextflow.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
process {
withName: 'MIRTOP_COUNTS' {
ext.args = '--add-extra'
}
}
10 changes: 10 additions & 0 deletions modules/nf-core/mirtop/export/environment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
# yaml-language-server: $schema=https://raw.githubusercontent.com/nf-core/modules/master/modules/environment-schema.json
channels:
- conda-forge
- bioconda
dependencies:
- "bioconda::mirtop=0.4.25"
- "bioconda::samtools=1.15.1"
- "conda-forge::r-base=4.1.1"
- "conda-forge::r-data.table=1.14.2"
57 changes: 57 additions & 0 deletions modules/nf-core/mirtop/export/main.nf
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
process MIRTOP_EXPORT {
tag "$meta.id"
label 'process_single'

conda "${moduleDir}/environment.yml"
container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ?
'https://depot.galaxyproject.org/singularity/mulled-v2-0c13ef770dd7cc5c76c2ce23ba6669234cf03385:63be019f50581cc5dfe4fc0f73ae50f2d4d661f7-0' :
'biocontainers/mulled-v2-0c13ef770dd7cc5c76c2ce23ba6669234cf03385:63be019f50581cc5dfe4fc0f73ae50f2d4d661f7-0' }"

input:
tuple val(meta), path(mirtop_gff)
tuple val(meta2), path(hairpin)
tuple val(meta3), path(gtf), val(species)

output:
tuple val(meta), path("export/*_rawData.tsv") , emit: tsv, optional: true
tuple val(meta), path("export/*.fasta") , emit: fasta, optional: true
tuple val(meta), path("export/*.vcf*") , emit: vcf , optional: true
path "versions.yml" , emit: versions

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

script:
def args = task.ext.args ?: '--format isomir'
def prefix = task.ext.prefix ?: "${meta.id}"
"""
mirtop \\
export \\
$args \\
--hairpin $hairpin\\
--gtf $gtf \\
--sps $species \\
-o export \\
$mirtop_gff
cat <<-END_VERSIONS > versions.yml
"${task.process}":
mirtop: \$(echo \$(mirtop --version 2>&1) | sed 's/^.*mirtop //')
END_VERSIONS
"""

stub:
def args = task.ext.args ?: ''
def prefix = task.ext.prefix ?: "${meta.id}"
"""
mkdir export
touch export/${prefix}.fasta
touch export/${prefix}.vcf
touch export/${prefix}.tsv
cat <<-END_VERSIONS > versions.yml
"${task.process}":
mirtop: \$(echo \$(mirtop --version 2>&1) | sed 's/^.*mirtop //')
END_VERSIONS
"""
}
Loading

0 comments on commit 9897e69

Please sign in to comment.