Entrez 检索与下载
用 Biopython 访问 NCBI
本节你将能
设置 email,用 Entrez.esearch/efetch 下载序列。
直觉模型
先 search 拿 ID 列表,再 fetch 拿记录——像图书馆先查目录再取书。
核心要点
- 必须设置
Entrez.email - 遵守请求频率;批量用历史/批处理
- 返回句柄配合 SeqIO 解析
from Bio import Entrez, SeqIO
Entrez.email = "you@example.com"
handle = Entrez.efetch(db="nucleotide", id="EU490707", rettype="fasta", retmode="text")
print(SeqIO.read(handle, "fasta").id)
常见误区
不设 email 或高频轰炸——可能被限流。
动手
下载一条核酸 FASTA 到本地。
互动
测验:Entrez 使用前通常要设置什么。
本节小结
下一节做序列统计与简单可视化。