RAGTAG-SCAFFOLD

https://img.shields.io/github/issues-pr/snakemake/snakemake-wrappers/bio/ragtag/scaffold?label=version%20update%20pull%20requests

Homology-based assembly scaffolding.

URL: https://github.com/malonge/RagTag/wiki/scaffold

Example

This wrapper can be used in the following way:

rule scaffold:
    input:
        query="fasta/{query}.fasta",
        ref="fasta/{reference}.fasta",
    output:
        fasta="{query}_scaffold_{reference}/ragtag.scaffold.fasta",
        agp="{query}_scaffold_{reference}/ragtag.scaffold.agp",
        stats="{query}_scaffold_{reference}/ragtag.scaffold.stats",
    params:
        extra="",
    threads: 16
    log:
        "logs/ragtag/{query}_scaffold_{reference}.log",
    wrapper:
        "v4.6.0-24-g250dd3e/bio/ragtag/scaffold"

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.

Notes

Multiple threads can be used during Minimap/Unimap alignment.

Software dependencies

  • ragtag=2.1.0

Input/Output

Input:

  • ref: reference fasta file (uncompressed or bgzipped)

  • query: query fasta file (uncompressed or bgzipped)

Output:

  • fasta: The scaffolds in FASTA format, defined by the ordering and orientations of ragtag.scaffold.agp.

  • agp: The ordering and orientations of query sequences in AGP format.

  • stats: Summary statistics for the scaffolding process.

Params

  • extra: additional parameters

Authors

  • Curro Campuzano Jiménez

Code

"""Snakemake wrapper for ragtag-scaffold."""

__author__ = "Curro Campuzano Jiménez"
__copyright__ = "Copyright 2023, Curro Campuzano Jiménez"
__email__ = "campuzanocurro@gmail.com"
__license__ = "MIT"


from snakemake.shell import shell
import tempfile

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

assert snakemake.output.keys(), "Output must contain at least one named file."

valid_keys = ["agp", "fasta", "stats"]
for key in snakemake.output.keys():
    assert (
        key in valid_keys
    ), "Invalid key in output. Valid keys are: %r. Given: %r." % (valid_keys, key)

with tempfile.TemporaryDirectory() as tmpdir:
    shell(
        "ragtag.py scaffold"
        " {snakemake.input.ref}"
        " {snakemake.input.query}"
        " {extra}"
        " -o {tmpdir} -t {snakemake.threads}"
        " {log}"
    )

    for key in valid_keys:
        outfile = snakemake.output.get(key)
        if outfile:
            shell("mv {tmpdir}/ragtag.scaffold.{key} {outfile}")