Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
111 changes: 81 additions & 30 deletions client/python/cryoet_data_portal/src/cryoet_data_portal/_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,16 +65,24 @@ class Alignment(Model):
"id",
"alignment_id",
)
per_section_alignments: List[PerSectionAlignmentParameters] = ListRelationship(
"PerSectionAlignmentParameters",
"id",
"alignment_id",
per_section_alignments: List[PerSectionAlignmentParameters] = (
ListRelationship(
"PerSectionAlignmentParameters",
"id",
"alignment_id",
)
)
deposition: Deposition = ItemRelationship(
"Deposition", "deposition_id", "id"
)
deposition: Deposition = ItemRelationship("Deposition", "deposition_id", "id")
deposition_id: int = IntField()
tiltseries: TiltSeries = ItemRelationship("TiltSeries", "tiltseries_id", "id")
tiltseries: TiltSeries = ItemRelationship(
"TiltSeries", "tiltseries_id", "id"
)
tiltseries_id: int = IntField()
tomograms: List[Tomogram] = ListRelationship("Tomogram", "id", "alignment_id")
tomograms: List[Tomogram] = ListRelationship(
"Tomogram", "id", "alignment_id"
)
run: Run = ItemRelationship("Run", "run_id", "id")
run_id: int = IntField()
alignment_type: str = StringField()
Expand Down Expand Up @@ -180,7 +188,9 @@ class Annotation(Model):
"id",
"annotation_id",
)
deposition: Deposition = ItemRelationship("Deposition", "deposition_id", "id")
deposition: Deposition = ItemRelationship(
"Deposition", "deposition_id", "id"
)
deposition_id: int = IntField()
s3_metadata_path: str = StringField()
https_metadata_path: str = StringField()
Expand Down Expand Up @@ -295,7 +305,9 @@ class AnnotationAuthor(Model):
_gql_root_field: str = "annotationAuthors"

id: int = IntField()
annotation: Annotation = ItemRelationship("Annotation", "annotation_id", "id")
annotation: Annotation = ItemRelationship(
"Annotation", "annotation_id", "id"
)
annotation_id: int = IntField()
author_list_order: int = IntField()
orcid: str = StringField()
Expand Down Expand Up @@ -442,7 +454,9 @@ class AnnotationMethodLink(Model):
_gql_root_field: str = "annotationMethodLinks"

id: int = IntField()
annotation: Annotation = ItemRelationship("Annotation", "annotation_id", "id")
annotation: Annotation = ItemRelationship(
"Annotation", "annotation_id", "id"
)
annotation_id: int = IntField()
link_type: str = StringField()
name: str = StringField()
Expand Down Expand Up @@ -490,14 +504,16 @@ class AnnotationShape(Model):
annotation (Annotation): The annotation this annotation shape is a part of
annotation_id (int): None
annotation_files (List[AnnotationFile]): The annotation files of this annotation shape
shape_type (str): The shape of the annotation (SegmentationMask, OrientedPoint, Point, InstanceSegmentation, Mesh)
shape_type (str): The shape of the annotation (SegmentationMask, OrientedPoint, Point, InstanceSegmentation, InstanceSegmentationMask, Mesh)
"""

_gql_type: str = "AnnotationShape"
_gql_root_field: str = "annotationShapes"

id: int = IntField()
annotation: Annotation = ItemRelationship("Annotation", "annotation_id", "id")
annotation: Annotation = ItemRelationship(
"Annotation", "annotation_id", "id"
)
annotation_id: int = IntField()
annotation_files: List[AnnotationFile] = ListRelationship(
"AnnotationFile",
Expand Down Expand Up @@ -588,14 +604,18 @@ class Dataset(Model):
_gql_root_field: str = "datasets"

id: int = IntField()
deposition: Deposition = ItemRelationship("Deposition", "deposition_id", "id")
deposition: Deposition = ItemRelationship(
"Deposition", "deposition_id", "id"
)
deposition_id: int = IntField()
funding_sources: List[DatasetFunding] = ListRelationship(
"DatasetFunding",
"id",
"dataset_id",
)
authors: List[DatasetAuthor] = ListRelationship("DatasetAuthor", "id", "dataset_id")
authors: List[DatasetAuthor] = ListRelationship(
"DatasetAuthor", "id", "dataset_id"
)
runs: List[Run] = ListRelationship("Run", "id", "dataset_id")
title: str = StringField()
description: str = StringField()
Expand Down Expand Up @@ -668,7 +688,9 @@ def download_everything(self, dest_path: Optional[str] = None):
Args:
dest_path (Optional[str], optional): Choose a destination directory. Defaults to $CWD.
"""
recursive_prefix = "/".join(self.s3_prefix.strip("/").split("/")[:-1]) + "/"
recursive_prefix = (
"/".join(self.s3_prefix.strip("/").split("/")[:-1]) + "/"
)
download_directory(self.s3_prefix, recursive_prefix, dest_path)


Expand Down Expand Up @@ -834,16 +856,24 @@ class Deposition(Model):
"id",
"deposition_id",
)
alignments: List[Alignment] = ListRelationship("Alignment", "id", "deposition_id")
alignments: List[Alignment] = ListRelationship(
"Alignment", "id", "deposition_id"
)
annotations: List[Annotation] = ListRelationship(
"Annotation",
"id",
"deposition_id",
)
datasets: List[Dataset] = ListRelationship("Dataset", "id", "deposition_id")
datasets: List[Dataset] = ListRelationship(
"Dataset", "id", "deposition_id"
)
frames: List[Frame] = ListRelationship("Frame", "id", "deposition_id")
tiltseries: List[TiltSeries] = ListRelationship("TiltSeries", "id", "deposition_id")
tomograms: List[Tomogram] = ListRelationship("Tomogram", "id", "deposition_id")
tiltseries: List[TiltSeries] = ListRelationship(
"TiltSeries", "id", "deposition_id"
)
tomograms: List[Tomogram] = ListRelationship(
"Tomogram", "id", "deposition_id"
)
title: str = StringField()
description: str = StringField()
tag: str = StringField()
Expand Down Expand Up @@ -916,7 +946,9 @@ class DepositionAuthor(Model):
_gql_root_field: str = "depositionAuthors"

id: int = IntField()
deposition: Deposition = ItemRelationship("Deposition", "deposition_id", "id")
deposition: Deposition = ItemRelationship(
"Deposition", "deposition_id", "id"
)
deposition_id: int = IntField()
author_list_order: int = IntField()
orcid: str = StringField()
Expand Down Expand Up @@ -976,7 +1008,9 @@ class DepositionType(Model):
_gql_root_field: str = "depositionTypes"

id: int = IntField()
deposition: Deposition = ItemRelationship("Deposition", "deposition_id", "id")
deposition: Deposition = ItemRelationship(
"Deposition", "deposition_id", "id"
)
deposition_id: int = IntField()
type: str = StringField()

Expand Down Expand Up @@ -1036,7 +1070,9 @@ class Frame(Model):
_gql_root_field: str = "frames"

id: int = IntField()
deposition: Deposition = ItemRelationship("Deposition", "deposition_id", "id")
deposition: Deposition = ItemRelationship(
"Deposition", "deposition_id", "id"
)
deposition_id: int = IntField()
run: Run = ItemRelationship("Run", "run_id", "id")
run_id: int = IntField()
Expand Down Expand Up @@ -1236,7 +1272,9 @@ def find(

>>> per_section_alignment_parameters = PerSectionAlignmentParameters.find(client)
"""
return super(PerSectionAlignmentParameters, cls).find(client, query_filters)
return super(PerSectionAlignmentParameters, cls).find(
client, query_filters
)

find.__func__.__doc__ = Model.find.__func__.__doc__ + find.__func__.__doc__

Expand Down Expand Up @@ -1290,7 +1328,9 @@ class PerSectionParameters(Model):
raw_angle: float = FloatField()
run: Run = ItemRelationship("Run", "run_id", "id")
run_id: int = IntField()
tiltseries: TiltSeries = ItemRelationship("TiltSeries", "tiltseries_id", "id")
tiltseries: TiltSeries = ItemRelationship(
"TiltSeries", "tiltseries_id", "id"
)
tiltseries_id: int = IntField()
z_index: int = IntField()

Expand Down Expand Up @@ -1354,7 +1394,9 @@ class Run(Model):

id: int = IntField()
alignments: List[Alignment] = ListRelationship("Alignment", "id", "run_id")
annotations: List[Annotation] = ListRelationship("Annotation", "id", "run_id")
annotations: List[Annotation] = ListRelationship(
"Annotation", "id", "run_id"
)
dataset: Dataset = ItemRelationship("Dataset", "dataset_id", "id")
dataset_id: int = IntField()
frames: List[Frame] = ListRelationship("Frame", "id", "run_id")
Expand All @@ -1369,7 +1411,9 @@ class Run(Model):
"id",
"run_id",
)
tiltseries: List[TiltSeries] = ListRelationship("TiltSeries", "id", "run_id")
tiltseries: List[TiltSeries] = ListRelationship(
"TiltSeries", "id", "run_id"
)
tomogram_voxel_spacings: List[TomogramVoxelSpacing] = ListRelationship(
"TomogramVoxelSpacing",
"id",
Expand Down Expand Up @@ -1484,10 +1528,14 @@ class TiltSeries(Model):
_gql_root_field: str = "tiltseries"

id: int = IntField()
alignments: List[Alignment] = ListRelationship("Alignment", "id", "tiltseries_id")
alignments: List[Alignment] = ListRelationship(
"Alignment", "id", "tiltseries_id"
)
run: Run = ItemRelationship("Run", "run_id", "id")
run_id: int = IntField()
deposition: Deposition = ItemRelationship("Deposition", "deposition_id", "id")
deposition: Deposition = ItemRelationship(
"Deposition", "deposition_id", "id"
)
deposition_id: int = IntField()
s3_omezarr_dir: str = StringField()
file_size_omezarr: float = FloatField()
Expand Down Expand Up @@ -1663,7 +1711,9 @@ class Tomogram(Model):
"id",
"tomogram_id",
)
deposition: Deposition = ItemRelationship("Deposition", "deposition_id", "id")
deposition: Deposition = ItemRelationship(
"Deposition", "deposition_id", "id"
)
deposition_id: int = IntField()
run: Run = ItemRelationship("Run", "run_id", "id")
run_id: int = IntField()
Expand Down Expand Up @@ -1774,7 +1824,8 @@ def download_all_annotations(
format (Optional[str], optional): Choose a specific file format to download (e.g.: mrc, ndjson)
"""
filters = [
AnnotationFile.tomogram_voxel_spacing_id == self.tomogram_voxel_spacing_id,
AnnotationFile.tomogram_voxel_spacing_id
== self.tomogram_voxel_spacing_id,
AnnotationFile.alignment_id == self.alignment_id,
]
if shape:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1637,6 +1637,7 @@ enum annotation_file_shape_type_enum {
OrientedPoint
Point
InstanceSegmentation
InstanceSegmentationMask
Mesh
}

Expand Down Expand Up @@ -1883,7 +1884,7 @@ type AnnotationShape implements EntityInterface & Node {
annotationFilesAggregate(where: AnnotationFileWhereClause = null): AnnotationFileAggregate

"""
The shape of the annotation (SegmentationMask, OrientedPoint, Point, InstanceSegmentation, Mesh)
The shape of the annotation (SegmentationMask, OrientedPoint, Point, InstanceSegmentation, InstanceSegmentationMask, Mesh)
"""
shapeType: annotation_file_shape_type_enum
}
Expand Down Expand Up @@ -5276,7 +5277,7 @@ input AnnotationShapeCreateInput {
annotationId: ID = null

"""
The shape of the annotation (SegmentationMask, OrientedPoint, Point, InstanceSegmentation, Mesh)
The shape of the annotation (SegmentationMask, OrientedPoint, Point, InstanceSegmentation, InstanceSegmentationMask, Mesh)
"""
shapeType: annotation_file_shape_type_enum = null

Expand All @@ -5289,7 +5290,7 @@ input AnnotationShapeUpdateInput {
annotationId: ID = null

"""
The shape of the annotation (SegmentationMask, OrientedPoint, Point, InstanceSegmentation, Mesh)
The shape of the annotation (SegmentationMask, OrientedPoint, Point, InstanceSegmentation, InstanceSegmentationMask, Mesh)
"""
shapeType: annotation_file_shape_type_enum = null

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ export function AnnotationsSummaryMetadataTable({
return <li key={shapeType}>{t('segmentationMasks')}</li>
case Annotation_File_Shape_Type_Enum.Mesh:
return <li key={shapeType}>{t('meshes')}</li>
case Annotation_File_Shape_Type_Enum.InstanceSegmentationMask:
return <li key={shapeType}>{t('instanceSegmentationMasks')}</li>
default:
return checkExhaustive(shapeType)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ export function getShapeTypeI18nKey(
return 'segmentationMask'
case Annotation_File_Shape_Type_Enum.Mesh:
return 'mesh'
case Annotation_File_Shape_Type_Enum.InstanceSegmentationMask:
return 'instanceSegmentationMask'
default:
return checkExhaustive(shapeType)
}
Expand Down
1 change: 1 addition & 0 deletions frontend/packages/data-portal/app/types/shapeTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ export type ObjectShapeType =
| 'OrientedPoint'
| 'Point'
| 'SegmentationMask'
| 'InstanceSegmentationMask'
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,8 @@
"info": "Info",
"instanceSegmentation": "Instance Segmentation",
"instanceSegmentations": "Instance Segmentations",
"instanceSegmentationMask": "Instance Segmentation Mask",
"instanceSegmentationMasks": "Instance Segmentation Masks",
"itemsRange": "{{startIndex}}-{{endIndex}} of {{total}} {{itemLabel}}",
"keyPhoto": "key photo",
"keyPhotoCaptionDataset": "Central slab from a representative tomogram of a {{organismName}} sample.",
Expand Down