SED

https://img.shields.io/badge/wrapper_version-v9.8.0-10785b https://img.shields.io/github/issues-pr/snakemake/snakemake-wrappers/utils/sed?label=version%20update%20pull%20requests&color=1cb481

sed (stream editor) is a non-interactive command-line text editor. For a helpful introduction, see the tutorial by Bruce Barnett.

URL: https://www.gnu.org/software/sed/

Example

This wrapper can be used in the following way:

rule test_sed:
    input:
        "table.csv",
    output:
        "out/sed.csv",
    log:
        "logs/sed.log",
    threads: 1
    params:
        expr="s/ENSG02/ENSG03/",
        extra="",
    wrapper:
        "v9.8.0/utils/sed"


rule test_sed_regex:
    input:
        "table.csv",
    output:
        "out/sed_regex.csv",
    log:
        "logs/sed_regex.log",
    threads: 1
    params:
        expr=r"s/ENSG0([0-9])/ENSG\1/",
        extra="-r",
    wrapper:
        "v9.8.0/utils/sed"

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

  • sed=4.10

Input/Output

Input:

  • Path to input file.

Output:

  • Path to output file.

Params

  • expr: SED expression to execute.

  • extra: Optional arguments for sed.

Authors

  • Filipe G. Vieira

Code

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

from snakemake.shell import shell

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

shell(
    "sed {extra} {snakemake.params.expr:q} {snakemake.input[0]} > {snakemake.output[0]} {log}"
)