← Về thư mục
📄 / / profiles / r-and-d / raw_evidence / OpenAI4S / skills / bioskills / bio-database-access-uniprot-access / references / usage-guide.md

UniProt Access Usage Guide

Overview

Query UniProt's REST API (https://rest.uniprot.org/). Encodes the 2022 endpoint migration (legacy https://www.uniprot.org/uniprot/... is deprecated; JSON schema changed substantially), the four UniProt resources (UniProtKB / UniRef / UniParc / Proteomes), search vs stream vs accessions endpoint trade-offs, isoform handling (P04637-2 suffix), async ID-mapping job pattern, the critical ?fields= for bulk pulls, and the Swiss-Prot vs TrEMBL distinction.

Prerequisites

pip install requests pandas

No API key required. Rate limit generous (~200 req/sec). ID-mapping has its own job queue.

Quick Start

Example Prompts

Single entry with defensive parsing

"Fetch UniProt P04637 as JSON and pull: primaryAccession, uniProtkbId, proteinDescription.recommendedName.fullName.value, genes[0].geneName.value, sequence.value, and all PDB cross-refs. Use .get() chains for every nested field -- the schema is deeply nested and some fields are optional."

Bulk pull with explicit fields

"Search human reviewed kinases. Use /search with format=tsv and fields=accession,gene_primary,protein_name,length,xref_pdb,xref_alphafolddb,size=500. Don't omit fields= -- default returns full JSON entries (~20-30 KB each) and 500 of them is 15 MB."

Stream for >500 results

"I want all human Swiss-Prot entries (~20,000). The /search endpoint caps at 500/page. Use /stream with fields=accession,gene_primary,length to stream all results in one HTTP response."

ID mapping async pattern

"Convert 100 Ensembl Gene IDs to UniProt accessions. Use POST /idmapping/run with from=Ensembl, to=UniProtKB. Poll /idmapping/status/{jobId} every 3 seconds with a 600-second timeout (jobs can hang). Retrieve via /idmapping/results/{jobId}."

Isoform handling

"TP53 (P04637) has multiple isoforms. The bare P04637 fetch returns the canonical sequence only. Walk comments[type=ALTERNATIVE PRODUCTS].isoforms; for each isoform, fetch P04637-2.fasta, P04637-3.fasta, etc."

Resolve obsolete accessions

"These accessions from a 2015 paper may be obsolete or merged. Run ID mapping from=UniProtKB_AC-ID, to=UniProtKB to resolve to current primary accessions before fetching."

What the Agent Will Do

  1. Always use the post-2022 endpoint (rest.uniprot.org); flag legacy URLs as broken.
  2. Pick the resource: UniProtKB (curated/auto entries), UniRef (clusters), UniParc (archival), Proteomes (organism sets).
  3. For any bulk pull, specify fields= explicitly to control payload.
  4. For >500 results, use /stream not /search.
  5. For ID mapping, follow the async pattern: submit, poll with timeout, retrieve.
  6. Filter reviewed:true for reference-quality analyses (avoids 250M TrEMBL).
  7. Combine queries with organism_id:9606 to scope by species.
  8. Navigate nested JSON with .get() chains and defensive defaults.
  9. For isoforms, fetch the -N suffixed accession separately; canonical is the default.

Tips