nf-core_modules/modules/ampir/main.nf

49 lines
1.8 KiB
Text
Raw Normal View History

2022-05-25 11:27:10 +00:00
process AMPIR {
tag "$meta.id"
label 'process_single'
2022-05-25 11:27:10 +00:00
conda (params.enable_conda ? "conda-forge::r-ampir=1.1.0" : null)
container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ?
'https://depot.galaxyproject.org/singularity/r-ampir:1.1.0':
'quay.io/biocontainers/r-ampir:1.1.0' }"
input:
tuple val(meta), path(faa)
val model
2022-06-09 14:59:00 +00:00
val min_length
val min_probability
2022-05-25 11:27:10 +00:00
output:
2022-06-09 13:37:35 +00:00
tuple val(meta), path("*.faa"), emit: amps_faa
2022-06-10 12:46:58 +00:00
tuple val(meta), path("*.tsv"), emit: amps_tsv
2022-06-09 13:37:35 +00:00
path "versions.yml" , emit: versions
2022-05-25 11:27:10 +00:00
when:
task.ext.when == null || task.ext.when
script:
def args = task.ext.args ?: ''
def prefix = task.ext.prefix ?: "${meta.id}"
2022-06-09 14:59:00 +00:00
min_length = ("${min_length}" == "[]") ? "": " min_len = as.integer(${min_length})," // Fall back to AMPir default value if none specified
if ("$faa" == "${prefix}.faa") error "Input and output names are the same, set prefix in module configuration to disambiguate!"
2022-05-25 11:27:10 +00:00
"""
#!/usr/bin/env Rscript
library(ampir)
2022-06-09 14:59:00 +00:00
input_seqs <- read_faa('${faa}')
prediction <- predict_amps(input_seqs,${min_length} model = '${model}')
prediction <- prediction[which(prediction\$prob_AMP >= as.numeric(${min_probability})), ]
output_seqs <- input_seqs[row.names(prediction), ]
write.table(prediction, file = "${prefix}.tsv", row.names = FALSE, sep = "\t", quote = FALSE, dec = '.')
2022-06-09 14:59:00 +00:00
df_to_faa(output_seqs, "${prefix}.faa")
2022-05-25 11:27:10 +00:00
version_file_path <- "versions.yml"
version_ampir <- paste(unlist(packageVersion("ampir")), collapse = ".")
f <- file(version_file_path, "w")
writeLines('"${task.process}":', f)
writeLines(" ampir: ", f, sep = "")
writeLines(version_ampir, f)
close(f)
"""
}