snakemake-rule

Generate and debug Snakemake rules following project conventions for logs, conda envs, and resources.

1|Updated Oct 25, 2020
One-click install
npx skills add https://github.com/bfairkun/dotfiles --skill snakemake-rule-bfairkun
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: snakemake-rule
Source: https://github.com/bfairkun/dotfiles/tree/main/agents/.agents/skills/snakemake-rule
Command: npx skills add https://github.com/bfairkun/dotfiles --skill snakemake-rule-bfairkun

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Writing Snakemake rules that follow consistent project conventions is error-prone: missing log directives, wrong relative paths, conda env naming collisions, and cluster failures that are hard to diagnose. This Skill encodes the project's rule-writing standards so every new or edited rule is correct and testable before cluster submission. ## Core Features & Use Cases - Convention-Compliant Rule Generation: Creates rules with mandatory log: directives, stdout/stderr redirection, correct code/-relative paths, conda env references, and mem_mb/threads resource settings. - Pre-Submission Testing Workflow: Enforces a three-step local validation process (verify conda env imports, run the script on the smallest sample, target a single output) before submitting all samples to Slurm. - Cluster Failure Debugging: Diagnoses Slurm errors including OOM kills, missing sbatch in PATH, shadow-prefix permission errors, and unexpected re-runs caused by log directive changes. - Use Case: You need to add a rule that counts reads per sample from BAM files. The Skill generates the rule with proper wildcards, logging, and conda env, then walks you through testing it on one small sample before scaling to the full dataset. ## Quick Start Ask the AI to add a new Snakemake rule in code/rules/ that processes your input files, following the project conventions for logging and conda environments.

Frequently Asked Questions about snakemake-rule

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I write a Snakemake rule with proper logging?▼

Every rule needs a log: directive pointing to a file like ../logs/rule_name.{sample}.log, and the shell command must redirect both stdout and stderr to it. Use >{output} 2>{log} for data on stdout, or >{log} 2>&1 when data goes to a file via a script flag.

How to test a Snakemake rule before submitting to Slurm?▼

First validate the conda env has required packages with conda run -n <env> python -c "import ...". Then run the script directly on the smallest sample, and finally target a single output with snakemake --profile before submitting all samples.

Why does Snakemake re-run rules after adding a log directive?▼

Adding or changing a log: directive changes the rule's code hash, which Snakemake interprets as a modification. This triggers re-execution of that rule and all downstream rules that depend on its outputs.

How do I diagnose OOM kills in Snakemake Slurm jobs?▼

Check sacct for ExitCode with MaxRSS near the ReqMem ceiling, which indicates an OOM kill. For tools like samtools sort -m that overshoot memory by ~50%, set mem_mb to at least threads times per-thread memory times 1.5 plus 2GB.

Can I name a conda env yaml py_general.yaml in Snakemake?▼

No, that name collides with a user-managed system environment and causes confusion. Use a descriptive name like pysam_utils.yaml, place it in code/envs/, and reference it relative to the Snakefile location.