nf-core_modules/software/last/train/main.nf
aleksandrabliznina b592cea30b
New last/train module to train alignment parameters. (#492)
* New last/train module to train alignment parameters.

The last-train command creates a parameter file that
will be used by last/lastal module for sequence alignment.
It takes indexed sequences and query sequences as input
and we use the metadata of both to create an id of the
parameter output file.

Submission of the LAST modules is discussed in more
details in the issue #464. For consistancy, we use LAST
version 1219 for this whole development and will upgrade later.

* Corrected files according to the nf-core v1.14 standards.

* Fixed function.nf file for the last-train module.

* Apply suggestions from code review

Co-authored-by: Harshil Patel <drpatelh@users.noreply.github.com>

* Find index name.

* Correct after the input channels were changed.

* Use double underscore as a name separator.

Single underscores can happen in ids, therefore, we would like to keep two underscores.

* Remove extra spaces.

* Fixed the passing of the "score matrix" line.

* Apply suggestions from code review

Co-authored-by: Harshil Patel <drpatelh@users.noreply.github.com>

* Update software/last/train/main.nf

Co-authored-by: Harshil Patel <drpatelh@users.noreply.github.com>
2021-05-19 08:37:08 +01:00

44 lines
1.4 KiB
Text

// Import generic module functions
include { initOptions; saveFiles; getSoftwareName } from './functions'
params.options = [:]
options = initOptions(params.options)
process LAST_TRAIN {
tag "$meta.id"
label 'process_high'
publishDir "${params.outdir}",
mode: params.publish_dir_mode,
saveAs: { filename -> saveFiles(filename:filename, options:params.options, publish_dir:getSoftwareName(task.process), meta:meta, publish_by_meta:['id']) }
conda (params.enable_conda ? "bioconda::last=1219" : null)
if (workflow.containerEngine == 'singularity' && !params.singularity_pull_docker_container) {
container "https://depot.galaxyproject.org/singularity/last:1219--h2e03b76_0"
} else {
container "quay.io/biocontainers/last:1219--h2e03b76_0"
}
input:
tuple val(meta), path(fastx)
path index
output:
tuple val(meta), path("*.par"), emit: param_file
path "*.version.txt" , emit: version
script:
def software = getSoftwareName(task.process)
def prefix = options.suffix ? "${meta.id}${options.suffix}" : "${meta.id}"
"""
INDEX_NAME=`find -L lastdb/ -name "*.bck" | sed 's/.bck//' | sed 's,lastdb/,,'`
last-train \\
$options.args \\
-P $task.cpus \\
${index}/\$INDEX_NAME \\
$fastx \\
> ${prefix}.\$INDEX_NAME.par
lastdb --version | sed 's/lastdb //' > ${software}.version.txt
"""
}