Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unicycler: Add parameter --long_reads #158

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,13 @@ resolution
- The `abyss` and `spades` components emit GFA in a secondary channel.
- The new `bandage` component can accept either FASTA from a primary channel
or GFA from a secondary channel.
- The new `unicycler` component can accept long reads from a secondary channel.

### New components

- Added component `abyss`.
- Added component `bandage`.
- Added component `porechop`.
- Added component `unicycler`.

### Minor/Other changes
Expand Down
9 changes: 9 additions & 0 deletions flowcraft/generator/components/assembly.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,8 +236,17 @@ def __init__(self, **kwargs):

self.input_type = "fastq"
self.output_type = "fasta"

self.link_end.append({"link": "long_reads", "alias": "long_reads"})
self.link_start.append("gfa1")

self.params = {
"long_reads": {
"default": "null",
"description": "FASTQ or FASTA file of long reads"
},
}

self.directives = {"unicycler": {
"cpus": 4,
"container": "quay.io/biocontainers/unicycler",
Expand Down
34 changes: 34 additions & 0 deletions flowcraft/generator/components/reads_quality_control.py
Original file line number Diff line number Diff line change
Expand Up @@ -433,3 +433,37 @@ def __init__(self, **kwargs):
self.status_channels = [
"downsample_fastq"
]

class Porechop(Process):
"""Porechop trims adapters from Oxford Nanopore reads.

This process is set with:

- ``input_type``: fastq
- ``output_type``: fastq
- ``ptype``: pre_assembly
"""

def __init__(self, **kwargs):
super().__init__(**kwargs)

self.input_type = "fastq"
self.output_type = "fastq"

self.link_end.append({"link": "raw_long_reads", "alias": "raw_long_reads"})
self.link_start.append("long_reads")

self.params = {
"long_reads": {
"default": "null",
"description": "FASTQ or FASTA file of long reads"
},
}

self.directives = {
"porechop": {
"cpus": 4,
"container": "quay.io/biocontainers/porechop",
"version": "0.2.3_seqan2.1.1--py36h2d50403_3"
}
}
1 change: 1 addition & 0 deletions flowcraft/generator/engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@
"momps": typing.Momps,
"patho_typing": typing.PathoTyping,
"pilon": ap.Pilon,
"porechop": readsqc.Porechop,
"process_skesa": ap.ProcessSkesa,
"process_spades": ap.ProcessSpades,
"progressive_mauve":alignment.ProgressiveMauve,
Expand Down
28 changes: 28 additions & 0 deletions flowcraft/generator/templates/porechop.nf
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// True when a raw_long_reads secondary channel is connected to this component.
has_raw_long_reads_{{pid}} = binding.hasVariable('raw_long_reads_{{pid}}')

process porechop_{{pid}} {
{% include "post.txt" ignore missing %}

publishDir "results/porechop_{{pid}}", pattern: "*.fastq.gz"
publishDir "reports/porechop_{{pid}}", pattern: "*.log"

tag { sample_id }

input:
set sample_id, file(fastq_pair) from {{input_channel}}
file raw_long_reads from has_raw_long_reads_{{pid}} ? raw_long_reads_{{pid}} :
Channel.fromPath(params.long_reads{{param_id}})

output:
set sample_id, file(fastq_pair) into {{output_channel}}
file "${sample_id}.porechop.fastq.gz" into long_reads_{{pid}}
{% with task_name="porechop" %}
{%- include "compiler_channels.txt" ignore missing -%}
{% endwith %}

script:
"time porechop -t $task.cpus --format fastq.gz -i ${raw_long_reads} -o ${sample_id}.porechop.fastq.gz >${sample_id}.log"
}

{{ forks }}
11 changes: 10 additions & 1 deletion flowcraft/generator/templates/unicycler.nf
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// True when a long_reads secondary channel is connected to this component.
has_long_reads_{{pid}} = binding.hasVariable('long_reads_{{pid}}')

process unicycler_{{pid}} {
{% include "post.txt" ignore missing %}

Expand All @@ -7,6 +10,9 @@ process unicycler_{{pid}} {

input:
set sample_id, file(fastq_pair) from {{input_channel}}
file long_reads from has_long_reads_{{pid}} ? long_reads_{{pid}} :
params.long_reads{{param_id}} ? Channel.fromPath(params.long_reads{{param_id}}) :
Channel.value("NA")

output:
set sample_id, file('assembly.fasta') into {{output_channel}}
Expand All @@ -16,7 +22,10 @@ process unicycler_{{pid}} {
{% endwith %}

script:
"unicycler -t $task.cpus -o . --no_correct --no_pilon -1 ${fastq_pair[0]} -2 ${fastq_pair[1]}"
command = "unicycler -t $task.cpus -o . --no_correct --no_pilon -1 ${fastq_pair[0]} -2 ${fastq_pair[1]}"
if (params.long_reads{{param_id}})
command += " -l ${long_reads}"
command
}

{{forks}}