Files
PlantAI-rag/evaluation/annotate_苦荞SPL_template.py
2026-07-10 17:59:59 +08:00

184 lines
6.9 KiB
Python
Executable File
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/usr/bin/env python3
"""
苦荞SPL论文人工标注模板
请按照以下步骤完成标注
"""
import sys
sys.path.insert(0, '/home/xzq/gene-family-mas-v2')
from evaluation.gold_standard_annotator import GoldStandardAnnotator
def main():
"""
==================== 人工标注指南 ====================
步骤1: 阅读论文
- 先读Abstract,了解主要发现
- 再读Results开头,看具体实验结果
- 重点关注: 基因名称、家族关系、表达模式、功能描述
步骤2: 标注实体
- 找到论文中出现的基因、蛋白、家族、结构域等
- 记录它们在原文中的位置(可选,用于验证)
- 确保每个实体有唯一的ID
步骤3: 标注关系
- 找到实体之间的生物学关系
- 必须提供原文证据(snippet)
- 标注置信度(high/medium/low)
步骤4: 验证
- 运行脚本,检查是否有警告
- 确保所有high/medium关系都有evidence
步骤5: 保存
- 保存为JSON
- 用于后续评估自动提取结果
"""
# ==================== 论文文本 ====================
# 请从PDF中提取以下章节文本(可以用PyMuPDF)
abstract_text = """
Background: SPL (SQUAMOSA promoter binding protein-like) is a class of
plant-specific transcription factors that play important roles in many growth
and developmental processes, including shoot and inflorescence branching,
embryonic development, signal transduction, leaf initiation, phase transition,
and flower and fruit development. The SPL gene family has been identified and
characterized in many species but has not been well studied in tartary buckwheat,
which is an important edible and medicinal crop.
Results: In this study, 24 Fagopyrum tataricum SPL (FtSPL) genes were identified
and renamed according to the chromosomal distribution of the FtSPL genes.
According to the amino acid sequence of the SBP domain and gene structure,
the SPL genes were divided into eight groups (group I to group VII) by
phylogenetic tree analysis. A total of 10 motifs were detected in the tartary
buckwheat SPL genes. The expression patterns of 23 SPL genes in different tissues
and fruits at different developmental stages (green fruit stage, discoloration
stage and initial maturity stage) were determined by quantitative real-time
polymerase chain reaction (qRT-PCR).
Conclusions: The tartary buckwheat genome contained 24 SPL genes, and most of
the genes were expressed in different tissues. qRT-PCR showed that FtSPLs played
important roles in the growth and development of tartary buckwheat, and genes
that might regulate flower and fruit development were preliminarily identified.
"""
# 可以添加更多章节文本
results_text = """
Results Identification of the FtSPL genes in tartary buckwheat
In this study, we extracted the SPL genes from the tartary buckwheat genome
by the two BLASTp methods, and we identified 24 SPL genes from tartary buckwheat
after removing the redundant sequences. We renamed the SPL genes based on their
location on the chromosomes of tartary buckwheat (Additional file 2 Table S1).
"""
# 合并文本(用于标注)
full_text = abstract_text + "\n\n" + results_text
# ==================== 创建标注器 ====================
annotator = GoldStandardAnnotator(
doc_id="pmid31286919",
text=full_text,
title="Genome-wide identification of the SPL gene family in Tartary Buckwheat"
)
# 设置元数据
annotator.set_metadata(
pmid="31286919",
doi="10.1186/s12870-019-1916-6",
species="Fagopyrum tataricum",
family="SPL"
)
# ==================== 步骤2: 标注实体 ====================
# 请根据论文内容,添加以下实体:
# 示例1: 基因家族
annotator.add_entity(
id="SPL",
name="SPL gene family",
type="gene_family",
description="SQUAMOSA promoter binding protein-like family"
)
# 示例2: 物种
annotator.add_entity(
id="Fagopyrum_tataricum",
name="Fagopyrum tataricum",
type="organism",
description="Tartary buckwheat"
)
# TODO: 请添加更多实体
# 提示:从文本中找以下类型的实体
# - gene: FtSPL相关基因(如FtSPL1, FtSPL2等,如果提到具体基因)
# - protein_domain: SBP domain, PF03110
# - tissue: flower, fruit, root, leaf等
# - developmental_stage: green fruit stage, discoloration stage等
# - assay: qRT-PCR, RNA-seq等
# - method: BLASTp, phylogenetic tree analysis等
# ==================== 步骤3: 标注关系 ====================
# 请根据论文内容,添加以下关系:
# 示例1: member_of关系
annotator.add_relation(
source="FtSPL", # 注意:需要先定义这个实体
target="SPL",
type="member_of",
confidence="high",
text_snippet="24 Fagopyrum tataricum SPL (FtSPL) genes were identified",
section="abstract",
evidence_level="prediction",
method="genome annotation",
member_count=24
)
# 示例2: contains关系(结构域)
annotator.add_relation(
source="FtSPL",
target="SBP", # 需要先定义SBP实体
type="contains",
confidence="high",
text_snippet="According to the amino acid sequence of the SBP domain",
section="abstract",
evidence_level="prediction",
method="domain annotation"
)
# TODO: 请添加更多关系
# 提示:从文本中找以下类型的关系
# - expressed_in: 基因在组织中表达
# - involved_in: 基因参与某过程
# - belongs_to: 基因属于某物种
# - classified_into: 基因被分到某组
# ==================== 步骤4: 添加关键发现 ====================
annotator.add_key_finding("24 FtSPL genes identified in tartary buckwheat genome")
annotator.add_key_finding("FtSPL genes contain SBP domain")
annotator.add_key_finding("FtSPL genes divided into eight groups")
annotator.add_key_finding("FtSPL genes expressed in different tissues")
annotator.add_key_finding("FtSPLs may regulate flower and fruit development")
# TODO: 添加更多关键发现
# ==================== 步骤5: 验证并保存 ====================
annotator.print_summary()
# 保存
output_path = "/home/xzq/gene-family-mas-v2/evaluation/gold_standard/pmid31286919_manual.json"
annotator.save(output_path)
print(f"\n✅ 标注完成!")
print(f"请检查输出文件: {output_path}")
print(f"\n下一步:")
print(f"1. 对比自动提取结果: python evaluate.py")
print(f"2. 计算准确率指标")
if __name__ == "__main__":
main()