Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Expand the Tomgram importer hash function to include processing software #340

Merged
merged 5 commits into from
Nov 5, 2024
Merged
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
13 changes: 9 additions & 4 deletions apiv2/db_import/importers/tomogram.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,15 @@

class TomogramItem(ItemDBImporter):
# TODO - add the alignment_id field once that data is added the first time.
# id_fields = ["run_id", "tomogram_voxel_spacing_id", "deposition_id", "alignment_id", "processing", "reconstruction_method""]
id_fields = ["run_id", "tomogram_voxel_spacing_id", "deposition_id", "processing", "reconstruction_method"]
id_fields = [
# "alignment_id",
"deposition_id",
"processing",
"processing_software",
"reconstruction_method",
"run_id",
"tomogram_voxel_spacing_id",
]
model_class = models.Tomogram
direct_mapped_fields = {
"name": ["run_name"],
Expand Down Expand Up @@ -101,8 +108,6 @@ def get_finder_args(self) -> dict[str, Any]:


class TomogramAuthorItem(ItemDBImporter):
# TODO - add the alignment_id field once that data is added the first time.
# id_fields = ["run_id", "tomogram_voxel_spacing_id", "deposition_id", "alignment_id", "processing", "reconstruction_method""]
id_fields = ["tomogram_id", "name"]
model_class = models.TomogramAuthor
direct_mapped_fields = {
Expand Down
5 changes: 4 additions & 1 deletion apiv2/db_import/tests/populate_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,7 @@ def populate_tomograms(session: sa.orm.Session) -> Tomogram:
scale1_dimensions="",
scale2_dimensions="",
processing="raw",
processing_software="tomo3D",
offset_x=0,
offset_y=0,
offset_z=0,
Expand Down Expand Up @@ -440,7 +441,9 @@ def populate_annotations(session: sa.orm.Session) -> Annotation:
id=ANNOTATION_ID,
run_id=RUN1_ID,
deposition_id=DEPOSITION_ID2,
s3_metadata_path="s3://test-public-bucket/30001/RUN1/Reconstructions/VoxelSpacing12.300/Annotations/100/foo-1.0.json",
s3_metadata_path=(
"s3://test-public-bucket/30001/RUN1/Reconstructions/VoxelSpacing12.300/Annotations/100/foo-1.0.json"
),
https_metadata_path="foo",
deposition_date="2025-04-01",
release_date="2025-06-01",
Expand Down
8 changes: 7 additions & 1 deletion ingestion_tools/scripts/importers/db/tomogram.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,13 @@ def get_data_map(self) -> dict[str, Any]:

@classmethod
def get_id_fields(cls) -> list[str]:
return ["tomogram_voxel_spacing_id", "deposition_id", "processing", "reconstruction_method"]
return [
"tomogram_voxel_spacing_id",
"deposition_id",
"processing",
"processing_software",
"reconstruction_method",
]

@classmethod
def get_db_model_class(cls) -> type[BaseModel]:
Expand Down
5 changes: 4 additions & 1 deletion ingestion_tools/scripts/importers/tomogram.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ def _generate_hash_key(
metadata.get("alignment_metadata_path", kwargs.get("alignment_metadata_path", "")),
metadata.get("reconstruction_method", ""),
metadata.get("processing", ""),
metadata.get("processing_software", ""),
str(metadata.get("deposition_id", int(parents["deposition"].name))),
],
)
Expand Down Expand Up @@ -79,7 +80,9 @@ def __init__(
allow_imports=allow_imports,
)

self.alignment_metadata_path = config.to_formatted_path(alignment_metadata_path or self.get_alignment_metadata_path())
self.alignment_metadata_path = config.to_formatted_path(
alignment_metadata_path or self.get_alignment_metadata_path(),
)
self.identifier = TomogramIdentifierHelper.get_identifier(
config,
self.get_base_metadata(),
Expand Down
1 change: 1 addition & 0 deletions ingestion_tools/scripts/tests/db_import/populate_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@ def populate_tomograms() -> None:
scale1_dimensions="",
scale2_dimensions="",
processing="raw",
processing_software="tomo3D",
deposition_id=DEPOSITION_ID1,
offset_x=0,
offset_y=0,
Expand Down
Loading