.. _`bio/entrez/efetch`: EFETCH ====== .. image:: https://img.shields.io/github/issues-pr/snakemake/snakemake-wrappers/bio/entrez/efetch?label=version%20update%20pull%20requests :target: https://github.com/snakemake/snakemake-wrappers/pulls?q=is%3Apr+is%3Aopen+label%3Abio/entrez/efetch Obtain data from NCBI and Genbank using Entrez efetch **URL**: https://www.ncbi.nlm.nih.gov/books/NBK179288/ Example ------- This wrapper can be used in the following way: .. code-block:: python rule get_fasta: output: "test.fasta", log: "logs/get_fasta.log", params: id="KY785484", db="nuccore", format="fasta", # optional mode mode=None, wrapper: "v3.3.3/bio/entrez/efetch" Note that input, output and log file paths can be chosen freely. When running with .. code-block:: bash snakemake --use-conda the software dependencies will be automatically deployed into an isolated environment before execution. Software dependencies --------------------- * ``entrez-direct=16.2`` Authors ------- * Johannes Köster Code ---- .. code-block:: python import subprocess as sp import sys if snakemake.log: sys.stderr = open(snakemake.log[0], "w") cmd = ["efetch"] def add_param(param, required=False): if snakemake.params.get(param): cmd.extend(["-" + param, snakemake.params[param]]) elif required: raise ValueError("Missing required parameter: " + param) else: return [] add_param("id", required=True) for param in ["db", "format", "mode"]: add_param(param) with open(snakemake.output[0], "w") as out: sp.run(cmd, stderr=sp.STDOUT, stdout=out, check=True) .. |nl| raw:: html