UNICYCLER

Assemble bacterial genomes with Unicycler.

You may find additional information on Unicycler’s github page.

Example

This wrapper can be used in the following way:

rule test_unicycler:
    input:
        # R1 and R2 short reads:
        paired = expand(
            "reads/{sample}.{read}.fq.gz",
            read=["R1", "R2"],
            allow_missing=True
        )
        # Long reads:
        # long = long_reads/{sample}.fq.gz
        # Unpaired reads:
        # unpaired = reads/{sample}.fq.gz
    output:
        "result/{sample}/assembly.fasta"
    log:
        "logs/{sample}.log"
    params:
        extra=""
    wrapper:
        "0.75.0-13-g0997adf/bio/unicycler"

Note that input, output and log file paths can be chosen freely. When running with

snakemake --use-conda

the software dependencies will be automatically deployed into an isolated environment before execution.

Software dependencies

  • bowtie2==2.4.1
  • bcftools==1.10.2
  • spades==3.14.1
  • samtools==1.10
  • pilon==1.23
  • racon==1.4.13
  • blast==2.10.1
  • unicycler==0.4.8

Input/Output

Input:

  • Fastq-formatted reads

Output:

  • Assembled reads

Authors

  • Thibault Dayris

Code

"""Snakemake wrapper for Unicycler"""

__author__ = "Thibault Dayris"
__copyright__ = "Copyright 2020, Dayris Thibault"
__email__ = "thibault.dayris@gustaveroussy.fr"
__license__ = "MIT"

from os.path import dirname
from snakemake.shell import shell

log = snakemake.log_fmt_shell(stdout=False, stderr=True)
extra = snakemake.params.get("extra", "")

input_reads = ""
if "paired" in snakemake.input.keys():
    input_reads += " --short1 {} --short2 {}".format(*snakemake.input.paired)
if "unpaired" in snakemake.input.keys():
    input_reads += " --unpaired {} ".format(snakemake.input["unpaired"])
if "long" in snakemake.input.keys():
    input_reads += " --long {} ".format(snakemake.input["long"])

output_dir = " --out {} ".format(dirname(snakemake.output[0]))

shell(
    " unicycler "
    " {input_reads} "
    " --threads {snakemake.threads} "
    " {output_dir} "
    " {extra} "
    " {log} "
)