Alterlab uniprot

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

Alterlab uniprot is an AI agent skill from the GitHub repository AlterLab-IEU/AlterLab-Academic-Skills. Provide direct REST API access to UniProt (Swiss-Prot/TrEMBL) for protein sequence searches, FASTA retrieval, functional annotations (GO terms, domains), and cross-database ID mapping. Use when looking up a protein entry, fetching a protein FASTA sequence, or mapping accessions between databases ove

How to use this skill

Skill file

UniProt Database

Overview

UniProt is the world's leading comprehensive protein sequence and functional information resource. Search proteins by name, gene, or accession, retrieve sequences in FASTA format, perform ID mapping across databases, access Swiss-Prot/TrEMBL annotations via REST API for protein analysis.

When to Use This Skill

This skill should be used when:

Does NOT Trigger

| Scenario | Use Instead |

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

| Experimental 3D structures and coordinates | alterlab-pdb |

| AI-predicted structures and pLDDT confidence | alterlab-alphafold-db |

| Protein-protein interaction networks | alterlab-string-db |

| Domain architecture and family classification | alterlab-interpro |

| Sequence similarity search (BLAST) | alterlab-blast |

Hand-off rule. When the request matches a row above, open your answer by naming that skill by its exact id (for example alterlab-pdb) 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. Searching for Proteins

Search UniProt using natural language queries or structured search syntax.

Common search patterns:

# Search by protein name
query = "insulin AND organism_name:\"Homo sapiens\""

# Search by gene name
query = "gene:BRCA1 AND reviewed:true"

# Search by accession
query = "accession:P12345"

# Search by sequence length
query = "length:[100 TO 500]"

# Search by taxonomy
query = "taxonomy_id:9606"  # Human proteins

# Search by GO term
query = "go:0005515"  # Protein binding

Use the API search endpoint: https://rest.uniprot.org/uniprotkb/search?query={query}&format={format}

Supported formats: JSON, TSV, Excel, XML, FASTA, RDF, TXT

2. Retrieving Individual Protein Entries

Retrieve specific protein entries by accession number.

Accession number formats:

Retrieve endpoint: https://rest.uniprot.org/uniprotkb/{accession}.{format}

Example: https://rest.uniprot.org/uniprotkb/P12345.fasta

3. Batch Retrieval and ID Mapping

Map protein identifiers between different database systems and retrieve multiple entries efficiently.

ID Mapping workflow:

  1. Submit mapping job (POST): https://rest.uniprot.org/idmapping/run with from, to, ids
  2. Poll job status: https://rest.uniprot.org/idmapping/status/{jobId}
  3. Retrieve results: https://rest.uniprot.org/idmapping/results/{jobId}

Non-obvious gotchas (the first two are handled in scripts/uniprot_client.py):

ENSG00000139618.17 finishes with no results and no error, while ENSG00000139618 maps to P51587

(checked 2026-10-23). Report IDs that still map to nothing (e.g. non-coding genes such as MALAT1) as unmapped.

Supported databases for mapping:

Limitations:

4. Streaming Large Result Sets

For large queries that exceed pagination limits, use the stream endpoint:

https://rest.uniprot.org/uniprotkb/stream?query={query}&format={format}

The stream endpoint returns all results without pagination, suitable for downloading complete datasets.

5. Customizing Retrieved Fields

Specify exactly which fields to retrieve for efficient data transfer.

Common fields:

Example: https://rest.uniprot.org/uniprotkb/search?query=insulin&fields=accession,gene_names,organism_name,length,sequence&format=tsv

See /references/api_fields.md for complete field list.

Python Implementation

For programmatic access, use the provided helper script scripts/uniprot_client.py which implements:

Alternative Python packages:

Query Syntax Examples

Boolean operators:

kinase AND organism_name:human
(diabetes OR insulin) AND reviewed:true
cancer NOT lung

Field-specific searches:

gene:BRCA1
accession:P12345
organism_id:9606
taxonomy_name:"Homo sapiens"
ft_signal:*

The pre-2022 annotation:(type:...), database:(type:...), created:/modified:, and existence:"Evidence at protein level" forms return HTTP 400 on the current API; use ft_<feature>:*, database:<db>, date_created:/date_modified:, and existence:1.

Range queries:

length:[100 TO 500]
mass:[50000 TO 100000]

Wildcards:

gene:BRCA*
protein_name:kinase*

See /references/query_syntax.md for comprehensive syntax documentation.

Best Practices

  1. Use reviewed entries when possible: Filter with reviewed:true for Swiss-Prot (manually curated) entries
  2. Specify format explicitly: Choose the most appropriate format (FASTA for sequences, TSV for tabular data, JSON for programmatic parsing)
  3. Use field selection: Only request fields you need to reduce bandwidth and processing time
  4. Handle pagination: For large result sets, implement proper pagination or use the stream endpoint
  5. Cache results: Store frequently accessed data locally to minimize API calls
  6. Rate limiting: Be respectful of API resources; implement delays for large batch operations
  7. Check data quality: TrEMBL entries are computational predictions; Swiss-Prot entries are manually reviewed

Resources

scripts/

uniprot_client.py - Python client with helper functions for common UniProt operations including search, retrieval, ID mapping, and streaming.

references/

Additional Resources

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.