def resource_list_with_prefix(layout_manager, prefix, res_class, num_ress): def name_from_line(line): field = LayoutManager.layline_objid(line) if field: return field return LayoutManager.layline_first_field(line) layline_test = lambda line: LayoutManager.field_starts_with(name_from_line(line), prefix) res_type = ResourceType(res_class, layline_test, name_from_line) res_list = [layout_manager.assign_unused_resource(res_type) for _ in range(num_ress)] res_list.sort(key=lambda r: r.layout_name()) return res_list
#!python3 from pyhamilton import HamiltonInterface, LayoutManager, INITIALIZE, WASH96_EMPTY def wash_empty_refill(ham, **more_options): print('wash_empty_refill: empty the washer' + ('' if not more_options else ' with extra options ' + str(more_options))) ham.wait_on_response(ham.send_command(WASH96_EMPTY, **more_options)) if __name__ == '__main__': LayoutManager('with_washer.lay', install=True) with HamiltonInterface() as ham_int: print('Please wait, system starting--preparing to wash washer.\n') ham_int.wait_on_response(ham_int.send_command(INITIALIZE), raise_first_exception=True) wash_empty_refill( ham_int, refillAfterEmpty=1, chamber1WashLiquid=1, chamber2WashLiquid=1) # 1=both chambers; 1=Liquid 2 (water) wash_empty_refill(ham_int) # empty
import os from pyhamilton import (HamiltonInterface, LayoutManager, ResourceType, Tip96, INITIALIZE, PICKUP, NoTipError, HardwareError) layfile = os.path.abspath(os.path.join('.', 'minimal_error_example.lay')) lmgr = LayoutManager(layfile) tip_name_from_line = lambda line: LayoutManager.layline_first_field(line) tip_name_condition = lambda line: LayoutManager.field_starts_with( tip_name_from_line(line), 'HTF_L_') tips_type = ResourceType(Tip96, tip_name_condition, tip_name_from_line) tips = lmgr.assign_unused_resource(tips_type) if __name__ == '__main__': with HamiltonInterface() as hammy: print('INITIALIZED!!', hammy.wait_on_response(hammy.send_command(INITIALIZE))) try: id = hammy.send_command(PICKUP, labwarePositions=str(tips.layout_name()) + ', 1;') print(hammy.wait_on_response(id, raise_first_exception=True)) except NoTipError: print('\n' * 10 + 'THERE WAS NO TIP THERE' + '\n' * 10) except HardwareError: print('\n' * 10 + 'Did I just crash into something?' + '\n' * 10)
def name_from_line(line): field = LayoutManager.layline_objid(line) if field: return field return LayoutManager.layline_first_field(line)
import os from pyhamilton import (HamiltonInterface, LayoutManager, ResourceType, Plate96, INITIALIZE, ISWAP_GET, ISWAP_PLACE, HamiltonError) layfile = os.path.abspath(os.path.join('.', 'grip_move_plate.lay')) lmgr = LayoutManager(layfile) plate_type = ResourceType(Plate96, 'Cos_96_Rd_0001') plate = lmgr.assign_unused_resource(plate_type) target_site_type = ResourceType(Plate96, 'Cos_96_Rd_0002') target_site = lmgr.assign_unused_resource(target_site_type) if __name__ == '__main__': plate_pos = plate.layout_name() + ', ' + plate.position_id(0) target_pos = target_site.layout_name() + ', ' + target_site.position_id(0) with HamiltonInterface() as hammy: hammy.wait_on_response(hammy.send_command(INITIALIZE)) for id in (hammy.send_command(ISWAP_GET, plateLabwarePositions=plate_pos), hammy.send_command(ISWAP_PLACE, plateLabwarePositions=target_pos)): print(hammy.wait_on_response(id, raise_first_exception=True)) for id in (hammy.send_command(ISWAP_GET, plateLabwarePositions=target_pos), hammy.send_command(ISWAP_PLACE, plateLabwarePositions=plate_pos)): print(hammy.wait_on_response(id, raise_first_exception=True))
width = l + 2*margin + 2 return ['#'*width, '#' + ' '*(width - 2) + '#', '#' + ' '*margin + banner_text + ' '*margin + '#', '#' + ' '*(width - 2) + '#', '#'*width] log_dir = os.path.join(this_file_dir, 'log') if not os.path.exists(log_dir): os.mkdir(log_dir) main_logfile = os.path.join(log_dir, 'main.log') total_move_vol = 250.0 # uL well_vol = 300.0 # uL layfile = os.path.join(this_file_dir, 'population_dynamics.lay') lmgr = LayoutManager(layfile) sys_state = lambda:None # simple namespace plates = resource_list_with_prefix(lmgr, 'site_top_left_', Plate96, 10) main_tips = lmgr.assign_unused_resource(ResourceType(Tip96, 'main_tips')) wet_tips = lmgr.assign_unused_resource(ResourceType(Tip96, 'cross_tips')) water_trough = lmgr.assign_unused_resource(ResourceType(Plate96, 'water_trough')) def next_tips_tups(): for column in range(11): # use prime number of columns to avoid sharing factors with other periodic activities yield [(main_tips, t) for t in range(8*column, 8*(column+1))] tips_tups_gen = next_tips_tups() tips_tups = None wet_prep_plates = len(sys.argv) > 1 and sys.argv[1] == '--wet'