Skip to content

Commit 927779b

Browse files
authored
A few fixes for CLEM workflow (#305)
* If an XLIF file has not been seen yet then self._files_in_series[series_name] will result in a KeyError * For the CLEM workflow, run post_transfer on every file as soon as the context has been identified * Add determination of CLEM context without the need for a LIF * Read XLIF using path on client machine * If rsync_module is an empty string use data
1 parent 3e42045 commit 927779b

File tree

2 files changed

+23
-7
lines changed

2 files changed

+23
-7
lines changed

src/murfey/client/analyser.py

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,11 +110,27 @@ def _find_context(self, file_path: Path) -> bool:
110110

111111
# CLEM workflow check
112112
# Look for LIF files
113-
if file_path.suffix == ".lif":
113+
if file_path.suffix in (".lif", ".xlif"):
114114
self._role = "detector"
115115
self._context = CLEMContext("leica", self._basepath)
116116
return True
117117

118+
if (
119+
"--" in file_path.name
120+
and file_path.suffix in (".tiff", ".tif")
121+
and self._environment
122+
):
123+
created_directories = set(
124+
get_machine_config(
125+
str(self._environment.url.geturl()),
126+
demo=self._environment.demo,
127+
).get("analyse_created_directories", [])
128+
)
129+
if created_directories.intersection(set(file_path.parts)):
130+
self._role = "detector"
131+
self._context = CLEMContext("leica", self._basepath)
132+
return True
133+
118134
split_file_name = file_path.name.split("_")
119135
if split_file_name:
120136
# Files starting with "FoilHole" belong to the SPA workflow
@@ -312,6 +328,8 @@ def _analyse(self):
312328
),
313329
}
314330
)
331+
elif isinstance(self._context, CLEMContext):
332+
self.post_transfer(transferred_file)
315333
elif not self._extension or self._unseen_xml:
316334
self._find_extension(transferred_file)
317335
if self._extension:
@@ -370,7 +388,6 @@ def _analyse(self):
370388
TomographyContext,
371389
SPAModularContext,
372390
SPAMetadataContext,
373-
CLEMContext,
374391
),
375392
):
376393
self.post_transfer(transferred_file)

src/murfey/client/contexts/clem.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def _file_transferred_to(
3434
)
3535
return (
3636
Path(machine_config.get("rsync_basepath", ""))
37-
/ machine_config.get("rsync_module", "data")
37+
/ (machine_config.get("rsync_module", "data") or "data")
3838
/ str(datetime.now().year)
3939
/ source.name
4040
/ file_path.relative_to(source)
@@ -143,7 +143,7 @@ def post_transfer(
143143
) # The previous 2 parent directories should be unique enough
144144

145145
# Extract metadata to get the expected size of the series
146-
metadata = parse(file_path).getroot()
146+
metadata = parse(transferred_file).getroot()
147147
metadata = get_image_elements(metadata)[0]
148148

149149
# Get channel and dimension information
@@ -170,9 +170,8 @@ def post_transfer(
170170
self._metadata_timestamp[series_name] = transferred_file.stat().st_ctime
171171

172172
# Post message if all files for the associated series have been collected
173-
if (
174-
len(self._tiff_series[series_name])
175-
== self._files_in_series[series_name]
173+
if len(self._tiff_series[series_name]) == self._files_in_series.get(
174+
series_name, 0
176175
):
177176

178177
# Construct URL for Murfey server to communicate with

0 commit comments

Comments
 (0)