-
Notifications
You must be signed in to change notification settings - Fork 187
/
main.nf
119 lines (110 loc) · 6.17 KB
/
main.nf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
{%- if not_empty_template -%}
// TODO nf-core: If in doubt look at other nf-core/modules to see how we are doing things! :)
// https://github.com/nf-core/modules/tree/master/modules/nf-core/
// You can also ask for help via your pull request or on the #modules channel on the nf-core Slack workspace:
// https://nf-co.re/join
// TODO nf-core: A module file SHOULD only define input and output files as command-line parameters.
// All other parameters MUST be provided using the "task.ext" directive, see here:
// https://www.nextflow.io/docs/latest/process.html#ext
// where "task.ext" is a string.
// Any parameters that need to be evaluated in the context of a particular sample
// e.g. single-end/paired-end data MUST also be defined and evaluated appropriately.
// TODO nf-core: Software that can be piped together SHOULD be added to separate module files
// unless there is a run-time, storage advantage in implementing in this way
// e.g. it's ok to have a single module for bwa to output BAM instead of SAM:
// bwa mem | samtools view -B -T ref.fasta
// TODO nf-core: Optional inputs are not currently supported by Nextflow. However, using an empty
// list (`[]`) instead of a file can be used to work around this issue.
{%- endif %}
process {{ component_name_underscore|upper }} {
tag {{ '"$meta.id"' if has_meta else "'$bam'" }}
label '{{ process_label }}'
{% if not_empty_template -%}
// TODO nf-core: List required Conda package(s).
// Software MUST be pinned to channel (i.e. "bioconda"), version (i.e. "1.10").
// For Conda, the build (i.e. "h9402c20_2") must be EXCLUDED to support installation on different operating systems.
// TODO nf-core: See section in main README for further information regarding finding and adding container addresses to the section below.
{% endif -%}
conda "${moduleDir}/environment.yml"
container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ?
'{{ singularity_container if singularity_container else 'https://depot.galaxyproject.org/singularity/YOUR-TOOL-HERE' }}':
'{{ docker_container if docker_container else 'biocontainers/YOUR-TOOL-HERE' }}' }"
input:
{% if not_empty_template -%}
// TODO nf-core: Where applicable all sample-specific information e.g. "id", "single_end", "read_group"
// MUST be provided as an input via a Groovy Map called "meta".
// This information may not be required in some instances e.g. indexing reference genome files:
// https://github.com/nf-core/modules/blob/master/modules/nf-core/bwa/index/main.nf
// TODO nf-core: Where applicable please provide/convert compressed files as input/output
// e.g. "*.fastq.gz" and NOT "*.fastq", "*.bam" and NOT "*.sam" etc.
{{ 'tuple val(meta), path(bam)' if has_meta else 'path bam' }}
{%- else -%}
{{ 'tuple val(meta), path(input)' if has_meta else 'path input' }}
{%- endif %}
output:
{% if not_empty_template -%}
// TODO nf-core: Named file extensions MUST be emitted for ALL output channels
{{ 'tuple val(meta), path("*.bam")' if has_meta else 'path "*.bam"' }}, emit: bam
{%- else -%}
{{ 'tuple val(meta), path("*")' if has_meta else 'path "*"' }}, emit: output
{%- endif %}
{% if not_empty_template -%}
// TODO nf-core: List additional required output channels/values here
{%- endif %}
path "versions.yml" , emit: versions
when:
task.ext.when == null || task.ext.when
script:
def args = task.ext.args ?: ''
{% if has_meta -%}
def prefix = task.ext.prefix ?: "${meta.id}"
{%- endif %}
{% if not_empty_template -%}
// TODO nf-core: Where possible, a command MUST be provided to obtain the version number of the software e.g. 1.10
// If the software is unable to output a version number on the command-line then it can be manually specified
// e.g. https://github.com/nf-core/modules/blob/master/modules/nf-core/homer/annotatepeaks/main.nf
// Each software used MUST provide the software name and version number in the YAML version file (versions.yml)
// TODO nf-core: It MUST be possible to pass additional parameters to the tool as a command-line string via the "task.ext.args" directive
// TODO nf-core: If the tool supports multi-threading then you MUST provide the appropriate parameter
// using the Nextflow "task" variable e.g. "--threads $task.cpus"
// TODO nf-core: Please replace the example samtools command below with your module's command
// TODO nf-core: Please indent the command appropriately (4 spaces!!) to help with readability ;)
{%- endif %}
"""
{% if not_empty_template -%}
samtools \\
sort \\
$args \\
-@ $task.cpus \\
{%- if has_meta %}
-o ${prefix}.bam \\
-T $prefix \\
{%- endif %}
$bam
{%- endif %}
cat <<-END_VERSIONS > versions.yml
"${task.process}":
{{ component }}: \$(samtools --version |& sed '1!d ; s/samtools //')
END_VERSIONS
"""
stub:
def args = task.ext.args ?: ''
{% if has_meta -%}
def prefix = task.ext.prefix ?: "${meta.id}"
{%- endif %}
{% if not_empty_template -%}
// TODO nf-core: A stub section should mimic the execution of the original module as best as possible
// Have a look at the following examples:
// Simple example: https://github.com/nf-core/modules/blob/818474a292b4860ae8ff88e149fbcda68814114d/modules/nf-core/bcftools/annotate/main.nf#L47-L63
// Complex example: https://github.com/nf-core/modules/blob/818474a292b4860ae8ff88e149fbcda68814114d/modules/nf-core/bedtools/split/main.nf#L38-L54
{%- endif %}
"""
{% if not_empty_template -%}
touch ${prefix}.bam
{%- endif %}
cat <<-END_VERSIONS > versions.yml
"${task.process}":
{{ component }}: \$(samtools --version |& sed '1!d ; s/samtools //')
END_VERSIONS
"""
}