kkonganti@1
|
1 process KMA_ALIGN {
|
kkonganti@1
|
2 tag "$meta.id"
|
kkonganti@1
|
3 label 'process_micro'
|
kkonganti@1
|
4
|
kkonganti@1
|
5 module (params.enable_module ? "${params.swmodulepath}${params.fs}kma${params.fs}1.4.4" : null)
|
kkonganti@1
|
6 conda (params.enable_conda ? "conda-forge::libgcc-ng bioconda::kma=1.4.3" : null)
|
kkonganti@1
|
7 container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ?
|
kkonganti@1
|
8 'https://depot.galaxyproject.org/singularity/kma:1.4.3--h7132678_1':
|
kkonganti@1
|
9 'quay.io/biocontainers/kma:1.4.3--h7132678_1' }"
|
kkonganti@1
|
10
|
kkonganti@1
|
11 input:
|
kkonganti@1
|
12 tuple val(meta), path(reads), path(index)
|
kkonganti@1
|
13
|
kkonganti@1
|
14 output:
|
kkonganti@1
|
15 path "${meta.id}_kma_res"
|
kkonganti@1
|
16 tuple val(meta), path("${meta.id}_kma_res${params.fs}*.res") , emit: res
|
kkonganti@1
|
17 tuple val(meta), path("${meta.id}_kma_res${params.fs}*.mapstat") , emit: mapstat, optional: true
|
kkonganti@1
|
18 tuple val(meta), path("${meta.id}_kma_res${params.fs}*_template_hits.txt"), emit: hits, optional: true
|
kkonganti@1
|
19 path "versions.yml" , emit: versions
|
kkonganti@1
|
20
|
kkonganti@1
|
21 when:
|
kkonganti@1
|
22 task.ext.when == null || task.ext.when
|
kkonganti@1
|
23
|
kkonganti@1
|
24 script:
|
kkonganti@1
|
25 def args = task.ext.args ?: ''
|
kkonganti@1
|
26 def prefix = task.ext.prefix ?: "${meta.id}"
|
kkonganti@1
|
27 def reads_in = (meta.single_end ? "-i $reads" : "-ipe ${reads[0]} ${reads[1]}")
|
kkonganti@1
|
28 def db = (meta.kma_t_db ?: "${index}")
|
kkonganti@1
|
29 def db_basename = (db ? "${index.baseName}" : '')
|
kkonganti@1
|
30 def get_hit_accs = (meta.get_kma_hit_accs ? 'true' : 'false')
|
kkonganti@1
|
31 def res_dir = prefix + '_kma_res'
|
kkonganti@1
|
32 reads_in = (params.kmaalign_int ? "-int $reads" : "-i $reads")
|
kkonganti@1
|
33 """
|
kkonganti@1
|
34 mkdir -p $res_dir || exit 1
|
kkonganti@1
|
35 kma \\
|
kkonganti@1
|
36 $args \\
|
kkonganti@1
|
37 -t_db $db${params.fs}$db_basename \\
|
kkonganti@1
|
38 -t $task.cpus \\
|
kkonganti@1
|
39 -o $res_dir${params.fs}$prefix \\
|
kkonganti@1
|
40 $reads_in
|
kkonganti@1
|
41
|
kkonganti@1
|
42 if [ "$get_hit_accs" == "true" ]; then
|
kkonganti@1
|
43 grep -v '^#' $res_dir${params.fs}${prefix}.res | \\
|
kkonganti@1
|
44 cut -f1 > $res_dir${params.fs}${prefix}_template_hits.txt
|
kkonganti@1
|
45 fi
|
kkonganti@1
|
46
|
kkonganti@1
|
47 cat <<-END_VERSIONS > versions.yml
|
kkonganti@1
|
48 "${task.process}":
|
kkonganti@1
|
49 kma: \$( kma -v | sed -e 's%KMA-%%' )
|
kkonganti@1
|
50 END_VERSIONS
|
kkonganti@1
|
51
|
kkonganti@1
|
52 mkdirver=""
|
kkonganti@1
|
53 cutver=""
|
kkonganti@1
|
54 grepver=""
|
kkonganti@1
|
55
|
kkonganti@1
|
56 if [ "${workflow.containerEngine}" != "null" ]; then
|
kkonganti@1
|
57 mkdirver=\$( mkdir --help 2>&1 | sed -e '1!d; s/ (.*\$//' | cut -f1-2 -d' ' )
|
kkonganti@1
|
58 cutver="\$mkdirver"
|
kkonganti@1
|
59 grepver="\$mkdirver"
|
kkonganti@1
|
60 else
|
kkonganti@1
|
61 mkdirver=\$( mkdir --version 2>&1 | sed '1!d; s/^.*(GNU coreutils//; s/) //;' )
|
kkonganti@1
|
62 cutver=\$( cut --version 2>&1 | sed '1!d; s/^.*(GNU coreutils//; s/) //;' )
|
kkonganti@1
|
63 grepver=\$( echo \$(grep --version 2>&1) | sed 's/^.*(GNU grep) //; s/ Copyright.*\$//' )
|
kkonganti@1
|
64 fi
|
kkonganti@1
|
65
|
kkonganti@1
|
66 cat <<-END_VERSIONS >> versions.yml
|
kkonganti@1
|
67 mkdir: \$mkdirver
|
kkonganti@1
|
68 cut: \$cutver
|
kkonganti@1
|
69 grep: \$grepver
|
kkonganti@1
|
70 END_VERSIONS
|
kkonganti@1
|
71 """
|
kkonganti@1
|
72 } |