Alterlab ena

From AlterLab-IEU/AlterLab-Academic-Skills · View interactive version

Alterlab ena is an AI agent skill from the GitHub repository AlterLab-IEU/AlterLab-Academic-Skills. Access the European Nucleotide Archive (ENA) via its API and FTP to retrieve DNA/RNA sequences, raw sequencing reads (FASTQ), and genome assemblies by accession, with support for multiple formats. Use when downloading reads or sequences for a study, run, or sample accession, or when sourcing nucleot

How to use this skill

Skill file

ENA Database

Overview

The European Nucleotide Archive (ENA) is a comprehensive public repository for nucleotide sequence data and associated metadata. Access and query DNA/RNA sequences, raw reads, genome assemblies, and functional annotations through REST APIs and FTP for genomics and bioinformatics pipelines.

When to Use This Skill

This skill should be used when:

Does NOT Trigger

| Scenario | Use Instead |

|----------|-------------|

| Processed expression series (GSE/GSM, series matrix) rather than raw reads | alterlab-geo |

| Gene-centric annotation (symbols, RefSeq, GO) from NCBI Gene | alterlab-gene-db |

| Genome annotation, VEP, orthologs, or coordinate lookups | alterlab-ensembl |

| Running BLAST locally against a custom database | alterlab-blast |

| Curated protein sequences, function, domains or UniProt accessions | alterlab-uniprot |

Hand-off rule. When the request matches a row above, open your answer by naming that skill by its exact id (for example alterlab-geo) and saying in one line why it fits better, then stop applying this skill's procedure. Name it even when you also need to ask for missing input. If only part of the request is out of scope, name the skill for that part and do only the in-scope part. A brief general pointer is fine; the named skill does the work.

Core Capabilities

1. Data Types and Structure

ENA organizes data into hierarchical object types:

Studies/Projects - Group related data and control release dates. Studies are the primary unit for citing archived data.

Samples - Represent units of biomaterial from which sequencing libraries were produced. Samples must be registered before submitting most data types.

Raw Reads - Consist of:

Assemblies - Genome, transcriptome, metagenome, or metatranscriptome assemblies at various completion levels.

Sequences - Assembled and annotated sequences stored in the EMBL Nucleotide Sequence Database, including coding/non-coding regions and functional annotations.

Analyses - Results from computational analyses of sequence data.

Taxonomy Records - Taxonomic information including lineage and rank.

2. Programmatic Access

ENA provides multiple REST APIs for data access. Consult references/api_reference.md for detailed endpoint documentation.

Key APIs:

ENA Portal API - Advanced search functionality across all ENA data types

ENA Browser API - Direct retrieval of records and metadata

ENA Taxonomy REST API - Query taxonomic information

ENA Cross Reference Service - Access related records from external databases

CRAM Reference Registry - Retrieve reference sequences

Rate Limiting: ENA caps programmatic access at 50 requests per second; exceeding it returns HTTP 429 (Too Many Requests).

3. Searching and Retrieving Data

Browser-Based Search:

Programmatic Queries:

Example API Query Pattern:

import requests

# Search for samples from a specific study
base_url = "https://www.ebi.ac.uk/ena/portal/api/search"
params = {
    "result": "sample",
    "query": "study_accession=PRJEB1234",
    "format": "json",
    "limit": 100
}

response = requests.get(base_url, params=params)
samples = response.json()

4. Data Retrieval Formats

Metadata Formats:

Sequence Data:

Download Methods:

5. Common Use Cases

Retrieve raw sequencing reads by accession:

# Get FASTQ download URLs via the Portal filereport endpoint
# (the Browser API xml/{accession} returns run METADATA, not file URLs).
accession = "ERR123456"
url = ("https://www.ebi.ac.uk/ena/portal/api/filereport"
       f"?accession={accession}&result=read_run"
       "&fields=run_accession,fastq_ftp,fastq_md5&format=tsv")
# Then fetch each ;-separated fastq_ftp URL over FTP/HTTPS.

Search for all samples in a study:

# Use Portal API to list samples; limit=0 returns every record
# (scripts/query_ena.py --limit defaults to 100)
study_id = "PRJNA123456"
url = f"https://www.ebi.ac.uk/ena/portal/api/search?result=sample&query=study_accession={study_id}&format=tsv&limit=0"

Find assemblies for a specific organism:

# Search assemblies by taxonomy. tax_tree()/tax_eq() take a numeric NCBI taxon ID —
# tax_tree(Escherichia coli) returns HTTP 400. Resolve names via the taxonomy API first.
taxon_id = 562  # Escherichia coli
url = ("https://www.ebi.ac.uk/ena/portal/api/search?result=assembly"
       f"&query=tax_tree({taxon_id})&fields=accession,scientific_name&format=json")

Get taxonomic lineage:

# Query taxonomy API
taxon_id = "562"  # E. coli
url = f"https://www.ebi.ac.uk/ena/taxonomy/rest/tax-id/{taxon_id}"

6. Integration with Analysis Pipelines

Bulk Download Pattern:

  1. Search for accessions matching criteria using Portal API
  2. Extract file URLs from search results
  3. Download files via FTP or using enaBrowserTools
  4. Process downloaded data in pipeline

BLAST Integration:

Integrate with EBI's NCBI BLAST service (REST/SOAP API) for sequence similarity searches against ENA sequences.

7. Best Practices

Rate Limiting:

Data Citation:

API Response Handling:

Performance:

Resources

This skill includes detailed reference documentation for working with ENA:

references/

api_reference.md - Comprehensive API endpoint documentation including:

Load this reference when constructing complex API queries, debugging API responses, or needing specific parameter details.

Scripts

scripts/query_ena.py — runnable helper for the ENA Portal API (no key):

python scripts/query_ena.py search --result read_run \
    --query 'study_accession="PRJEB1787"' --fields run_accession,fastq_ftp --limit 5
python scripts/query_ena.py filereport ERR164407
Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.