File size: 608 Bytes
80a72c3 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | 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
|