|
1 | | -from typing import List |
| 1 | +from enum import Enum |
| 2 | +from typing import List, Optional |
2 | 3 |
|
3 | | -from pydantic import BaseModel |
| 4 | +from pydantic import BaseModel, Field |
4 | 5 |
|
5 | 6 | from app.constants import ( |
6 | 7 | JOB_FAILED_ERROR_MESSAGE, |
@@ -66,3 +67,236 @@ class SearchResults(BaseModel): |
66 | 67 | current_page: int |
67 | 68 | total_pages: int |
68 | 69 | max_results_per_page: int |
| 70 | + |
| 71 | + |
| 72 | +class ChecksumType(str, Enum): |
| 73 | + """Type of checksum enumeration""" |
| 74 | + |
| 75 | + CRC64 = "CRC64" |
| 76 | + MD5 = "MD5" |
| 77 | + |
| 78 | + |
| 79 | +class ModelCategory(str, Enum): |
| 80 | + """Model category enumeration""" |
| 81 | + |
| 82 | + EXPERIMENTALLY_DETERMINED = "EXPERIMENTALLY DETERMINED" |
| 83 | + TEMPLATE_BASED = "TEMPLATE-BASED" |
| 84 | + AB_INITIO = "AB-INITIO" |
| 85 | + CONFORMATIONAL_ENSEMBLE = "CONFORMATIONAL ENSEMBLE" |
| 86 | + |
| 87 | + |
| 88 | +class ModelFormat(str, Enum): |
| 89 | + """Model format enumeration""" |
| 90 | + |
| 91 | + PDB = "PDB" |
| 92 | + MMCIF = "MMCIF" |
| 93 | + BCIF = "BCIF" |
| 94 | + |
| 95 | + |
| 96 | +class ModelType(str, Enum): |
| 97 | + """Model type enumeration""" |
| 98 | + |
| 99 | + ATOMIC = "ATOMIC" |
| 100 | + DUMMY = "DUMMY" |
| 101 | + MIX = "MIX" |
| 102 | + |
| 103 | + |
| 104 | +class ExperimentalMethod(str, Enum): |
| 105 | + """Experimental method enumeration""" |
| 106 | + |
| 107 | + ELECTRON_CRYSTALLOGRAPHY = "ELECTRON CRYSTALLOGRAPHY" |
| 108 | + ELECTRON_MICROSCOPY = "ELECTRON MICROSCOPY" |
| 109 | + EPR = "EPR" |
| 110 | + FIBER_DIFFRACTION = "FIBER DIFFRACTION" |
| 111 | + FLUORESCENCE_TRANSFER = "FLUORESCENCE TRANSFER" |
| 112 | + INFRARED_SPECTROSCOPY = "INFRARED SPECTROSCOPY" |
| 113 | + NEUTRON_DIFFRACTION = "NEUTRON DIFFRACTION" |
| 114 | + X_RAY_POWDER_DIFFRACTION = "X-RAY POWDER DIFFRACTION" |
| 115 | + SOLID_STATE_NMR = "SOLID-STATE NMR" |
| 116 | + SOLUTION_NMR = "SOLUTION NMR" |
| 117 | + X_RAY_SOLUTION_SCATTERING = "X-RAY SOLUTION SCATTERING" |
| 118 | + THEORETICAL_MODEL = "THEORETICAL MODEL" |
| 119 | + X_RAY_DIFFRACTION = "X-RAY DIFFRACTION" |
| 120 | + HYBRID = "HYBRID" |
| 121 | + |
| 122 | + |
| 123 | +class ConfidenceType(str, Enum): |
| 124 | + """Confidence type enumeration""" |
| 125 | + |
| 126 | + PLDDT = "pLDDT" |
| 127 | + QMEANDISCO = "QMEANDisCo" |
| 128 | + IPTM_PTM = "ipTM+pTM" |
| 129 | + |
| 130 | + |
| 131 | +class OligomericState(str, Enum): |
| 132 | + """Oligomeric state enumeration""" |
| 133 | + |
| 134 | + MONOMER = "MONOMER" |
| 135 | + HOMODIMER = "HOMODIMER" |
| 136 | + HETERODIMER = "HETERODIMER" |
| 137 | + HOMO_OLIGOMER = "HOMO-OLIGOMER" |
| 138 | + HETERO_OLIGOMER = "HETERO-OLIGOMER" |
| 139 | + |
| 140 | + |
| 141 | +class EntityType(str, Enum): |
| 142 | + """Entity type enumeration""" |
| 143 | + |
| 144 | + BRANCHED = "BRANCHED" |
| 145 | + MACROLIDE = "MACROLIDE" |
| 146 | + NON_POLYMER = "NON-POLYMER" |
| 147 | + POLYMER = "POLYMER" |
| 148 | + WATER = "WATER" |
| 149 | + |
| 150 | + |
| 151 | +class EntityPolyType(str, Enum): |
| 152 | + """Entity poly type enumeration""" |
| 153 | + |
| 154 | + CYCLIC_PSEUDO_PEPTIDE = "CYCLIC-PSEUDO-PEPTIDE" |
| 155 | + PEPTIDE_NUCLEIC_ACID = "PEPTIDE NUCLEIC ACID" |
| 156 | + POLYDEOXYRIBONUCLEOTIDE = "POLYDEOXYRIBONUCLEOTIDE" |
| 157 | + POLYDEOXYRIBONUCLEOTIDE_POLYRIBONUCLEOTIDE_HYBRID = ( |
| 158 | + "POLYDEOXYRIBONUCLEOTIDE/POLYRIBONUCLEOTIDE HYBRID" |
| 159 | + ) |
| 160 | + POLYPEPTIDE_D = "POLYPEPTIDE(D)" |
| 161 | + POLYPEPTIDE_L = "POLYPEPTIDE(L)" |
| 162 | + POLYRIBONUCLEOTIDE = "POLYRIBONUCLEOTIDE" |
| 163 | + OTHER = "OTHER" |
| 164 | + |
| 165 | + |
| 166 | +class IdentifierCategory(str, Enum): |
| 167 | + """Identifier category enumeration""" |
| 168 | + |
| 169 | + UNIPROT = "UNIPROT" |
| 170 | + RFAM = "RFAM" |
| 171 | + CCD = "CCD" |
| 172 | + SMILES = "SMILES" |
| 173 | + INCHI = "INCHI" |
| 174 | + INCHIKEY = "INCHIKEY" |
| 175 | + |
| 176 | + |
| 177 | +class SequenceIdType(str, Enum): |
| 178 | + SEQUENCE = "sequence" |
| 179 | + CRC64 = "crc64" |
| 180 | + MD5 = "md5" |
| 181 | + |
| 182 | + |
| 183 | +class Entity(BaseModel): |
| 184 | + """Molecular entity in the model""" |
| 185 | + |
| 186 | + entity_type: EntityType = Field(..., description="Type of the molecular entity") |
| 187 | + entity_poly_type: Optional[EntityPolyType] = Field( |
| 188 | + None, description="Type of the molecular entity polymer" |
| 189 | + ) |
| 190 | + identifier: Optional[str] = Field(None, description="Identifier of the molecule") |
| 191 | + identifier_category: Optional[IdentifierCategory] = Field( |
| 192 | + None, description="Category of the identifier" |
| 193 | + ) |
| 194 | + description: str = Field(..., description="Textual label of the molecule") |
| 195 | + chain_ids: List[str] = Field( |
| 196 | + ..., description="List of chain identifiers of the molecule" |
| 197 | + ) |
| 198 | + |
| 199 | + |
| 200 | +class SummaryItems(BaseModel): |
| 201 | + """Summary items for a structure""" |
| 202 | + |
| 203 | + model_identifier: str = Field( |
| 204 | + ..., description="Identifier of the model, such as PDB id" |
| 205 | + ) |
| 206 | + model_category: ModelCategory = Field(..., description="Category of the model") |
| 207 | + model_url: str = Field(..., description="URL of the model coordinates") |
| 208 | + model_format: ModelFormat = Field(..., description="File format of the coordinates") |
| 209 | + model_type: Optional[ModelType] = Field( |
| 210 | + None, |
| 211 | + description="Defines if coordinates are atomic-level or contain dummy atoms", |
| 212 | + ) |
| 213 | + model_page_url: Optional[str] = Field( |
| 214 | + None, description="URL of a web page showing the model" |
| 215 | + ) |
| 216 | + provider: str = Field(..., description="Name of the model provider") |
| 217 | + number_of_conformers: Optional[float] = Field( |
| 218 | + None, description="Number of conformers in a conformational ensemble" |
| 219 | + ) |
| 220 | + ensemble_sample_url: Optional[str] = Field( |
| 221 | + None, description="URL of a sample of conformations from ensemble" |
| 222 | + ) |
| 223 | + ensemble_sample_format: Optional[ModelFormat] = Field( |
| 224 | + None, description="File format of the sample coordinates" |
| 225 | + ) |
| 226 | + created: str = Field( |
| 227 | + ..., |
| 228 | + description="Date of release of model generation in the format of YYYY-MM-DD", |
| 229 | + example="2021-12-21", |
| 230 | + ) |
| 231 | + sequence_identity: float = Field( |
| 232 | + ..., ge=0, le=1, description="Sequence identity of model to UniProt sequence" |
| 233 | + ) |
| 234 | + coverage: float = Field( |
| 235 | + ..., ge=0, le=1, description="Fraction of UniProt sequence covered by the model" |
| 236 | + ) |
| 237 | + experimental_method: Optional[ExperimentalMethod] = Field( |
| 238 | + None, description="Experimental method used to determine structure" |
| 239 | + ) |
| 240 | + resolution: Optional[float] = Field( |
| 241 | + None, gt=0, description="Resolution of the model in Angstrom" |
| 242 | + ) |
| 243 | + confidence_type: Optional[ConfidenceType] = Field( |
| 244 | + None, description="Type of confidence measure" |
| 245 | + ) |
| 246 | + confidence_version: Optional[str] = Field( |
| 247 | + None, description="Version of confidence measure software" |
| 248 | + ) |
| 249 | + confidence_avg_local_score: Optional[float] = Field( |
| 250 | + None, description="Average of confidence measures" |
| 251 | + ) |
| 252 | + oligomeric_state: Optional[OligomericState] = Field( |
| 253 | + None, description="Oligomeric state of the model" |
| 254 | + ) |
| 255 | + oligomeric_state_confidence: Optional[float] = Field( |
| 256 | + None, description="Confidence in oligomeric state" |
| 257 | + ) |
| 258 | + preferred_assembly_id: Optional[str] = Field( |
| 259 | + None, description="Identifier of preferred assembly" |
| 260 | + ) |
| 261 | + entities: List[Entity] = Field( |
| 262 | + ..., description="List of molecular entities in the model" |
| 263 | + ) |
| 264 | + |
| 265 | + |
| 266 | +class SequenceOverview(BaseModel): |
| 267 | + """Sequence overview containing summary items""" |
| 268 | + |
| 269 | + summary: SummaryItems = Field( |
| 270 | + ..., description="Summary information for the structure" |
| 271 | + ) |
| 272 | + |
| 273 | + |
| 274 | +class Entry(BaseModel): |
| 275 | + """Entry information for sequence summary""" |
| 276 | + |
| 277 | + sequence: str = Field(..., description="The protein sequence") |
| 278 | + checksum: str = Field(..., description="CRC64 or MD5 checksum of the sequence") |
| 279 | + checksum_type: ChecksumType = Field(..., description="Type of the checksum") |
| 280 | + |
| 281 | + |
| 282 | +class SequenceSummary(BaseModel): |
| 283 | + """Main response model for /sequence/summary endpoint""" |
| 284 | + |
| 285 | + entry: Entry = Field( |
| 286 | + ..., description="Entry information including sequence and checksum" |
| 287 | + ) |
| 288 | + structures: List[SequenceOverview] = Field( |
| 289 | + ..., description="List of available structures" |
| 290 | + ) |
| 291 | + |
| 292 | + |
| 293 | +# Request models for the endpoint |
| 294 | +class SequenceSummaryRequest(BaseModel): |
| 295 | + """Request parameters for /sequence/summary endpoint""" |
| 296 | + |
| 297 | + |
| 298 | +# Response models |
| 299 | +class SequenceSummaryResponse(BaseModel): |
| 300 | + """Response wrapper for successful requests""" |
| 301 | + |
| 302 | + data: SequenceSummary |
0 commit comments