bioservices
它能做什么
BioServices 是一个帮助连接不同生物学数据库(如 UniProt 和 KEGG)的工具。研究人员可以用它搜索蛋白质、基因和化合物的信息,以及它们在生物网络中的关系。
适用场景
- ✓需要在多个数据库中查找某个特定蛋白质的信息时。
- ✓想了解某个基因参与了哪些生物通路时。
- ✓需要把一种化合物标识符转换为另一种时(例如从 ChEBI 转换到 ChEMBL)。
技能链接
https://github.com/K-Dense-AI/scientific-agent-skills/blob/main/skills/bioservices/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“查找人类 ZAP70 蛋白的信息,并告诉我它的登录号和基因名称。”
每周 5 个新技能,1 分钟读完。
工作原理
这个工具会把你的查询发送到在线生物学服务,并收集返回的结果。它知道如何与不同数据库通信,并把结果整理成易懂的形式呈现给你。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
BioServices
When to use
Use BioServices when combining protein annotation, gene/pathway membership, compound cross-references, or genomic resources in Python. Its service clients share transport helpers, but their request parameters and return types differ. Use the service reference before composing clients; method names from PubChemPy, mygene, or older BioServices are not portable.
Targets bioservices 1.16.0, the current PyPI release at review. Package metadata allows Python >=3.9,<4; the bundled tests were run in an isolated Python 3.13 environment. The previous 3.12 upper bound was not a package requirement.
uv pip install "bioservices==1.16.0"
Workflow
- Resolve the requested organism and entity to stable accessions. Review search hits before selecting one; gene symbols and compound names may be ambiguous.
- Inspect the service's actual response type, including pagination and errors.
BioServices can return an integer-like HTTP error or
None, not only raise. - Preserve one-to-many mappings, failed identifiers, taxonomy, database release, query parameters, and retrieval date alongside derived tables.
- Distinguish annotations and inferred associations from experimental evidence. Pathway membership alone is not an enrichment analysis or causal finding.
- Run a small lookup before batching; honor provider limits and retain failures separately from confirmed empty results.
Protein search, sequence retrieval, and mapping
from bioservices import UniProt
u = UniProt(verbose=False)
u.services.TIMEOUT = 30
rows = u.search(
"gene_exact:ZAP70 AND organism_id:9606 AND reviewed:true",
frmt="tsv", columns="accession,gene_names,organism_name,length",
limit=5, size=5,
)
if not isinstance(rows, str):
raise RuntimeError("UniProt search failed")
print(rows)
fasta = u.retrieve("P43403", frmt="fasta")
record = u.retrieve("P43403", frmt="json")
mapping = u.mapping(fr="UniProtKB_AC-ID", to="KEGG", query="P43403")
if not isinstance(mapping, dict) or "results" not in mapping:
raise RuntimeError("Mapping incomplete or failed")
kegg_ids = [row["to"] for row in mapping["results"] if row["from"] == "P43403"]
print(kegg_ids, mapping.get("failedIds", []))
Use frmt="tsv", not "tab"; current field names include accession,
gene_names, organism_name, protein_name, go_id, and xref_pdb.
mapping() returns a results/failedIds envelope, not a source-to-list
dictionary. Mapping to UniProt uses to="UniProtKB" and returns full records
in row["to"]; extract primaryAccession. UniProtKB_AC-ID is a source code.
See identifier mapping for allowed pairs,
normalization, and limits. For bounded searches set size=limit (at most 500);
1.16.0 mixes the two values in its pagination loop.
KEGG pathways and networks
from bioservices import KEGG
k = KEGG(verbose=False)
k.services.url = "https://rest.kegg.jp"
pathway_names = k.get_pathway_by_gene("7535", "hsa") # dict: pathway ID -> name
print(pathway_names)
kgml = k.parse_kgml_pathway("hsa04660")
entries = {entry["id"]: entry for entry in kgml["entries"]}
for relation in kgml["relations"][:5]:
print(entries[relation["entry1"]]["name"], relation["name"],
entries[relation["entry2"]]["name"])
The reviewed /list/organism endpoint returned HTTP 400 despite remaining in
the manual. SDK methods that validate against that catalogue can fail. The
bundled compound and pathway-list scripts use the documented scoped endpoints
through k.services.http_get to avoid that unrelated catalogue dependency.
KEGG get permits at most ten entries; KGML permits one pathway per request.
Keep requests at or below three per second. list/find return TSV strings;
get returns a flat-file string unless an option changes the representation.
KGML entries include genes, compounds, groups, and maps. A relation can produce
several subtype records; those counts are neither unique genes nor independent
physical interactions. Entry IDs are local to each pathway. The bundled SIF
export namespaces them as pathway#entry so combining pathways cannot merge
unrelated nodes. pathway2sif(..., uniprot=False) is an optional lossy projection
of gene-to-gene activation/inhibition, not a complete pathway network.
Compound cross-references
from bioservices import UniChem
uc = UniChem(verbose=False)
…
常见问题
UniProt、KEGG、ChEMBL、Reactome 和 QuickGO 是什么?
它们都是大型数据库,分别存储蛋白质、基因、化合物和生物过程等方面的信息。
什么是“蛋白质注释”?
指为蛋白质添加描述性信息的过程,比如它的功能、所在位置和相互作用等。
什么是生物“通路”?
通路是细胞内发生的一系列分子相互作用,最终会产生某种产物或引起某种细胞变化。
详情
作者的原始描述
Provides a Python interface to bioinformatics services including UniProt, KEGG, ChEMBL, Reactome, QuickGO, and UniChem. Used for cross-database protein annotation, pathway retrieval, chemical identifier mapping, and integrated biological data workflows with BioServices.
热度
- GitHub 星标
- 51k
- 排名
- #3433
- 许可证
- MIT
- 更新时间
- 2026/10/15
评论
- …