# HepatoSeahorse — 검수 로그 (QA)

빌드 일시: 2026-05-11
빌드 에이전트: step2 #3

## 환경
- Python 3 (system)
- 사용 가능: pandas, numpy, scipy, openpyxl, lxml, streamlit
- 사용 불가: statsmodels, plotly → 코드에서 try/except 폴백 처리 (scipy.stats.tukey_hsd 사용)

## 검수 1: AST parse 5개 파일
```
python3 -c "import ast; ast.parse(open('main.py').read())"               -> OK
python3 -c "import ast; ast.parse(open('seahorse_parser.py').read())"    -> OK
python3 -c "import ast; ast.parse(open('bioenergetics.py').read())"      -> OK
python3 -c "import ast; ast.parse(open('qc.py').read())"                 -> OK
python3 -c "import ast; ast.parse(open('data/synthetic_generator.py').read())" -> OK
```
결과: PASS (5/5)

## 검수 2: 합성 데이터 생성
```
python3 data/synthetic_generator.py
[gen] mito_stress.csv: 288 rows
[gen] glycolysis_stress.csv: 288 rows
[gen] fao_assay.csv: 288 rows
[gen] atp_rate.csv: 216 rows
[done] wrote 1080 rows
```
결과: PASS — 4개 CSV 생성, seed=42 재현 가능

## 검수 3: CSV load 가능 여부
```
pandas.read_csv('data/synthetic/mito_stress.csv')
-> shape (288, 13)
-> cols: plate_id, well, group, cell_type, drug, dose, substrate,
         measurement, time_min, injection, ocr, ecar, ppr
```
결과: PASS — 모든 필수 컬럼 (well, measurement, ocr, ecar) + optional 컬럼 존재

## 검수 4: CLI demo 실행 (streamlit 없이)
`python3 main.py --demo` 정상 종료 (exit 0). 출력 요약:
- 4 plate 모두 감지: ATP Rate Assay, FAO Assay, Glycolysis Stress, Mito Stress
- 각 plate 24 well 분석 완료
- QC: Mito Stress 23 Pass / 1 Excludable, FAO 22/0/2, Glyc 22/0/2, ATP 20/3/1
- 11 parameter 모두 정상 계산
  - 예: Mito Stress 기저 OCR 평균, ATP-linked, maximal, spare, proton leak, non-mito
  - 예: Glyc Stress glycolytic capacity (82.01 ± 38.35), reserve (34.90 ± 16.79)
  - 예: ATP Rate basal_atp_rate (124.96 ± 10.43), max_atp_rate (171.01 ± 14.81)
- Phenotype quadrant 분류 동작 (Energetic / Glycolytic / Aerobic / Quiescent)
- Substrate dependence (FAO Assay):
  - HepG2 vehicle: FAO=24.17, CPT1-dep=42.71, Gln-dep=26.04, flex_idx=0.037
- ANOVA basal_OCR ~ drug: F=37.68, p<0.0001 (ATP Rate Assay)
- Tukey HSD: 7 pair p<0.05 (ATP Rate Assay)
- 한국어 manuscript-ready 요약 출력 OK

결과: PASS

## 검수 5: Protocol auto-detect
초기에는 FAO assay가 Mito Stress로 감지됨 (injection sequence 동일). 
substrate 컬럼에 "palmitate"/"etomoxir"/"bsa" 포함되면 FAO Assay로 보정하는 refinement 추가.
재실행 결과: 4 protocol 모두 정확히 감지.
결과: PASS

## 종합 결과
- AST parse:       5/5 PASS
- 데이터 생성:     PASS (1080 rows / 4 CSV)
- CSV load:        PASS
- CLI demo:        PASS (exit 0, 모든 5 기능 정상 동작)
- Protocol detect: PASS (Mito / Glyc / FAO / ATP Rate 모두 정확)

## 제약 준수
- 외부 네트워크 호출 없음
- pip install 없음 (시스템 패키지만 사용)
- statsmodels/plotly 미설치 환경 대응 (scipy / matplotlib 폴백)
- Wave .asyr binary는 stub (계획대로)
- 의학적 디스클레이머 README 최상단 포함
- 24h 범위 내 5개 기능만 구현

## 실행법
```
streamlit run main.py    # interactive UI
python3 main.py --demo   # CLI demo (offline, recommended for capture)
python3 main.py --regen  # regenerate synthetic data
```
