> ## Documentation Index
> Fetch the complete documentation index at: https://proto.evodesign.org/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# ENCODE

> The [ENCODE portal](https://www.encodeproject.org) hosts the experiments and uniformly processed files of the Encyclopedia of DNA Elements, including ChIP-seq, ATAC-seq, DNase-seq, RNA-seq and Hi-C across human and mouse biosamples. The `encode-search` tool runs faceted searches of the portal by assay, target, biosample, output type and assembly, and returns each file's or experiment's accession, metadata and direct download URL.

![ENCODE](https://proto-bio.github.io/proto-assets/images/tool/encode/hero.png)[![](https://avatars.githubusercontent.com/u/1713898?s=200\&v=4) ENCODE DCC](https://proto.evodesign.org/docs/tools/organizations/encode-dcc.md) [![](https://mintcdn.com/bio-pro/Bgc19Em8MDwlJakq/assets/images/cached/30c2d8dfa42f.png?fit=max\&auto=format\&n=Bgc19Em8MDwlJakq\&q=85\&s=e0427cf93eecd8fadd924cc436b3a639) Stanford University](https://proto.evodesign.org/docs/tools/organizations/stanford-university.md)

> [!NOTE]
>
> **License:** ENCODE retrieves data from the ENCODE portal, distributed under the ENCODE Data Use Policy. Attribution to the ENCODE portal is required when the data is redistributed. The client wrapper code is MIT-licensed. Please refer to [the data terms](https://www.encodeproject.org/help/citing-encode/) for full terms.

Proto is not affiliated with ENCODE DCC and Stanford University. This toolkit is open source and builds on the implementations produced by these organizations. Product names, logos, and trademarks are the property of their respective owners.

***

&#x20;GitHub GitHub  Website Website  Publication Publication  Cite Cite  Tool Source Tool Source  Open as Notebook Open as Notebook  Run Locally Run Locally

![/](https://opengraph.githubassets.com/1//)

&#x20;/

&#x20;View repo

[Open](https://github.com/ENCODE-DCC)

&#x20;encodeproject.org

&#x20;Visit website

[Open](https://www.encodeproject.org)

New developments on the Encyclopedia of DNA Elements (ENCODE) data portalYunhai Luo, Benjamin C Hitz, ... J Michael CherryNucleic Acids Research (2020)

&#x20;Read paper

[Open](https://doi.org/10.1093/nar/gkz1062)

@articleluo2020encode

```bibtex theme={null}
@article{luo2020encode,
  title={New developments on the Encyclopedia of DNA Elements (ENCODE) data portal},
  author={Luo, Yunhai and Hitz, Benjamin C and Gabdank, Idan and Hilton, Jason A and Kagda, Meenakshi S and Lam, Bonita and Myers, Zachary and Sud, Paul and Jou, Jennifer and Lin, Khine and Baymuradov, Ulugbek K and Graham, Keenan and Litton, Casey and Miyasato, Stuart R and Strattan, J Seth and Jolanki, Otto and Lee, Jin-Wook and Tanaka, Forrest Y and Adenekan, Philip and O'Neill, Emma and Cherry, J Michael},
  journal={Nucleic Acids Research},
  volume={48},
  number={D1},
  pages={D882--D889},
  year={2020},
  publisher={Oxford University Press},
  doi={10.1093/nar/gkz1062}
}
```

&#x20;Copy citation

![Proto](https://mintcdn.com/bio-pro/cMLt8hAqaP9M3LKy/assets/logo/logo-light.svg?fit=max\&auto=format\&n=cMLt8hAqaP9M3LKy\&q=85\&s=f5e5dfd1b8f9b9db3a0be0e2eb01f678)

evo-design/proto-tools

&#x20;View source

[Open](https://github.com/evo-design/proto-tools/tree/0a918bae9551824984526ee13f2cff66e6fc4713/proto_tools/tools/database_retrieval/encode)

Open Notebook

&#x20;Open notebook

[Open](https://github.com/evo-design/proto-tools/blob/0a918bae9551824984526ee13f2cff66e6fc4713/proto_tools/tools/database_retrieval/encode/examples/example.ipynb)

[![proto-tools on GitHub](https://opengraph.githubassets.com/1/evo-design/proto-tools)](https://github.com/evo-design/proto-tools)

Run locally with proto-tools

```bash theme={null}
pip install git+https://github.com/evo-design/proto-tools.git
```

Toolkit contributors[![](https://avatars.githubusercontent.com/u/21143637?v=4\&s=64)bviggiano](https://github.com/bviggiano)[![](https://avatars.githubusercontent.com/u/61667248?v=4\&s=64)adititm](https://github.com/adititm)

| Function | Description | |
| - | - | - |
| `run_encode_search()` | Search the ENCODE portal for experiments and processed files (peaks, signal, alignments) by assay... | [ Docs](#api-run-encode-search) [ Source](https://github.com/evo-design/proto-tools/blob/0a918bae9551824984526ee13f2cff66e6fc4713/proto_tools/tools/database_retrieval/encode/encode_search.py#L394) |

## Background

The ENCODE Consortium maps functional elements in the human and mouse genomes: transcription factor binding, histone modifications, chromatin accessibility, transcription and 3D genome contacts. The ENCODE Data Coordination Center at Stanford runs the portal, which is described in [*New developments on the Encyclopedia of DNA Elements (ENCODE) data portal*](https://doi.org/10.1093/nar/gkz1062) by Luo et al., published in *Nucleic Acids Research*.

Data is organized as **experiments** (`ENCSR...` accessions), each with a biosample, an assay and, for ChIP-seq, a target. Each experiment holds **files** (`ENCFF...` accessions): raw reads, and the outputs of the uniform processing pipelines such as alignments, signal tracks and peak calls on a given genome assembly. For each output type and assembly, the portal flags one file as the **preferred default**, for example the replicated IDR thresholded peaks of a TF ChIP-seq experiment.

The tool queries the portal's [REST API](https://www.encodeproject.org/help/rest-api/), whose search endpoint accepts the same facet filters as the portal's search pages and returns JSON.

### Learning Resources

* [ENCODE REST API](https://www.encodeproject.org/help/rest-api/) (ENCODE DCC) - the search endpoint, facet filters and JSON responses.
* [Getting started with ENCODE](https://www.encodeproject.org/help/getting-started/) (ENCODE DCC) - experiments, files, biosamples and how to browse them.
* [ENCODE file formats](https://www.encodeproject.org/help/file-formats/) (ENCODE DCC) - bed narrowPeak, bigWig, BAM and other processed formats.
* [ENCODE pipelines](https://www.encodeproject.org/pipelines/) (ENCODE DCC) - the uniform processing pipelines that produce the processed files.

## Tools

### ENCODE Search (`encode-search`)

Runs one portal search per query. A query is a mapping of ENCODE facet filters, such as `assay_title`, `target.label`, `biosample_ontology.term_name`, `output_type`, `assembly` and `file_format`, with optional free text. It returns files (default) or experiments with accession, parent experiment, assay, target, biosample, organism, output type, assembly, file format and type, size, MD5 checksum, replicates, preferred-default flag, lab, portal page URL and, for files, the direct download URL. Each result also reports the total match count and the request URL.

#### API Reference

[ Source](https://github.com/evo-design/proto-tools/blob/0a918bae9551824984526ee13f2cff66e6fc4713/proto_tools/tools/database_retrieval/encode/encode_search.py#L152)

> [accordion] Input: EncodeSearchInput
>
> **queries** `List[EncodeSearchQuery]` *required*
>
> One or more searches. A bare dict (a query or a plain filter mapping) is normalized to a one-item list.
>
> **EncodeSearchQuery**
>
> **filters** `Dict[string, string | List[string]]`
>
> ENCODE facet filters, e.g. `{"assay_title": "TF ChIP-seq", "target.label": "CTCF", "biosample_ontology.term_name": "K562", "output_type": "IDR thresholded peaks", "assembly": "GRCh38", "file_format": "bed"}`. Values must match the portal's facet terms exactly. A list matches any of its values, e.g. `{"target.label": ["CTCF", "RAD21"]}`. A key ending in `!` negates the filter; with a list, it excludes every value.
>
> **search\_term** `string`
>
> Free-text search (the portal's `searchTerm`), e.g. `"MAFK HepG2"`.

[ Source](https://github.com/evo-design/proto-tools/blob/0a918bae9551824984526ee13f2cff66e6fc4713/proto_tools/tools/database_retrieval/encode/encode_search.py#L173)

> [accordion] Config: EncodeSearchConfig
>
> **item\_type** `enum` (default: File)
>
> Search processed and raw files, or experiments.
>
> Available options: `File`, `Experiment`
>
> **released\_only** `boolean` (default: True)
>
> Restrict to `status=released`, excluding archived, revoked and in-progress items. Ignored when the query sets its own `status` filter.
>
> **default\_only** `boolean` (default: False)
>
> Restrict files to `preferred_default=true`, the portal's default file per output type (e.g. the default IDR thresholded peaks). Files only.
>
> **max\_results** `integer` (default: 25)
>
> Maximum hits returned per query (1-1000).
>
> **verbose** `integer` (default: 0)
>
> Verbosity level (0=quiet, 1=info, 2=debug, 3=raw subprocess stderr). `True` is coerced to `1` and `False` to `0`.
>
> **device** `string` (default: cpu)
>
> Device to run the tool on.
>
> **timeout** `integer` (default: 3600)
>
> Maximum execution time in seconds, not counting time spent while a weights download keeps progressing. `None` waits indefinitely.
>
> **seed** `integer`
>
> Random seed. When set, tools run reproducibly up to small GPU float noise (see `BaseToolOutput.approx_equal`), and the seed participates in cache keys. When None, cacheable seed-sensitive tools skip cache until seeded.

[ Source](https://github.com/evo-design/proto-tools/blob/0a918bae9551824984526ee13f2cff66e6fc4713/proto_tools/tools/database_retrieval/encode/encode_search.py#L274)

> [accordion] Output: EncodeSearchOutput
>
> **results** `List[EncodeSearchResult]`
>
> Results in input order.
>
> **EncodeSearchResult**
>
> **query** `EncodeSearchQuery` *required*
>
> The query as given.
>
> **request\_url** `string` *required*
>
> Full search URL sent, including type, status and default filters.
>
> **total\_count** `integer` *required*
>
> Total matching items reported by the portal.
>
> **hits** `List[EncodeSearchHit]`
>
> Hits in the portal's order.
>
> **source\_url** `string` *required*
>
> ENCODE search endpoint used.
>
> **tool\_version** `string`
>
> Version of the toolkit that produced the output, from its `versions.yaml`. Suffixed `+dirty` when the source no longer matches that version. See `notes/versioning.md`.

#### Applications

Searches locate specific processed ENCODE files, such as the default IDR thresholded peaks for a transcription factor in a cell line or the fold-change signal for a histone mark. The download URLs and MD5 checksums can be cited or used to fetch the files for analysis. Experiment searches list the assays available for a target or biosample before choosing files.

#### Usage Tips

* **Filter values must match portal terms exactly.** Facets match exact, case-sensitive strings, e.g. `"TF ChIP-seq"`, `"IDR thresholded peaks"`, `"HepG2"`. Copy terms from the facet lists on the [portal search page](https://www.encodeproject.org/search/?type=File).
* **A list matches any of its values.** `{"target.label": ["CTCF", "RAD21"]}` returns files for either target in one search and one ranked result, and lists combine across filters, e.g. several cell lines for one target. A negated list such as `{"assembly!": ["hg19", "GRCh37"]}` excludes every value.
* **Filters that match nothing are reported in `warnings`.** The portal accepts a misspelled value or unknown facet name without error and simply returns no hits. When a search returns nothing, the tool counts each filter on its own and warns about any that match no item, with suggestions such as `'k562'` → `'K562'` or `target.lable` → `target.label`. A search with no hits and no warning means the filters are valid but no item matches all of them. Negated filters and list values are always checked, since a misspelled `key!` silently excludes nothing and a misspelled list value silently adds nothing.
* **Use `default_only` for the canonical file.** `default_only=True` adds `preferred_default=true`, which usually leaves one file per experiment, output type and assembly. Leave it off to see per-replicate and superseded outputs.
* **`released_only` drops archived and revoked items.** It adds `status=released` unless the query sets its own `status` filter. A key ending in `!`, e.g. `"assembly!": "hg19"`, negates a filter.
* **`organism` is exact for experiments and inferred for files.** Experiments report their biosamples' species. Files have no organism field, so it comes from the donor (human or mouse) or the assembly (`dm6`, `ce11`, ...), and is `None` when neither identifies the species. To restrict files to a species, filter on `assembly`. For experiments, filter on `replicates.library.biosample.donor.organism.scientific_name`.
* **Free text is fuzzy.** `search_term` matches across descriptions and metadata, which helps when facet terms are unknown. Combine it with filters to narrow the hits.
* **The tool returns metadata, not files.** Call `output.download(directory)` to fetch the file hits. It verifies each file's MD5, skips files already downloaded, and refuses before starting when the total exceeds `max_total_bytes` (1 GB by default). Peak and quantification files are a few MB. Signal tracks, alignments and reads are often hundreds of MB to several GB. Pass `accessions` to fetch only some hits. Results export as JSON (full output) or CSV (one row per hit).

## Toolkit Notes

These apply to every ENCODE tool in this toolkit (`encode-search`).

* **Requires network access.** The tool calls the live ENCODE portal over HTTPS and runs in the current Python process.
* **Results follow the live portal.** New releases and reprocessing can add, archive or change default files. Keep the accessions and MD5 checksums with exported results for provenance.

> [!TIP]
>
> **Example notebook:** See the [full working example](https://github.com/evo-design/proto-tools/blob/0a918bae9551824984526ee13f2cff66e6fc4713/proto_tools/tools/database_retrieval/encode/examples/example.ipynb) for a copy-paste-ready walkthrough.

## Infrastructure Guides

The following guides cover how to run tools efficiently and at scale.

> [card] [Tool Persistence](https://proto.evodesign.org/docs/tools/guides/tool-persistence.md)
>
> Keep a tool's model warm across calls instead of reloading it every invocation.

> [card] [Device Management](https://proto.evodesign.org/docs/tools/guides/device-management.md)
>
> How GPUs are allocated to tools and how to target specific devices.

> [card] [Parallel Execution](https://proto.evodesign.org/docs/tools/guides/parallel-execution.md)
>
> Fan a batch of inputs out across multiple GPUs.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.