GFATOOLS

Tools for manipulating sequence graphs in the GFA and rGFA formats

URL: https://github.com/lh3/gfatools

Example

This wrapper can be used in the following way:

rule gfatools_stat:
    input:
        "{sample}.gfa",
    output:
        "{sample}.stat",
    log:
        "logs/{sample}.stat.log",
    params:
        command="stat",
    wrapper:
        "v1.14.1-1-gad41354/bio/gfatools"


rule gfatools_gfa2fa:
    input:
        "{sample}.gfa",
    output:
        "{sample}.fas",
    log:
        "logs/{sample}.gfa2fa.log",
    params:
        command="gfa2fa",
    extra="-l 90",
    wrapper:
        "v1.14.1-1-gad41354/bio/gfatools"


rule gfatools_gfa2bed:
    input:
        "{sample}.gfa",
    output:
        "{sample}.bed",
    log:
        "logs/{sample}.gfa2bed.log",
    params:
        command="gfa2bed",
    wrapper:
        "v1.14.1-1-gad41354/bio/gfatools"


rule gfatools_blacklist:
    input:
        "{sample}.gfa",
    output:
        "{sample}.blacklist",
    log:
        "logs/{sample}.blacklist.log",
    params:
        command="blacklist",
    extra="-l 100",
    wrapper:
        "v1.14.1-1-gad41354/bio/gfatools"


rule gfatools_bubble:
    input:
        "{sample}.gfa",
    output:
        "{sample}.bubble",
    log:
        "logs/{sample}.bubble.log",
    params:
        command="bubble",
    wrapper:
        "v1.14.1-1-gad41354/bio/gfatools"


rule gfatools_asm:
    input:
        "{sample}.gfa",
    output:
        "{sample}.asm",
    log:
        "logs/{sample}.asm.log",
    params:
        command="asm",
    extra="-u",
    wrapper:
        "v1.14.1-1-gad41354/bio/gfatools"


rule gfatools_sql:
    input:
        "{sample}.gfa",
    output:
        "{sample}.sql",
    log:
        "logs/{sample}.sql.log",
    params:
        command="sql",
    wrapper:
        "v1.14.1-1-gad41354/bio/gfatools"

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

  • The command param allows to specify how to do with the GFA: view [default], stat, gfa2fa, gfa2bed, blacklist, bubble, asm, sql, or version.

Software dependencies

  • gfatools=0.5

Input/Output

Input:

  • GFA file

Output:

  • GFA/stats/FAS/BED/ASM/SQL/TXT (depends on command)

Authors

  • Filipe G. Vieira

Code

__author__ = "Filipe G. Vieira"
__copyright__ = "Copyright 2022, Filipe G. Vieira"
__license__ = "MIT"


from snakemake.shell import shell


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


command = snakemake.params.get("command", "view")
assert command in [
    "view",
    "stat",
    "gfa2fa",
    "gfa2bed",
    "blacklist",
    "bubble",
    "asm",
    "sql",
    "version",
], "invalid command specified."


shell("gfatools {command} {extra} {snakemake.input[0]} > {snakemake.output[0]} {log}")