示例#1
0
def find_max_stock_volume_labware(experiment_csv_dict,
                                  custom_labware_dict=None):
    """
    Using the stock labware name from the csv, loads the appropiate labware
    from both a custom and the native libary and determines the maximum volume
    for one stock labware well. Assumes all labware is all identical.

    Parameters
    -----------


    Returns
    --------
    """
    # Protocol encapsulated as only need an instance to simualte and toss
    if custom_labware_dict:
        protocol = simulate.get_protocol_api('2.8',
                                             extra_labware=custom_labware_dict)
    else:
        protocol = simulate.get_protocol_api('2.8')
    stock_plate = protocol.load_labware(
        experiment_csv_dict['OT2 Stock Labwares'][0],
        experiment_csv_dict['OT2 Stock Labware Slots'][0])
    stock_plate_rows = [well for row in stock_plate.rows() for well in row]
    stock_plate_well_volume = stock_plate.__dict__['_well_definition']['A1'][
        'totalLiquidVolume']
    return stock_plate_well_volume
def test_add_buffer_fullplate():
    protocol = get_protocol_api(apilevel)

    tips = protocol.load_labware('opentrons_96_tiprack_300ul', 8)
    plate = protocol.load_labware('biorad_96_wellplate_200ul_pcr',
                                  3, 'plate')
    reagents = protocol.load_labware('usascientific_12_reservoir_22ml',
                                     9, 'reagents')
    pipette = protocol.load_instrument('p300_multi',
                                       'left',
                                       tip_racks=[tips])

    remaining, source_wells = add_buffer(pipette,
                                         [reagents['A1'],
                                          reagents['A2']],
                                         plate,
                                         ['A1', 'A2', 'A3', 'A4',
                                          'A5', 'A6', 'A7', 'A8',
                                          'A9', 'A10', 'A11', 'A12'],
                                         300,
                                         20000 / 8,
                                         dead_vol=800 / 8)

    assert remaining == 1300
    assert source_wells == [reagents['A2']]
示例#3
0
def test_bead_mix():
    protocol = get_protocol_api('2.5')
    scraper = CommandScraper(logging.getLogger('opentrons'), '1',
                             protocol.broker)

    tips = protocol.load_labware('opentrons_96_tiprack_300ul', 8)
    plate = protocol.load_labware('biorad_96_wellplate_200ul_pcr', 3, 'plate')
    pipette = protocol.load_instrument('p300_multi', 'left', tip_racks=[tips])

    cols = ['A1']

    bead_mix(pipette, plate, cols, tips)

    exp = [
        'Picking up tip from A1 of Opentrons 96 Tip Rack 300 µL on 8',
        'Mixing 5 times with a volume of 200.0 ul',
        'Aspirating 200.0 uL from A1 of plate on 3 at 1.0 speed',
        'Dispensing 200.0 uL into A1 of plate on 3 at 1.0 speed',
        'Aspirating 200.0 uL from A1 of plate on 3 at 1.0 speed',
        'Dispensing 200.0 uL into A1 of plate on 3 at 1.0 speed',
        'Aspirating 200.0 uL from A1 of plate on 3 at 1.0 speed',
        'Dispensing 200.0 uL into A1 of plate on 3 at 1.0 speed',
        'Aspirating 200.0 uL from A1 of plate on 3 at 1.0 speed',
        'Dispensing 200.0 uL into A1 of plate on 3 at 1.0 speed',
        'Aspirating 200.0 uL from A1 of plate on 3 at 1.0 speed',
        'Dispensing 200.0 uL into A1 of plate on 3 at 1.0 speed',
        'Blowing out at A1 of plate on 3', 'Returning tip',
        'Dropping tip into A1 of Opentrons 96 Tip Rack 300 µL on 8'
    ]

    obs = [x['payload']['text'] for x in scraper.commands]

    assert exp == obs
示例#4
0
def test_transfer_elute():

    protocol = get_protocol_api('2.5')
    scraper = CommandScraper(logging.getLogger('opentrons'), '1',
                             protocol.broker)

    tips = protocol.load_labware('opentrons_96_tiprack_300ul', 8)
    plate = protocol.load_labware('biorad_96_wellplate_200ul_pcr', 3, 'plate')
    elute = protocol.load_labware('biorad_96_wellplate_200ul_pcr', 7, 'elute')
    pipette = protocol.load_instrument('p300_multi', 'left', tip_racks=[tips])

    cols = ['A1']

    transfer_elute(pipette,
                   plate,
                   elute,
                   cols,
                   tips,
                   50,
                   z_offset=0.5,
                   x_offset=1,
                   rate=0.25,
                   drop_tip=True)

    exp = [
        'Picking up tip from A1 of Opentrons 96 Tip Rack 300 µL on 8',
        'Aspirating 50.0 uL from A1 of plate on 3 at 0.25 speed',
        'Dispensing 50.0 uL into A1 of elute on 7 at 1.0 speed',
        'Dropping tip into A1 of Opentrons Fixed Trash on 12'
    ]

    obs = [x['payload']['text'] for x in scraper.commands]

    assert exp == obs
def test_add_buffer():
    protocol = get_protocol_api(apilevel)
    scraper = CommandScraper(logging.getLogger('opentrons'),
                             '1',
                             protocol.broker)

    tips = protocol.load_labware('opentrons_96_tiprack_300ul', 8)
    plate = protocol.load_labware('biorad_96_wellplate_200ul_pcr',
                                  3, 'plate')
    reagents = protocol.load_labware('nest_12_reservoir_15ml',
                                     9, 'reagents')
    pipette = protocol.load_instrument('p300_multi',
                                       'left',
                                       tip_racks=[tips])

    remaining, source_wells = add_buffer(pipette,
                                         [reagents['A1']],
                                         plate,
                                         ['A1', 'A2'],
                                         300,
                                         1000)

    assert remaining == 400
    assert source_wells == [reagents['A1']]

    exp = ['Picking up tip from A1 of Opentrons 96 Tip Rack 300 µL on 8',
           'Aspirating 150.0 uL from A1 of reagents on 9 at 1.0 speed',
           'Air gap',
           'Aspirating 10.0 uL from A1 of reagents on 9 at 1.0 speed',
           'Dispensing 160.0 uL into A1 of plate on 3 at 1.0 speed',
           'Aspirating 150.0 uL from A1 of reagents on 9 at 1.0 speed',
           'Air gap',
           'Aspirating 10.0 uL from A1 of reagents on 9 at 1.0 speed',
           'Dispensing 160.0 uL into A1 of plate on 3 at 1.0 speed',
           'Blowing out',
           'Aspirating 150.0 uL from A1 of reagents on 9 at 1.0 speed',
           'Air gap',
           'Aspirating 10.0 uL from A1 of reagents on 9 at 1.0 speed',
           'Dispensing 160.0 uL into A2 of plate on 3 at 1.0 speed',
           'Aspirating 150.0 uL from A1 of reagents on 9 at 1.0 speed',
           'Air gap',
           'Aspirating 10.0 uL from A1 of reagents on 9 at 1.0 speed',
           'Dispensing 160.0 uL into A2 of plate on 3 at 1.0 speed',
           'Blowing out',
           'Dropping tip into A1 of Opentrons Fixed Trash on 12']

    obs = [x['payload']['text'] for x in scraper.commands]

    assert exp == obs
示例#6
0
def test_simulate_extra_labware(protocol, protocol_file, monkeypatch):
    fixturedir = HERE / '..' / '..' / '..' /\
        'shared-data' / 'labware' / 'fixtures' / '2'
    # make sure we can load labware explicitly
    # make sure we don't have an exception from not finding the labware
    runlog, _ = simulate.simulate(protocol.filelike, 'custom_labware.py',
                                  custom_labware_paths=[str(fixturedir)])
    assert len(runlog) == 4

    protocol.filelike.seek(0)
    # make sure we don't get autoload behavior when not on a robot
    with pytest.raises(ExceptionInProtocolError,
                       match='.*FileNotFoundError.*'):
        simulate.simulate(protocol.filelike, 'custom_labware.py')
    no_lw = simulate.get_protocol_api('2.0')
    assert not no_lw._extra_labware
    protocol.filelike.seek(0)
    monkeypatch.setattr(simulate, 'IS_ROBOT', True)
    monkeypatch.setattr(simulate, 'JUPYTER_NOTEBOOK_LABWARE_DIR',
                        fixturedir)
    # make sure we don't have an exception from not finding the labware
    runlog, _ = simulate.simulate(protocol.filelike, 'custom_labware.py')
    assert len(runlog) == 4

    # make sure the extra labware loaded by default is right
    ctx = simulate.get_protocol_api('2.0')
    assert len(ctx._extra_labware.keys()) == len(os.listdir(fixturedir))

    assert ctx.load_labware('fixture_12_trough', 1, namespace='fixture')

    # if there is no labware dir, make sure everything still works
    monkeypatch.setattr(simulate, 'JUPYTER_NOTEBOOK_LABWARE_DIR',
                        HERE / 'nosuchdirectory')
    ctx = simulate.get_protocol_api('2.0')
    with pytest.raises(FileNotFoundError):
        ctx.load_labware("fixture_12_trough", 1, namespace='fixture')
def test_add_buffer_runout():
    protocol = get_protocol_api(apilevel)

    tips = protocol.load_labware('opentrons_96_tiprack_300ul', 8)
    plate = protocol.load_labware('biorad_96_wellplate_200ul_pcr',
                                  3, 'plate')
    reagents = protocol.load_labware('nest_12_reservoir_15ml',
                                     9, 'reagents')
    pipette = protocol.load_instrument('p300_multi',
                                       'left',
                                       tip_racks=[tips])

    with pytest.raises(IndexError):
        remaining, source_wells = add_buffer(pipette,
                                             [reagents['A1']],
                                             plate,
                                             ['A1', 'A2'],
                                             300,
                                             600)
示例#8
0
def test_remove_supernatant():
    protocol = get_protocol_api('2.5')
    scraper = CommandScraper(logging.getLogger('opentrons'), '1',
                             protocol.broker)

    tips = protocol.load_labware('opentrons_96_tiprack_300ul', 8)
    plate = protocol.load_labware('biorad_96_wellplate_200ul_pcr', 3, 'plate')
    waste = protocol.load_labware('nest_1_reservoir_195ml', 7, 'waste')
    pipette = protocol.load_instrument('p300_multi', 'left', tip_racks=[tips])

    cols = ['A1']

    remove_supernatant(pipette,
                       plate,
                       cols,
                       tips,
                       waste['A1'],
                       super_vol=200,
                       tip_vol=200,
                       rate=0.25,
                       bottom_offset=2,
                       drop_tip=False)

    exp = [
        'Picking up tip from A1 of Opentrons 96 Tip Rack 300 µL on 8',
        'Aspirating 190.0 uL from A1 of plate on 3 at 0.25 speed', 'Air gap',
        'Aspirating 10.0 uL from A1 of plate on 3 at 1.0 speed',
        'Dispensing 200.0 uL into A1 of waste on 7 at 1.0 speed',
        'Aspirating 10.0 uL from A1 of plate on 3 at 0.25 speed', 'Air gap',
        'Aspirating 10.0 uL from A1 of plate on 3 at 1.0 speed',
        'Dispensing 20.0 uL into A1 of waste on 7 at 1.0 speed', 'Blowing out',
        'Returning tip',
        'Dropping tip into A1 of Opentrons 96 Tip Rack 300 µL on 8'
    ]

    obs = [x['payload']['text'] for x in scraper.commands]

    assert exp == obs
    _all_values = json.loads(
        """{"pipette_type":"p300_multi_gen2","dilution_factor":3,"num_of_dilutions":11,"total_mixing_volume":150,"tip_use_strategy":"never"}"""
    )
    return [_all_values[n] for n in names]


metadata = {
    'protocolName': 'Customizable Serial Dilution',
    'author': 'Opentrons <*****@*****.**>',
    'source': 'Protocol Library',
    'apiLevel': '2.7'
}

from opentrons import simulate
metadata = {'apiLevel': '2.7'}
protocol = simulate.get_protocol_api('2.7')
[
    pipette_type, dilution_factor, num_of_dilutions, total_mixing_volume,
    tip_use_strategy
] = get_values(  # noqa: F821
    'pipette_type', 'dilution_factor', 'num_of_dilutions',
    'total_mixing_volume', 'tip_use_strategy')

# labware
trough = protocol.load_labware('usascientific_12_reservoir_22ml', '2')
liquid_trash = trough.wells()[0]
plate = protocol.load_labware('corning_96_wellplate_360ul_flat', '3')
tiprack = [
    protocol.load_labware('opentrons_96_tiprack_300ul', slot)
    for slot in ['1', '4']
]
示例#10
0
                
                # touch tip
                if(j < (len(c_target_deck)-1)):
                    if("384" not in str(labwareCaller[get_LabwareCaller(c_target_deck[-1])])):
                        c_pipette.touch_tip(labwareCaller[get_LabwareCaller(c_target_deck[-1])].wells_by_name()[c_target_slot[-1]])
                    else:
                        c_pipette.touch_tip(labwareCaller[get_LabwareCaller(c_target_deck[-1])].wells_by_name()[c_target_slot[-1]],
                                            radius=0.8, speed=15)
                        
            
                #   update target amount list
                amtList = update_amtList(amtList, c_target_deck[j], c_target_slot[j], float(c_amt[j]), 'dispense')
            
            #   blow out at last target
            c_pipette.blow_out(labwareCaller[get_LabwareCaller(c_target_deck[-1])].wells_by_name()[c_target_slot[-1]].bottom(current_dspH+3))
            if("384" not in str(labwareCaller[get_LabwareCaller(c_target_deck[-1])])):
                c_pipette.touch_tip(labwareCaller[get_LabwareCaller(c_target_deck[-1])].wells_by_name()[c_target_slot[-1]])
            else:
                c_pipette.touch_tip(labwareCaller[get_LabwareCaller(c_target_deck[-1])].wells_by_name()[c_target_slot[-1]],
                                    radius=0.8, speed=15)
                    
        #drop tip decision
        if(int(tip_next) != int(current_tip) or (i == len(aspirate_groups2)-1)):
            c_pipette.drop_tip(protocol.fixed_trash['A1'].top().move(types.Point(10, 5, 12)))


######### SIMULATION ############
from opentrons import simulate
bep = simulate.get_protocol_api('2.10')
bep.home()
run(bep) 
示例#11
0
 def simulate(self):
     from opentrons import simulate
     self.run(simulate.get_protocol_api(self.metadata["apiLevel"]))
示例#12
0
    def to96(self, maxVol: int, filepath: str):
        self.protocol = simulate.get_protocol_api(self._api)
        self.protocol.home()
        
        tuberack_1 = self.protocol.load_labware(self._tuberack1_name, self._tuberack1_pos)

        
        tuberack_2 = self.protocol.load_labware(self._tuberack2_name, self._tuberack2_pos)
        tiprack_1 = self.protocol.load_labware(self._tiprack_name, self._tiprack_pos)

        plate = self.protocol.load_labware(self._plate_name, self._plate_pos)
        pipette = self.protocol.load_instrument('p300_single', 'right', tip_racks=[tiprack_1])


        df = pd.read_csv(filepath, sep='\t')




            #[0.0 for df1.loc[i] in [1..12]

        #calculate the concentration (total should = 1)
        sources = list(df)
        sources.remove("wells")
        tubes = len(df.columns) - 1
        df['sumVol'] = df[sources].sum(axis=1)



        #create the output file

        df1 = pd.DataFrame(columns = [])
        df1.index.name = 'wells'



        #initialize the sources column
        for i in range (12):
            df1['source ' + str(i+1)] = 0

        #initialize the values of each cell 
        for i in range (96):
            df1.loc[i] = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]


        #make index start at 1
        df1.index=df1.index+1
        df1.sort_index()


        #check invalid concentration (total not = 1)
        #create an ignore array that includes wells with no solution
        #determine validWells to constrain the range of inner for loop


        ignore=[]
        validWells = 0; 
        for i in df.index:
            sum = df['sumVol'][i]



            if int(round(sum,3)) != 1 and sum != 0:
                print("Invalid vol at well ")
                print (i+1)
                ignore.append(i)

            elif int(round(sum,3)) == 1:
                validWells = i+1;

            elif sum == 0:
                ignore.append(i)



        #set tubeRack
        #start transfering
        curRack = tuberack_1

        curTube = -1;



        #nested loops to transfer from 1 tube to many wells
        #outer loop: accessing tube
        for i in range(tubes):

            #switch from tuberack_1 to tuberack_2
            if i+1 == 7:
                curRack = tuberack_2
                curTube = -1

            curTube += 1


            pipette.pick_up_tip()


            #inner loop: accessing the wells
            for j in range(validWells):


                volTip = (df.iat[j,i+1])*maxVol

                if j not in ignore:
                    if volTip != 0:

                        pipette.aspirate(float(volTip), curRack.wells()[curTube])
                        pipette.dispense(float(volTip), plate.wells()[j])
                        pipette.blow_out(curRack.wells()[curTube])
                        if i+1 < 7:
                            df1.at[j+1,'source '+str(curTube+1)] = float(volTip)

                        else:
                            df1.at[j+1,'source '+str(curTube+7)] = float(volTip)


                if j == validWells - 1:
                    pipette.drop_tip()



        df1.to_csv("output.tsv", sep="\t")


        for line in self.protocol.commands():
            print (line)
示例#13
0
def test_bead_wash():
    apilevel = '2.5'
    protocol = get_protocol_api(apilevel)
    scraper = CommandScraper(logging.getLogger('opentrons'), '1',
                             protocol.broker)

    tips = protocol.load_labware('opentrons_96_tiprack_300ul', 8)
    reagents = protocol.load_labware('nest_12_reservoir_15ml', 9, 'reagents')
    waste = protocol.load_labware('nest_1_reservoir_195ml', 7, 'waste')
    pipette = protocol.load_instrument('p300_multi', 'left', tip_racks=[tips])
    magblock = protocol.load_module('Magnetic Module', 10)
    mag_plate = magblock.load_labware('biorad_96_wellplate_200ul_pcr')

    cols = ['A1']

    remaining, wells = bead_wash(  # global arguments
        protocol,
        magblock,
        pipette,
        mag_plate,
        cols,
        # super arguments
        waste['A1'],
        tips,
        # wash buffer arguments
        [reagents['A1']],
        20000 / 8,
        # mix arguments
        tips,
        # optional arguments
        super_vol=150,
        rate=0.25,
        super_bottom_offset=2,
        drop_super_tip=True,
        wash_vol=150,
        remaining=None,
        wash_tip=None,
        drop_wash_tip=True,
        mix_vol=200,
        mix_n=2,
        drop_mix_tip=False,
        mag_engage_height=None,
        pause_s=300)
    assert remaining == pytest.approx(2350.0)
    assert wells == [reagents['A1']]

    exp = [
        'Picking up tip from A1 of Opentrons 96 Tip Rack 300 µL on 8',
        'Aspirating 150.0 uL from A1 of Bio-Rad 96 Well Plate 200 µL PCR on'
        ' Magnetic Module GEN1 on 10 at 0.25 speed', 'Air gap',
        'Aspirating 10.0 uL from A1 of Bio-Rad 96 Well Plate 200 µL PCR on '
        'Magnetic Module GEN1 on 10 at 1.0 speed',
        'Dispensing 160.0 uL into A1 of waste on 7 at 1.0 speed',
        'Blowing out', 'Dropping tip into A1 of Opentrons Fixed Trash on 12',
        'Disengaging Magnetic Module',
        'Picking up tip from A2 of Opentrons 96 Tip Rack 300 µL on 8',
        'Aspirating 150.0 uL from A1 of reagents on 9 at 1.0 speed', 'Air gap',
        'Aspirating 10.0 uL from A1 of reagents on 9 at 1.0 speed',
        'Dispensing 160.0 uL into A1 of Bio-Rad 96 Well Plate 200 µL PCR on '
        'Magnetic Module GEN1 on 10 at 1.0 speed', 'Blowing out',
        'Dropping tip into A1 of Opentrons Fixed Trash on 12',
        'Picking up tip from A1 of Opentrons 96 Tip Rack 300 µL on 8',
        'Mixing 2 times with a volume of 200.0 ul',
        'Aspirating 200.0 uL from A1 of Bio-Rad 96 Well Plate 200 µL PCR on '
        'Magnetic Module GEN1 on 10 at 1.0 speed',
        'Dispensing 200.0 uL into A1 of Bio-Rad 96 Well Plate 200 µL PCR on '
        'Magnetic Module GEN1 on 10 at 1.0 speed',
        'Aspirating 200.0 uL from A1 of Bio-Rad 96 Well Plate 200 µL PCR on '
        'Magnetic Module GEN1 on 10 at 1.0 speed',
        'Dispensing 200.0 uL into A1 of Bio-Rad 96 Well Plate 200 µL PCR on '
        'Magnetic Module GEN1 on 10 at 1.0 speed',
        'Blowing out at A1 of Bio-Rad 96 Well Plate 200 µL PCR on Magnetic '
        'Module GEN1 on 10', 'Returning tip',
        'Dropping tip into A1 of Opentrons 96 Tip Rack 300 µL on 8',
        'Engaging Magnetic Module', 'Delaying for 5 minutes and 0 seconds'
    ]

    obs = [x['payload']['text'] for x in scraper.commands]

    assert exp == obs