feat(encode): add gget encode module to query and download ENCODE data (#151)#231
feat(encode): add gget encode module to query and download ENCODE data (#151)#231Elarwei001 wants to merge 5 commits into
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## dev #231 +/- ##
==========================================
- Coverage 56.70% 56.66% -0.05%
==========================================
Files 29 30 +1
Lines 9392 9497 +105
==========================================
+ Hits 5326 5381 +55
- Misses 4066 4116 +50 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
scverse#151) New module `gget encode` queries the ENCODE project REST API (https://www.encodeproject.org/). Passing an ENCODE accession (experiment or file) returns the matching file(s) with download URLs, optionally filtered by assembly/file_format/output_type and downloaded with download=True; any other input is used as a free-text search returning matching ENCODE objects of a given type. Exposed via the Python API and the command line. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
for more information, see https://pre-commit.ci
Add network-free mocked tests for _encode_get error/404 branches, the output_type filter, generic-object metadata path, accession download, search-path verbose/download warning, save CSV/JSON, and the streaming _download_files body. gget_encode.py now fully covered. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
e930bb0 to
3a806d4
Compare
…, live tests (scverse#151) - docs: put the ENCODE (2012) citation before gget's, per convention - docs: drop the issue link from the updates.md changelog entry - docs: warn that --download fetches every filtered file (an experiment can be dozens of files / tens of GB) — filter first - docs: add the Espanol SUMMARY.md nav entry for parity (es page itself is bot-auto-translated) - tests: add live tests (skipped when offline, never downloading) against the real ENCODE API for the file, experiment, and search paths Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
Hi @lauraluebbert — this PR is ready for review whenever you have time. Quick overview:
It's built on ENCODE's current REST API (the /{accession}/ and /search/ endpoints, plus the files' direct-download links), not the older kundajelab/ENCODE_downloader script the issue referenced (which you and @akundaje noted was pretty old). The PR description has real return-value examples (tables + JSON) and a full-output attachment.
Happy to adjust anything — thanks! |
Resolves #151
Summary
gget encode: new module to query and download data from the ENCODE project via its official REST API. Two modes, chosen automatically from the input:ENCSR000AKSexperiment orENCFF000BXKfile) → lists the object's file(s) with download URLs, optionally filtered byassembly/file_format/output_typeand fetched withdownload=True.type(defaultExperiment).Available in the Python API and on the command line.
Example return values
The file listings also include a
urlcolumn (the direct@@downloadlink) — it is omitted from the tables below for width, but it is part of the returned DataFrame, as the JSON snippet further down shows.Mode A — a single file —
gget.encode("ENCFF000BXK"):Mode A — an experiment's files, filtered to BAMs —
gget.encode("ENCSR000AKS", file_format="bam")(20 of the experiment's 82 files; note it spans assemblies):Mode B — free-text search —
gget.encode("CTCF K562", type="Experiment", limit=5):With
json=True(the command-line default) the same rows come back as records — e.g. the file above:[ { "file_accession": "ENCFF000BXK", "file_format": "bam", "output_type": "alignments", "assembly": "hg19", "file_size": 964104660, "status": "archived", "url": "https://www.encodeproject.org/files/ENCFF000BXK/@@download/ENCFF000BXK.bam" } ]Add⚠️ Download pulls every file left after filtering — an experiment has ~82 files (tens of GB), so narrow with
download=True(CLI--download, with--out_dir) to fetch the files in theurlcolumn.assembly/file_format/output_typefirst.Full example output — the file (
ENCFF000BXK), the experiment's complete 82-file listing (ENCSR000AKS), and aCTCF K562experiment search (CSV + JSON) are attached here: https://gist.github.com/Elarwei001/7cee4ce617ee7a239b3a6ac104790e05Testing
Unit tests —
tests/test_encode.py(offline / mocked, fixture intests/fixtures/):assembly/file_format/output_typefilters, and free-text search;_download_filesstreaming, thedownload=Truerouting, and the search-mode "download not supported" warning;Live tests — hit the real ENCODE API (skipped when offline, and they never trigger a download):
ENCFF000BXKfile (assertsfile_format == "bam");ENCSR000AKSexperiment listing (many files, incl. BAMs);CTCFexperiment search.