From b0c025cf41c5504c8e796ca66d241c0a1b02e4d8 Mon Sep 17 00:00:00 2001 From: Jessica Gadling Date: Wed, 31 Jan 2024 14:14:20 -0500 Subject: [PATCH 1/3] Update tests to handle data changes. --- src/napari_cryoet_data_portal/_sample_data.py | 29 +++++++++++++------ 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/src/napari_cryoet_data_portal/_sample_data.py b/src/napari_cryoet_data_portal/_sample_data.py index adb8934..b368e32 100644 --- a/src/napari_cryoet_data_portal/_sample_data.py +++ b/src/napari_cryoet_data_portal/_sample_data.py @@ -1,13 +1,10 @@ from typing import List import numpy as np -from npe2.types import FullLayerData from cryoet_data_portal import Client, Tomogram, TomogramVoxelSpacing +from npe2.types import FullLayerData -from napari_cryoet_data_portal import ( - read_annotation, - read_tomogram, -) +from napari_cryoet_data_portal import read_annotation, read_tomogram def tomogram_10000_ts_026() -> List[FullLayerData]: @@ -22,9 +19,13 @@ def tomogram_10000_ts_027() -> List[FullLayerData]: def _read_tomogram_from_10000(name: str) -> List[FullLayerData]: client = Client() - + tomogram_spacing_url = f"https://files.cryoetdataportal.cziscience.com/10000/{name}/Tomograms/VoxelSpacing13.480/" - tomogram_spacing = next(TomogramVoxelSpacing.find(client, [TomogramVoxelSpacing.https_prefix == tomogram_spacing_url])) + tomogram_spacing = next( + TomogramVoxelSpacing.find( + client, [TomogramVoxelSpacing.https_prefix == tomogram_spacing_url] + ) + ) tomogram: Tomogram = next(tomogram_spacing.tomograms) @@ -34,8 +35,18 @@ def _read_tomogram_from_10000(name: str) -> List[FullLayerData]: tomogram_image[1]["scale"] = (4, 4, 4) annotations = tuple(tomogram_spacing.annotations) - ribosome_points = read_annotation(annotations[0], tomogram=tomogram) - fatty_acid_points = read_annotation(annotations[1], tomogram=tomogram) + ribosome_annotations = [ + item + for item in annotations + if item.object_name.lower() == "cytosolic ribosome" + ].pop() + fas_annotations = [ + item + for item in annotations + if item.object_name.lower() == "fatty acid synthase" + ].pop() + ribosome_points = read_annotation(ribosome_annotations, tomogram=tomogram) + fatty_acid_points = read_annotation(fas_annotations, tomogram=tomogram) return [ tomogram_image, From 20d2a4479d4ea005aa45c605e3d7366688abddbe Mon Sep 17 00:00:00 2001 From: Jessica Gadling Date: Wed, 31 Jan 2024 14:25:37 -0500 Subject: [PATCH 2/3] Set dependency version to a major version. --- setup.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.cfg b/setup.cfg index 2628041..035b469 100644 --- a/setup.cfg +++ b/setup.cfg @@ -31,7 +31,7 @@ project_urls = [options] packages = find: install_requires = - cryoet_data_portal>=2 + cryoet_data_portal ~= 2.0 fsspec[http,s3] npe2 numpy From 899b201e9138180cd6268d2b9499bc5f5297d075 Mon Sep 17 00:00:00 2001 From: Jessica Gadling Date: Wed, 31 Jan 2024 14:27:13 -0500 Subject: [PATCH 3/3] Update the napari cryoet data portal plugin to support the newest client version. --- setup.cfg | 2 +- src/napari_cryoet_data_portal/_sample_data.py | 10 ++++------ src/napari_cryoet_data_portal/_tests/conftest.py | 11 ++++++++--- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/setup.cfg b/setup.cfg index 035b469..55657c6 100644 --- a/setup.cfg +++ b/setup.cfg @@ -31,7 +31,7 @@ project_urls = [options] packages = find: install_requires = - cryoet_data_portal ~= 2.0 + cryoet_data_portal ~= 3.0 fsspec[http,s3] npe2 numpy diff --git a/src/napari_cryoet_data_portal/_sample_data.py b/src/napari_cryoet_data_portal/_sample_data.py index b368e32..225396e 100644 --- a/src/napari_cryoet_data_portal/_sample_data.py +++ b/src/napari_cryoet_data_portal/_sample_data.py @@ -21,13 +21,11 @@ def _read_tomogram_from_10000(name: str) -> List[FullLayerData]: client = Client() tomogram_spacing_url = f"https://files.cryoetdataportal.cziscience.com/10000/{name}/Tomograms/VoxelSpacing13.480/" - tomogram_spacing = next( - TomogramVoxelSpacing.find( - client, [TomogramVoxelSpacing.https_prefix == tomogram_spacing_url] - ) - ) + tomogram_spacing = TomogramVoxelSpacing.find( + client, [TomogramVoxelSpacing.https_prefix == tomogram_spacing_url] + ).pop() - tomogram: Tomogram = next(tomogram_spacing.tomograms) + tomogram: Tomogram = tomogram_spacing.tomograms.pop() tomogram_image = read_tomogram(tomogram) # Materialize lowest resolution for speed. diff --git a/src/napari_cryoet_data_portal/_tests/conftest.py b/src/napari_cryoet_data_portal/_tests/conftest.py index debfb84..1ade18f 100644 --- a/src/napari_cryoet_data_portal/_tests/conftest.py +++ b/src/napari_cryoet_data_portal/_tests/conftest.py @@ -1,5 +1,4 @@ import pytest - from cryoet_data_portal import Client, Dataset, Tomogram @@ -10,9 +9,15 @@ def client() -> Client: @pytest.fixture() def dataset(client: Client) -> Dataset: - return next(Dataset.find(client, [Dataset.id == 10000])) + return Dataset.find(client, [Dataset.id == 10000]).pop() @pytest.fixture() def tomogram(client: Client) -> Tomogram: - return next(Tomogram.find(client, [Tomogram.name == 'TS_026', Tomogram.https_omezarr_dir.like("%13.480%")])) \ No newline at end of file + return Tomogram.find( + client, + [ + Tomogram.name == "TS_026", + Tomogram.https_omezarr_dir.like("%13.480%"), + ], + ).pop()