Skip to content

Commit

Permalink
fix specimen and biosample export for images (#266)
Browse files Browse the repository at this point in the history
  • Loading branch information
sherwoodf authored Dec 10, 2024
1 parent 7fe65c4 commit 9d7b766
Show file tree
Hide file tree
Showing 2 changed files with 85 additions and 9 deletions.
12 changes: 8 additions & 4 deletions bia-export/bia_export/website_export/images/transform.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
from typing import List, Type
from bia_export.website_export.generic_object_retrieval import retrieve_object_list, retrieve_object
from bia_export.website_export.generic_object_retrieval import (
retrieve_object_list,
retrieve_object,
)
from bia_integrator_api import models as api_models
from pydantic import BaseModel
from bia_export.website_export.images.models import (
Expand Down Expand Up @@ -75,7 +78,7 @@ def transform_creation_process(
api_specimen: api_models.Specimen = retrieve_object(
api_creation_process.subject_specimen_uuid, api_models.Specimen, context
)
website_fields["subject_specimen"] = transform_specimen(api_specimen, context)
website_fields["subject"] = transform_specimen(api_specimen, context)

if len(api_creation_process.annotation_method_uuid) > 0:
api_annotation_method = retrieve_object_list(
Expand Down Expand Up @@ -106,8 +109,9 @@ def transform_specimen(
api_bio_samples = retrieve_object_list(
api_specimen.sample_of_uuid, api_models.BioSample, context
)
biosamples = []
for api_bio_sample in api_bio_samples:
transform_biosample(api_bio_sample, context)
biosamples.append(transform_biosample(api_bio_sample, context))

api_specimen_imaging_preparation_protocols = retrieve_object_list(
api_specimen.imaging_preparation_protocol_uuid,
Expand All @@ -120,7 +124,7 @@ def transform_specimen(
api_specimen_imaging_preparation_protocols,
SpecimenImagingPreparationProtocol,
),
"sample_of": transform_details_object_list(api_bio_samples, BioSample),
"sample_of": biosamples,
}
return Specimen(**specimen_dict)

Expand Down
82 changes: 77 additions & 5 deletions bia-export/test/output_data/bia_image_export.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
],
"acquisition_process": [],
"subject": null,
"protocol": [],
"annotation_method": [
{
"default_open": true,
Expand All @@ -48,7 +47,8 @@
],
"annotation_source_indicator": null
}
]
],
"protocol": []
},
"representation": []
},
Expand Down Expand Up @@ -94,9 +94,81 @@
]
}
],
"subject": null,
"protocol": [],
"annotation_method": []
"subject": {
"uuid": "dcc18482-fa1a-468f-878f-c00f9cd46376",
"version": 1,
"model": {
"type_name": "Specimen",
"version": 1
},
"attribute": [],
"imaging_preparation_protocol_uuid": [
"7199d730-29f1-4ad8-b599-e9089cbb2d7b"
],
"sample_of_uuid": [
"64a67727-4e7c-469a-91c4-6219ae072e99"
],
"imaging_preparation_protocol": [
{
"default_open": true,
"title_id": "Test specimen 1",
"uuid": "7199d730-29f1-4ad8-b599-e9089cbb2d7b",
"version": 1,
"model": {
"type_name": "SpecimenImagingPreparationProtocol",
"version": 2
},
"attribute": [],
"protocol_description": "Test sample preparation protocol 1",
"signal_channel_information": []
}
],
"sample_of": [
{
"default_open": true,
"title_id": "Test Biosample 1",
"uuid": "64a67727-4e7c-469a-91c4-6219ae072e99",
"version": 1,
"model": {
"type_name": "BioSample",
"version": 3
},
"attribute": [],
"organism_classification": [
{
"attribute": null,
"common_name": "human",
"scientific_name": "Homo sapiens",
"ncbi_id": null
}
],
"biological_entity_description": "Test biological entity 1",
"experimental_variable_description": [
"Test experimental entity 1"
],
"extrinsic_variable_description": [
"Test extrinsic variable 1"
],
"intrinsic_variable_description": [
"Test intrinsic variable 1\\nwith escaped character"
],
"growth_protocol_uuid": "a2ce3950-3b28-40b3-a6a5-23c4f7864912",
"growth_protocol": {
"title_id": "Test specimen 1",
"uuid": "a2ce3950-3b28-40b3-a6a5-23c4f7864912",
"version": 2,
"model": {
"type_name": "Protocol",
"version": 1
},
"attribute": [],
"protocol_description": "Test sample growth protocol 1"
}
}
]
},
"annotation_method": [],
"protocol": []
},
"representation": [
{
Expand Down

0 comments on commit 9d7b766

Please sign in to comment.