$npx -y skills add adaptyvbio/protein-design-skills --skill uniprotAccess UniProt for protein sequence and annotation retrieval. Use this skill when: (1) Looking up protein sequences by accession, (2) Finding functional annotations, (3) Getting domain boundaries, (4) Finding homologs and variants, (5) Cross-referencing to PDB structures. For str
| 1 | # UniProt Database Access |
| 2 | |
| 3 | **Note**: This skill uses the UniProt REST API directly. No Modal deployment needed - all operations run locally via HTTP requests. |
| 4 | |
| 5 | ## Fetching Sequences |
| 6 | |
| 7 | ### By Accession |
| 8 | ```bash |
| 9 | # FASTA format |
| 10 | curl "https://rest.uniprot.org/uniprotkb/P00533.fasta" |
| 11 | |
| 12 | # JSON format with annotations |
| 13 | curl "https://rest.uniprot.org/uniprotkb/P00533.json" |
| 14 | ``` |
| 15 | |
| 16 | ### Using Python |
| 17 | ```python |
| 18 | import requests |
| 19 | |
| 20 | def get_uniprot_sequence(accession): |
| 21 | """Fetch sequence from UniProt.""" |
| 22 | url = f"https://rest.uniprot.org/uniprotkb/{accession}.fasta" |
| 23 | response = requests.get(url) |
| 24 | if response.ok: |
| 25 | lines = response.text.strip().split('\n') |
| 26 | header = lines[0] |
| 27 | sequence = ''.join(lines[1:]) |
| 28 | return header, sequence |
| 29 | return None, None |
| 30 | ``` |
| 31 | |
| 32 | ## Getting Annotations |
| 33 | |
| 34 | ### Full Entry |
| 35 | ```python |
| 36 | def get_uniprot_entry(accession): |
| 37 | """Fetch full UniProt entry as JSON.""" |
| 38 | url = f"https://rest.uniprot.org/uniprotkb/{accession}.json" |
| 39 | response = requests.get(url) |
| 40 | return response.json() if response.ok else None |
| 41 | |
| 42 | entry = get_uniprot_entry("P00533") |
| 43 | print(f"Protein: {entry['proteinDescription']['recommendedName']['fullName']['value']}") |
| 44 | ``` |
| 45 | |
| 46 | ### Domain Boundaries |
| 47 | ```python |
| 48 | def get_domains(accession): |
| 49 | """Extract domain annotations.""" |
| 50 | entry = get_uniprot_entry(accession) |
| 51 | domains = [] |
| 52 | |
| 53 | for feature in entry.get('features', []): |
| 54 | if feature['type'] == 'Domain': |
| 55 | domains.append({ |
| 56 | 'name': feature.get('description', ''), |
| 57 | 'start': feature['location']['start']['value'], |
| 58 | 'end': feature['location']['end']['value'] |
| 59 | }) |
| 60 | |
| 61 | return domains |
| 62 | |
| 63 | # Example: EGFR domains |
| 64 | domains = get_domains("P00533") |
| 65 | # [{'name': 'Kinase', 'start': 712, 'end': 979}, ...] |
| 66 | ``` |
| 67 | |
| 68 | ## Searching UniProt |
| 69 | |
| 70 | ### By Gene Name |
| 71 | ```python |
| 72 | def search_uniprot(query, organism=None, limit=10): |
| 73 | """Search UniProt by query.""" |
| 74 | url = "https://rest.uniprot.org/uniprotkb/search" |
| 75 | params = { |
| 76 | "query": query, |
| 77 | "format": "json", |
| 78 | "size": limit |
| 79 | } |
| 80 | if organism: |
| 81 | params["query"] += f" AND organism_id:{organism}" |
| 82 | |
| 83 | response = requests.get(url, params=params) |
| 84 | return response.json()['results'] |
| 85 | |
| 86 | # Search for human EGFR |
| 87 | results = search_uniprot("EGFR", organism=9606) |
| 88 | ``` |
| 89 | |
| 90 | ### By Sequence Similarity (BLAST) |
| 91 | ```python |
| 92 | # Use UniProt BLAST |
| 93 | # https://www.uniprot.org/blast |
| 94 | ``` |
| 95 | |
| 96 | ## Cross-References |
| 97 | |
| 98 | ### Get PDB Structures |
| 99 | ```python |
| 100 | def get_pdb_references(accession): |
| 101 | """Get PDB structures for UniProt entry.""" |
| 102 | entry = get_uniprot_entry(accession) |
| 103 | pdbs = [] |
| 104 | |
| 105 | for xref in entry.get('uniProtKBCrossReferences', []): |
| 106 | if xref['database'] == 'PDB': |
| 107 | pdbs.append({ |
| 108 | 'pdb_id': xref['id'], |
| 109 | 'method': xref.get('properties', [{}])[0].get('value', ''), |
| 110 | 'chains': xref.get('properties', [{}])[1].get('value', '') |
| 111 | }) |
| 112 | |
| 113 | return pdbs |
| 114 | |
| 115 | # Example: PDB structures for EGFR |
| 116 | pdbs = get_pdb_references("P00533") |
| 117 | ``` |
| 118 | |
| 119 | ## Common Use Cases |
| 120 | |
| 121 | ### Target Selection |
| 122 | ```python |
| 123 | # 1. Find protein by name |
| 124 | results = search_uniprot("insulin receptor", organism=9606) |
| 125 | |
| 126 | # 2. Get accession |
| 127 | accession = results[0]['primaryAccession'] # e.g., P06213 |
| 128 | |
| 129 | # 3. Get domains |
| 130 | domains = get_domains(accession) |
| 131 | |
| 132 | # 4. Find PDB structure |
| 133 | pdbs = get_pdb_references(accession) |
| 134 | |
| 135 | # 5. Download best structure for design |
| 136 | ``` |
| 137 | |
| 138 | ### Sequence Alignment Info |
| 139 | ```python |
| 140 | def get_sequence_variants(accession): |
| 141 | """Get natural variants from UniProt.""" |
| 142 | entry = get_uniprot_entry(accession) |
| 143 | variants = [] |
| 144 | |
| 145 | for feature in entry.get('features', []): |
| 146 | if feature['type'] == 'Natural variant': |
| 147 | variants.append({ |
| 148 | 'position': feature['location']['start']['value'], |
| 149 | 'original': feature.get('alternativeSequence', {}).get('originalSequence', ''), |
| 150 | 'variant': feature.get('alternativeSequence', {}).get('alternativeSequences', [''])[0], |
| 151 | 'description': feature.get('description', '') |
| 152 | }) |
| 153 | |
| 154 | return variants |
| 155 | ``` |
| 156 | |
| 157 | ## API Reference |
| 158 | |
| 159 | | Endpoint | Description | |
| 160 | |----------|-------------| |
| 161 | | `/uniprotkb/{id}.fasta` | FASTA sequence | |
| 162 | | `/uniprotkb/{id}.json` | Full entry JSON | |
| 163 | | `/uniprotkb/search` | Search entries | |
| 164 | | `/uniprotkb/stream` | Batch download | |
| 165 | |
| 166 | ## Troubleshooting |
| 167 | |
| 168 | **Entry not found**: Check accession format (e.g., P00533) |
| 169 | **Rate limits**: Add delay between requests |
| 170 | **Large downloads**: Use stream endpoint with pagination |
| 171 | |
| 172 | --- |
| 173 | |
| 174 | **Next**: Use s |