LinuxCommandLibrary
GitHubF-DroidGoogle Play Store

snakefmt

Opinionated code formatter for Snakemake workflow files

TLDR

Format Snakefile
$ snakefmt [Snakefile]
copy
Check formatting
$ snakefmt --check [Snakefile]
copy
Format directory
$ snakefmt [workflow/]
copy
Show diff
$ snakefmt --diff [Snakefile]
copy
Set line length
$ snakefmt -l [100] [Snakefile]
copy
Format stdin
$ cat [Snakefile] | snakefmt -
copy
Verbose output
$ snakefmt -v [Snakefile]
copy

SYNOPSIS

snakefmt [--check] [--diff] [-l length] [options] files

DESCRIPTION

snakefmt is an opinionated code formatter for Snakemake workflow files. It enforces a consistent style across Snakefiles and associated rules files, handling both standard Python syntax and Snakemake-specific extensions like rule, checkpoint, and module blocks.The formatter is built on top of Python's black formatter, using the same default line length of 88 characters and similar formatting philosophy. It understands Snakemake's domain-specific syntax, correctly formatting rule parameters like input, output, params, and shell while preserving semantic meaning.Check mode (--check) verifies formatting without modifying files, returning a non-zero exit code if changes are needed, which is useful for CI pipelines. Diff mode (--diff) previews the exact changes that would be made before committing to them.

PARAMETERS

--check

Check only, no changes.
--diff
Show changes.
-l, --line-length N
Max line length.
-v, --verbose
Verbose output.
--include PATTERN
Regular expression for files to include when formatting directories.
--exclude PATTERN
Regular expression for files to exclude when formatting directories.
--config FILE
Read configuration from a pyproject.toml or .editorconfig file.
-
Read from stdin.

INSTALL

brew install snakefmt
copy
nix profile install nixpkgs#snakefmt
copy

CAVEATS

Snakemake-specific and not suitable for general Python files. Uses the same default line length (88) as black. Configuration can be set in pyproject.toml. May not handle all custom Snakemake wrappers or heavily templated rules gracefully.

HISTORY

snakefmt was created for the Snakemake workflow management system. It brings consistent formatting to bioinformatics pipelines.

SEE ALSO

snakemake(1), black(1), python(1), ruff(1), yapf(1)

Braincup
Open source brain training for math, memory and focus
Braincup mini-games
41 mini-games · Apache-2.0
No ads · No tracking
Play in browser
Download Braincup on the App StoreGet Braincup on Google PlayGet Braincup on F-Droid
276 stars
From the maker of Linux Command Library
Copied to clipboard
Braincup
Open source brain training for math, memory and focus. 41 mini-games, from mental arithmetic to Sudoku, N-Back and Solo Chess.
Apache-2.0 licensed · No ads · No tracking · No account
From the maker of Linux Command Library
Download Braincup on the App StoreGet Braincup on Google PlayGet Braincup on F-Droid