{"id":8656,"library":"snakemake","title":"Snakemake Workflow Management System","description":"Snakemake is a Python-based workflow management system designed to create reproducible and scalable data analyses. It enables writing workflows in a Python-like DSL called Snakefile, allowing for automatic parallelization, dependency tracking, and execution on various platforms. The current version is 9.19.0, with frequent patch releases and major feature updates typically every few months.","status":"active","version":"9.19.0","language":"en","source_language":"en","source_url":"https://github.com/snakemake/snakemake","tags":["workflow","bioinformatics","data science","pipeline","reproducibility","automation"],"install":[{"cmd":"pip install snakemake","lang":"bash","label":"Install Snakemake"}],"dependencies":[{"reason":"Core dependency for Snakemake's internal interfaces.","package":"snakemake-interface-common","optional":false},{"reason":"Required for S3-compatible storage backend support.","package":"snakemake-storage-plugin-s3","optional":true},{"reason":"Required for Kubernetes cluster execution profiles.","package":"snakemake-profile-kubernetes","optional":true}],"imports":[{"note":"For programmatic interaction (e.g., running workflows from Python), use SnakemakeApi. Direct 'import snakemake' primarily loads the CLI entry point but isn't the preferred way for library usage.","wrong":"import snakemake","symbol":"SnakemakeApi","correct":"from snakemake.api import SnakemakeApi"}],"quickstart":{"code":"import os\n\n# Create a dummy Snakefile for demonstration\nsnakefile_content = \"\"\"\nrule all:\n    input: \"results/final.txt\"\n\nrule prepare_data:\n    output: \"data/input.txt\"\n    shell: \"mkdir -p data && echo 'Hello, Snakemake!' > {output}\"\n\nrule process_data:\n    input: \"data/input.txt\"\n    output: \"results/processed.txt\"\n    shell: \"mkdir -p results && cat {input} | tr 'A-Z' 'a-z' > {output}\"\n\nrule analyze_results:\n    input: \"results/processed.txt\"\n    output: \"results/final.txt\"\n    shell: \"echo 'Analysis complete for: ' $(cat {input}) > {output}\"\n\"\"\"\n\nwith open(\"Snakefile\", \"w\") as f:\n    f.write(snakefile_content)\n\nprint(\"Snakefile created. Running workflow...\")\n\n# To run this, you would typically use the command line:\n# snakemake -c 1\n# Or for programmatic execution (more complex, but possible):\n# from snakemake.api import SnakemakeApi\n# snakemake_runner = SnakemakeApi(\n#    snakefile='Snakefile',\n#    target_files=['results/final.txt'],\n#    cores=1\n# )\n# success = snakemake_runner.execute()\n# print(f\"Workflow execution {'succeeded' if success else 'failed'}\")\n\n# Clean up example files (optional)\n# import shutil\n# if os.path.exists(\"data\"): shutil.rmtree(\"data\")\n# if os.path.exists(\"results\"): shutil.rmtree(\"results\")\n# if os.path.exists(\"Snakefile\"): os.remove(\"Snakefile\")\n","lang":"python","description":"Create a `Snakefile` (the workflow definition) and then execute it using the `snakemake` command-line tool. The example generates a simple file processing workflow and shows how the workflow rules are defined. To run the workflow, execute `snakemake -c 1` in your terminal in the same directory as the Snakefile."},"warnings":[{"fix":"Replace `--use-conda` with `--conda-frontend conda` or `--conda-frontend mamba` in your `snakemake` commands. Ensure `mamba` is installed for faster dependency resolution.","message":"The `--use-conda` CLI flag is deprecated. It has been replaced by `--conda-frontend conda` or `--conda-frontend mamba` for explicit control over the Conda solver.","severity":"deprecated","affected_versions":">=8.0.0"},{"fix":"If using a single profile, consolidate configuration into a `profile.yaml` file within your profile directory. If you explicitly pass a profile directory, Snakemake will still look for `config.yaml`, `cluster.yaml`, etc., but `profile.yaml` will take precedence if present.","message":"Snakemake profiles now default to `profile.yaml` instead of a `profile` directory containing multiple files. While the directory structure is still supported, the YAML file is preferred for simplicity.","severity":"gotcha","affected_versions":">=9.19.0"},{"fix":"Only specify `threads` or `resources` if a rule truly benefits from or requires them. For CPU-bound tasks, `threads: 1` is often sufficient unless the tool explicitly uses multiple threads. Use `resources` to specify memory or other custom requirements.","message":"Over-specification of `threads` or `resources` in rules can lead to deadlocks or inefficient scheduling, especially on cluster systems where resources might be requested but not used.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"Check the spelling of file paths and rule names. Ensure all necessary input and output files are defined correctly across rules, and that a rule exists to produce the requested output.","cause":"Snakemake cannot find a rule that generates the specified target file or an intermediate file required to produce it. This often means a typo in file paths, missing rule, or incorrect dependencies.","error":"No rule to produce output file 'path/to/output.txt'"},{"fix":"Verify that the input file `path/to/input.txt` either exists on disk before the workflow starts, or that there is another rule defined earlier in the Snakefile that produces it as its output.","cause":"A rule is trying to access an input file that does not exist and cannot be generated by any preceding rule in the workflow.","error":"MissingInputException: Missing input files for rule X: path/to/input.txt"},{"fix":"If no other Snakemake process is running, manually remove the lock file using `snakemake --unlock` from the command line within your workflow directory.","cause":"Another Snakemake process, or a previously crashed process, still holds a lock on the `.snakemake` directory in your workflow.","error":"Error: Directory cannot be locked. Please make sure that no other Snakemake process is running in the workflow directory."},{"fix":"Install Miniconda or Mambaforge and ensure its `bin` directory is added to your system's PATH environment variable. Alternatively, use a different `--conda-frontend` or disable Conda integration if not needed.","cause":"Snakemake is configured to use Conda/Mamba for environment management (e.g., via `conda: \"envs/myenv.yaml\"` or `--conda-frontend`), but the `conda` or `mamba` executable is not found in the system's PATH.","error":"Command 'conda' not found. Ensure that you have Conda or Mamba installed and available in your PATH."}]}