44"""
55
66from datetime import datetime
7- from typing import List , Optional
7+ from typing import TYPE_CHECKING , List , Optional
88
99import sqlalchemy
1010from sqlmodel import Field , Relationship , SQLModel , create_engine
1111
12+ if TYPE_CHECKING :
13+ from murfey .util .processing_db import (
14+ CTF ,
15+ MotionCorrection ,
16+ ParticleClassificationGroup ,
17+ ParticlePicker ,
18+ RelativeIceThickness ,
19+ TiltImageAlignment ,
20+ Tomogram ,
21+ )
22+
1223"""
1324GENERAL
1425"""
@@ -407,7 +418,7 @@ class Tilt(SQLModel, table=True): # type: ignore
407418 tilt_series : Optional [TiltSeries ] = Relationship (back_populates = "tilts" )
408419
409420
410- class DataCollectionGroupModel (SQLModel , table = True ): # type: ignore
421+ class DataCollectionGroup (SQLModel , table = True ): # type: ignore
411422 id : int = Field (primary_key = True , unique = True )
412423 session_id : int = Field (foreign_key = "session.id" , primary_key = True )
413424 tag : str = Field (primary_key = True )
@@ -434,11 +445,14 @@ class DataCollectionGroupModel(SQLModel, table=True): # type: ignore
434445 sa_relationship_kwargs = {"cascade" : "delete" },
435446 )
436447 )
437-
438-
439- @mapper_registry .mapped
440- class DataCollectionGroup (DataCollectionGroupModel , table = True ): # type: ignore
441- pass
448+ grid_squares : Optional [List ["GridSquare" ]] = Relationship (
449+ back_populates = "data_collection_group" ,
450+ sa_relationship_kwargs = {"cascade" : "delete" },
451+ )
452+ search_maps : Optional [List ["SearchMap" ]] = Relationship (
453+ back_populates = "data_collection_group" ,
454+ sa_relationship_kwargs = {"cascade" : "delete" },
455+ )
442456
443457
444458class NotificationParameter (SQLModel , table = True ): # type: ignore
@@ -481,6 +495,12 @@ class DataCollection(SQLModel, table=True): # type: ignore
481495 movies : List ["Movie" ] = Relationship (
482496 back_populates = "data_collection" , sa_relationship_kwargs = {"cascade" : "delete" }
483497 )
498+ motion_correction : Optional [List ["MotionCorrection" ]] = Relationship (
499+ back_populates = "data_collection"
500+ )
501+ tomogram : Optional [List ["Tomogram" ]] = Relationship (
502+ back_populates = "data_collection"
503+ )
484504
485505
486506class ProcessingJob (SQLModel , table = True ): # type: ignore
@@ -582,6 +602,22 @@ class AutoProcProgram(SQLModel, table=True): # type: ignore
582602 murfey_ids : List ["MurfeyLedger" ] = Relationship (
583603 back_populates = "auto_proc_program" , sa_relationship_kwargs = {"cascade" : "delete" }
584604 )
605+ motion_correction : Optional [List ["MotionCorrection" ]] = Relationship (
606+ back_populates = "data_collection"
607+ )
608+ tomogram : Optional [List ["Tomogram" ]] = Relationship (
609+ back_populates = "auto_proc_program"
610+ )
611+ ctf : Optional [List ["CTF" ]] = Relationship (back_populates = "auto_proc_program" )
612+ particle_picker : Optional [List ["ParticlePicker" ]] = Relationship (
613+ back_populates = "auto_proc_program"
614+ )
615+ relative_ice_thickness : Optional [List ["RelativeIceThickness" ]] = Relationship (
616+ back_populates = "auto_proc_program"
617+ )
618+ particle_classification_group : Optional [List ["ParticleClassificationGroup" ]] = (
619+ Relationship (back_populates = "auto_proc_program" )
620+ )
585621
586622
587623class MurfeyLedger (SQLModel , table = True ): # type: ignore
@@ -640,6 +676,17 @@ class GridSquare(SQLModel, table=True): # type: ignore
640676 foil_holes : List ["FoilHole" ] = Relationship (
641677 back_populates = "grid_square" , sa_relationship_kwargs = {"cascade" : "delete" }
642678 )
679+ atlas_id : Optional [int ] = Field (foreign_key = "datacollectiongroup.id" )
680+ scaled_pixel_size : Optional [float ] = None
681+ pixel_location_x : Optional [int ] = None
682+ pixel_location_y : Optional [int ] = None
683+ height : Optional [int ] = None
684+ width : Optional [int ] = None
685+ angle : Optional [float ] = None
686+ quality_indicator : Optional [float ] = None
687+ data_collection_group : Optional ["DataCollectionGroup" ] = Relationship (
688+ back_populates = "grid_squares"
689+ )
643690
644691
645692class FoilHole (SQLModel , table = True ): # type: ignore
@@ -665,6 +712,11 @@ class FoilHole(SQLModel, table=True): # type: ignore
665712 preprocess_stashes : List [PreprocessStash ] = Relationship (
666713 back_populates = "foil_hole" , sa_relationship_kwargs = {"cascade" : "delete" }
667714 )
715+ scaled_pixel_size : Optional [float ] = None
716+ pixel_location_x : Optional [int ] = None
717+ pixel_location_y : Optional [int ] = None
718+ diameter : Optional [int ] = None
719+ quality_indicator : Optional [float ] = None
668720
669721
670722class SearchMap (SQLModel , table = True ): # type: ignore
@@ -697,6 +749,18 @@ class SearchMap(SQLModel, table=True): # type: ignore
697749 tilt_series : List ["TiltSeries" ] = Relationship (
698750 back_populates = "search_map" , sa_relationship_kwargs = {"cascade" : "delete" }
699751 )
752+ atlas_id : Optional [int ] = Field (foreign_key = "datacollectiongroup.id" )
753+ scaled_pixel_size : Optional [float ] = None
754+ pixel_location_x : Optional [int ] = None
755+ pixel_location_y : Optional [int ] = None
756+ scaled_height : Optional [int ] = None
757+ scaled_width : Optional [int ] = None
758+ angle : Optional [float ] = None
759+ quality_indicator : Optional [float ] = None
760+ data_collection_group : Optional ["DataCollectionGroup" ] = Relationship (
761+ back_populates = "search_maps"
762+ )
763+ tomogram : Optional [List ["Tomogram" ]] = Relationship (back_populates = "search_map" )
700764
701765
702766class Movie (SQLModel , table = True ): # type: ignore
@@ -710,6 +774,12 @@ class Movie(SQLModel, table=True): # type: ignore
710774 murfey_ledger : Optional [MurfeyLedger ] = Relationship (back_populates = "movies" )
711775 data_collection : Optional ["DataCollection" ] = Relationship (back_populates = "movies" )
712776 foil_hole : Optional [FoilHole ] = Relationship (back_populates = "movies" )
777+ motion_correction : Optional [List ["MotionCorrection" ]] = Relationship (
778+ back_populates = "movie"
779+ )
780+ tilt_image_alignment : Optional [List ["TiltImageAlignment" ]] = Relationship (
781+ back_populates = "movie"
782+ )
713783
714784
715785class CtfParameters (SQLModel , table = True ): # type: ignore
0 commit comments