def system_initialize(): ham_int, reader_int, reader_int, shaker, *_ = sys_state.instruments if mid_run: print('CONTINUING A PREVIOUSLY INITIALIZED AND PAUSED RUN. WILL SKIP CLEANING. OK? 5 SECONDS TO CANCEL...') time.sleep(5) local_log_dir = os.path.join(method_local_dir, 'log') if not os.path.exists(local_log_dir): os.mkdir(local_log_dir) main_logfile = os.path.join(local_log_dir, 'main.log') logging.basicConfig(filename=main_logfile, level=logging.DEBUG, format='[%(asctime)s] %(name)s %(levelname)s %(message)s') add_robot_level_log() add_stderr_logging() for banner_line in log_banner('Begin execution of ' + __file__): logging.info(banner_line) if sys_state.disable_pumps or simulation_on: pump_int.disable() if simulation_on: reader_int.disable() shaker.disable() ham_int.set_log_dir(os.path.join(local_log_dir, 'hamilton.log')) if mid_run: prime_and_clean = None else: prime_and_clean = run_async(lambda: (#pump_int.prime(), # important that the shaker is shaker.start(shake_speed), pump_int.bleach_clean(), shaker.stop())) # started and stopped at least once initialize(ham_int) hepa_on(ham_int, simulate=int(simulation_on)) method_start_time = time.time() if not sys_state.disable_pumps: wash_empty_refill(ham_int, refillAfterEmpty=2, chamber2WashLiquid=0) # 2=chamber 1 only; 0=Liquid 1 (bleach) if prime_and_clean: prime_and_clean.join() shaker.start(shake_speed) # TODO: For asynchrony
def system_clean(): ham_int, reader_int, reader_int, shaker, *_ = sys_state.instruments sys_state.waffle_clean_thread = run_async(pump_int.bleach_clean) tip_pick_up_96(ham_int, wash_tips) for i in range(2): aspirate_96(ham_int, bleach_site, wash_vol) dispense_96(ham_int, reader_plate, wash_vol) aspirate_96(ham_int, reader_plate, wash_vol + read_sample_vol, mixVolume=wash_vol, mixCycles=2) dispense_96(ham_int, bleach_site, wash_vol + read_sample_vol) tip_eject_96(ham_int, wash_tips) if not sys_state.disable_pumps: wash_empty_refill(ham_int, refillAfterEmpty=2, chamber2WashLiquid=0) # 2=chamber 1 only; 0=Liquid 1 (bleach)
def service_lagoons(ham_int, pump_int, reader_int): logging.info( '\n\n##### ------------------ Servicing lagoons ------------------' ) logging.info('\n##### Filling reservoir and adding inducer.') culture_fill_thread = run_async( lambda: pump_int.refill(culture_supply_vol)) #while True: # try: # tip_pick_up(ham_int, [next(inducer_tip_pos_gen)]) # break # except pyhamilton.NoTipError: # continue #liq_class_300uL = 'StandardVolumeFilter_Water_DispenseJet_Empty_with_transport_vol' while True: try: tip_pick_up(ham_int, next(disp_lagoon_tips_gen)) break except pyhamilton.NoTipError: continue tip_eject(ham_int, disp_tip_poss) culture_fill_thread.join() #aspirate(ham_int, [(inducer_site, 0)], [inducer_vol], liquidClass=liq_class_300uL) #dispense(ham_int, [(culture_reservoir, 93)], [inducer_vol], liquidClass=liq_class_300uL) #tip_eject(ham_int) logging.info('\n##### Moving fresh culture into lagoons.') change_96_tips(ham_int, culture_tips) aspirate_96(ham_int, culture_reservoir, cycle_replace_vol, mixCycles=6, mixVolume=100, liquidHeight=.5, airTransportRetractDist=30) waffle_clean_thread = run_async(lambda: (pump_int.empty( culture_supply_vol), clean_reservoir(pump_int, shaker))) dispense_96(ham_int, lagoon_plate, cycle_replace_vol, liquidHeight=lagoon_fly_disp_height, dispenseMode=9, airTransportRetractDist=30) # mode: blowout put_96_tips(ham_int, culture_tips, immediately=True) logging.info('\n##### Mixing lagoons.') if sys_state.need_to_read_plate: logging.info( '\n##### Sampling liquid from lagoons to reader plates.') while True: try: reader_plate = next(reader_plate_gen) move_plate(ham_int, reader_plate, reader_plate_site) break except pyhamilton.LabwareError: pass change_96_tips(ham_int, mixing_tips) aspirate_96(ham_int, lagoon_plate, read_sample_vol, mixCycles=2, mixPosition=2, mixVolume=400, liquidFollowing=1, liquidHeight=fixed_lagoon_height, airTransportRetractDist=30) dispense_96(ham_int, reader_plate_site, read_sample_vol, liquidHeight=5, dispenseMode=9, airTransportRetractDist=30) # mode: blowout else: change_96_tips(ham_int, mixing_tips) aspirate_96(ham_int, lagoon_plate, read_sample_vol, mixCycles=2, mixPosition=2, mixVolume=400, liquidFollowing=1, liquidHeight=fixed_lagoon_height, airTransportRetractDist=30) dispense_96(ham_int, lagoon_plate, read_sample_vol, liquidHeight=fixed_lagoon_height + 3, dispenseMode=9, airTransportRetractDist=30) # mode: blowout logging.info('\n##### Draining lagoons to constant height.') excess_vol = max_transfer_vol * .8 aspirate_96(ham_int, lagoon_plate, excess_vol, liquidHeight=fixed_lagoon_height, airTransportRetractDist=30) dispense_96(ham_int, bleach_site, excess_vol, liquidHeight=10, dispenseMode=9, airTransportRetractDist=30) # mode: blowout put_96_tips(ham_int, mixing_corral) change_96_tips(ham_int, temp_layout) if sys_state.need_to_read_plate: aspirate_96(ham_int, lagoon_plate, read_sample_vol, mixCycles=2, mixPosition=2, mixVolume=400, liquidFollowing=1, liquidHeight=fixed_lagoon_height, airTransportRetractDist=30) dispense_96(ham_int, reader_plate_site, read_sample_vol, liquidHeight=5, dispenseMode=9, airTransportRetractDist=30) # mode: blowout else: aspirate_96(ham_int, lagoon_plate, read_sample_vol, mixCycles=2, mixPosition=2, mixVolume=400, liquidFollowing=1, liquidHeight=fixed_lagoon_height, airTransportRetractDist=30) dispense_96(ham_int, lagoon_plate, read_sample_vol, liquidHeight=fixed_lagoon_height + 3, dispenseMode=9, airTransportRetractDist=30) # mode: blowout logging.info('\n##### Draining lagoons to constant height.') aspirate_96(ham_int, lagoon_plate, excess_vol, liquidHeight=fixed_lagoon_height, airTransportRetractDist=30) dispense_96(ham_int, bleach_site, excess_vol, liquidHeight=10, dispenseMode=9, airTransportRetractDist=30) # mode: blowout put_96_tips(ham_int, DEFAULT_WASTE, immediately=True) def bleach(): change_96_tips(ham_int, mixing_corral) bleach_mounted_tips(ham_int, destination=mixing_tips) change_96_tips(ham_int, None) if sys_state.need_to_read_plate: plate_id = reader_plate_id(reader_plate) protocols = ['17_8_12_lum', '17_8_12_abs'] data_types = ['lum', 'abs'] platedatas = read_plate( ham_int, reader_int, reader_tray, reader_plate_site, protocols, plate_id, plate_destination=plate_trash, async_task=bleach ) # throw out plate when done and asynchronously bleach if simulation_on: platedatas = [ PlateData(os.path.join('assets', 'dummy_platedata.csv')) ] * 2 # sim dummies for platedata, data_type in zip(platedatas, data_types): platedata.wait_for_file() db_add_plate_data(platedata, data_type, reader_plate, lagoons, [ *range(8 * 10), *range(8 * 11, 8 * 11 + num_disp_lagoons) ]) reader_int.plate_in(block=False) sys_state.need_to_read_plate = False else: bleach() change_96_tips(ham_int, None) waffle_clean_thread.join() logging.info( '\n##### --------------- Done servicing lagoons ---------------\n')
shaker = Shaker() with HamiltonInterface(simulate=simulation_on) as ham_int, LBPumps( ) as pump_int, ClarioStar() as reader_int: if sys_state.disable_pumps or simulation_on: pump_int.disable() if simulation_on: reader_int.disable() shaker.disable() ham_int.set_log_dir(os.path.join(local_log_dir, 'hamilton.log')) logging.info('\n##### Priming pump lines and cleaning reservoir.') if mid_run: prime_and_clean = None else: prime_and_clean = run_async(lambda: ( pump_int.prime(), # important that the shaker is shaker.start(300), pump_int.bleach_clean(), shaker.stop())) # started and stopped at least once initialize(ham_int) hepa_on(ham_int, simulate=int(simulation_on)) logging.info( '\n##### Filling bleach so first waste dispense does not froth up.' ) if not sys_state.disable_pumps: wash_empty_refill( ham_int, refillAfterEmpty=3, chamber2WashLiquid=0) # 3=chamber 2 only; 0=Liquid 1 (bleach) if prime_and_clean: prime_and_clean.join() try: errmsg_str = ''
with HamiltonInterface(simulate=simulation_on) as ham_int, LBPumps( ) as pump_int, ClarioStar() as reader_int: if sys_state.disable_pumps or simulation_on: pump_int.disable() if simulation_on: reader_int.disable() shaker.disable() ham_int.set_log_dir(os.path.join(local_log_dir, 'hamilton.log')) logging.info('\n##### Priming pump lines and cleaning reservoir.') if mid_run: prime_and_clean = None else: prime_and_clean = run_async( lambda: ( #pump_int.prime(), # important that the shaker is shaker.start(300), pump_int.bleach_clean(), shaker.stop() )) # started and stopped at least once initialize(ham_int) hepa_on(ham_int, simulate=int(simulation_on)) method_start_time = time.time() try: # make sure we initially have something to dispense frothy waste into if not sys_state.disable_pumps: wash_empty_refill( ham_int, refillAfterEmpty= 3, # 3=Refill chamber 2 only, which is BLEACH chamber2WashLiquid=0 ) # 0=Liquid 1 (red container) (bleach)