Files
PlantAI-rag-new/agent/legacy-rag/scripts/utils/add_missing_genes.py
T
jerryandClaude Fable 5 2f82c4a8dc P4/M5: agent/legacy-rag 源码迁移(449 模块 191K 行)+ 影子 7911/7912 冒烟
- 按生产 7900 容器黄金清单迁移(compile.manifest 449 条目,0 缺失)
- 入口双态:api.app(生产同源 3 路由)/ api.main(裁剪 11 路由族 91 路径)
- 修复:advanced/__init__ 空文件(包标记误覆盖,已从主项目恢复)
- 修复:api/rag_routes.py 跨环境 site-packages 注入改 LEGACY_GF_SITE_PACKAGES 门控
- 修复:scripts/utils 缺失(动态加载 reasoning_engine)
- 影子验证:kg/stats 数据连通(6.2s,与 7900 同源 normalized 后端)

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-08-31 14:20:41 +08:00

76 lines
2.1 KiB
Python
Executable File

#!/usr/bin/env python3
"""
从附表补全 FtSPL5-24 实体
"""
import json
def main():
print("=" * 70)
print("Adding Missing FtSPL5-24 Genes")
print("=" * 70)
# 加载基因列表
with open('ftspl_gene_list.json') as f:
gene_list = json.load(f)
# 加载当前结果
with open('evaluation/auto_results/pmid31286919_final_v2.json') as f:
current = json.load(f)
# 当前已有的实体ID
existing_ids = {e['id'] for e in current['entities']}
print(f"\nCurrent entities: {len(existing_ids)}")
print(f"Gene list: {len(gene_list)}")
# 添加缺失的基因实体
added = 0
for gene in gene_list:
symbol = gene['symbol']
if symbol not in existing_ids:
entity = {
"id": symbol,
"name": symbol,
"type": "gene",
"species": "Fagopyrum tataricum",
"primary_id": gene['locus_id'],
"protein_length": gene['protein_length'],
"attributes": {"domain": gene.get('domain', '')}
}
current['entities'].append(entity)
existing_ids.add(symbol)
added += 1
print(f"\nAdded {added} new gene entities")
# 不添加 member_of 关系(Gold 中没有这些具体关系)
print(f"Note: Not adding member_of relations for all genes (not in Gold Standard)")
# 保存
print(f"\nFinal stats:")
print(f" Total entities: {len(current['entities'])}")
print(f" Total relations: {len(current['relations'])}")
output_path = 'evaluation/auto_results/pmid31286919_complete.json'
with open(output_path, 'w') as f:
json.dump(current, f, indent=2)
print(f"\n✓ Saved to: {output_path}")
# 评估
print("\n" + "=" * 70)
print("Evaluation")
print("=" * 70)
import subprocess
subprocess.run([
'python3', 'evaluation/compare_extraction.py',
'--gold', 'evaluation/gold_standard/pmid31286919_layer2_full.json',
'--pred', output_path
])
if __name__ == "__main__":
main()