> ## Documentation Index
> Fetch the complete documentation index at: https://docs.kallima.bio/llms.txt
> Use this file to discover all available pages before exploring further.

# Immunogenicity analysis

> Predict MHC-I, MHC-II, and B-cell epitope risk from sequence.

Immunogenicity analysis predicts T-cell and B-cell epitope burden across the variable region of your variant. The output includes per-class risk scores (0–1), epitope lists with binding affinities, and deimmunization suggestions. The job takes 1–3 minutes and costs 2 credits.

## Submit a job

```python theme={null}
from kallima import KallimaClient

client = KallimaClient(api_key)

job = client.immunogenicity_analyses.submit(variant_id=variant_id)
job.wait(timeout=300)
```

## Read the result

```python theme={null}
result = job.results

print(result["risk_score"])   # composite immunogenicity risk, 0–1
print(result["mhc1_risk"])    # MHC class I risk, 0–1
print(result["mhc2_risk"])    # MHC class II risk, 0–1
print(result["bcell_risk"])   # linear B-cell epitope risk, 0–1
```

Lower is better. A `mhc2_risk` above \~0.5 warrants deimmunization before advancing.

### Epitope lists

```python theme={null}
for epitope in result["mhc1_epitopes"] or []:
    print(epitope["peptide"], epitope["allele"], epitope["affinity_nm"])

for epitope in result["mhc2_epitopes"] or []:
    print(epitope["peptide"], epitope["allele"], epitope["score"])

for epitope in result["bcell_epitopes"] or []:
    print(epitope["start"], epitope["end"], epitope["sequence"])
```

### Deimmunization suggestions

```python theme={null}
for suggestion in result["deimmunization_suggestions"] or []:
    print(suggestion["position"], suggestion["wild_type"], suggestion["mutation"],
          suggestion["mhc1_risk_delta"], suggestion["mhc2_risk_delta"])
```

Each suggestion is a point mutation that reduces epitope burden. `risk_delta` values are negative when the substitution helps.

### Predictor versions

```python theme={null}
print(result["model_versions"])  # e.g. {"mhcflurry": "2.1.4"}
```

## Compare across variants

```python theme={null}
import os
from kallima import KallimaClient

client = KallimaClient(os.environ["KALLIMA_API_KEY"])

variant_ids = ["var_aaa...", "var_bbb...", "var_ccc..."]
jobs = [client.immunogenicity_analyses.submit(vid) for vid in variant_ids]

for job in jobs:
    job.wait(timeout=300)
    r = job.results
    print(f"{job.variant_id}  MHC-II risk: {r['mhc2_risk']:.2f}  B-cell: {r['bcell_risk']:.2f}")
```

## List prior analyses for a variant

```python theme={null}
for job in client.immunogenicity_analyses.list(variant_id=variant_id):
    print(job.id, job.status, job["created_at"])
```
