kkonganti@11
|
1 process SOURMASH_SIG_KMERS {
|
kkonganti@11
|
2 tag "$meta.id"
|
kkonganti@11
|
3 label 'process_micro'
|
kkonganti@11
|
4
|
kkonganti@11
|
5 module (params.enable_module ? "${params.swmodulepath}${params.fs}sourmash${params.fs}4.6.1" : null)
|
kkonganti@11
|
6 conda (params.enable_conda ? "conda-forge::python bioconda::sourmash=4.6.1" : null)
|
kkonganti@11
|
7 container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ?
|
kkonganti@11
|
8 'https://depot.galaxyproject.org/singularity/sourmash:4.6.1--hdfd78af_0' :
|
kkonganti@11
|
9 'quay.io/biocontainers/sourmash:4.6.1--hdfd78af_0' }"
|
kkonganti@11
|
10
|
kkonganti@11
|
11 input:
|
kkonganti@11
|
12 tuple val(meta), path(sig_or_seq), path(sequence)
|
kkonganti@11
|
13
|
kkonganti@11
|
14 output:
|
kkonganti@11
|
15 tuple val(meta), path("*.csv") , emit: signatures, optional: true
|
kkonganti@11
|
16 tuple val(meta), path("*.fasta"), emit: extracted_fasta, optional: true
|
kkonganti@11
|
17 path "versions.yml" , emit: versions
|
kkonganti@11
|
18
|
kkonganti@11
|
19 when:
|
kkonganti@11
|
20 task.ext.when == null || task.ext.when
|
kkonganti@11
|
21
|
kkonganti@11
|
22 script:
|
kkonganti@11
|
23 // required defaults for the tool to run, but can be overridden
|
kkonganti@11
|
24 def args = task.ext.args ?: ''
|
kkonganti@11
|
25 def is_seq = "${sig_or_seq.baseName.findAll(/(?i)\.(fa|fasta|fna)\.{0,1}(gz){0,1}$/).size()}"
|
kkonganti@11
|
26 def save_kmers = (params.sourmashsigkmers_save_kmers ? "--save-kmers ${meta.id}.sm.kmers.csv" : '')
|
kkonganti@11
|
27 def save_seqs = (params.sourmashsigkmers_save_seqs ? "--save-sequences ${meta.id}.sm.seq.fasta" : '')
|
kkonganti@11
|
28 def sketch_mode = (params.sourmashsketch_mode ?: 'dna')
|
kkonganti@11
|
29 def sketch_p = (params.sourmashsketch_p ?: "abund,scaled=1000,k=71")
|
kkonganti@11
|
30 def prefix = task.ext.prefix ?: "${meta.id}"
|
kkonganti@11
|
31 """
|
kkonganti@11
|
32 db_sig="${sig_or_seq}"
|
kkonganti@11
|
33 if [[ $is_seq -ge 1 ]]; then
|
kkonganti@11
|
34 db_sig="${prefix}.db.sig"
|
kkonganti@11
|
35 sourmash sketch \\
|
kkonganti@11
|
36 $sketch_mode \\
|
kkonganti@11
|
37 -p '$sketch_p' \\
|
kkonganti@11
|
38 --output \$db_sig \\
|
kkonganti@11
|
39 $sig_or_seq
|
kkonganti@11
|
40 fi
|
kkonganti@11
|
41
|
kkonganti@11
|
42 sourmash signature kmers \\
|
kkonganti@11
|
43 $args \\
|
kkonganti@11
|
44 $save_kmers \\
|
kkonganti@11
|
45 $save_seqs \\
|
kkonganti@11
|
46 --signatures \$db_sig \\
|
kkonganti@11
|
47 --sequences $sequence
|
kkonganti@11
|
48
|
kkonganti@11
|
49 cat <<-END_VERSIONS > versions.yml
|
kkonganti@11
|
50 "${task.process}":
|
kkonganti@11
|
51 sourmash: \$(echo \$(sourmash --version 2>&1) | sed 's/^sourmash //' )
|
kkonganti@11
|
52 bash: \$( bash --version 2>&1 | sed '1!d; s/^.*version //; s/ (.*\$//' )
|
kkonganti@11
|
53 END_VERSIONS
|
kkonganti@11
|
54 """
|
kkonganti@11
|
55 } |