Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
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
10 changes: 10 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@

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

### Components changes

- Added new `disableRR` param in the `spades` component that disables repeat
resolution

### New components

- Added component `abyss`.

### Minor/Other changes

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

### New components

- Added component `fast_ani`.

### Minor/Other changes
Expand Down
39 changes: 39 additions & 0 deletions flowcraft/generator/components/assembly.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ def __init__(self, **kwargs):
"is only useful to remove temporary files in large "
"workflows and prevents nextflow's resume functionality. "
"Use with caution."
},
"disableRR": {
"default": "false",
"description":
"disables repeat resolution stage of assembling."
}
}

Expand Down Expand Up @@ -177,3 +182,37 @@ def __init__(self, **kwargs):
"Use with caution."
}
}

class Abyss(Process):
"""ABySS process template interface

This process is set with:

- ``input_type``: fastq
- ``output_type``: assembly
- ``ptype``: assembly

"""

def __init__(self, **kwargs):

super().__init__(**kwargs)

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

self.params = {
"abyssKmer": {
"default": "96",
"description":
"kmer size for assembly."
}
}

self.directives = {"abyss": {
"cpus": 4,
"memory": "{ 5.GB * task.attempt }",
"container": "flowcraft/abyss",
"version": "2.1.1",
"scratch": "true"
}}
4 changes: 3 additions & 1 deletion flowcraft/generator/engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@


process_map = {
"abyss": assembly.Abyss,
"abricate": annotation.Abricate,
"assembly_mapping": ap.AssemblyMapping,
"bowtie": mapping.Bowtie,
Expand Down Expand Up @@ -101,7 +102,8 @@
"split_assembly": meta.SplitAssembly,
"trimmomatic": readsqc.Trimmomatic,
"true_coverage": readsqc.TrueCoverage,
"viral_assembly": assembly.ViralAssembly
"viral_assembly": assembly.ViralAssembly,
"abyss": assembly.Abyss
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Although this will probably be refactored according to #145 , can you keep the alphabetical order for now?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

}

"""
Expand Down
26 changes: 26 additions & 0 deletions flowcraft/generator/templates/abyss.nf
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@

IN_abyss_kmer_{{ pid }} = Channel.value(params.abyssKmer{{ param_id }})

process abyss_{{ pid }} {

// Send POST request to platform
{% include "post.txt" ignore missing %}

tag { sample_id }
publishDir 'results/assembly/abyss_{{ pid }}/', pattern: '*-scaffolds.fa', mode: 'copy'

input:
set sample_id, file(fastq_pair) from {{ input_channel }}
val kmer from IN_abyss_kmer_{{ pid }}

output:
set sample_id, file('*.fa') into {{ output_channel }}
{% with task_name="abyss" %}
{%- include "compiler_channels.txt" ignore missing -%}
{% endwith %}

script:
"abyss-pe in=\"${fastq_pair[0]} ${fastq_pair[1]}\" k=${kmer} name=${sample_id}"
}

{{ forks }}
9 changes: 8 additions & 1 deletion flowcraft/generator/templates/spades.nf
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ if ( !params.spadesMinKmerCoverage{{ param_id }}.toString().isNumber()){
exit 1, "'spadesMinKmerCoverage{{ param_id }}' parameter must be a number. Provided value: '${params.spadesMinKmerCoverage{{ param_id }}}'"
}

IN_spades_opts_{{ pid }} = Channel.value([params.spadesMinCoverage{{ param_id }},params.spadesMinKmerCoverage{{ param_id }}])
IN_spades_opts_{{ pid }} = Channel.value(
[params.spadesMinCoverage{{ param_id }},
params.spadesMinKmerCoverage{{ param_id }}
])

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

clear = params.clearInput{{ param_id }} ? "true" : "false"
disable_rr = params.disableRR{{ param_id }} ? "true" : "false"

checkpointClear_{{ pid }} = Channel.value(clear)
disableRR_{{ pid }} = Channel.value(disable_rr)

process spades_{{ pid }} {

Expand All @@ -32,6 +38,7 @@ process spades_{{ pid }} {
val opts from IN_spades_opts_{{ pid }}
val kmers from IN_spades_kmers_{{ pid }}
val clear from checkpointClear_{{ pid }}
val disable_rr from disableRR_{{ pid }}

output:
set sample_id, file('*_spades*.fasta') into {{ output_channel }}
Expand Down
15 changes: 11 additions & 4 deletions flowcraft/templates/spades.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ def __get_version_spades():
MAX_LEN = int('$max_len'.strip())
KMERS = '$kmers'.strip()
CLEAR = '$clear'
DISABLE_RR = '$disable_rr'
OPTS = [x.strip() for x in '$opts'.strip("[]").split(",")]
CLEAR = '$clear'
logger.debug("Running {} with parameters:".format(
Expand All @@ -95,6 +96,7 @@ def __get_version_spades():
logger.debug("KMERS: {}".format(KMERS))
logger.debug("OPTS: {}".format(OPTS))
logger.debug("CLEAR: {}".format(CLEAR))
logger.debug("DISABLE_RR: {}".format(DISABLE_RR))


def set_kmers(kmer_opt, max_read_len):
Expand Down Expand Up @@ -163,7 +165,7 @@ def clean_up(fastq):


@MainWrapper
def main(sample_id, fastq_pair, max_len, kmer, opts, clear):
def main(sample_id, fastq_pair, max_len, kmer, opts, clear, disable_rr):
"""Main executor of the spades template.

Parameters
Expand All @@ -182,7 +184,9 @@ def main(sample_id, fastq_pair, max_len, kmer, opts, clear):
clear : str
Can be either 'true' or 'false'. If 'true', the input fastq files will
be removed at the end of the run, IF they are in the working directory

disable_rr : str
Can either be 'true' or 'false'. If 'true', disables repeat resolution
stage of assembling
"""

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

# Disable RR?
if disable_rr == 'true':
cli += ['--disable-rr']

logger.debug("Running SPAdes subprocess with command: {}".format(cli))

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


if __name__ == '__main__':

main(SAMPLE_ID, FASTQ_PAIR, MAX_LEN, KMERS, OPTS, CLEAR)
main(SAMPLE_ID, FASTQ_PAIR, MAX_LEN, KMERS, OPTS, CLEAR, DISABLE_RR)