Skip to content

Commit 6034a2e

Browse files
authored
Merge pull request #146 from emreerhan/abyss
Added an abyss component to flowcraft, and added a new disableRR parameter to spades
2 parents 6bf0971 + 1972917 commit 6034a2e

File tree

6 files changed

+97
-6
lines changed

6 files changed

+97
-6
lines changed

changelog.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,15 @@
22

33
## Changes in upcoming release (`dev` branch)
44

5+
### Components changes
6+
7+
- Added new `disableRR` param in the `spades` component that disables repeat
8+
resolution
9+
10+
### New components
11+
12+
- Added component `abyss`.
13+
514
### Minor/Other changes
615

716
- Added removal of duplicate IDs from `reads_download` component input.
@@ -27,6 +36,7 @@ which is particularly useful in very large workflows.
2736
`mapping_patlas`.
2837

2938
### New components
39+
3040
- Added component `fast_ani`.
3141

3242
### Minor/Other changes

flowcraft/generator/components/assembly.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,11 @@ def __init__(self, **kwargs):
5858
"is only useful to remove temporary files in large "
5959
"workflows and prevents nextflow's resume functionality. "
6060
"Use with caution."
61+
},
62+
"disableRR": {
63+
"default": "false",
64+
"description":
65+
"disables repeat resolution stage of assembling."
6166
}
6267
}
6368

@@ -177,3 +182,37 @@ def __init__(self, **kwargs):
177182
"Use with caution."
178183
}
179184
}
185+
186+
class Abyss(Process):
187+
"""ABySS process template interface
188+
189+
This process is set with:
190+
191+
- ``input_type``: fastq
192+
- ``output_type``: assembly
193+
- ``ptype``: assembly
194+
195+
"""
196+
197+
def __init__(self, **kwargs):
198+
199+
super().__init__(**kwargs)
200+
201+
self.input_type = "fastq"
202+
self.output_type = "fasta"
203+
204+
self.params = {
205+
"abyssKmer": {
206+
"default": "96",
207+
"description":
208+
"kmer size for assembly."
209+
}
210+
}
211+
212+
self.directives = {"abyss": {
213+
"cpus": 4,
214+
"memory": "{ 5.GB * task.attempt }",
215+
"container": "flowcraft/abyss",
216+
"version": "2.1.1",
217+
"scratch": "true"
218+
}}

flowcraft/generator/engine.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555

5656

5757
process_map = {
58+
"abyss": assembly.Abyss,
5859
"abricate": annotation.Abricate,
5960
"assembly_mapping": ap.AssemblyMapping,
6061
"bowtie": mapping.Bowtie,
@@ -101,7 +102,8 @@
101102
"split_assembly": meta.SplitAssembly,
102103
"trimmomatic": readsqc.Trimmomatic,
103104
"true_coverage": readsqc.TrueCoverage,
104-
"viral_assembly": assembly.ViralAssembly
105+
"viral_assembly": assembly.ViralAssembly,
106+
"abyss": assembly.Abyss
105107
}
106108

107109
"""
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
2+
IN_abyss_kmer_{{ pid }} = Channel.value(params.abyssKmer{{ param_id }})
3+
4+
process abyss_{{ pid }} {
5+
6+
// Send POST request to platform
7+
{% include "post.txt" ignore missing %}
8+
9+
tag { sample_id }
10+
publishDir 'results/assembly/abyss_{{ pid }}/', pattern: '*-scaffolds.fa', mode: 'copy'
11+
12+
input:
13+
set sample_id, file(fastq_pair) from {{ input_channel }}
14+
val kmer from IN_abyss_kmer_{{ pid }}
15+
16+
output:
17+
set sample_id, file('*.fa') into {{ output_channel }}
18+
{% with task_name="abyss" %}
19+
{%- include "compiler_channels.txt" ignore missing -%}
20+
{% endwith %}
21+
22+
script:
23+
"abyss-pe in=\"${fastq_pair[0]} ${fastq_pair[1]}\" k=${kmer} name=${sample_id}"
24+
}
25+
26+
{{ forks }}

flowcraft/generator/templates/spades.nf

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@ if ( !params.spadesMinKmerCoverage{{ param_id }}.toString().isNumber()){
55
exit 1, "'spadesMinKmerCoverage{{ param_id }}' parameter must be a number. Provided value: '${params.spadesMinKmerCoverage{{ param_id }}}'"
66
}
77

8-
IN_spades_opts_{{ pid }} = Channel.value([params.spadesMinCoverage{{ param_id }},params.spadesMinKmerCoverage{{ param_id }}])
8+
IN_spades_opts_{{ pid }} = Channel.value(
9+
[params.spadesMinCoverage{{ param_id }},
10+
params.spadesMinKmerCoverage{{ param_id }}
11+
])
912

1013
if ( params.spadesKmers{{ param_id }}.toString().split(" ").size() <= 1 ){
1114
if (params.spadesKmers{{ param_id }}.toString() != 'auto'){
@@ -15,7 +18,10 @@ if ( params.spadesKmers{{ param_id }}.toString().split(" ").size() <= 1 ){
1518
IN_spades_kmers_{{pid}} = Channel.value(params.spadesKmers{{ param_id }})
1619

1720
clear = params.clearInput{{ param_id }} ? "true" : "false"
21+
disable_rr = params.disableRR{{ param_id }} ? "true" : "false"
22+
1823
checkpointClear_{{ pid }} = Channel.value(clear)
24+
disableRR_{{ pid }} = Channel.value(disable_rr)
1925

2026
process spades_{{ pid }} {
2127

@@ -32,6 +38,7 @@ process spades_{{ pid }} {
3238
val opts from IN_spades_opts_{{ pid }}
3339
val kmers from IN_spades_kmers_{{ pid }}
3440
val clear from checkpointClear_{{ pid }}
41+
val disable_rr from disableRR_{{ pid }}
3542

3643
output:
3744
set sample_id, file('*_spades*.fasta') into {{ output_channel }}

flowcraft/templates/spades.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ def __get_version_spades():
8585
MAX_LEN = int('$max_len'.strip())
8686
KMERS = '$kmers'.strip()
8787
CLEAR = '$clear'
88+
DISABLE_RR = '$disable_rr'
8889
OPTS = [x.strip() for x in '$opts'.strip("[]").split(",")]
8990
CLEAR = '$clear'
9091
logger.debug("Running {} with parameters:".format(
@@ -95,6 +96,7 @@ def __get_version_spades():
9596
logger.debug("KMERS: {}".format(KMERS))
9697
logger.debug("OPTS: {}".format(OPTS))
9798
logger.debug("CLEAR: {}".format(CLEAR))
99+
logger.debug("DISABLE_RR: {}".format(DISABLE_RR))
98100

99101

100102
def set_kmers(kmer_opt, max_read_len):
@@ -163,7 +165,7 @@ def clean_up(fastq):
163165

164166

165167
@MainWrapper
166-
def main(sample_id, fastq_pair, max_len, kmer, opts, clear):
168+
def main(sample_id, fastq_pair, max_len, kmer, opts, clear, disable_rr):
167169
"""Main executor of the spades template.
168170
169171
Parameters
@@ -182,7 +184,9 @@ def main(sample_id, fastq_pair, max_len, kmer, opts, clear):
182184
clear : str
183185
Can be either 'true' or 'false'. If 'true', the input fastq files will
184186
be removed at the end of the run, IF they are in the working directory
185-
187+
disable_rr : str
188+
Can either be 'true' or 'false'. If 'true', disables repeat resolution
189+
stage of assembling
186190
"""
187191

188192
logger.info("Starting spades")
@@ -217,6 +221,10 @@ def main(sample_id, fastq_pair, max_len, kmer, opts, clear):
217221
fastq_pair[1]
218222
]
219223

224+
# Disable RR?
225+
if disable_rr == 'true':
226+
cli += ['--disable-rr']
227+
220228
logger.debug("Running SPAdes subprocess with command: {}".format(cli))
221229

222230
p = subprocess.Popen(cli, stdout=PIPE, stderr=PIPE)
@@ -263,5 +271,4 @@ def main(sample_id, fastq_pair, max_len, kmer, opts, clear):
263271

264272

265273
if __name__ == '__main__':
266-
267-
main(SAMPLE_ID, FASTQ_PAIR, MAX_LEN, KMERS, OPTS, CLEAR)
274+
main(SAMPLE_ID, FASTQ_PAIR, MAX_LEN, KMERS, OPTS, CLEAR, DISABLE_RR)

0 commit comments

Comments
 (0)