Skip to content

Commit 3e67f3d

Browse files
committed
Try importing whole db
1 parent 4d87a97 commit 3e67f3d

1 file changed

Lines changed: 22 additions & 31 deletions

File tree

src/murfey/util/processing_db.py

Lines changed: 22 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,10 @@
55
from pydantic import ConfigDict
66
from sqlmodel import Enum, Field, Relationship, create_engine
77

8-
from murfey.util.db import (
9-
AutoProcProgram as AutoProcProgramOrig,
10-
DataCollection as DataCollectionOrig,
11-
DataCollectionGroup as DataCollectionGroupOrig,
12-
FoilHole as FoilHoleOrig,
13-
GridSquare as GridSquareOrig,
14-
Movie as MovieOrig,
15-
SearchMap as SearchMapOrig,
16-
SQLModel,
17-
)
18-
19-
20-
class DataCollectionGroup(DataCollectionGroupOrig):
8+
from murfey.util import db
9+
10+
11+
class DataCollectionGroup(db.DataCollectionGroup):
2112
grid_squares: List["GridSquare"] = Relationship(
2213
back_populates="data_collection_group",
2314
sa_relationship_kwargs={"cascade": "delete"},
@@ -30,14 +21,14 @@ class DataCollectionGroup(DataCollectionGroupOrig):
3021
model_config = ConfigDict(arbitrary_types_allowed=True)
3122

3223

33-
class DataCollection(DataCollectionOrig):
24+
class DataCollection(db.DataCollection):
3425
MotionCorrection: List["MotionCorrection"] = Relationship(
3526
back_populates="DataCollection"
3627
)
3728
Tomogram: List["Tomogram"] = Relationship(back_populates="DataCollection")
3829

3930

40-
class AutoProcProgram(AutoProcProgramOrig):
31+
class AutoProcProgram(db.AutoProcProgram):
4132
MotionCorrection: List["MotionCorrection"] = Relationship(
4233
back_populates="DataCollection"
4334
)
@@ -54,7 +45,7 @@ class AutoProcProgram(AutoProcProgramOrig):
5445
)
5546

5647

57-
class GridSquare(GridSquareOrig):
48+
class GridSquare(db.GridSquare):
5849
atlas_id: Optional[int] = Field(foreign_key="datacollectiongroup.id")
5950
scaled_pixel_size: Optional[float] = None
6051
pixel_location_x: Optional[int] = None
@@ -68,15 +59,15 @@ class GridSquare(GridSquareOrig):
6859
)
6960

7061

71-
class FoilHole(FoilHoleOrig):
62+
class FoilHole(db.FoilHole):
7263
scaled_pixel_size: Optional[float] = None
7364
pixel_location_x: Optional[int] = None
7465
pixel_location_y: Optional[int] = None
7566
diameter: Optional[int] = None
7667
quality_indicator: Optional[float] = None
7768

7869

79-
class SearchMap(SearchMapOrig):
70+
class SearchMap(db.SearchMap):
8071
atlas_id: Optional[int] = Field(foreign_key="datacollectiongroup.id")
8172
scaled_pixel_size: Optional[float] = None
8273
pixel_location_x: Optional[int] = None
@@ -91,14 +82,14 @@ class SearchMap(SearchMapOrig):
9182
Tomogram: List["Tomogram"] = Relationship(back_populates="SearchMap")
9283

9384

94-
class Movie(MovieOrig):
85+
class Movie(db.Movie):
9586
MotionCorrection: List["MotionCorrection"] = Relationship(back_populates="Movie")
9687
TiltImageAlignment: List["TiltImageAlignment"] = Relationship(
9788
back_populates="Movie"
9889
)
9990

10091

101-
class MotionCorrection(SQLModel, table=True): # type: ignore
92+
class MotionCorrection(db.SQLModel, table=True): # type: ignore
10293
motionCorrectionId: int = Field(primary_key=True, unique=True)
10394
dataCollectionId: Optional[int] = Field(foreign_key="DataCollection.id")
10495
autoProcProgramId: Optional[int] = Field(foreign_key="AutoProcProgram.id")
@@ -134,7 +125,7 @@ class MotionCorrection(SQLModel, table=True): # type: ignore
134125
)
135126

136127

137-
class CTF(SQLModel, table=True): # type: ignore
128+
class CTF(db.SQLModel, table=True): # type: ignore
138129
ctfId: int = Field(primary_key=True, unique=True)
139130
motionCorrectionId: Optional[int] = Field(
140131
foreign_key="MotionCorrection.motionCorrectionId"
@@ -159,7 +150,7 @@ class CTF(SQLModel, table=True): # type: ignore
159150
MotionCorrection: Optional["MotionCorrection"] = Relationship(back_populates="CTF")
160151

161152

162-
class ParticlePicker(SQLModel, table=True): # type: ignore
153+
class ParticlePicker(db.SQLModel, table=True): # type: ignore
163154
particlePickerId: int = Field(primary_key=True, unique=True)
164155
programId: Optional[int] = Field(foreign_key="AutoProcProgram.autoProcProgramId")
165156
firstMotionCorrectionId: Optional[int] = Field(
@@ -180,7 +171,7 @@ class ParticlePicker(SQLModel, table=True): # type: ignore
180171
)
181172

182173

183-
class Tomogram(SQLModel, table=True): # type: ignore
174+
class Tomogram(db.SQLModel, table=True): # type: ignore
184175
tomogramId: int = Field(primary_key=True, unique=True)
185176
dataCollectionId: Optional[int] = Field(foreign_key="DataCollection.id")
186177
autoProcProgramId: Optional[int] = Field(foreign_key="AutoProcProgram.id")
@@ -219,15 +210,15 @@ class Tomogram(SQLModel, table=True): # type: ignore
219210
)
220211

221212

222-
class ProcessedTomogram(SQLModel, table=True): # type: ignore
213+
class ProcessedTomogram(db.SQLModel, table=True): # type: ignore
223214
processedTomogramId: int = Field(primary_key=True, unique=True)
224215
tomogramId: int = Field(foreign_key="Tomogram.tomogramId")
225216
filePath: Optional[str] = None
226217
processingType: Optional[str] = None
227218
Tomogram: Optional["Tomogram"] = Relationship(back_populates="ProcessedTomogram")
228219

229220

230-
class RelativeIceThickness(SQLModel, table=True): # type: ignore
221+
class RelativeIceThickness(db.SQLModel, table=True): # type: ignore
231222
relativeIceThicknessId: int = Field(primary_key=True, unique=True)
232223
motionCorrectionId: Optional[int] = Field(
233224
foreign_key="MotionCorrection.motionCorrectionId"
@@ -248,7 +239,7 @@ class RelativeIceThickness(SQLModel, table=True): # type: ignore
248239
)
249240

250241

251-
class TiltImageAlignment(SQLModel, table=True): # type: ignore
242+
class TiltImageAlignment(db.SQLModel, table=True): # type: ignore
252243
movieId: int = Field(foreign_key="Movie.murfey_id", primary_key=True)
253244
tomogramId: int = Field(foreign_key="Tomogram.tomogramId", primary_key=True)
254245
defocusU: Optional[float] = None
@@ -264,7 +255,7 @@ class TiltImageAlignment(SQLModel, table=True): # type: ignore
264255
Tomogram: Optional["Tomogram"] = Relationship(back_populates="TiltImageAlignment")
265256

266257

267-
class ParticleClassificationGroup(SQLModel, table=True): # type: ignore
258+
class ParticleClassificationGroup(db.SQLModel, table=True): # type: ignore
268259
particleClassificationGroupId: int = Field(primary_key=True, unique=True)
269260
particlePickerId: Optional[int] = Field(
270261
foreign_key="ParticlePicker.particlePickerId"
@@ -287,7 +278,7 @@ class ParticleClassificationGroup(SQLModel, table=True): # type: ignore
287278
)
288279

289280

290-
class ParticleClassification(SQLModel, table=True): # type: ignore
281+
class ParticleClassification(db.SQLModel, table=True): # type: ignore
291282
particleClassificationId: int = Field(primary_key=True, unique=True)
292283
classNumber: Optional[int] = None
293284
classImageFullPath: Optional[str] = None
@@ -317,7 +308,7 @@ class ParticleClassification(SQLModel, table=True): # type: ignore
317308
)
318309

319310

320-
class BFactorFit(SQLModel, table=True): # type: ignore
311+
class BFactorFit(db.SQLModel, table=True): # type: ignore
321312
bFactorFitId: int = Field(primary_key=True, unique=True)
322313
particleClassificationId: int = Field(
323314
foreign_key="ParticleClassification.particleClassificationId"
@@ -330,7 +321,7 @@ class BFactorFit(SQLModel, table=True): # type: ignore
330321
)
331322

332323

333-
class CryoemInitialModel(SQLModel, table=True): # type: ignore
324+
class CryoemInitialModel(db.SQLModel, table=True): # type: ignore
334325
cryoemInitialModelId: int = Field(primary_key=True, unique=True)
335326
particleClassificationId: int = Field(
336327
foreign_key="ParticleClassification.particleClassificationId"
@@ -349,7 +340,7 @@ class CryoemInitialModel(SQLModel, table=True): # type: ignore
349340

350341
def setup(url: str):
351342
engine = create_engine(url)
352-
SQLModel.metadata.create_all(engine)
343+
db.SQLModel.metadata.create_all(engine)
353344

354345

355346
def clear(url: str):

0 commit comments

Comments
 (0)