diff --git a/setup.cfg b/setup.cfg index 2628041..55657c6 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 ~= 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 adb8934..225396e 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,11 +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 = 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. @@ -34,8 +33,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, 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()