Commit
·
7010654
1
Parent(s):
c80bf30
Initial deployment: Antibody non-specificity predictor
Browse files- ESM-1v (650M) + Logistic Regression
- Trained on Boughter dataset
- Pydantic v2 validation
- Gradio 5.x UI
app.py
CHANGED
|
@@ -11,7 +11,7 @@ import logging
|
|
| 11 |
import os
|
| 12 |
import sys
|
| 13 |
from pathlib import Path
|
| 14 |
-
from typing import Any
|
| 15 |
|
| 16 |
# Add src to Python path for local imports (HF Spaces doesn't install package)
|
| 17 |
sys.path.insert(0, str(Path(__file__).parent / "src"))
|
|
@@ -21,7 +21,7 @@ import torch
|
|
| 21 |
from pydantic import ValidationError
|
| 22 |
|
| 23 |
from antibody_training_esm.core.prediction import Predictor
|
| 24 |
-
from antibody_training_esm.models.prediction import PredictionRequest
|
| 25 |
|
| 26 |
# Configure logging
|
| 27 |
logging.basicConfig(level=logging.INFO)
|
|
@@ -73,12 +73,14 @@ def predict_sequence(
|
|
| 73 |
"""
|
| 74 |
try:
|
| 75 |
# Handle "None" string from dropdown
|
| 76 |
-
|
| 77 |
-
|
|
|
|
|
|
|
| 78 |
|
| 79 |
# Validate with Pydantic
|
| 80 |
request = PredictionRequest(
|
| 81 |
-
sequence=sequence, threshold=threshold, assay_type=
|
| 82 |
)
|
| 83 |
|
| 84 |
# Log request
|
|
|
|
| 11 |
import os
|
| 12 |
import sys
|
| 13 |
from pathlib import Path
|
| 14 |
+
from typing import Any, cast
|
| 15 |
|
| 16 |
# Add src to Python path for local imports (HF Spaces doesn't install package)
|
| 17 |
sys.path.insert(0, str(Path(__file__).parent / "src"))
|
|
|
|
| 21 |
from pydantic import ValidationError
|
| 22 |
|
| 23 |
from antibody_training_esm.core.prediction import Predictor
|
| 24 |
+
from antibody_training_esm.models.prediction import AssayType, PredictionRequest
|
| 25 |
|
| 26 |
# Configure logging
|
| 27 |
logging.basicConfig(level=logging.INFO)
|
|
|
|
| 73 |
"""
|
| 74 |
try:
|
| 75 |
# Handle "None" string from dropdown
|
| 76 |
+
validated_assay: AssayType | None = None
|
| 77 |
+
if assay_type and assay_type not in ("None", ""):
|
| 78 |
+
# Gradio dropdown guarantees value is "ELISA" or "PSR"
|
| 79 |
+
validated_assay = cast(AssayType, assay_type)
|
| 80 |
|
| 81 |
# Validate with Pydantic
|
| 82 |
request = PredictionRequest(
|
| 83 |
+
sequence=sequence, threshold=threshold, assay_type=validated_assay
|
| 84 |
)
|
| 85 |
|
| 86 |
# Log request
|
src/antibody_training_esm/schemas/__pycache__/dataset.cpython-312.pyc
CHANGED
|
Binary files a/src/antibody_training_esm/schemas/__pycache__/dataset.cpython-312.pyc and b/src/antibody_training_esm/schemas/__pycache__/dataset.cpython-312.pyc differ
|
|
|
src/antibody_training_esm/schemas/dataset.py
CHANGED
|
@@ -3,7 +3,6 @@ from __future__ import annotations
|
|
| 3 |
import re
|
| 4 |
|
| 5 |
import pandas as pd
|
| 6 |
-
import pandera.backends.pandas # noqa: F401 # registers pandas backend
|
| 7 |
import pandera.pandas as pa
|
| 8 |
|
| 9 |
VALID_AA = set("ACDEFGHIKLMNPQRSTVWYX")
|
|
|
|
| 3 |
import re
|
| 4 |
|
| 5 |
import pandas as pd
|
|
|
|
| 6 |
import pandera.pandas as pa
|
| 7 |
|
| 8 |
VALID_AA = set("ACDEFGHIKLMNPQRSTVWYX")
|