ensembl-database by davila7/claude-code-templates
npx skills add https://github.com/davila7/claude-code-templates --skill ensembl-database访问和查询 Ensembl 基因组数据库,这是一个由 EMBL-EBI 维护的综合性脊椎动物基因组数据资源。该数据库为超过 250 个物种提供基因注释、序列、变异、调控信息和比较基因组学数据。当前版本为 115(2025 年 9 月)。
在以下情况下应使用此技能:
通过基因符号、Ensembl ID 或外部数据库标识符查询基因数据。
常见操作:
使用 ensembl_rest 包:
from ensembl_rest import EnsemblClient
client = EnsemblClient()
# 通过符号查找基因
gene_data = client.symbol_lookup(
species='human',
symbol='BRCA2'
)
# 获取详细的基因信息
gene_info = client.lookup_id(
id='ENSG00000139618', # BRCA2 Ensembl ID
expand=True
)
直接使用 REST API(无需安装包):
import requests
server = "https://rest.ensembl.org"
# 符号查找
response = requests.get(
f"{server}/lookup/symbol/homo_sapiens/BRCA2",
headers={"Content-Type": "application/json"}
)
gene_data = response.json()
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
以各种格式(JSON、FASTA、纯文本)获取基因组、转录本或蛋白质序列。
操作:
示例:
# 使用 ensembl_rest 包
sequence = client.sequence_id(
id='ENSG00000139618', # Gene ID
content_type='application/json'
)
# 获取基因组区域的序列
region_seq = client.sequence_region(
species='human',
region='7:140424943-140624564' # chromosome:start-end
)
查询遗传变异数据并使用变异效应预测器(VEP)预测变异后果。
功能:
VEP 示例:
# 预测变异后果
vep_result = client.vep_hgvs(
species='human',
hgvs_notation='ENST00000380152.7:c.803C>T'
)
# 通过 rsID 查询变异
variant = client.variation_id(
species='human',
id='rs699'
)
执行跨物种比较以识别直系同源物、旁系同源物和进化关系。
操作:
示例:
# 查找人类基因的直系同源物
orthologs = client.homology_ensemblgene(
id='ENSG00000139618', # Human BRCA2
target_species='mouse'
)
# 获取基因树
gene_tree = client.genetree_member_symbol(
species='human',
symbol='BRCA2'
)
查找特定区域内的所有基因组特征(基因、转录本、调控元件)。
使用场景:
示例:
# 查找区域内的所有特征
features = client.overlap_region(
species='human',
region='7:140424943-140624564',
feature='gene'
)
在不同基因组组装版本之间转换坐标(例如,GRCh37 到 GRCh38)。
重要提示: 对于 GRCh37/hg19 查询使用 https://grch37.rest.ensembl.org,对于当前组装版本使用 https://rest.ensembl.org。
示例:
from ensembl_rest import AssemblyMapper
# 将坐标从 GRCh37 映射到 GRCh38
mapper = AssemblyMapper(
species='human',
asm_from='GRCh37',
asm_to='GRCh38'
)
mapped = mapper.map(chrom='7', start=140453136, end=140453136)
Ensembl REST API 有速率限制。请遵循以下实践:
Retry-After 标头并等待始终实施适当的错误处理:
import requests
import time
def query_ensembl(endpoint, params=None, max_retries=3):
server = "https://rest.ensembl.org"
headers = {"Content-Type": "application/json"}
for attempt in range(max_retries):
response = requests.get(
f"{server}{endpoint}",
headers=headers,
params=params
)
if response.status_code == 200:
return response.json()
elif response.status_code == 429:
# 速率限制 - 等待并重试
retry_after = int(response.headers.get('Retry-After', 1))
time.sleep(retry_after)
else:
response.raise_for_status()
raise Exception(f"Failed after {max_retries} attempts")
uv pip install ensembl_rest
ensembl_rest 包为所有 Ensembl REST API 端点提供了 Python 风格的接口。
无需安装 - 使用标准的 HTTP 库,如 requests:
uv pip install requests
api_endpoints.md:包含所有 17 个 API 端点类别的综合文档,附有示例和参数说明ensembl_query.py:用于常见 Ensembl 查询的可重用 Python 脚本,内置速率限制和错误处理功能要查询可用的物种和组装版本:
# 列出所有可用物种
species_list = client.info_species()
# 获取物种的组装信息
assembly_info = client.info_assembly(species='human')
常见的物种标识符:
homo_sapiens 或 humanmus_musculus 或 mousedanio_rerio 或 zebrafishdrosophila_melanogaster每周安装量
136
代码仓库
GitHub 星标数
23.4K
首次出现
2026 年 1 月 21 日
安全审计
安装于
claude-code119
opencode111
cursor106
gemini-cli105
antigravity100
codex95
Access and query the Ensembl genome database, a comprehensive resource for vertebrate genomic data maintained by EMBL-EBI. The database provides gene annotations, sequences, variants, regulatory information, and comparative genomics data for over 250 species. Current release is 115 (September 2025).
This skill should be used when:
Query gene data by symbol, Ensembl ID, or external database identifiers.
Common operations:
Using the ensembl_rest package:
from ensembl_rest import EnsemblClient
client = EnsemblClient()
# Look up gene by symbol
gene_data = client.symbol_lookup(
species='human',
symbol='BRCA2'
)
# Get detailed gene information
gene_info = client.lookup_id(
id='ENSG00000139618', # BRCA2 Ensembl ID
expand=True
)
Direct REST API (no package):
import requests
server = "https://rest.ensembl.org"
# Symbol lookup
response = requests.get(
f"{server}/lookup/symbol/homo_sapiens/BRCA2",
headers={"Content-Type": "application/json"}
)
gene_data = response.json()
Fetch genomic, transcript, or protein sequences in various formats (JSON, FASTA, plain text).
Operations:
Example:
# Using ensembl_rest package
sequence = client.sequence_id(
id='ENSG00000139618', # Gene ID
content_type='application/json'
)
# Get sequence for a genomic region
region_seq = client.sequence_region(
species='human',
region='7:140424943-140624564' # chromosome:start-end
)
Query genetic variation data and predict variant consequences using the Variant Effect Predictor (VEP).
Capabilities:
VEP example:
# Predict variant consequences
vep_result = client.vep_hgvs(
species='human',
hgvs_notation='ENST00000380152.7:c.803C>T'
)
# Query variant by rsID
variant = client.variation_id(
species='human',
id='rs699'
)
Perform cross-species comparisons to identify orthologs, paralogs, and evolutionary relationships.
Operations:
Example:
# Find orthologs for a human gene
orthologs = client.homology_ensemblgene(
id='ENSG00000139618', # Human BRCA2
target_species='mouse'
)
# Get gene tree
gene_tree = client.genetree_member_symbol(
species='human',
symbol='BRCA2'
)
Find all genomic features (genes, transcripts, regulatory elements) in a specific region.
Use cases:
Example:
# Find all features in a region
features = client.overlap_region(
species='human',
region='7:140424943-140624564',
feature='gene'
)
Convert coordinates between different genome assemblies (e.g., GRCh37 to GRCh38).
Important: Use https://grch37.rest.ensembl.org for GRCh37/hg19 queries and https://rest.ensembl.org for current assemblies.
Example:
from ensembl_rest import AssemblyMapper
# Map coordinates from GRCh37 to GRCh38
mapper = AssemblyMapper(
species='human',
asm_from='GRCh37',
asm_to='GRCh38'
)
mapped = mapper.map(chrom='7', start=140453136, end=140453136)
The Ensembl REST API has rate limits. Follow these practices:
Retry-After header and waitAlways implement proper error handling:
import requests
import time
def query_ensembl(endpoint, params=None, max_retries=3):
server = "https://rest.ensembl.org"
headers = {"Content-Type": "application/json"}
for attempt in range(max_retries):
response = requests.get(
f"{server}{endpoint}",
headers=headers,
params=params
)
if response.status_code == 200:
return response.json()
elif response.status_code == 429:
# Rate limited - wait and retry
retry_after = int(response.headers.get('Retry-After', 1))
time.sleep(retry_after)
else:
response.raise_for_status()
raise Exception(f"Failed after {max_retries} attempts")
uv pip install ensembl_rest
The ensembl_rest package provides a Pythonic interface to all Ensembl REST API endpoints.
No installation needed - use standard HTTP libraries like requests:
uv pip install requests
api_endpoints.md: Comprehensive documentation of all 17 API endpoint categories with examples and parametersensembl_query.py: Reusable Python script for common Ensembl queries with built-in rate limiting and error handlingTo query available species and assemblies:
# List all available species
species_list = client.info_species()
# Get assembly information for a species
assembly_info = client.info_assembly(species='human')
Common species identifiers:
homo_sapiens or humanmus_musculus or mousedanio_rerio or zebrafishdrosophila_melanogasterWeekly Installs
136
Repository
GitHub Stars
23.4K
First Seen
Jan 21, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykPass
Installed on
claude-code119
opencode111
cursor106
gemini-cli105
antigravity100
codex95
智能OCR文字识别工具 - 支持100+语言,高精度提取图片/PDF/手写文本
1,100 周安装