Skip to content

Commit

Permalink
update pippette to use utils getxyz function and remove this from pip…
Browse files Browse the repository at this point in the history
…ette module
  • Loading branch information
brendenpelkie committed Dec 5, 2023
1 parent 5c80e73 commit 052a919
Showing 1 changed file with 9 additions and 29 deletions.
38 changes: 9 additions & 29 deletions science_jubilee/tools/Pipette.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

from science_jubilee.labware.Labware import Labware, Well, Location
from science_jubilee.tools.Tool import Tool, ToolStateError, ToolConfigurationError, requires_active_tool
from science_jubilee import utils
from typing import Tuple, Union


Expand Down Expand Up @@ -125,27 +126,6 @@ def from_config(cls, machine, index, name, config_file: str,

return cls(machine, index, name, **kwargs)

@staticmethod
def _getxyz(location: Union[Well, Tuple, Location]):
"""Helper function to extract the x, y, z coordinates of a location object.
:param location: The location object to extract the coordinates from. This can either be a
:class:`Well`, a :tuple: of x, y, z coordinates, or a :class:`Location` object
:type location: Union[Well, Tuple, Location]
:raises ValueError: If the location is not a :class:`Well`, a :class:`tuple`, or a :class:`Location` object
:return: The x, y, z coordinates of the location
:rtype: float, float, float
"""
if type(location) == Well:
x, y, z = location.x, location.y, location.z
elif type(location) == Tuple:
x, y, z = location
elif type(location)==Location:
x,y,z= location._point
else:
raise ValueError("Location should be of type Well or Tuple")

return x,y,z

def vol2move(self, vol):
"""Converts desired volume in uL to a movement of the pipette motor axis
Expand Down Expand Up @@ -203,7 +183,7 @@ def aspirate(self, vol: float, location : Union[Well, Tuple, Location], s:int =
:type s: int, optional
:raises ToolStateError: If the pipette does not have a tip attached
"""
x, y, z = self._getxyz(location)
x, y, z = self.utils.getxyz(location)

if type(location) == Well:
self.current_well = location
Expand Down Expand Up @@ -254,7 +234,7 @@ def dispense(self, vol: float, location :Union[Well, Tuple, Location], s:int = 2
Note:: Ideally the user does not call this functions directly, but instead uses the :method:`dispense` method
"""
x, y, z = self._getxyz(location)
x, y, z = self.utils.getxyz(location)

if type(location) == Well:
self.current_well = location
Expand Down Expand Up @@ -305,7 +285,7 @@ def transfer(self, vol: float, source_well: Union[Well, Tuple, Location],

vol_ = self.vol2move(vol)
# get locations
xs, ys, zs = self._getxyz(source_well)
xs, ys, zs = self.utils.getxyz(source_well)

if self.is_primed == True:
pass
Expand All @@ -318,7 +298,7 @@ def transfer(self, vol: float, source_well: Union[Well, Tuple, Location],

if isinstance(destination_well, list):
for well in destination_well:
xd, yd, zd =self._getxyz(well)
xd, yd, zd =self.utils.getxyz(well)

self._machine.safe_z_movement()
self._machine.move_to(x= xs, y=ys)
Expand Down Expand Up @@ -519,7 +499,7 @@ def pickup_tip(self, tip_ : Union[Well, Tuple] = None):
else:
tip = tip_

x, y, z = self._getxyz(tip)
x, y, z = self.utils.getxyz(tip)
self._machine.safe_z_movement()
self._machine.move_to(x=x, y=y)
self._pickup_tip(z)
Expand All @@ -540,9 +520,9 @@ def return_tip(self, location: Well = None):
:type location: :class:`Well`, optional
"""
if location is None:
x, y, z = self._getxyz(self.first_available_tip)
x, y, z = self.utils.getxyz(self.first_available_tip)
else:
x, y, z = self._getxyz(location)
x, y, z = self.utils.getxyz(location)
self._machine.safe_z_movement()
self._machine.move_to(x=x, y=y)
# z moves up/down to make sure tip actually makes it into rack
Expand Down Expand Up @@ -577,7 +557,7 @@ def drop_tip(self, location: Union[Well, Tuple]):
:param location: The location to drop the tip into
:type location: Union[:class:`Well`, tuple]
"""
x, y, z = self._getxyz(location)
x, y, z = self.utils.getxyz(location)

self._machine.safe_z_movement()
if x is not None or y is not None:
Expand Down

0 comments on commit 052a919

Please sign in to comment.