Chainsaw / model /models /results.py
wuxing0105's picture
Upload folder using huggingface_hub
80a72c3 verified
Raw
History Blame Contribute Delete
608 Bytes
from pathlib import Path
from typing import Optional
from pydantic import BaseModel, validator
def chain_id_from_pdb_path(pdb_path: Path):
return pdb_path.stem
class PredictionResult(BaseModel):
pdb_path: Path
confidence: float
chain_id: Optional[str] = None
sequence_md5: str
ndom: int
nres: int
chopping: Optional[str] = None
time_sec: Optional[float] = None
@validator('chain_id', always=True, pre=True, allow_reuse=True)
def set_chain_id(cls, v, values):
if v is None:
return chain_id_from_pdb_path(values['pdb_path'])
return v