bioservices by davila7/claude-code-templates
npx skills add https://github.com/davila7/claude-code-templates --skill bioservicesBioServices 是一个 Python 软件包,提供对大约 40 个生物信息学网络服务和数据库的程序化访问。通过 Python 工作流检索生物数据、执行跨数据库查询、映射标识符、分析序列并整合多个生物资源。该软件包透明地处理 REST 和 SOAP/WSDL 协议。
此技能应在以下情况使用:
检索蛋白质信息、序列和功能注释:
from bioservices import UniProt
u = UniProt(verbose=False)
# 按名称搜索蛋白质
results = u.search("ZAP70_HUMAN", frmt="tab", columns="id,genes,organism")
# 检索 FASTA 序列
sequence = u.retrieve("P43403", "fasta")
# 在数据库之间映射标识符
kegg_ids = u.mapping(fr="UniProtKB_AC-ID", to="KEGG", query="P43403")
关键方法:
search(): 使用灵活的搜索词查询 UniProtretrieve(): 以各种格式(FASTA、XML、tab)获取蛋白质条目广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
mapping(): 在数据库之间转换标识符参考:references/services_reference.md 获取完整的 UniProt API 详情。
访问基因和生物体的 KEGG 途径信息:
from bioservices import KEGG
k = KEGG()
k.organism = "hsa" # 设置为人类
# 搜索生物体
k.lookfor_organism("droso") # 查找果蝇物种
# 按名称查找途径
k.lookfor_pathway("B cell") # 返回匹配的途径 ID
# 获取包含特定基因的途径
pathways = k.get_pathway_by_gene("7535", "hsa") # ZAP70 基因
# 检索并解析途径数据
data = k.get("hsa04660")
parsed = k.parse(data)
# 提取途径相互作用
interactions = k.parse_kgml_pathway("hsa04660")
relations = interactions['relations'] # 蛋白质-蛋白质相互作用
# 转换为简单交互格式
sif_data = k.pathway2sif("hsa04660")
关键方法:
lookfor_organism()、lookfor_pathway(): 按名称搜索get_pathway_by_gene(): 查找包含基因的途径parse_kgml_pathway(): 提取结构化途径数据pathway2sif(): 获取蛋白质相互作用网络参考:references/workflow_patterns.md 获取完整的途径分析工作流。
跨多个数据库搜索和交叉引用化合物:
from bioservices import KEGG, UniChem
k = KEGG()
# 按名称搜索化合物
results = k.find("compound", "Geldanamycin") # 返回 cpd:C11222
# 获取包含数据库链接的化合物信息
compound_info = k.get("cpd:C11222") # 包含 ChEBI 链接
# 使用 UniChem 进行 KEGG → ChEMBL 交叉引用
u = UniChem()
chembl_id = u.get_compound_id_from_kegg("C11222") # 返回 CHEMBL278315
常见工作流:
参考:references/identifier_mapping.md 获取完整的跨数据库映射指南。
运行 BLAST 搜索和序列比对:
from bioservices import NCBIblast
s = NCBIblast(verbose=False)
# 针对 UniProtKB 运行 BLASTP
jobid = s.run(
program="blastp",
sequence=protein_sequence,
stype="protein",
database="uniprotkb",
email="your.email@example.com" # NCBI 要求
)
# 检查作业状态并检索结果
s.getStatus(jobid)
results = s.getResult(jobid, "out")
注意: BLAST 作业是异步的。检索结果前请检查状态。
在不同生物数据库之间转换标识符:
from bioservices import UniProt, KEGG
# UniProt 映射(支持许多数据库对)
u = UniProt()
results = u.mapping(
fr="UniProtKB_AC-ID", # 源数据库
to="KEGG", # 目标数据库
query="P43403" # 要转换的标识符
)
# KEGG 基因 ID → UniProt
kegg_to_uniprot = u.mapping(fr="KEGG", to="UniProtKB_AC-ID", query="hsa:7535")
# 对于化合物,使用 UniChem
from bioservices import UniChem
u = UniChem()
chembl_from_kegg = u.get_compound_id_from_kegg("C11222")
支持的映射(UniProt):
references/identifier_mapping.md)访问 GO 术语和注释:
from bioservices import QuickGO
g = QuickGO(verbose=False)
# 检索 GO 术语信息
term_info = g.Term("GO:0003824", frmt="obo")
# 搜索注释
annotations = g.Annotation(protein="P43403", format="tsv")
通过 PSICQUIC 查询相互作用数据库:
from bioservices import PSICQUIC
s = PSICQUIC(verbose=False)
# 查询特定数据库(例如,MINT)
interactions = s.query("mint", "ZAP70 AND species:9606")
# 列出可用的相互作用数据库
databases = s.activeDBs
可用数据库: MINT、IntAct、BioGRID、DIP 以及其他 30 多个。
BioServices 擅长整合多个服务进行综合分析。常见的集成模式:
执行完整的蛋白质表征工作流:
python scripts/protein_analysis_workflow.py ZAP70_HUMAN your.email@example.com
此脚本演示:
分析生物体的所有途径:
python scripts/pathway_analysis.py hsa output_directory/
提取并分析:
跨数据库映射化合物标识符:
python scripts/compound_cross_reference.py Geldanamycin
检索:
一次转换多个标识符:
python scripts/batch_id_converter.py input_ids.txt --from UniProtKB_AC-ID --to KEGG
不同服务以各种格式返回数据:
控制 API 请求行为:
from bioservices import KEGG
k = KEGG(verbose=False) # 抑制 HTTP 请求详情
k.TIMEOUT = 30 # 为慢速连接调整超时时间
将服务调用包装在 try-except 块中:
try:
results = u.search("ambiguous_query")
if results:
# 处理结果
pass
except Exception as e:
print(f"搜索失败: {e}")
使用标准生物体缩写:
hsa: 智人(人类)mmu: 小家鼠(小鼠)dme: 黑腹果蝇sce: 酿酒酵母(酵母)列出所有生物体:k.list("organism") 或 k.organismIds
BioServices 可与以下工具良好协作:
演示完整工作流的可执行 Python 脚本:
protein_analysis_workflow.py: 端到端蛋白质表征pathway_analysis.py: KEGG 途径发现和网络提取compound_cross_reference.py: 多数据库化合物搜索batch_id_converter.py: 批量标识符映射工具脚本可以直接执行或根据特定用例进行调整。
按需加载的详细文档:
services_reference.md: 包含所有 40 多个服务及其方法的综合列表workflow_patterns.md: 详细的多步骤分析工作流identifier_mapping.md: 跨数据库 ID 转换的完整指南在处理特定服务或复杂集成任务时加载参考文档。
uv pip install bioservices
依赖项自动管理。软件包在 Python 3.9-3.12 上测试。
有关详细的 API 文档和高级功能,请参考:
references/services_reference.md每周安装次数
154
仓库
GitHub 星标数
23.4K
首次出现
2026年1月21日
安全审计
安装于
claude-code129
opencode127
gemini-cli123
cursor123
antigravity114
codex112
BioServices is a Python package providing programmatic access to approximately 40 bioinformatics web services and databases. Retrieve biological data, perform cross-database queries, map identifiers, analyze sequences, and integrate multiple biological resources in Python workflows. The package handles both REST and SOAP/WSDL protocols transparently.
This skill should be used when:
Retrieve protein information, sequences, and functional annotations:
from bioservices import UniProt
u = UniProt(verbose=False)
# Search for protein by name
results = u.search("ZAP70_HUMAN", frmt="tab", columns="id,genes,organism")
# Retrieve FASTA sequence
sequence = u.retrieve("P43403", "fasta")
# Map identifiers between databases
kegg_ids = u.mapping(fr="UniProtKB_AC-ID", to="KEGG", query="P43403")
Key methods:
search(): Query UniProt with flexible search termsretrieve(): Get protein entries in various formats (FASTA, XML, tab)mapping(): Convert identifiers between databasesReference: references/services_reference.md for complete UniProt API details.
Access KEGG pathway information for genes and organisms:
from bioservices import KEGG
k = KEGG()
k.organism = "hsa" # Set to human
# Search for organisms
k.lookfor_organism("droso") # Find Drosophila species
# Find pathways by name
k.lookfor_pathway("B cell") # Returns matching pathway IDs
# Get pathways containing specific genes
pathways = k.get_pathway_by_gene("7535", "hsa") # ZAP70 gene
# Retrieve and parse pathway data
data = k.get("hsa04660")
parsed = k.parse(data)
# Extract pathway interactions
interactions = k.parse_kgml_pathway("hsa04660")
relations = interactions['relations'] # Protein-protein interactions
# Convert to Simple Interaction Format
sif_data = k.pathway2sif("hsa04660")
Key methods:
lookfor_organism(), lookfor_pathway(): Search by nameget_pathway_by_gene(): Find pathways containing genesparse_kgml_pathway(): Extract structured pathway datapathway2sif(): Get protein interaction networksReference: references/workflow_patterns.md for complete pathway analysis workflows.
Search and cross-reference compounds across multiple databases:
from bioservices import KEGG, UniChem
k = KEGG()
# Search compounds by name
results = k.find("compound", "Geldanamycin") # Returns cpd:C11222
# Get compound information with database links
compound_info = k.get("cpd:C11222") # Includes ChEBI links
# Cross-reference KEGG → ChEMBL using UniChem
u = UniChem()
chembl_id = u.get_compound_id_from_kegg("C11222") # Returns CHEMBL278315
Common workflow:
Reference: references/identifier_mapping.md for complete cross-database mapping guide.
Run BLAST searches and sequence alignments:
from bioservices import NCBIblast
s = NCBIblast(verbose=False)
# Run BLASTP against UniProtKB
jobid = s.run(
program="blastp",
sequence=protein_sequence,
stype="protein",
database="uniprotkb",
email="your.email@example.com" # Required by NCBI
)
# Check job status and retrieve results
s.getStatus(jobid)
results = s.getResult(jobid, "out")
Note: BLAST jobs are asynchronous. Check status before retrieving results.
Convert identifiers between different biological databases:
from bioservices import UniProt, KEGG
# UniProt mapping (many database pairs supported)
u = UniProt()
results = u.mapping(
fr="UniProtKB_AC-ID", # Source database
to="KEGG", # Target database
query="P43403" # Identifier(s) to convert
)
# KEGG gene ID → UniProt
kegg_to_uniprot = u.mapping(fr="KEGG", to="UniProtKB_AC-ID", query="hsa:7535")
# For compounds, use UniChem
from bioservices import UniChem
u = UniChem()
chembl_from_kegg = u.get_compound_id_from_kegg("C11222")
Supported mappings (UniProt):
references/identifier_mapping.md)Access GO terms and annotations:
from bioservices import QuickGO
g = QuickGO(verbose=False)
# Retrieve GO term information
term_info = g.Term("GO:0003824", frmt="obo")
# Search annotations
annotations = g.Annotation(protein="P43403", format="tsv")
Query interaction databases via PSICQUIC:
from bioservices import PSICQUIC
s = PSICQUIC(verbose=False)
# Query specific database (e.g., MINT)
interactions = s.query("mint", "ZAP70 AND species:9606")
# List available interaction databases
databases = s.activeDBs
Available databases: MINT, IntAct, BioGRID, DIP, and 30+ others.
BioServices excels at combining multiple services for comprehensive analysis. Common integration patterns:
Execute a full protein characterization workflow:
python scripts/protein_analysis_workflow.py ZAP70_HUMAN your.email@example.com
This script demonstrates:
Analyze all pathways for an organism:
python scripts/pathway_analysis.py hsa output_directory/
Extracts and analyzes:
Map compound identifiers across databases:
python scripts/compound_cross_reference.py Geldanamycin
Retrieves:
Convert multiple identifiers at once:
python scripts/batch_id_converter.py input_ids.txt --from UniProtKB_AC-ID --to KEGG
Different services return data in various formats:
Control API request behavior:
from bioservices import KEGG
k = KEGG(verbose=False) # Suppress HTTP request details
k.TIMEOUT = 30 # Adjust timeout for slow connections
Wrap service calls in try-except blocks:
try:
results = u.search("ambiguous_query")
if results:
# Process results
pass
except Exception as e:
print(f"Search failed: {e}")
Use standard organism abbreviations:
hsa: Homo sapiens (human)mmu: Mus musculus (mouse)dme: Drosophila melanogastersce: Saccharomyces cerevisiae (yeast)List all organisms: k.list("organism") or k.organismIds
BioServices works well with:
Executable Python scripts demonstrating complete workflows:
protein_analysis_workflow.py: End-to-end protein characterizationpathway_analysis.py: KEGG pathway discovery and network extractioncompound_cross_reference.py: Multi-database compound searchingbatch_id_converter.py: Bulk identifier mapping utilityScripts can be executed directly or adapted for specific use cases.
Detailed documentation loaded as needed:
services_reference.md: Comprehensive list of all 40+ services with methodsworkflow_patterns.md: Detailed multi-step analysis workflowsidentifier_mapping.md: Complete guide to cross-database ID conversionLoad references when working with specific services or complex integration tasks.
uv pip install bioservices
Dependencies are automatically managed. Package is tested on Python 3.9-3.12.
For detailed API documentation and advanced features, refer to:
references/services_reference.mdWeekly Installs
154
Repository
GitHub Stars
23.4K
First Seen
Jan 21, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykWarn
Installed on
claude-code129
opencode127
gemini-cli123
cursor123
antigravity114
codex112
Apify Actor 输出模式生成工具 - 自动化创建 dataset_schema.json 与 output_schema.json
1,100 周安装