# QA 로그 — HepatoLipidFlux

- 대상 프로젝트: `2026-05-18-3-hepato-lipid-flux`
- QA 수행일: 2026-05-18
- 실행 환경: Python 3.9.6 (macOS)
- 설치 패키지: numpy 2.0.2, scipy 1.13.1, pandas 2.3.3, matplotlib OK
- 미설치 패키지: **streamlit**, **statsmodels** (전역 설치 금지 제약에 따라 미설치)

> 본 도구는 연구용·참고용입니다. QA는 코드 정상 동작 검증 목적이며
> 데이터는 전부 합성(synthetic)입니다.

---

## 체크 1 — Python 구문 검사 (`ast.parse`)

| 파일 | 명령 | 결과 |
|------|------|------|
| `flux_core.py` | `python3 -c "import ast; ast.parse(open('flux_core.py').read())"` | **PASS** |
| `app.py` | `python3 -c "import ast; ast.parse(open('app.py').read())"` | **PASS** |
| `generate_sample_data.py` | `python3 -c "import ast; ast.parse(open('generate_sample_data.py').read())"` | **PASS** |

세 파일 모두 구문 오류 없음.

## 체크 2 — 샘플 데이터 생성

- 명령: `python3 generate_sample_data.py`
- 결과: **PASS**
- 생성 파일 (`data/`):
  - `animal_meta.csv` — 18 행
  - `plasma_tg_timeseries.csv` — 126 행 (18마리 × 7 시점)
  - `dnl_isotopomer.csv` — 18 행
  - `oxidation_tracer.csv` — 18 행
- 난수 시드 `20260518` 고정 → 재현 가능.

## 체크 3 — 생성 CSV pandas 재로딩

- 명령: `pd.read_csv()` 로 4개 파일 로드
- 결과: **PASS** — 모든 파일 정상 파싱 (126 / 18 / 18 / 18 행).

## 체크 4 — `flux_core.py` 단독 import (Streamlit 비의존)

- 명령: 프로젝트 디렉터리에서 `python3 -c "import flux_core"`
- 결과: **PASS** — streamlit 미설치 환경에서 정상 import.
  (`flux_core.py`는 streamlit을 import하지 않음. statsmodels/scipy는
  try/except로 선택적 처리하여 미설치 시에도 동작.)

## 체크 5 — `flux_core.py` 기능 점검 (데모 데이터)

데모 데이터를 로드해 5개 기능 함수를 모두 실행. 결과: **PASS**.

```
--- CSV reload ---  rows: 126 18 18 18

--- F1 VLDL ---
group means (mg/kg/h): {'Chow': 182.7, 'GAN_MASH': 311.4, 'GAN_MASH_DrugX': 233.0}
r2 range: 0.951-1.000 ; nonlinear: 15/18

--- F2 DNL (MIDA) ---
fractional DNL group means: {'Chow': 0.087, 'GAN_MASH': 0.362, 'GAN_MASH_DrugX': 0.138}
sensitivity spread example (row0): -20%=0.070 +20%=0.056

--- F3 Oxidation ---
flux group means (umol/kg/h): {'Chow': 365.6, 'GAN_MASH': 139.6, 'GAN_MASH_DrugX': 277.6}

--- F4 QC ---
GAN_MASH vldl vs GAN diet ref: in range
GAN_MASH dnl vs GAN diet ref: in range

--- F5 stats + mechanism ---
ANOVA VLDL F=56.33 p=1.06e-07 ; DNL F=53.67 p=1.46e-07 ; OX F=43.72 p=5.52e-07
mechanism GAN_MASH->DrugX: mixed (VLDL -25.2%, DNL -61.8%, OX +98.8%)
mixed-effects model: skipped (statsmodels 미설치 — 정상 fallback)

ALL FUNCTIONAL CHECKS PASSED
```

**수치 타당성 평가:**
- VLDL 분비율: Chow 183 < GAN_MASH 311 — MASH 모델에서 VLDL 분비
  증가 경향과 일치, 모두 참조범위 내.
- 비선형 포화 감지: 18마리 중 15마리에서 후기 포화 구간 자동 제외
  (5~6 시점만 회귀 사용) — 선형구간 자동탐지 기능 정상 작동.
- fractional DNL: Chow 0.087 → GAN_MASH 0.362 (MASH에서 DNL 항진),
  DrugX 0.138 로 억제 — 합리적. 전구체 ±20% 민감도 정상 산출.
- 산화 플럭스: GAN_MASH(140)에서 가장 낮고 DrugX(278)에서 회복 —
  MASH 산화 저하 경향과 일치.
- ANOVA: 세 지표 모두 p < 1e-6 으로 그룹 차이 유의 (scipy 사용).
- 기전 분류: GAN_MASH→DrugX 가 DNL -62%, 산화 +99% 로 'mixed'
  (합성억제 + 산화촉진) 분류 — 합리적.
- isotopomer 분포 합 = 1.000000 (이항모델 정규화 검증).

## 체크 6 — `app.py` 검증

- streamlit 미설치 환경이므로 실행 검증 불가.
- 수행: `ast.parse` 구문 검사 → **PASS**.
- 비고: **streamlit not installed in env, syntax-checked only.**
- `app.py`는 `flux_core.py`의 검증된 함수만 호출하며, 데모 데이터
  로드 분기(`Load demo data` 버튼)와 파일 업로드 분기를 모두 구현.

---

## 종합 결과: **PASS**

- 6개 체크 모두 통과 (체크 6은 streamlit 미설치로 구문검사만 — 제약 명시).
- 5개 핵심 기능이 데모 데이터에서 정상 동작하고 생리학적으로
  타당한 수치를 산출함을 확인.
- 외부 네트워크/API 호출 없음, 합성 데이터만 사용 — 제약 준수.

### 재현 방법
```bash
cd 2026-05-18-3-hepato-lipid-flux
python3 -c "import ast; [ast.parse(open(f).read()) for f in ['app.py','flux_core.py','generate_sample_data.py']]"
python3 generate_sample_data.py
python3 -c "import flux_core"
# (전체 앱 실행 시) pip install -r requirements.txt && streamlit run app.py
```
