Skip to content

Commit

Permalink
Merge pull request #51 from machineagency/sonicator
Browse files Browse the repository at this point in the history
Added Sonicator tool module and documentation. Also, fixed issue #50
  • Loading branch information
MariaPoliti authored Jan 19, 2024
2 parents 690ecd7 + 3fa9501 commit 1471840
Show file tree
Hide file tree
Showing 21 changed files with 60,904 additions and 172 deletions.
28 changes: 26 additions & 2 deletions science_jubilee/labware/Labware.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import os
import json

import numpy as np

from dataclasses import dataclass
from itertools import chain
from typing import List, Dict, Tuple, Union, Iterable, NamedTuple
import os
import json


@dataclass
Expand Down Expand Up @@ -509,6 +511,28 @@ def withWellOrder(self, order) -> list:

self.wells = ordered_wells

@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

## Adapted from Opentrons API opentrons.types##
class Point(NamedTuple):
"""A point in the Jubilee 3D coordinate system.
Expand Down
14 changes: 8 additions & 6 deletions science_jubilee/tools/Camera.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
from .Tool import Tool, ToolStateError, requires_active_tool
from science_jubilee.labware.Labware import Labware, Well
from typing import Tuple, Union
import cv2
import matplotlib
import platform
import time

import numpy as np

matplotlib.use("TkAgg")
from matplotlib import pyplot as plt
import numpy as np
import time
import platform
from science_jubilee.labware.Labware import Well
from science_jubilee.tools.Tool import Tool, requires_active_tool
from typing import Tuple


if platform.system() == "Linux":
import picamera # Note that this can only be installed on raspbery pi.
Expand Down
14 changes: 8 additions & 6 deletions science_jubilee/tools/Loop.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
from science_jubilee.tools.Tool import Tool, ToolStateError, ToolConfigurationError, requires_active_tool
from science_jubilee.labware.Labware import Labware, Well
from typing import Tuple, Union
import warnings
import numpy as np
import os
import json
import os
import random
import warnings

import numpy as np

from science_jubilee.labware.Labware import Well
from science_jubilee.tools.Tool import Tool, requires_active_tool
from typing import Tuple


class Loop(Tool):
Expand Down
4 changes: 2 additions & 2 deletions science_jubilee/tools/PeristalticPumps.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
import logging
import os

from science_jubilee.tools.Tool import Tool, ToolStateError, ToolConfigurationError
from typing import Tuple, Union
from science_jubilee.tools.Tool import Tool
from typing import Union

class PeristalticPumps(Tool):
"""
Expand Down
24 changes: 9 additions & 15 deletions science_jubilee/tools/Pipette.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

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 All @@ -23,7 +22,7 @@ def wrapper(self, *args, **kwargs):
class Pipette(Tool):
""" A class representation of an Opentrons OT2 pipette.
"""
def __init__(self, machine, index, name, brand, model, max_volume,
def __init__(self, index, name, brand, model, max_volume,
min_volume, zero_position, blowout_position,
drop_tip_position, mm_to_ul):
""" Initialize the pipette object
Expand All @@ -49,14 +48,11 @@ def __init__(self, machine, index, name, brand, model, max_volume,
:param mm_to_ul: The conversion factor for converting motor microsteps in mm to uL
:type mm_to_ul: float
"""
#TODO:Removed machine from init, check if this should be asigned here or is added later
super().__init__(index, name, brand = brand,
model = model, max_volume = max_volume, min_volume = min_volume,
zero_position = zero_position, blowout_position = blowout_position,
drop_tip_position = drop_tip_position, mm_to_ul = mm_to_ul)
self._machine = machine
self.has_tip = False
# TODO: add a way to change this to True/False and check before performing action with tool
self.first_available_tip = None
self.tool_offset = self._machine.tool_z_offsets[self.index]
self.is_primed = False
Expand All @@ -68,8 +64,6 @@ def from_config(cls, index, name, config_file: str,

"""Initialize the pipette object from a config file
:param machine: The :class:`Machine` object that the pipette is loaded on
:type machine: :class:`Machine`
:param index: The tool index of the pipette on the machine
:type index: int
:param name: The tool name
Expand Down Expand Up @@ -144,7 +138,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 = utils.getxyz(location)
x, y, z = Labware._getxyz(location)

if type(location) == Well:
self.current_well = location
Expand Down Expand Up @@ -194,7 +188,7 @@ def dispense(self, vol: float, location :Union[Well, Tuple, Location], s:int = 2
:type s: int, optional
:raises ToolStateError: If the pipette does not have a tip attached
"""
x, y, z = utils.getxyz(location)
x, y, z = Labware._getxyz(location)

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

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

if self.is_primed == True:
pass
Expand All @@ -258,7 +252,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 = utils.getxyz(well)
xd, yd, zd = Labware._getxyz(well)

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

x, y, z = utils.getxyz(tip)
x, y, z = Labware._getxyz(tip)
self._machine.safe_z_movement()
self._machine.move_to(x=x, y=y)
self._pickup_tip(z)
Expand All @@ -480,9 +474,9 @@ def return_tip(self, location: Well = None):
:type location: :class:`Well`, optional
"""
if location is None:
x, y, z = utils.getxyz(self.first_available_tip)
x, y, z = Labware._getxyz(self.first_available_tip)
else:
x, y, z = utils.getxyz(location)
x, y, z = Labware._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 @@ -517,7 +511,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 = utils.getxyz(location)
x, y, z = Labware._getxyz(location)

self._machine.safe_z_movement()
if x is not None or y is not None:
Expand Down
8 changes: 4 additions & 4 deletions science_jubilee/tools/PumpDispenser.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
import os

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


class PumpDispenser(Tool):
"""
Expand Down Expand Up @@ -116,7 +116,7 @@ def dispense(self, vol: Union[float, int, list], location:Union[Well, Tuple, Loc


# calculate XY location for each dispense head
x, y, z = utils.getxyz(location)
x, y, z = Labware._getxyz(location)

if type(location) == Well:
if z == location.z:
Expand Down Expand Up @@ -171,7 +171,7 @@ def prime_lines(self, volume: Union[int, float] = None, location:Union[Well, Tup
location = self.waste

# calculate XY location for each dispense head
x, y, z = utils.getxyz(location)
x, y, z = Labware._getxyz(location)

if type(location) == Well:
if z == location.z:
Expand Down
Loading

0 comments on commit 1471840

Please sign in to comment.