PostgreSQL + Apache AGE에 식품-바이오마커 관계 추가: 1. schema_food_biomarker.sql - foods 테이블: 식품 마스터 (염증 유발/항염증) - biomarkers 테이블: IL-1β, CRP 등 바이오마커 - food_biomarker_effects: 식품-바이오마커 관계 - disease_biomarker_association: 질병-바이오마커 연결 - v_il1beta_increasing_foods 뷰: IL-1β 증가 식품 목록 - get_foods_to_avoid() 함수: 질병별 피해야 할 식품 2. age_food_graph.py - Apache AGE 그래프 노드 생성 (Food, Biomarker, Disease) - 관계 생성 (INCREASES, DECREASES, ASSOCIATED_WITH) - PostgreSQL 테이블 → Cypher 그래프 변환 3. import_il1beta_foods.py - PubMed 검색 결과 기반 식품 데이터 자동 입력 - 10개 식품 데이터 (7개 염증 유발 + 3개 항염증) - 근거 논문 PMID 포함 (36776889, 40864681 등) 4. il1beta_proinflammatory_foods_research.py - PubMed 검색: 고지방, 고당, 가공육, 적색육, 알코올 - 24개 논문 분석 - 카테고리별 분류 및 메커니즘 분석 활용: - NAFLD 환자 식이 지도 (고지방식 금지) - 관절염 환자 항염증 식단 (오메가-3 권장) - 근거 기반 영양 상담 (PubMed PMID 제시) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
335 lines
9.8 KiB
Python
335 lines
9.8 KiB
Python
"""
|
|
IL-1β(Interleukin-1 beta) 증가시키는 음식/건강기능식품 연구
|
|
|
|
목적: PubMed에서 IL-1β를 증가시키는(염증 유발) 식품 관련 논문 검색
|
|
작성일: 2026-02-04
|
|
"""
|
|
|
|
import sys
|
|
import os
|
|
|
|
# UTF-8 인코딩 강제 (Windows 한글 깨짐 방지)
|
|
if sys.platform == 'win32':
|
|
import io
|
|
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8')
|
|
sys.stderr = io.TextIOWrapper(sys.stderr.buffer, encoding='utf-8')
|
|
|
|
from Bio import Entrez
|
|
from dotenv import load_dotenv
|
|
|
|
load_dotenv()
|
|
|
|
# NCBI Entrez 설정
|
|
Entrez.email = os.getenv('PUBMED_EMAIL', 'test@example.com')
|
|
api_key = os.getenv('PUBMED_API_KEY')
|
|
if api_key:
|
|
Entrez.api_key = api_key
|
|
|
|
|
|
def search_pubmed(query, max_results=10):
|
|
"""PubMed 논문 검색"""
|
|
try:
|
|
print("=" * 80)
|
|
print(f"검색어: {query}")
|
|
print("=" * 80)
|
|
|
|
handle = Entrez.esearch(
|
|
db="pubmed",
|
|
term=query,
|
|
retmax=max_results,
|
|
sort="relevance"
|
|
)
|
|
record = Entrez.read(handle)
|
|
handle.close()
|
|
|
|
pmids = record["IdList"]
|
|
total_count = int(record["Count"])
|
|
|
|
print(f"[OK] 총 {total_count}건 검색됨, 상위 {len(pmids)}건 조회\n")
|
|
|
|
return pmids
|
|
|
|
except Exception as e:
|
|
print(f"[ERROR] 검색 실패: {e}")
|
|
return []
|
|
|
|
|
|
def fetch_paper_details(pmids):
|
|
"""PMID로 논문 상세 정보 가져오기"""
|
|
try:
|
|
handle = Entrez.efetch(
|
|
db="pubmed",
|
|
id=pmids,
|
|
rettype="medline",
|
|
retmode="xml"
|
|
)
|
|
papers = Entrez.read(handle)
|
|
handle.close()
|
|
|
|
results = []
|
|
|
|
for idx, paper in enumerate(papers['PubmedArticle'], 1):
|
|
article = paper['MedlineCitation']['Article']
|
|
pmid = str(paper['MedlineCitation']['PMID'])
|
|
title = article.get('ArticleTitle', '')
|
|
|
|
# 초록 추출
|
|
abstract_parts = article.get('Abstract', {}).get('AbstractText', [])
|
|
full_abstract = ""
|
|
if abstract_parts:
|
|
if isinstance(abstract_parts, list):
|
|
for part in abstract_parts:
|
|
if hasattr(part, 'attributes') and 'Label' in part.attributes:
|
|
label = part.attributes['Label']
|
|
full_abstract += f"\n\n**{label}**\n{str(part)}"
|
|
else:
|
|
full_abstract += f"\n{str(part)}"
|
|
else:
|
|
full_abstract = str(abstract_parts)
|
|
|
|
# 메타데이터
|
|
journal = article.get('Journal', {}).get('Title', '')
|
|
pub_date = article.get('Journal', {}).get('JournalIssue', {}).get('PubDate', {})
|
|
year = pub_date.get('Year', '')
|
|
|
|
result = {
|
|
'pmid': pmid,
|
|
'title': title,
|
|
'abstract': full_abstract.strip(),
|
|
'journal': journal,
|
|
'year': year
|
|
}
|
|
|
|
results.append(result)
|
|
|
|
# 출력
|
|
print(f"[{idx}] PMID: {pmid}")
|
|
print(f"제목: {title}")
|
|
print(f"저널: {journal} ({year})")
|
|
print(f"링크: https://pubmed.ncbi.nlm.nih.gov/{pmid}/")
|
|
print("-" * 80)
|
|
print(f"초록:\n{full_abstract}")
|
|
print("=" * 80)
|
|
print()
|
|
|
|
return results
|
|
|
|
except Exception as e:
|
|
print(f"[ERROR] 논문 정보 가져오기 실패: {e}")
|
|
return []
|
|
|
|
|
|
def analyze_findings(papers):
|
|
"""연구 결과 분석 및 요약"""
|
|
|
|
print("\n" + "=" * 80)
|
|
print("IL-1β 증가시키는 식품 분석 결과")
|
|
print("=" * 80)
|
|
|
|
# 키워드 기반 분류
|
|
categories = {
|
|
'고지방 식품': ['high-fat', 'fatty', 'saturated fat', 'trans fat', 'lipid'],
|
|
'고당 식품': ['sugar', 'glucose', 'fructose', 'high-carbohydrate', 'sweetened'],
|
|
'가공식품': ['processed', 'ultra-processed', 'refined', 'junk food'],
|
|
'적색육': ['red meat', 'beef', 'pork', 'processed meat'],
|
|
'알코올': ['alcohol', 'ethanol', 'drinking'],
|
|
'염증 유발 오일': ['omega-6', 'vegetable oil', 'corn oil', 'soybean oil'],
|
|
'기타': []
|
|
}
|
|
|
|
findings = {cat: [] for cat in categories.keys()}
|
|
|
|
for paper in papers:
|
|
abstract_lower = paper['abstract'].lower()
|
|
title_lower = paper['title'].lower()
|
|
combined_text = title_lower + ' ' + abstract_lower
|
|
|
|
# IL-1β 증가 관련 키워드 확인
|
|
if any(keyword in combined_text for keyword in ['increase', 'elevated', 'upregulated', 'higher']):
|
|
if 'il-1' in combined_text or 'interleukin-1' in combined_text:
|
|
|
|
# 카테고리 분류
|
|
categorized = False
|
|
for category, keywords in categories.items():
|
|
if category == '기타':
|
|
continue
|
|
if any(keyword in combined_text for keyword in keywords):
|
|
findings[category].append({
|
|
'pmid': paper['pmid'],
|
|
'title': paper['title'],
|
|
'year': paper['year']
|
|
})
|
|
categorized = True
|
|
break
|
|
|
|
if not categorized:
|
|
findings['기타'].append({
|
|
'pmid': paper['pmid'],
|
|
'title': paper['title'],
|
|
'year': paper['year']
|
|
})
|
|
|
|
# 결과 출력
|
|
for category, papers_list in findings.items():
|
|
if papers_list:
|
|
print(f"\n### {category} ({len(papers_list)}건)")
|
|
for paper in papers_list:
|
|
print(f" - [{paper['year']}] {paper['title']}")
|
|
print(f" PMID: {paper['pmid']}")
|
|
|
|
print("\n" + "=" * 80)
|
|
|
|
|
|
def print_summary():
|
|
"""연구 요약 및 GraphRAG 구조 제안"""
|
|
|
|
print("\n" + "=" * 80)
|
|
print("GraphRAG 지식 그래프 구조 제안")
|
|
print("=" * 80)
|
|
|
|
summary = '''
|
|
## IL-1β 증가시키는 식품 GraphRAG 모델
|
|
|
|
### 노드 타입
|
|
1. Food (음식)
|
|
- name: "고지방 식품", "설탕", "가공육" 등
|
|
- category: "pro_inflammatory"
|
|
|
|
2. Biomarker (바이오마커)
|
|
- name: "IL-1β"
|
|
- type: "inflammatory_cytokine"
|
|
|
|
3. Disease (질병)
|
|
- name: "만성 염증", "대사증후군", "심혈관질환"
|
|
|
|
4. Evidence (PubMed 논문)
|
|
- pmid: "12345678"
|
|
- reliability: 0.85
|
|
|
|
### 관계 타입
|
|
1. INCREASES (음식 → IL-1β)
|
|
- magnitude: "high", "moderate", "low"
|
|
- mechanism: "AGE_formation", "oxidative_stress", "gut_microbiome"
|
|
|
|
2. ASSOCIATED_WITH (IL-1β → 질병)
|
|
- strength: 0.8
|
|
|
|
3. SUPPORTED_BY (관계 → Evidence)
|
|
- pmid: "12345678"
|
|
|
|
### Cypher 쿼리 예시
|
|
|
|
# 1. IL-1β를 증가시키는 모든 식품 조회
|
|
MATCH (food:Food)-[inc:INCREASES]->(il1b:Biomarker {name: 'IL-1β'})
|
|
OPTIONAL MATCH (inc)-[:SUPPORTED_BY]->(e:Evidence)
|
|
RETURN food.name AS 식품,
|
|
inc.magnitude AS 증가정도,
|
|
inc.mechanism AS 메커니즘,
|
|
e.pmid AS 근거논문
|
|
ORDER BY inc.magnitude DESC
|
|
|
|
# 2. 고지방 식품 → IL-1β → 질병 경로
|
|
MATCH path = (food:Food {category: 'high_fat'})
|
|
-[:INCREASES]->(il1b:Biomarker {name: 'IL-1β'})
|
|
-[:ASSOCIATED_WITH]->(disease:Disease)
|
|
RETURN food.name AS 식품,
|
|
disease.name AS 질병,
|
|
[node IN nodes(path) | node.name] AS 경로
|
|
|
|
# 3. 특정 환자에게 피해야 할 식품 추천
|
|
MATCH (patient:PatientProfile {conditions: ['chronic_inflammation']})
|
|
MATCH (food:Food)-[:INCREASES]->(il1b:Biomarker {name: 'IL-1β'})
|
|
-[:ASSOCIATED_WITH]->(disease:Disease)
|
|
WHERE disease.name IN patient.conditions
|
|
RETURN DISTINCT food.name AS 피해야할식품,
|
|
disease.name AS 이유
|
|
ORDER BY food.name
|
|
|
|
### 약국 활용 시나리오
|
|
|
|
**시나리오 1: 만성 염증 환자 상담**
|
|
```
|
|
환자: "관절염이 있는데 식습관 개선 방법이 있나요?"
|
|
약사 (시스템):
|
|
"IL-1β 염증 지표를 증가시키는 다음 식품들을 피하세요:
|
|
1. 가공육 (베이컨, 소시지) - PMID:30371340
|
|
2. 설탕 함유 음료 - PMID:27959716
|
|
3. 트랜스지방 (마가린) - PMID:34559859
|
|
|
|
대신 오메가-3 (EPA/DHA) 보충제를 권장합니다."
|
|
```
|
|
|
|
**시나리오 2: 건강기능식품 업셀링**
|
|
```
|
|
고객: "염증 줄이는 제품 있나요?"
|
|
약사 (시스템):
|
|
"IL-1β 감소 효과가 있는 제품:
|
|
1. 오메가-3 1000mg (하루 2회)
|
|
- IL-1β 30% 감소 (PMID:12345678)
|
|
2. 커큐민 500mg
|
|
- NF-κB 억제로 IL-1β 감소
|
|
|
|
피해야 할 식품:
|
|
- 고지방 패스트푸드
|
|
- 탄산음료
|
|
- 가공 스낵"
|
|
```
|
|
'''
|
|
|
|
print(summary)
|
|
|
|
|
|
def main():
|
|
"""메인 실행"""
|
|
|
|
print("\n" + "=" * 80)
|
|
print("IL-1β 증가시키는 음식/건강기능식품 연구")
|
|
print("=" * 80)
|
|
|
|
# 검색어 목록
|
|
queries = [
|
|
# 1. 고지방 식품
|
|
"high-fat diet AND interleukin-1 beta AND inflammation",
|
|
|
|
# 2. 고당 식품
|
|
"sugar AND IL-1β AND inflammatory response",
|
|
|
|
# 3. 가공식품
|
|
"processed food AND interleukin-1 AND pro-inflammatory",
|
|
|
|
# 4. 적색육
|
|
"red meat AND IL-1β AND inflammation",
|
|
|
|
# 5. 알코올
|
|
"alcohol AND interleukin-1 beta AND inflammation"
|
|
]
|
|
|
|
all_papers = []
|
|
|
|
for query in queries:
|
|
# PubMed 검색
|
|
pmids = search_pubmed(query, max_results=5)
|
|
|
|
if not pmids:
|
|
print(f"[WARNING] '{query}' 검색 결과 없음\n")
|
|
continue
|
|
|
|
# 논문 상세 정보
|
|
papers = fetch_paper_details(pmids)
|
|
all_papers.extend(papers)
|
|
|
|
# 결과 분석
|
|
if all_papers:
|
|
analyze_findings(all_papers)
|
|
print_summary()
|
|
|
|
print("\n" + "=" * 80)
|
|
print(f"총 {len(all_papers)}개 논문 분석 완료")
|
|
print("=" * 80)
|
|
else:
|
|
print("\n[ERROR] 검색된 논문이 없습니다.")
|
|
|
|
|
|
if __name__ == '__main__':
|
|
main()
|