Beispiel #1
0
 def test_grid_row_addresses(self):
     """ Grid row groups contain the correct addresses. """
     plate = Microplate()
     rows = plate.row(1).human_address
     self.assertEqual(
         rows, ['A2', 'B2', 'C2', 'D2', 'E2', 'F2', 'G2', 'H2']
     )
Beispiel #2
0
 def test_address(self):
     """ Address. """
     plate = Microplate()
     self.assertEqual(plate.well('A1').address, [(0, 0)])
     self.assertEqual(plate.well('a1').human_address, 'A1')
     deck = Deck()
     deck.add_module('A1', 'microplate')
     well = deck.slot('A1').well('B4')
     self.assertEqual(well.human_address, 'A1:B4')
     self.assertEqual(well.address, [(0, 0), (1, 3)])
Beispiel #3
0
 def test_group_transfer(self):
     plate = Microplate()
     plate.col('A').transfer(10, plate.col('B'))
     self.assertEqual(
         plate.col('A').get_volume(), [-10 for _ in range(12)]
     )
     self.assertEqual(
         plate.col('B').get_volume(), [10 for _ in range(12)]
     )
Beispiel #4
0
 def setUp(self):
     self.plate = Microplate()
Beispiel #5
0
 def setUp(self):
     self.plate = Microplate()
     self.well  = self.plate.well('A1')
Beispiel #6
0
class MicroplateWellTest(unittest.TestCase):

    def setUp(self):
        self.plate = Microplate()
        self.well  = self.plate.well('A1')

    def liquid_allocation_test(self):
        """Add volume to well."""
        set_vol = 50
        # Add an initial value of 100ul water to this well.
        self.well.allocate(water=set_vol)
        vol = self.well.get_volume()
        self.assertEqual(vol, set_vol)

    def liquid_capacity_test(self):
        """Reject well overflow volumes."""
        set_vol = 10000
        # Way too much water for a microplate!
        with self.assertRaises(ValueError):
            self.well.allocate(water=set_vol)

    def liquid_total_capacity_test(self):
        """Reject combined well overflow."""
        self.well.allocate(water=90)
        self.well.add_liquid(water=10)
        with self.assertRaises(ValueError):
            self.well.add_liquid(water=1)

    def liquid_total_mixture_test(self):
        """Reject combined well overflow from mixed liquids."""
        self.well.allocate(water=90)
        self.well.add_liquid(buffer=10)
        with self.assertRaises(ValueError):
            self.well.add_liquid(saline=1)

    def mixture_transfer_test(self):
        """Mixture transfers."""
        wellA = self.well
        wellB = self.plate.well('A2')

        wellA.allocate(water=90, buffer=9, saline=1)
        wellA.transfer(20, wellB)

        # Check Well A to ensure things have been removed.
        wat = wellA.get_proportion('water')
        buf = wellA.get_proportion('buffer')
        sal = wellA.get_proportion('saline')

        # We use almostEqual because it's floating-point.
        self.assertAlmostEqual(wat, .9)
        self.assertAlmostEqual(buf, .09)
        self.assertAlmostEqual(sal, .01)

        self.assertEqual(wellA.get_volume(), 80)

        # Check WellB to ensure things have been added.
        wat = wellB.get_proportion('water')
        buf = wellB.get_proportion('buffer')
        sal = wellB.get_proportion('saline')

        # We use almostEqual because it's floating-point.
        self.assertAlmostEqual(wat, .9)
        self.assertAlmostEqual(buf, .09)
        self.assertAlmostEqual(sal, .01)

        self.assertEqual(wellB.get_volume(), 20)

    def proportion_key_error_test(self):
        """Raises for proportion of liquid not present in mixture."""
        with self.assertRaises(KeyError):
            self.well.get_proportion('water')

    def liquid_key_error_test(self):
        """Raises if wrong liquid named in get_volume."""
        self.well.allocate(saline=10)
        with self.assertRaises(KeyError):
            self.well.get_volume('water')

    def liquid_value_error_test(self):
        """Raises on named get_volume if multiple liquids present."""
        self.well.allocate(water=10, saline=10)
        with self.assertRaises(ValueError):
            self.well.get_volume('water')

    def ml_conversion_test(self):
        """ml to µl conversion."""
        self.well.allocate(water=.1, ml=True)
        self.assertEqual(self.well.get_volume(), 100)
Beispiel #7
0
class MicroplateTest(unittest.TestCase):

    expected_margin = 9  # ANSI standard.

    def setUp(self):
        self.plate = Microplate()

    def a2_coordinate_test(self):
        """Calibrated coordinates of A2."""
        a2 = self.plate.well('A2').coordinates()
        self.assertEqual(a2, (0, self.expected_margin))

    def b1_coordinate_test(self):
        """Calibrated coordinates of B1."""
        b1 = self.plate.well('B1').coordinates()
        self.assertEqual(b1, (self.expected_margin, 0))

    def b2_coordinate_test(self):
        """Calibrated coordinates of B2."""
        b2 = self.plate.well('B2').coordinates()
        margin = self.expected_margin
        self.assertEqual(b2, (margin, margin))

    def coordinate_lowercase_test(self):
        """Lowercase coordinates."""
        b2 = self.plate.well('b2').coordinates()
        margin = self.expected_margin
        self.assertEqual(b2, (margin, margin))

    def col_sanity_test(self):
        """Don't return out-of-range columns."""
        col = chr(ord('a') + self.plate.cols + 1)
        with self.assertRaises(KeyError):
            self.plate.well('{}1'.format(col))

    def unicode_coord_test(self):
        """Unicode coordinates."""
        self.plate.well(u'A1')

    def row_sanity_test(self):
        """Don't return out-of-range rows."""
        row = self.plate.rows + 1
        with self.assertRaises(KeyError):
            self.plate.well('A{}'.format(row))

    def col_type_sanity_test(self):
        """Sanity check on well coordinates."""
        with self.assertRaises(ValueError):
            self.plate.well('ABC')
Beispiel #8
0
class MicroplateTest(unittest.TestCase):

    expected_margin = 9  # ANSI standard.

    def setUp(self):
        self.plate = Microplate()

    def a2_coordinate_test(self):
        """Calibrated coordinates of A2."""
        a2 = self.plate.well('A2').coordinates()
        self.assertEqual(a2, (0, self.expected_margin))

    def b1_coordinate_test(self):
        """Calibrated coordinates of B1."""
        b1 = self.plate.well('B1').coordinates()
        self.assertEqual(b1, (self.expected_margin, 0))

    def b2_coordinate_test(self):
        """Calibrated coordinates of B2."""
        b2 = self.plate.well('B2').coordinates()
        margin = self.expected_margin
        self.assertEqual(b2, (margin, margin))

    def coordinate_lowercase_test(self):
        """Lowercase coordinates."""
        b2 = self.plate.well('b2').coordinates()
        margin = self.expected_margin
        self.assertEqual(b2, (margin, margin))

    def col_sanity_test(self):
        """Don't return out-of-range columns."""
        col = chr(ord('a') + self.plate.cols + 1)
        with self.assertRaises(x.SlotMissing):
            self.plate.well('{}1'.format(col))

    def unicode_coord_test(self):
        """Unicode coordinates."""
        self.plate.well(u'A1')

    def row_sanity_test(self):
        """Don't return out-of-range rows."""
        row = self.plate.rows + 1
        with self.assertRaises(x.SlotMissing):
            self.plate.well('A{}'.format(row))

    def col_type_sanity_test(self):
        """Sanity check on well coordinates."""
        with self.assertRaises(ValueError):
            self.plate.well('ABC')
Beispiel #9
0
 def setUp(self):
     self.plate = Microplate()
     self.well  = self.plate.well('A1')
Beispiel #10
0
 def setUp(self):
     self.plate = Microplate()
     self.plate.calibrate(x=10, y=11, z=12)
Beispiel #11
0
 def setUp(self):
     self.plate = Microplate()
Beispiel #12
0
 def test_grid_col_addresses(self):
     """ Grid row groups contain the correct addresses. """
     plate = Microplate()
     rows = plate.col('A').human_address
     self.assertEqual(rows, ['A{}'.format(i + 1) for i in range(12)])
Beispiel #13
0
 def test_grid_row_group(self):
     """ Grid row acts as group. """
     plate = Microplate()
     plate.col('A').allocate(water=10)
     vols = [plate.well((0, r)).get_volume('water') for r in range(12)]
     self.assertEqual([10 for _ in range(12)], vols)
     self.assertEqual(plate.col('A').get_volume('water'), vols)
     vols = [plate.well((0, r)).get_volume('water') for r in range(12)]
     expected_vols = [15 for _ in range(8)]
     expected_vols[0] += 10  # Remember, we added to the column.
     plate.row(0).allocate(water=15)
     rvols = [plate.well((c, 0)).get_volume('water') for c in range(8)]
     self.assertEqual(plate.row(0).get_volume('water'), expected_vols)
     self.assertEqual(rvols, plate.row(0).get_volume('water'))
     self.assertEqual(plate.row(0).get_volume('water'), rvols)
Beispiel #14
0
 def test_module_add(self):
     """Add a module to the deck."""
     self.deck.add_modules(a1=Microplate())
     plate = self.deck.slot('a1')
     self.assertTrue(isinstance(plate, Microplate))
Beispiel #15
0
class MicroplateWellTest(unittest.TestCase):

    def setUp(self):
        self.plate = Microplate()
        self.well  = self.plate.well('A1')

    def liquid_allocation_test(self):
        """Add volume to well."""
        set_vol = 50
        # Add an initial value of 100ul water to this well.
        self.well.allocate(water=set_vol)
        vol = self.well.get_volume()
        self.assertEqual(vol, set_vol)

    def liquid_capacity_test(self):
        """Reject well overflow volumes."""
        set_vol = 10000
        # Way too much water for a microplate!
        with self.assertRaises(x.LiquidOverflow):
            self.well.allocate(water=set_vol)

    def liquid_total_capacity_test(self):
        """Reject combined well overflow."""
        self.well.allocate(water=90)
        self.well.add_liquid(water=10)
        with self.assertRaises(x.LiquidOverflow):
            self.well.add_liquid(water=1)

    def liquid_total_mixture_test(self):
        """Reject combined well overflow from mixed liquids."""
        self.well.allocate(water=90)
        self.well.add_liquid(buffer=10)
        with self.assertRaises(x.LiquidOverflow):
            self.well.add_liquid(saline=1)

    def mixture_transfer_test(self):
        """Mixture transfers."""
        wellA = self.well
        wellB = self.plate.well('A2')

        wellA.allocate(water=90, buffer=9, saline=1)
        wellA.transfer(20, wellB)

        # Check Well A to ensure things have been removed.
        wat = wellA.get_proportion('water')
        buf = wellA.get_proportion('buffer')
        sal = wellA.get_proportion('saline')

        # We use almostEqual because it's floating-point.
        self.assertAlmostEqual(wat, .9)
        self.assertAlmostEqual(buf, .09)
        self.assertAlmostEqual(sal, .01)

        self.assertEqual(wellA.get_volume(), 80)

        # Check WellB to ensure things have been added.
        wat = wellB.get_proportion('water')
        buf = wellB.get_proportion('buffer')
        sal = wellB.get_proportion('saline')

        # We use almostEqual because it's floating-point.
        self.assertAlmostEqual(wat, .9)
        self.assertAlmostEqual(buf, .09)
        self.assertAlmostEqual(sal, .01)

        self.assertEqual(wellB.get_volume(), 20)

    def proportion_key_error_test(self):
        """Raises for proportion of liquid not present in mixture."""
        with self.assertRaises(x.LiquidMismatch):
            self.well.get_proportion('water')

    def liquid_key_error_test(self):
        """Raises if wrong liquid named in get_volume."""
        self.well.allocate(saline=10)
        with self.assertRaises(x.LiquidMismatch):
            self.well.get_volume('water')

    def liquid_value_error_test(self):
        """Raises on named get_volume if multiple liquids present."""
        self.well.allocate(water=10, saline=10)
        with self.assertRaises(x.LiquidMismatch):
            self.well.get_volume('water')

    def ml_conversion_test(self):
        """ml to µl conversion."""
        self.well.allocate(water=.1, ml=True)
        self.assertEqual(self.well.get_volume(), 100)
Beispiel #16
0
 def test_module_add_to_filled_slot(self):
     """Raise when adding module to filled deck slot."""
     self.deck.add_modules(a1=Microplate())
     with self.assertRaises(x.ContainerConflict):
         self.deck.add_modules(a1=Microplate())
Beispiel #17
0
class MicroplateTest(unittest.TestCase):

    expected_margin = 9  # ANSI standard.

    def setUp(self):
        self.plate = Microplate()
        self.plate.calibrate(x=10, y=11, z=12)

    def a1_calibration_test(self):
        """Basic calibration."""
        a1 = self.plate.well('A1').coordinates()
        print(self.plate._calibration)
        self.assertEqual(a1, (10, 11, 12))

    def a2_coordinate_test(self):
        """Calibrated coordinates of A2."""
        a2 = self.plate.well('A2').coordinates()
        self.assertEqual(a2, (10, 11 + self.expected_margin, 12))

    def b1_coordinate_test(self):
        """Calibrated coordinates of B1."""
        b1 = self.plate.well('B1').coordinates()
        self.assertEqual(b1, (10 + self.expected_margin, 11, 12))

    def b2_coordinate_test(self):
        """Calibrated coordinates of B2."""
        b2 = self.plate.well('B2').coordinates()
        margin = self.expected_margin
        self.assertEqual(b2, (10 + margin, 11 + margin, 12))

    def coordinate_lowercase_test(self):
        """Lowercase coordinates."""
        b2 = self.plate.well('b2').coordinates()
        margin = self.expected_margin
        self.assertEqual(b2, (10 + margin, 11 + margin, 12))

    def col_sanity_test(self):
        """Don't return out-of-range columns."""
        col = chr(ord('a') + self.plate.cols + 1)
        with self.assertRaises(KeyError):
            self.plate.well('{}1'.format(col))

    def unicode_coord_test(self):
        """Unicode coordinates."""
        self.plate.well(u'A1')

    def row_sanity_test(self):
        """Don't return out-of-range rows."""
        row = self.plate.rows + 1
        with self.assertRaises(KeyError):
            self.plate.well('A{}'.format(row))

    def col_type_sanity_test(self):
        """Sanity check on well coordinates."""
        with self.assertRaises(ValueError):
            self.plate.well('ABC')

    def deck_calibration_test(self):
        """Calibrates through deck."""
        config = {
            'calibration': {
                'a1': {
                    'type': 'microplate_96',
                    'x': 10,
                    'y': 11,
                    'z': 12
                }
            }
        }

        deck = Deck(a1=Microplate())
        deck.configure(config)

        margin = self.expected_margin

        plate = deck.slot('a1')

        a1 = plate.well('a1').coordinates()
        b2 = plate.well('b2').coordinates()

        self.assertEqual(a1, (10, 11, 12))
        self.assertEqual(b2, (10 + margin, 11 + margin, 12))