Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 67 additions & 0 deletions modules/nextflow/chaintools/coverage/main.nf
Original file line number Diff line number Diff line change
@@ -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.
*/

/*
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
CHAINTOOLS_COVERAGE — Measure annotation feature coverage by aligned chain blocks.
Measures how many bases of annotation features (cds/exon/intron/utr) from
BED/GTF/GFF are covered by chain alignment blocks on the selected side
(reference/query) in forward genomic coordinates. Reports per-chrom and
total coverage fractions.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*/

process CHAINTOOLS_COVERAGE {
tag "$meta.id"
label 'process_low'

conda "${moduleDir}/environment.yml"
container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ?
'' :
'ghcr.io/alejandrogzi/chaintools:latest' }"

input:
tuple val(meta), path(chains)
path intervals
val side
val feature

output:
tuple val(meta), path("*.coverage.txt") , 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}"
"""
chaintools coverage \\
$args \\
--chains $chains \\
--side $side \\
--intervals $intervals \\
--feature $feature \\
--threads ${task.cpus} \\
> ${prefix}.coverage.txt

cat <<-END_VERSIONS > versions.yml
"${task.process}":
chaintools: \$( chaintools --version | sed 's/chaintools //g' )
END_VERSIONS
"""

stub:
def prefix = task.ext.prefix ?: "${meta.id}"
"""
touch ${prefix}.coverage.txt

cat <<-END_VERSIONS > versions.yml
"${task.process}":
chaintools: \$( chaintools --version | sed 's/chaintools //g' )
END_VERSIONS
"""
}
73 changes: 73 additions & 0 deletions modules/wdl/chaintools/coverage/main.wdl
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# Copyright (c) 2026 The Hiller Lab at the Senckenberg Gessellschaft für Naturforschung
# Distributed under the terms of the Apache License, Version 2.0.

# CHAINTOOLS_COVERAGE — Measure annotation feature coverage by aligned chain blocks.
# Measures how many bases of annotation features (cds/exon/intron/utr) from
# BED/GTF/GFF are covered by chain alignment blocks on the selected side
# (reference/query) in forward genomic coordinates. Reports per-chrom and
# total coverage fractions.

version 1.3

task coverage {
input {
Array[File] chains
File intervals
String side
String feature
Int threads = 1
String extra_args = ""
String prefix = ""
}

String out_prefix = if prefix == "" then "coverage" else prefix
String out_report = out_prefix + ".coverage.txt"

command <<<
set -euo pipefail

chaintools coverage \
--chains ~{sep=" " chains} \
--side ~{side} \
--intervals ~{intervals} \
--feature ~{feature} \
--threads ~{threads} \
~{extra_args} \
> ~{out_report}
>>>

output {
File report = out_report
}

requirements {
container: "ghcr.io/alejandrogzi/chaintools:latest"
}
}

workflow run {
input {
Array[File] chains
File intervals
String side
String feature
Int threads = 1
String extra_args = ""
String prefix = ""
}

call coverage {
input:
chains = chains,
intervals = intervals,
side = side,
feature = feature,
threads = threads,
extra_args = extra_args,
prefix = prefix
}

output {
File report = coverage.report
}
}
Loading