Skip to content

Commit 97b50cd

Browse files
authored
Merge pull request #155 from sjackman/bandage-gfa
abyss, bandage, spades: Add GFA
2 parents 4c63ced + 80300b9 commit 97b50cd

File tree

6 files changed

+48
-55
lines changed

6 files changed

+48
-55
lines changed

changelog.md

+3
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ recipes, the `--recipe-list` and `--recipe-list-short` options were added.
1313

1414
- Added new `disableRR` param in the `spades` component that disables repeat
1515
resolution
16+
- The `abyss` and `spades` components emit GFA in a secondary channel.
17+
- The new `bandage` component can accept either FASTA from a primary channel
18+
or GFA from a secondary channel.
1619

1720
### New components
1821

flowcraft/generator/components/assembly.py

+2
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ def __init__(self, **kwargs):
2727
self.output_type = "fasta"
2828

2929
self.link_end.append({"link": "SIDE_max_len", "alias": "SIDE_max_len"})
30+
self.link_start.append("gfa1")
3031

3132
self.dependencies = ["integrity_coverage"]
3233

@@ -200,6 +201,7 @@ def __init__(self, **kwargs):
200201

201202
self.input_type = "fastq"
202203
self.output_type = "fasta"
204+
self.link_start.append("gfa1")
203205

204206
self.params = {
205207
"abyssKmer": {

flowcraft/generator/components/assembly_processing.py

+2
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,8 @@ def __init__(self, **kwargs):
247247
self.input_type = "fasta"
248248
self.output_type = None
249249

250+
self.link_end.append({"link": "gfa1", "alias": "gfa1"})
251+
250252
self.params = {
251253
"reference": {
252254
"default": "null",
+6-9
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,23 @@
1-
2-
IN_abyss_kmer_{{ pid }} = Channel.value(params.abyssKmer{{ param_id }})
3-
41
process abyss_{{ pid }} {
5-
6-
// Send POST request to platform
72
{% include "post.txt" ignore missing %}
83

94
tag { sample_id }
10-
publishDir 'results/assembly/abyss_{{ pid }}/', pattern: '*-scaffolds.fa', mode: 'copy'
5+
publishDir 'results/assembly/abyss_{{ pid }}/', pattern: '*-scaffolds.fa'
6+
publishDir 'results/assembly/abyss_{{ pid }}/', pattern: '*-scaffolds.gfa'
117

128
input:
139
set sample_id, file(fastq_pair) from {{ input_channel }}
14-
val kmer from IN_abyss_kmer_{{ pid }}
10+
val k from Channel.value(params.abyssKmer{{ param_id }})
1511

1612
output:
17-
set sample_id, file('*.fa') into {{ output_channel }}
13+
set sample_id, file('*-scaffolds.fa') into {{ output_channel }}
14+
file "*-scaffolds.gfa" into gfa1_{{ pid }}
1815
{% with task_name="abyss" %}
1916
{%- include "compiler_channels.txt" ignore missing -%}
2017
{% endwith %}
2118

2219
script:
23-
"abyss-pe in=\"${fastq_pair[0]} ${fastq_pair[1]}\" k=${kmer} name=${sample_id}"
20+
"abyss-pe name=${sample_id} graph=gfa k=${k} v=-v in=\"${fastq_pair[0]} ${fastq_pair[1]}\""
2421
}
2522

2623
{{ forks }}
+34-45
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,39 @@
1-
if (params.reference{{param_id}} != null) {
2-
process bandage_{{pid}} {
3-
{% include "post.txt" ignore missing %}
4-
5-
tag { sample_id }
6-
publishDir "reports/assembly/bandage_{{pid}}/$sample_id"
7-
8-
input:
9-
set sample_id, file(assembly) from {{input_channel}}
10-
file reference from Channel.fromPath(params.reference{{param_id}})
11-
12-
output:
13-
file "*.png"
14-
file "*.svg"
15-
{% with task_name="bandage" %}
16-
{%- include "compiler_channels.txt" ignore missing -%}
17-
{% endwith %}
18-
19-
script:
20-
"""
21-
time Bandage image $assembly ${assembly}.png >>.command.log 2>&1
22-
time Bandage image $assembly ${assembly}.svg >>.command.log 2>&1
23-
time Bandage image $assembly ${assembly}.ref.png --query $reference >>.command.log 2>&1
24-
time Bandage image $assembly ${assembly}.ref.svg --query $reference >>.command.log 2>&1
25-
"""
26-
}
27-
} else {
28-
process bandage_{{pid}} {
29-
{% include "post.txt" ignore missing %}
30-
31-
tag { sample_id }
32-
publishDir "reports/assembly/bandage_{{pid}}/$sample_id"
33-
34-
input:
35-
set sample_id, file(assembly) from {{input_channel}}
36-
37-
output:
38-
file "*.png"
39-
file "*.svg"
40-
{% with task_name="bandage" %}
41-
{%- include "compiler_channels.txt" ignore missing -%}
42-
{% endwith %}
43-
44-
script:
1+
// True when a GFA secondary channel is connected to this component.
2+
has_gfa1_{{pid}} = binding.hasVariable('gfa1_{{pid}}')
3+
4+
process bandage_{{pid}} {
5+
{% include "post.txt" ignore missing %}
6+
7+
tag { sample_id }
8+
publishDir "reports/assembly/bandage_{{pid}}/$sample_id"
9+
10+
input:
11+
set sample_id, file(fasta) from {{input_channel}}
12+
file gfa1 from has_gfa1_{{pid}} ? gfa1_{{pid}} : Channel.value("NA")
13+
file reference from params.reference{{param_id}} ?
14+
Channel.fromPath(params.reference{{param_id}}) :
15+
Channel.value("NA")
16+
17+
output:
18+
file "*.png"
19+
file "*.svg"
20+
{% with task_name="bandage" %}
21+
{%- include "compiler_channels.txt" ignore missing -%}
22+
{% endwith %}
23+
24+
script:
25+
// Use the GFA assembly when available and FASTA otherwise.
26+
assembly = has_gfa1_{{pid}} ? gfa1 : fasta
27+
command =
4528
"""
4629
time Bandage image $assembly ${assembly}.png >>.command.log 2>&1
4730
time Bandage image $assembly ${assembly}.svg >>.command.log 2>&1
4831
"""
49-
}
32+
if (params.reference{{param_id}})
33+
command +=
34+
"""
35+
time Bandage image $assembly ${assembly}.ref.png --query $reference >>.command.log 2>&1
36+
time Bandage image $assembly ${assembly}.ref.svg --query $reference >>.command.log 2>&1
37+
"""
38+
command
5039
}

flowcraft/generator/templates/spades.nf

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ process spades_{{ pid }} {
4343
output:
4444
set sample_id, file('*_spades*.fasta') into {{ output_channel }}
4545
file "*.fastg" optional true
46-
file "*.gfa" optional true
46+
file "*.gfa" into gfa1_{{ pid }}
4747
{% with task_name="spades" %}
4848
{%- include "compiler_channels.txt" ignore missing -%}
4949
{% endwith %}

0 commit comments

Comments
 (0)