Skip to content

Commit

Permalink
Introduce Worklist(diti_mode=...) for DiTi-compatible wash schemes
Browse files Browse the repository at this point in the history
Closes #77
  • Loading branch information
michaelosthege committed Jul 19, 2024
1 parent 090f3d1 commit 525a9c8
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 1 deletion.
3 changes: 2 additions & 1 deletion robotools/fluenttools/worklist.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@ def __init__(
filepath: Optional[Union[str, Path]] = None,
max_volume: Union[int, float] = 950,
auto_split: bool = True,
diti_mode: bool = False,
) -> None:
super().__init__(filepath, max_volume, auto_split)
super().__init__(filepath, max_volume, auto_split, diti_mode)

def _get_well_position(self, labware: Labware, well: str) -> int:
return get_well_position(labware, well)
Expand Down
11 changes: 11 additions & 0 deletions robotools/worklists/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ def __init__(
filepath: Optional[Union[str, Path]] = None,
max_volume: Union[int, float] = 950,
auto_split: bool = True,
diti_mode: bool = False,
) -> None:
"""Creates a worklist writer.
Expand All @@ -38,6 +39,9 @@ def __init__(
auto_split : bool
If `True`, large volumes in transfer operations are automatically splitted.
If set to `False`, `InvalidOperationError` is raised when a pipetting volume exceeds `max_volume`.
diti_mode
Activate this when using DiTis.
Uses ``W;`` for all wash schemes and raises errors when using commands that are only for fixed tips.
"""
self._filepath: Optional[Path] = None
if filepath is not None:
Expand All @@ -46,6 +50,7 @@ def __init__(
raise ValueError("The `max_volume` parameter is required.")
self.max_volume = max_volume
self.auto_split = auto_split
self.diti_mode = diti_mode
super().__init__()

@property
Expand Down Expand Up @@ -113,13 +118,19 @@ def wash(self, scheme: int = 1) -> None:
scheme : int
Number indicating the wash scheme (default: 1)
"""
if self.diti_mode:
self.append("W;")
return

if not scheme in {1, 2, 3, 4}:
raise ValueError("scheme must be either 1, 2, 3 or 4")
self.append(f"W{scheme};")
return

def decontaminate(self) -> None:
"""Decontamination wash consists of a decontamination wash followed by a normal wash."""
if self.diti_mode:
raise InvalidOperationError("Decontamination wash is not available with DiTis.")
self.append("WD;")
return

Expand Down
17 changes: 17 additions & 0 deletions robotools/worklists/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,14 @@ def test_wash(self) -> None:
"W4;",
]
assert wl == exp

with BaseWorklist(diti_mode=True) as wl:
wl.wash()
wl.wash(3)
assert wl == [
"W;",
"W;",
]
return

@pytest.mark.parametrize("cls", [EvoWorklist, FluentWorklist])
Expand Down Expand Up @@ -233,12 +241,21 @@ def test_wash_schemes(self, cls, scheme, exp):
assert wl[-1] == "F;"
else:
raise NotImplementedError()

# In DiTi mode, any numeric wash scheme results in "W;"
with cls(diti_mode=True) as wl:
wl.transfer(A, "A01", A, "A01", 25, wash_scheme=2)
assert wl[-1] == "W;"
pass

def test_decontaminate(self) -> None:
with BaseWorklist() as wl:
wl.decontaminate()
assert wl == ["WD;"]

with BaseWorklist(diti_mode=True) as wl:
with pytest.raises(InvalidOperationError, match="not available"):
wl.decontaminate()
return

def test_flush(self) -> None:
Expand Down

0 comments on commit 525a9c8

Please sign in to comment.