diff --git a/modules/nextflow/bed2gtf/main.nf b/modules/nextflow/bed2gtf/main.nf new file mode 100644 index 0000000..5480b1c --- /dev/null +++ b/modules/nextflow/bed2gtf/main.nf @@ -0,0 +1,67 @@ +/* +Copyright (c) 2026 The Hiller Lab at the Senckenberg Gessellschaft für Naturforschung +Distributed under the terms of the Apache License, Version 2.0. +*/ + +/* +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + BED2GTF — Convert BED to GTF. +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +*/ + + +process BED2GTF { + tag "$meta.id" + label 'process_low' + + conda "${moduleDir}/environment.yml" + container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ? + '' : + 'ghcr.io/alejandrogzi/bed2gtf:latest' }" + + input: + tuple val(meta), path(bed) + tuple val(meta1), path(isoforms) + + output: + tuple val(meta), path("*.gtf"), optional: true, emit: gtf + tuple val(meta), path("*.gtf.gz"), optional: true, emit: gtf_gz + tuple val(meta), path("*.gff"), optional: true, emit: gff + tuple val(meta), path("*.gff.gz"), optional: true, emit: gff_gz + path "versions.yml" , emit: versions + + when: + task.ext.when == null || task.ext.when + + script: + def args = task.ext.args ?: '' + def format = task.ext.format ?: 'gtf' + def prefix = task.ext.prefix ?: bed.baseName + '.' + format + def isf = isoforms ? "--isoforms ${isoforms}" : '' + """ + bed2gtf \\ + $args \\ + $isf \\ + -T ${task.cpus} \\ + -i ${bed} \\ + -o $prefix + + cat <<-END_VERSIONS > versions.yml + "${task.process}": + bed2gtf: \$(bed2gtf --version | sed -e "s/bed2gtf v//g") + END_VERSIONS + """ + + stub: + """ + touch *.gtf + touch *.gtf.gz + touch *.gff + touch *.gff.gz + + cat <<-END_VERSIONS > versions.yml + "${task.process}": + bed2gtf: \$(bed2gtf --version | sed -e "s/bed2gtf v//g") + END_VERSIONS + """ +} diff --git a/modules/nextflow/isotools/fusion/main.nf b/modules/nextflow/isotools/fusion/main.nf index 89a1af4..349675e 100644 --- a/modules/nextflow/isotools/fusion/main.nf +++ b/modules/nextflow/isotools/fusion/main.nf @@ -12,7 +12,7 @@ Distributed under the terms of the Apache License, Version 2.0. */ process ISOTOOLS_FUSION { - tag "$meta.id:$meta.chr" + tag "$meta.id" label 'process_low' conda "${moduleDir}/environment.yml" @@ -22,7 +22,7 @@ process ISOTOOLS_FUSION { input: tuple val(meta), path(bed) - path(reference) + tuple val(meta1), path(reference) output: tuple val(meta), path("*/fusions.bed") , optional: true, emit: fusion @@ -35,7 +35,7 @@ process ISOTOOLS_FUSION { script: def args = task.ext.args ?: '' - def prefix = task.ext.prefix ?: "${meta.id}_${meta.chr}" + def prefix = task.ext.prefix ?: "${meta.id}" def queries = (bed instanceof List) ? bed.join(',') : bed """ iso-fusion \\ diff --git a/modules/nextflow/isotools/orphan/main.nf b/modules/nextflow/isotools/orphan/main.nf index 3fbb7f8..af0f27b 100644 --- a/modules/nextflow/isotools/orphan/main.nf +++ b/modules/nextflow/isotools/orphan/main.nf @@ -23,11 +23,12 @@ process ISOTOOLS_ORPHAN { input: tuple val(meta), path(bed) tuple val(meta1), path(reference) + tuple val(meta2), path(splice_scores) output: - tuple val(meta), path("*/*.hq.bed") , optional: true, emit: hq - tuple val(meta1), path("*/*.scraps.bed") , optional: true, emit: scraps - path "versions.yml" , emit: versions + tuple val(meta), path("*/*.hq.bed") , optional: true, emit: hq + tuple val(meta_scraps), path("*/*.scraps.bed") , optional: true, emit: scraps + path "versions.yml" , emit: versions when: task.ext.when == null || task.ext.when @@ -35,40 +36,20 @@ process ISOTOOLS_ORPHAN { script: def args = task.ext.args ?: '' def prefix = task.ext.prefix ?: "${meta.id}" + def scores = splice_scores ? "--splicing-scores $splice_scores" : '' - meta1 = meta.clone() - meta1.id = meta.id.split('.')[0] + '.scraps' + meta_scraps = meta.clone() + meta_scraps.id = meta.id + '.scraps' """ - cut -f1-12 ${bed} > tmp.bed - iso-orphan \\ $args \\ + $scores \\ --ref $reference \\ --query tmp.bed \\ --all \\ --threads ${task.cpus} \\ --prefix ${prefix} - if [ ! -s orphans/${prefix}.hq.bed ]; then - rm orphans/${prefix}.hq.bed - else - grep -f \\ - <(cut -f4 orphans/${prefix}.hq.bed) ${bed} \\ - > tmp.bed && \\ - mv tmp.bed orphans/${prefix}.hq.bed - fi - - if [ ! -s orphans/${prefix}.scraps.bed ]; then - rm orphans/${prefix}.scraps.bed - else - grep -f \\ - <(cut -f4 orphans/${prefix}.scraps.bed) ${bed} \\ - > tmp.bed && \\ - mv tmp.bed orphans/${prefix}.scraps.bed - fi - - rm tmp.bed - cat <<-END_VERSIONS > versions.yml "${task.process}": iso-orphan: \$( iso-orphan --version | sed 's/iso-orphan //g' ) diff --git a/modules/wdl/bed2gtf/main.wdl b/modules/wdl/bed2gtf/main.wdl new file mode 100644 index 0000000..8ab04e1 --- /dev/null +++ b/modules/wdl/bed2gtf/main.wdl @@ -0,0 +1,62 @@ +# Copyright (c) 2026 The Hiller Lab at the Senckenberg Gessellschaft für Naturforschung +# Distributed under the terms of the Apache License, Version 2.0. + +# BED2GTF — Convert BED to GTF. +# Transforms BED format files to GTF/GFF format for compatibility +# with downstream analysis tools. + +version 1.3 + +task bed2gtf { + input { + File bed + File? isoforms + String args = "" + String format = "gtf" + Int cpus = 1 + } + + String prefix = sub(basename(bed), "\\.bed$", "") + "." + format + + command <<< + set -euo pipefail + + bed2gtf \ + ~{args} \ + ~{"--isoforms " + isoforms} \ + -T ~{cpus} \ + -i ~{bed} \ + -o ~{prefix} + >>> + + output { + File gtf = prefix + } + + requirements { + container: "ghcr.io/alejandrogzi/bed2gtf:latest" + } +} + +workflow run { + input { + File bed + File? isoforms + String args = "" + String format = "gtf" + Int cpus = 1 + } + + call bed2gtf { + input: + bed = bed, + isoforms = isoforms, + args = args, + format = format, + cpus = cpus + } + + output { + File gtf = bed2gtf.gtf + } +} \ No newline at end of file