예제 #1
0
    def setUp(self, mock_serial, mock_sleep):
        logging.disable(logging.CRITICAL)
        self.ber = bl.robot(cartesian_port_name='COM1',
                            loadcell_port_name='COM2')
        self.s1 = bl.createSample('eppendorf', 's1', self.ber.samples_rack, 1,
                                  0, 0)
        self.beads_5ml = bl.createSample('5mL', 'beads_5ml',
                                         self.ber.samples_rack, 1, 0, 0)

        self.eppendorf_mix_script_file_path = 'eppendorf_mix_script.csv'
예제 #2
0
 def test_isLowVolumeUptakeNeeded(self):
     s1 = bl.createSample('eppendorf', 's1', self.ber.samples_rack, 1, 0, 1000)
     self.assertEqual(s1.getCloseToBottomVol(), 50)
     self.assertEqual(s1.getVolume(), 1000)
     self.assertEqual(s1.getExtraImmersionVol(), 200)
     
     low_volume_uptake_needed = s1._isLowVolumeUptakeNeeded(0)
     self.assertFalse(low_volume_uptake_needed)
     low_volume_uptake_needed = s1._isLowVolumeUptakeNeeded(250)
     self.assertFalse(low_volume_uptake_needed)
     
     s1 = bl.createSample('eppendorf', 's1', self.ber.samples_rack, 1, 0, 200)
     low_volume_uptake_needed = s1._isLowVolumeUptakeNeeded(0)
     self.assertTrue(low_volume_uptake_needed)
예제 #3
0
 def test_MixScriptSettings(self):
     # Creating mock mix script file
     line1 = "Height,H_relative_to,Plunger_pos,dx,dy,min_vol_condition,max_vol_condition,delay,comment\n"
     line2 = "0,top,down,0,0,0,1700,0.5,Initially lowering the plunger\n"
     line3 = "1,bottom,up,0,0,0,250,0.5,mixing in place\n"
     
     with open(self.mix_script_filename, mode='a') as csv_file:
         csv_file.write(line1)
         csv_file.write(line2)
         csv_file.write(line3)
     
     # Making sure the file was in fact created
     self.assertTrue(os.path.exists(self.mix_script_filename))
     # Making sure the file reads
     df = pd.read_csv(self.mix_script_filename)
     self.assertEqual(df['Height'][0], 0)
     self.assertEqual(df['Height'][1], 1)
     self.assertEqual(df['H_relative_to'][0], 'top')
     self.assertEqual(df['H_relative_to'][1], 'bottom')
         
     # Creating a sample_name
     s1 = bl.createSample(self.sample_type, self.sample_name, self.ber.samples_rack, 1, 0, 0)
     
     # Saving mix script file path
     s1.stype.setMixScriptFilePath(self.mix_script_filename)
     # Testing whether file name was saved
     self.assertTrue(os.path.exists(self.sample_type+'.json'))
     self.assertEqual(s1.stype.data['mix_script_file_path'], self.mix_script_filename)
     self.assertEqual(s1.stype.getMixScriptFilePath(), self.mix_script_filename)
     # Testing whether the dataframe obtained through getMixScript is correct
     df = s1.stype.getMixScript()
     self.assertEqual(df['Height'][0], 0)
     self.assertEqual(df['Height'][1], 1)
     self.assertEqual(df['H_relative_to'][0], 'top')
     self.assertEqual(df['H_relative_to'][1], 'bottom')
예제 #4
0
 def test_SaveSampleTypeSetting(self):
     s1 = bl.createSample(self.sample_type, self.sample_name, self.ber.samples_rack, 1, 0, 0)
     
     s1.stype._setSetting('new_setting_name', 'asdf')
     
     self.assertTrue(os.path.exists(self.sample_type+'.json'))
     self.assertEqual(s1.stype.data['new_setting_name'], 'asdf')
     self.assertEqual(s1.stype._getSetting('new_setting_name'), 'asdf')
예제 #5
0
 def test_creteTestSample(self):
     s1 = bl.createSample(self.sample_type, self.sample_name, self.ber.samples_rack, 1, 0, 0)
     
     self.assertEqual(s1.name, self.sample_name)
     self.assertEqual(s1.stype.name, self.sample_type)
     self.assertEqual(s1.rack, self.ber.samples_rack)
     self.assertEqual(s1.getWell(), (1, 0))
     self.assertEqual(s1.getVolume(), 0)
 def test__allowPlungerLagCompensation(self):
     s1 = bl.createSample('eppendorf', 's1', self.ber.samples_rack, 1, 0,
                          1000)
     lag = s1._allowPlungerLagCompensation(200, 5)
     self.assertEqual(lag, 5)
     s1 = bl.createSample('eppendorf', 's1', self.ber.samples_rack, 1, 0,
                          200)
     lag = s1._allowPlungerLagCompensation(199, 5)
     self.assertEqual(lag, 1)
     s1 = bl.createSample('eppendorf', 's1', self.ber.samples_rack, 1, 0,
                          100)
     lag = s1._allowPlungerLagCompensation(100, 0)
     self.assertEqual(lag, 0)
     s1 = bl.createSample('eppendorf', 's1', self.ber.samples_rack, 1, 0,
                          90)
     lag = s1._allowPlungerLagCompensation(100, 0)
     self.assertEqual(lag, 0)
    def test_uptakeLiquid__save_sample_bottom_coord(self):

        z_bottom = 120
        s1 = bl.createSample('eppendorf', 's1', self.ber.samples_rack, 1, 0,
                             100)
        self.uptakeLiquid_patched(s1, 100, None, 5, False, False, False,
                                  z_bottom)
        saved_z_bottom = s1.getZBottom()
        self.assertEqual(saved_z_bottom, z_bottom)
예제 #8
0
 def initReagent(self, reagent):
     reagent = reagent.capitalize()
     rack_name = self.settings._getRackName(reagent)
     rack = self.getRack(rack_name, reagent)
     tube_type = self.settings._getTubeType(reagent)
     col, row = self.settings._getTubePositionInRack(reagent)
     sample_name = reagent + '_tube'
     v = self.settings._getReagentVolume(reagent)
     tube = bl.createSample(tube_type, sample_name, rack, col, row, v)
     return tube
    def test_uptakeLiquid__touch_bottom_decision(self,
                                                 mock_moveDownUntilPress):

        z_bottom = 120  # Mocked Z coordinate of the bottom of the tube

        # Sample which has lots of liquid should not be probed for the bottom
        s1 = bl.createSample('eppendorf', 's1', self.ber.samples_rack, 1, 0,
                             1000)
        sample_has_low_volume = s1._isLowVolumeUptakeNeeded(205)

        self.uptakeLiquid_patched(s1, 200, None, 5, False, False, False,
                                  z_bottom)

        self.assertFalse(sample_has_low_volume)
        self.assertFalse(self.ber.moveDownUntilPress.called)
        # Regardless of the liquid amount
        s1 = bl.createSample('eppendorf', 's1', self.ber.samples_rack, 1, 0,
                             1000)
        sample_has_low_volume = s1._isLowVolumeUptakeNeeded(205)
        self.uptakeLiquid_patched(s1, 20, None, 5, False, False, False,
                                  z_bottom)

        self.assertFalse(sample_has_low_volume)
        self.assertFalse(self.ber.moveDownUntilPress.called)
    def prep_uptakeLiquids_pipetteLagsHandling(self, v_sample,
                                               expected_calls_list,
                                               mock_moveToSample,
                                               mock_moveAxisDelta,
                                               mock_moveDownUntilPress,
                                               mock_movePipetteToVolume):
        self.ber.moveDownUntilPress.return_value = 100
        v = 100
        lag_vol = 5
        # Creating a sample
        s1 = bl.createSample('eppendorf', 's1', self.ber.samples_rack, 1, 0,
                             v_sample)
        # figuring lag volume down
        lag_vol_down = s1._allowPlungerLagCompensation(v, lag_vol)

        self.ber.uptakeLiquid(s1, 100, lag_vol=lag_vol)  # Tested function

        calls_list = self.ber.movePipetteToVolume.mock_calls
        for call, expected_call in zip(calls_list, expected_calls_list):
            self.assertEqual(call, mock.call(expected_call))
예제 #11
0
def initReagents(robot, settings):
    """
    Return 4 instances of the reagent tubes: 
    for beads, waste, eluent, ethanol 80%; in this particular order.
    The parameters for the tubes (such as volume and location) are also defined according to the sample sheet.
    """

    # Beads tube settings
    beads_tube_type = returnProtocolParameter(settings, 'Beads tube type')
    beads_rack_name = returnProtocolParameter(settings, 'Beads tube rack')
    if beads_rack_name == 'samples':
        beads_rack = robot.samples_rack
    elif beads_rack_name == 'reagents':
        beads_rack = robot.reagents_rack
    else:
        print("wrong Beads tube rack specified in the samplesheet file")
        return
    beads_col = int(returnProtocolParameter(settings, 'Beads tube column'))
    beads_row = int(returnProtocolParameter(settings, 'Beads tube well'))
    V_avail_beads = returnProtocolParameter(settings, 'Beads initial volume')

    # Initializing beads tube
    beads_tube = bl.createSample(beads_tube_type, 'beads', beads_rack,
                                 beads_col, beads_row, V_avail_beads)

    # -------------------
    # Waste tube settings
    waste_tube_type = returnProtocolParameter(settings, 'Waste tube type')
    waste_rack_name = returnProtocolParameter(settings, 'Waste tube rack')
    if waste_rack_name == 'reagents':
        waste_rack = robot.reagents_rack
    else:
        print("wrong Waste tube rack specified in the samplesheet file")
        return
    waste_col = 0
    waste_row = int(returnProtocolParameter(settings, 'Waste tube position'))
    V_waste = returnProtocolParameter(settings, 'Waste volume')

    # Initializing waste tube
    waste_tube = bl.createSample(waste_tube_type, 'liquid_waste', waste_rack,
                                 waste_col, waste_row, V_waste)

    # -------------------
    # Eluent tube settings
    eluent_tube_type = returnProtocolParameter(settings, 'Eluent tube type')
    eluent_rack_name = returnProtocolParameter(settings, 'Eluent tube rack')
    if eluent_rack_name == 'reagents':
        eluent_rack = robot.reagents_rack
    else:
        print("wrong Eluent tube rack specified in the samplesheet file")
        return
    eluent_col = 0
    eluent_row = int(returnProtocolParameter(settings, 'Eluent tube position'))
    V_avail_eluent = returnProtocolParameter(settings, 'Eluent volume')

    # Initializing eluent tube
    eluent_tube = bl.createSample(eluent_tube_type, 'eluent', eluent_rack,
                                  eluent_col, eluent_row, V_avail_eluent)

    # -------------------
    # Ethanol tube settings
    ethanol_tube_type = returnProtocolParameter(settings, 'Ethanol tube type')
    ethanol_rack_name = returnProtocolParameter(settings, 'Ethanol tube rack')
    if ethanol_rack_name == 'reagents':
        ethanol_rack = robot.reagents_rack
    else:
        print("wrong Ethanol tube rack specified in the samplesheet file")
        return
    ethanol_col = 0
    ethanol_row = int(
        returnProtocolParameter(settings, 'Ethanol tube position'))
    V_avail_ethanol = returnProtocolParameter(settings, 'Ethanol volume')

    ethanol80_tube = bl.createSample(ethanol_tube_type, 'EtOH80pct',
                                     ethanol_rack, ethanol_col, ethanol_row,
                                     V_avail_ethanol)

    return beads_tube, waste_tube, eluent_tube, ethanol80_tube