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

Upgrade to cryoet-data-portal client v3.0 #28

Merged
merged 3 commits into from
Jan 31, 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
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
29 changes: 19 additions & 10 deletions src/napari_cryoet_data_portal/_sample_data.py
Original file line number Diff line number Diff line change
@@ -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]:
Expand All @@ -22,20 +19,32 @@ 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()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[0] would be equivalent, but I assume we only expect one element, so it doesn't really matter.


tomogram_image = read_tomogram(tomogram)
# Materialize lowest resolution for speed.
tomogram_image = (np.asarray(tomogram_image[0][-1]), *tomogram_image[1:])
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,
Expand Down
11 changes: 8 additions & 3 deletions src/napari_cryoet_data_portal/_tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import pytest

from cryoet_data_portal import Client, Dataset, Tomogram


Expand All @@ -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%")]))
return Tomogram.find(
client,
[
Tomogram.name == "TS_026",
Tomogram.https_omezarr_dir.like("%13.480%"),
],
).pop()
Loading