Exemple #1
0
    def generate_plate(self, wells, cols, spacing, offset, radius):
        c = Container()

        for i in range(0, wells):
            well = Well(properties={'radius': radius})
            row, col = divmod(i, cols)
            name = chr(row + ord('A')) + str(1 + col)
            coordinates = (col * spacing[0] + offset[0],
                           row * spacing[1] + offset[1], 0)
            c.add(well, name, coordinates)
        return c
    def generate_deck(self):
        deck = Deck()
        slot = Slot()
        deck.add(slot, 'A1', (5, 10, 0))
        c = Container()
        red = Well(properties={'radius': 5})
        blue = Well(properties={'radius': 5})
        c.add(red, "Red", (5, 5, 0))
        c.add(blue, "Blue", (15, 5, 0))
        slot.add(c, 'tube_rack')

        return deck
Exemple #3
0
    def test_get_name(self):
        deck = Deck()
        slot = Slot()
        c = Container()
        deck.add(slot, 'A1', (0, 0, 0))
        red = Well(properties={'radius': 5})
        blue = Well(properties={'radius': 5})
        c.add(red, "Red", (0, 0, 0))
        c.add(blue, "Blue", (10, 0, 0))
        slot.add(c)

        self.assertEqual(red.get_name(), 'Red')
Exemple #4
0
def create_container_obj_from_dict(container_data: dict) -> Container:
    """

    Example input:
    container data for a "24-plate":
    {
         "origin-offset":{
            "x":13.3,
            "y":17.5
         },
         "locations":{
            "A1":{
               "x":0.0,
               "total-liquid-volume":3400,
               "y":0.0,
               "depth":16.2,
               "z":0,
               "diameter":15.62
            },
            "A2":{
               "x":0.0,
               "total-liquid-volume":3400,
               "y":19.3,
               "depth":16.2,
               "z":0,
               "diameter":15.62
            }

    Exampl input #2:
    "trough-12row":

    {
         "locations":{
            "A1":{
               "x":0,
               "y":0,
               "z":0,
               "depth":40,
               "length":8,
               "width":70,
               "total-liquid-volume":22000
            },
            "A2":{
               "x":0,
               "y":9,
               "z":0,
               "depth":40,
               "length":8,
               "width":70,
               "total-liquid-volume":22000
            },
            "A3":{
               "x":0,
               "y":18,
               "z":0,
               "depth":40,
               "length":8,
               "width":70,
               "total-liquid-volume":22000
            }
    """
    container_data = copy.deepcopy(container_data)
    origin_offset_x = container_data.get('origin-offset', {}).get('x') or 0
    origin_offset_y = container_data.get('origin-offset', {}).get('y') or 0

    container = Container()
    locations = container_data.get('locations')

    for well_name, well_properties in locations.items():
        x = well_properties.pop('x')
        y = well_properties.pop('y')
        z = well_properties.pop('z')

        # assert 'depth' in well_properties
        # assert 'diameter' in well_properties
        # assert 'length' in well_properties
        # assert 'width' in well_properties
        # assert 'total-liquid-volume' in well_properties
        assert isinstance(x, numbers.Number)
        assert isinstance(y, numbers.Number)
        assert isinstance(z, numbers.Number)

        well = Well(properties=well_properties)

        well_coordinates = (x + origin_offset_x, y + origin_offset_y, z)

        container.add(well, well_name, well_coordinates)

    return container