diff --git a/modules/nextflow/chaintools/score/main.nf b/modules/nextflow/chaintools/score/main.nf new file mode 100644 index 0000000..ea7ba5c --- /dev/null +++ b/modules/nextflow/chaintools/score/main.nf @@ -0,0 +1,65 @@ +/* +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_SCORE — Remove chains that are primiarily the result of + repeats of degenerated DNA. Output is a suffixed .scored.chain file. +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +*/ + +process CHAINTOOLS_SCORE { + 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(chain) + tuple val(meta1), path(reference) + tuple val(meta2), path(query) + + output: + tuple val(meta), path("*.scored.chain") , optional: true, emit: chain + tuple val(meta), path("*.scored.chain.gz") , optional: true, emit: chain_gz + 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 score \\ + $args \\ + --chain $chain \\ + --reference $reference \\ + --query $query \\ + --threads ${task.cpus} \\ + --sort-by-score \\ + --out-chain ${prefix}.scored.chain + + 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}.scored.chain + touch ${prefix}.scored.chain.gz + + cat <<-END_VERSIONS > versions.yml + "${task.process}": + chaintools: \$( chaintools --version | sed 's/chaintools //g' ) + END_VERSIONS + """ +} diff --git a/modules/wdl/chaintools/score/main.wdl b/modules/wdl/chaintools/score/main.wdl new file mode 100644 index 0000000..900fbdb --- /dev/null +++ b/modules/wdl/chaintools/score/main.wdl @@ -0,0 +1,66 @@ +# 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_SCORE — Remove chains that are primiarily the result of +# repeats of degenerated DNA. Output is a suffixed .scored.chain file. + +version 1.3 + +task score { + input { + File chain + File reference + File query + Int threads = 1 + String extra_args = "" + } + + String prefix = sub(basename(chain, ".gz"), "\\.chain$", "") + String out_chain = prefix + ".scored.chain" + + command <<< + set -euo pipefail + + chaintools score \ + --chain ~{chain} \ + --reference ~{reference} \ + --query ~{query} \ + --threads ~{threads} \ + --sort-by-score \ + --out-chain ~{out_chain} \ + ~{extra_args} + >>> + + output { + File scored_chain = out_chain + File scored_chain_gz = out_chain + ".gz" + } + + requirements { + container: "ghcr.io/alejandrogzi/chaintools:latest" + } +} + +workflow run { + input { + File chain + File reference + File query + Int threads = 1 + String extra_args = "" + } + + call score { + input: + chain = chain, + reference = reference, + query = query, + threads = threads, + extra_args = extra_args + } + + output { + File scored_chain = score.scored_chain + File scored_chain_gz = score.scored_chain_gz + } +}