Skip to content
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
8 changes: 8 additions & 0 deletions src/murfey/client/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,14 @@ def ensure_dcg_exists(

if collection_type == "tomo":
windows_path = session_data["TomographySession"]["AtlasId"]
if (
session_data.get("TomographySession", {}).get("LamellaWorkflow", None)
== "true"
):
# Lamella tomography experiment type
experiment_type_id = 49
else:
logger.warning("Cannot find tomography Session.dm file")
else:
windows_path = session_data["EpuSessionXml"]["Samples"]["_items"][
"SampleXml"
Expand Down
23 changes: 19 additions & 4 deletions tests/client/test_context.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,22 @@
from unittest.mock import patch
from urllib.parse import urlparse

import pytest

from murfey.client.context import ensure_dcg_exists
from murfey.client.instance_environment import MurfeyInstanceEnvironment

# Lamella experiment type options and experiment type ids
lamella_types: list[tuple[str | None, int]] = [
(None, 36),
("false", 36),
("true", 49),
]


@pytest.mark.parametrize("lamella", lamella_types)
@patch("murfey.client.context.capture_post")
def test_ensure_dcg_exists_tomo(mock_capture_post, tmp_path):
def test_ensure_dcg_exists_tomo(mock_capture_post, lamella, tmp_path):
env = MurfeyInstanceEnvironment(
url=urlparse("http://localhost:8000"),
client_id=0,
Expand All @@ -25,9 +35,14 @@ def test_ensure_dcg_exists_tomo(mock_capture_post, tmp_path):
with open(metadata_source / "Session.dm", "w") as dm_file:
dm_file.write(
"<TomographySession><AtlasId>"
r"X:\cm12345-6\atlas\atlas_metadata\Sample6\Atlas\Atlas.dm"
"</AtlasId></TomographySession>"
r"X:\cm12345-6\atlas\atlas_metadata\Sample6\Atlas\Atlas.dm</AtlasId>"
)
dm_file.write(
rf"<LamellaWorkflow>{lamella[0]}</LamellaWorkflow>"
if lamella[0] is not None
else ""
)
dm_file.write(r"</TomographySession>")

atlas_xml = tmp_path / "cm12345-6/atlas/atlas_metadata/Sample6/Atlas/Atlas_4.xml"
atlas_xml.parent.mkdir(parents=True)
Expand All @@ -46,7 +61,7 @@ def test_ensure_dcg_exists_tomo(mock_capture_post, tmp_path):
)

dcg_data = {
"experiment_type_id": 36,
"experiment_type_id": lamella[1],
"tag": f"{tmp_path}/metadata_folder",
"atlas": f"{tmp_path}/destination/{atlas_xml.relative_to(tmp_path).with_suffix('.jpg')}",
"sample": 6,
Expand Down