# 蛋白结构数据 API（实测可用）

## UniProt：序列 + 结构域 + 位点

```python
import json, urllib.request
d = json.load(urllib.request.urlopen(
    'https://rest.uniprot.org/uniprotkb/P19821.json'))
seq = d['sequence']['value']; n = len(seq)
feats = [f for f in d['features']
         if f['type'] in ('Domain','Region','Active site','Metal binding','Site','Motif','Binding site')]
for f in feats:
    print(f['type'], f['location']['start']['value'], f['location']['end']['value'], f.get('description'))
```

- 按名称搜：`https://rest.uniprot.org/uniprotkb/search?format=json&size=5&query=<urlencoded>`
- **`protein_name:"..." AND organism_id:<taxid>` 经常返回空**；改用 `gene:<gene> AND organism_id:<taxid>` 或直接拿已知 accession。
- 常用 accession：Taq `P19821`（832 aa）、Tth `P52028`（834 aa）、M-MLV Gag-Pol `P03355`（1,738 aa）、E. coli UNG `P12295`（229 aa）。
- **注意别拿错条目**：`P0A8F0` 是尿嘧啶磷酸核糖转移酶，不是 UNG。

## PDB：从 UniProt 交叉引用拿候选

```python
pdbs = []
for x in d.get('uniProtKBCrossReferences', []):
    if x.get('database') == 'PDB':
        props = {p['key']: p['value'] for p in x.get('properties', [])}
        pdbs.append({'id': x['id'], 'resolution': props.get('Resolution'), 'method': props.get('Method')})
```

覆盖度（关键，别只看分辨率）：

```python
e = json.load(urllib.request.urlopen('https://data.rcsb.org/rest/v1/core/entry/' + pid))
n = e['rcsb_entry_info']['deposited_polymer_monomer_count']
coverage = n / uniprot_length
```

下载：`https://files.rcsb.org/download/<ID>.pdb`（1TAQ ~591 KB）。

## AlphaFold DB：预测补全

```python
import json, urllib.request
req = urllib.request.Request('https://alphafold.ebi.ac.uk/api/prediction/P03355',
                             headers={'User-Agent': 'Mozilla/5.0 ...', 'Accept': 'application/json'})
entries = json.load(urllib.request.urlopen(req))
entries.sort(key=lambda x: x['uniprotEnd'] - x['uniprotStart'], reverse=True)
url = entries[0]['pdbUrl']; plddt = entries[0]['globalMetricValue']
```

- **直接拼 `AF-<acc>-F1-model_v4.pdb` 会 403**，必须走 API 拿返回的文件名（可能是 `AF-0000000365763060-model_v1.pdb` 这种内部 ID）。
- 一个 UniProt 可能对应多个片段（如 P03355 分成 661–1331 与 1332–1738），**按覆盖长度选，不要按 pLDDT 选**。
- pLDDT 写在图上和页面里（>90 高置信，70–90 可用，<70 慎用）。

## PubMed：只取有摘要的证据

```python
ids = json.load(urllib.request.urlopen(
    'https://eutils.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi?db=pubmed&retmode=json&retmax=5&term=' + q))
xml = urllib.request.urlopen(
    'https://eutils.ncbi.nlm.nih.gov/entrez/eutils/efetch.fcgi?db=pubmed&retmode=xml&id=' + ','.join(ids))
```

- `retmode=text` 拿到的是「期刊行 + 标题」，容易把期刊当标题；**用 `retmode=xml` 取 `ArticleTitle` / `AbstractText`**。
- 速率：无 key 时 3 req/s，加 `time.sleep(0.4)`。

## 本批已验证的 PMID

| 论断 | PMID |
|---|---|
| Taq 5′→3′ 外切酶水解探针 | 10510675 |
| Taq F667Y 掺入 ddNTP | 8891223 |
| Tth 在 Mn²⁺ 下具逆转录活性 | 1714296 |
| M-MLV RT 五域结构 | 25959458 |
| M-MLV RNase H 突变影响合成/链转移 | 7539510、8576137 |
| UNG 防污染 | 33469645 |
| 热不稳定 UNG 设计 | 35183522 |
| 鳕鱼 UNG 冷适应 | 11126771、21959147 |
