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
65 changes: 65 additions & 0 deletions modules/nextflow/chaintools/score/main.nf
Original file line number Diff line number Diff line change
@@ -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
"""
}
66 changes: 66 additions & 0 deletions modules/wdl/chaintools/score/main.wdl
Original file line number Diff line number Diff line change
@@ -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
}
}
Loading