def runTest(self):
        protocol = Protocol()
        resource = protocol.ref("resource", None, "96-flat", discard=True)
        pcr = protocol.ref("pcr", None, "96-flat", discard=True)
        bacteria = protocol.ref("bacteria", None, "96-flat", discard=True)
        self.assertEqual(len(protocol.as_dict()['refs']), 3,
                         'incorrect number of refs')
        self.assertEqual(protocol.as_dict()['refs']['resource'], {
            "new": "96-flat",
            "discard": True
        })

        bacteria_wells = WellGroup([
            bacteria.well("B1"),
            bacteria.well("C5"),
            bacteria.well("A5"),
            bacteria.well("A1")
        ])

        protocol.distribute(
            resource.well("A1").set_volume("40:microliter"),
            pcr.wells_from('A1', 5), "5:microliter")
        protocol.distribute(
            resource.well("A1").set_volume("40:microliter"), bacteria_wells,
            "5:microliter")

        self.assertEqual(len(protocol.instructions), 1)
        self.assertEqual(protocol.instructions[0].op, "pipette")
        self.assertEqual(len(protocol.instructions[0].groups), 2)

        protocol.incubate(bacteria, "warm_37", "30:minute")

        self.assertEqual(len(protocol.instructions), 2)
        self.assertEqual(protocol.instructions[1].op, "incubate")
        self.assertEqual(protocol.instructions[1].duration, "30:minute")
 def test_as_dict(self):
     p = Protocol()
     cont1 = p.ref("cont_1", None, "96-flat", discard=True)
     well1 = WellGroup([cont1.well(0)])
     comp = Compound("Daylight Canonical SMILES", "C1=NC2=NC=NC(=C2N1)N")
     assert AttachCompounds(well1, [comp]).as_dict() == {
         "type": "attach_compounds",
         "data": {
             "wells": well1,
             "compounds": [comp]
         },
     }
 def test_validate(self):
     p = Protocol()
     cont1 = p.ref("cont_1", None, "96-flat", discard=True)
     well1 = WellGroup([cont1.well(0)])
     comp = Compound("Daylight Canonical SMILES", "C1=NC2=NC=NC(=C2N1)N")
     with pytest.raises(TypeError):
         AttachCompounds(well1, comp)
     with pytest.raises(TypeError):
         AttachCompounds("foo", [comp])
     with pytest.raises(TypeError):
         AttachCompounds(well1, "C1=NC2=NC=NC(=C2N1)N")
     with pytest.raises(CompoundError):
         AttachCompounds(
             well1, [Compound("Daylight Canonical SMILES", "InChI=xxx")])
    def test_attach_compounds(self):
        p = Protocol()
        cont1 = p.ref("cont_1", None, "96-flat", discard=True)
        well1 = cont1.well(0)
        well2 = cont1.well(1)
        wg1 = WellGroup([well1, well2])
        comp1 = Compound("Daylight Canonical SMILES",
                         "CN1C=NC2=C1C(=O)N(C(=O)N2C)C")
        comp2 = Compound("Daylight Canonical SMILES", "C1=NC2=NC=NC(=C2N1)N")

        assert AttachCompounds(well1, [comp1]).compounds == [comp1]
        assert AttachCompounds(well1, [comp1]).wells == well1
        assert AttachCompounds(wg1, [comp1, comp2]).compounds == [comp1, comp2]
        assert AttachCompounds(wg1, [comp1, comp2]).wells == wg1
Example #5
0
    def test_get_wells(self):
        p = Protocol()
        cont1 = p.ref("cont1", None, "6-flat", discard=True)
        cont2 = p.ref("cont2", None, "6-flat", discard=True)
        example_data = {
            "list": [cont1.well(0), cont1.well(1)],
            "well": cont2,
            "dict": {"key1": 1, "key2": "bar", "dict_well": cont1.well(2)},
            "bar": [
                {"key4": "value", "key5": {"well": cont1.well(3)}},
                {"key4": "value", "key5": {"well_group": WellGroup([cont1.well(4)])}},
            ],
            "duplicate": cont1.well(0),
            "nest": [{"list": [{"more_nested": [{"wells": [cont1.well(5)]}]}]}],
        }
        inst = Instruction(op="test", data=example_data)

        wells = set(cont1.all_wells().wells + cont2.all_wells().wells)
        assert set(inst.get_wells(example_data)) == wells
#

Lstated = [ Unit(x, "moles/liter") for x in [20.0e-6,9.15e-6,4.18e-6,1.91e-6,0.875e-6,0.4e-6,0.183e-6,0.0837e-6,0.0383e-6,0.0175e-6,0.008e-6,0] ] # gefitinib concentration
Pstated = Unit(0.5e-6, "moles/liter")
well_volume = Unit(100, "milliliter")
receptor_name = 'Src'
ligand_name = 'gefitinib'

# Load data into well format.
filename = "../ipynbs/data-analysis/binding-assay/data/Gef_WIP_SMH_SrcBos_Extend_013015_mdfx_20150220_18.xml"
from assaytools import platereader
data = platereader.read_icontrol_xml(filename)

# Define wells for fluorescence assay (the verbose way; we'd provide convenience methods to format the plate)
ncolumns = 12
well_group = WellGroup([])
for column in range(ncolumns):
    for row in ['A', 'B']:
        well_name = row + str(column+1)
        well = container.well(well_name)
        well.set_volume(well_volume)
        well.set_properties({'area' : well_area})

        # Set concentrations of well components
        if row == 'A':
            well.set_properties({'concentrations' : {receptor_name : Pstated, ligand_name : Lstated[column]} })
            well.set_properties({'concentration_uncertainties' : {receptor_name  : 0.10 * Pstated, ligand_name : 0.08 * Lstated[column]} })
        elif row == 'B':
            well.set_properties({'concentrations' : {ligand_name : Lstated[column]} })
            well.set_properties({'concentration_uncertainties' : {ligand_name : 0.08 * Lstated[column]} })
Example #7
0
        0.0837e-6, 0.0383e-6, 0.0175e-6, 0.008e-6, 0
    ]
]  # gefitinib concentration
Pstated = Unit(0.5e-6, "moles/liter")
well_volume = Unit(100, "milliliter")
receptor_name = 'Src'
ligand_name = 'gefitinib'

# Load data into well format.
filename = "../ipynbs/data-analysis/binding-assay/data/Gef_WIP_SMH_SrcBos_Extend_013015_mdfx_20150220_18.xml"
from assaytools import platereader
data = platereader.read_icontrol_xml(filename)

# Define wells for fluorescence assay (the verbose way; we'd provide convenience methods to format the plate)
ncolumns = 12
well_group = WellGroup([])
for column in range(ncolumns):
    for row in ['A', 'B']:
        well_name = row + str(column + 1)
        well = container.well(well_name)
        well.set_volume(well_volume)
        well.set_properties({'area': well_area})

        # Set concentrations of well components
        if row == 'A':
            well.set_properties({
                'concentrations': {
                    receptor_name: Pstated,
                    ligand_name: Lstated[column]
                }
            })
Example #8
0
def coordinate_rect_to_well_group(container: Container, coordinates: str):
    indices = coordinate_rect_to_row_col_pairs(coordinates)
    wells = [container.well_from_coordinates(i, j) for i, j in indices]
    return WellGroup(wells)
Example #9
0
    def __init__(self,
                 d300_xml_filename,
                 infinite_xml_filename,
                 dmso_stocks_csv_filename,
                 hpd300_fluids,
                 hpd300_plate_index,
                 receptor_species,
                 protein_absorbance,
                 protein_extinction_coefficient,
                 protein_molecular_weight,
                 protein_stock_volume,
                 buffer_volume,
                 rows_to_analyze,
                 assay_volume,
                 wavelengths_to_analyze=None,
                 measurements_to_analyze=None):
        """
        Set up a single-point assay.

        Parameters
        ----------
        d300_xml_filename : str
            HP D300 dispense simulated DATA file
        infinite_xml_filename : str
            Tecan Infinite plate reader output data, e.g. 'Abl Gef gain 120 bw1020 2016-01-19 15-59-53_plate_1.xml'
        dmso_stocks_csv_filename : str
            CSV file of DMSO stock inventory, e.g. 'dmso'stocks-Sheet1.csv'
        hpd300_fluids : list of str
            uuids of DMSO stocks from dmso_stocks_csv_filename (or 'DMSO' for pure DMSO) used to define HP D300 XML <Fluids> block, e.g. ['GEF001', 'IMA001', 'DMSO']
        hpd300_plate_index : int
            Plate index for HP D300 dispense
        receptor_species
            Name of receptor species, e.g. 'Abl(D382N)'
        protein_absorbance
            Absorbance reading of concentrated protein stock before dilution
        protein_extinction_coefficient : Unit compatible with 1/(moles/liter)/centimeters
            Extinction coefficient for protein, e.g. Unit(49850, '1/(moles/liter)/centimeter')
        protein_molecular_weight : Unit compatible with daltons
            Protein molecular weight
        protein_stock_volume : Unit compatible with microliters
            Volume of high-concentration protein stock solution used to make 1 uM protein stock
        buffer_volume : Unit compatible with milliliters
            Volume of buffer used to make ~1 uM protein stock used to fill wells
        rows_to_analyze : list
            Rows to analyze, e.g. ['A', 'B']
        assay_volume : Unit compatible with microliters
            Quantity of protein or buffer dispensed into plate
        wavelengths_to_analyze : list, optional, default=None
            If not None, only these wavelengths will be analyzed. e.g. ['280:nanometers', '480:nanometers']
        measurements_to_analyze : list, optional, default=None
            if not None, only these measurements will be analyzed. e.g. ['fluorescence top', 'absorbance'] or ['fluorescence bottom']

        """
        # Read DMSO stock solutions from inventory CSV file
        from assaytools.experiments import DMSOStockSolutions, DMSO, Buffer, ProteinSolution
        solutions = DMSOStockSolutions(
            dmso_stocks_csv_filename
        )  # all solutions from DMSO stocks inventory

        # Enumerate all ligand species from DMSO stocks.
        ligand_species = set([
            solution.species for solution in solutions.values()
            if (solution.species != None)
        ])

        # Add buffer and protein stock solutions
        solutions['buffer'] = Buffer(shortname='buffer',
                                     description='20 mM Tris buffer')
        solutions['protein'] = ProteinSolution(
            shortname='protein',
            description='1 uM %s' % receptor_species,
            species=receptor_species,
            buffer=solutions['buffer'],
            absorbance=protein_absorbance,
            extinction_coefficient=protein_extinction_coefficient,
            molecular_weight=protein_molecular_weight,
            protein_stock_volume=protein_stock_volume,
            buffer_volume=buffer_volume)

        # Populate the Container data structure with well contents and measurements
        from assaytools.experiments import provision_assay_plate, dispense_evo, dispense_hpd300, read_infinite
        plate = provision_assay_plate(name='assay-plate',
                                      plate_type='4titude 4ti-0223')
        dispense_evo(plate,
                     solution=solutions['protein'],
                     volume=assay_volume,
                     rows=['A', 'C', 'E', 'G'])
        dispense_evo(plate,
                     solution=solutions['buffer'],
                     volume=assay_volume,
                     rows=['B', 'D', 'F', 'H'])
        dispense_hpd300(plate,
                        solutions=[solutions[id] for id in hpd300_fluids],
                        xml_filename=d300_xml_filename,
                        plate_index=hpd300_plate_index)
        read_infinite(plate,
                      xml_filename=infinite_xml_filename,
                      wavelengths_to_analyze=wavelengths_to_analyze,
                      measurements_to_analyze=measurements_to_analyze)
        self.plate = plate

        # Select specified rows for analysis.
        from autoprotocol import WellGroup
        well_group = WellGroup([
            well for well in plate.all_wells()
            if (well.humanize()[0] in rows_to_analyze)
        ])

        # Create a model
        from assaytools.analysis import CompetitiveBindingAnalysis
        #from assaytools.analysis3 import CompetitiveBindingAnalysis
        self.experiment = CompetitiveBindingAnalysis(
            solutions=solutions,
            wells=well_group,
            receptor_name=receptor_species,
            DeltaG_prior='chembl')
Example #10
0
def kunkel_mutagenesis(protocol, params):
    def find_part(part_name, check_primer=False):
        if check_primer and (params.t7pro or params.t7term):
            return 'primer'
        else:
            aq = find_aliquot_by_name(part_name)
            if not aq:
                raise ValueError("Couldn't find aliquot with name '%s'" %
                                 part_name)
            container = None
            for r in protocol.refs.itervalues():
                if r.opts.get('id') == aq['container']['id']:
                    container = r.container
                    break
            if container is None:
                container = protocol.ref(
                    aq['container']['label'] or aq['container']['id'],
                    aq['container']['id'],
                    aq['container']['container_type']['shortname'],
                    discard=False,
                    storage="cold_20")
            return container.well(aq['well_idx']).set_volume("%s:microliter" %
                                                             aq['volume_ul'])

    def make_10_atp(vol):
        # account for tube dead_vol
        vol = vol + 15
        atp = protocol.ref("atp_10mM", cont_type='micro-1.5',
                           discard=True).well(0)
        protocol.provision('rs16pccshb6cb4', atp, "%s:microliter" % (vol / 10))
        protocol.provision('rs17gmh5wafm5p', atp,
                           "%s:microliter" % (vol - (vol / 10)))
        return atp

    def provision_reagents(reagents, dest):
        for key, reagent in reagents.iteritems():
            protocol.provision(
                reagent[0], dest, "%s:microliter" %
                ((len(params.mutants) + 1.0) * reagent[1] * add_mm))

    def isLast(itr):
        old = itr.next()
        for new in itr:
            yield False, old
            old = new
        yield True, old

    params = make_dottable_dict(params)
    params.ssDNA = find_part(params.ssDNA)
    params.mutants = []
    # read in oligos and mutants
    with open('kunkel_mutants.csv', 'rU') as rxtmap:
        reader = csv.reader(rxtmap)
        current_mutant_label = ''
        current_sequencing_primer = ''

        for idx, (is_last, row) in enumerate(isLast(reader)):
            if idx == 0 and row[0] == 'mutant_label':
                continue
            if row[0] != current_mutant_label:
                if current_mutant_label != '':
                    params.mutants.append({
                        'sequencing_primer':
                        find_part(current_sequencing_primer, True),
                        'mutant_label':
                        current_mutant_label,
                        'oligos':
                        my_oligos
                    })
                current_mutant_label = row[0]
                current_sequencing_primer = row[1]
                my_oligos = []

            my_oligos.append({
                "oligo_label": row[2],
                "sequence": row[3],
                "scale": row[4],
                "purification": row[5]
            })
            if is_last:
                params.mutants.append({
                    'sequencing_primer':
                    find_part(current_sequencing_primer, True),
                    'mutant_label':
                    current_mutant_label,
                    'oligos':
                    my_oligos
                })

    # mastermix vol to make - needs to be adjusted based on testing
    add_mm = 1.3
    # Get unique set of oligos based on sequence data
    # Oligosynthesize
    oligos_to_synthesize = []
    for i, mutant in enumerate(params.mutants):
        mutant["mutant_label"] = mutant["mutant_label"] or "mutant_%s" % (i +
                                                                          1)
        oligos_to_synthesize.append(mutant["oligos"])
    flattened = [val for sublist in oligos_to_synthesize for val in sublist]
    oligos_to_synthesize = list({v['sequence']: v for v in flattened}.values())

    # re-factor to remove add_properites
    oligo_containers = []
    oligos = []
    for i, oligo in enumerate(oligos_to_synthesize):
        label = oligo["oligo_label"] or "seq_%s" % i
        oligo_containers.append(
            protocol.ref(label, None, "micro-2.0", storage="cold_4").well(0))
        oligo_containers[i].add_properties({"sequence": oligo["sequence"]})
        oligos.append({
            "sequence": oligo["sequence"],
            "destination": oligo_containers[i],
            "scale": oligo["scale"],
            "purification": oligo["purification"]
        })

    protocol.oligosynthesize(oligos)

    # Kinase
    kinase_oligo_plate = protocol.ref("kinase_oligo_plate",
                                      None,
                                      "96-pcr",
                                      storage="cold_20")
    wells_to_kinase = kinase_oligo_plate.wells_from("A1", len(oligos))

    # provision atp for entire protocol
    atp_needed = ((len(oligos) * add_mm) +
                  (len(params.mutants) + 1) * 0.4 * add_mm)
    atp = make_10_atp(atp_needed)

    kinase_mix = []
    for i in range(int(math.ceil(len(oligos) / 60.0))):
        kinase_mix.append(
            protocol.ref("kinase_mix-%s" % (i + 1),
                         None,
                         "micro-1.5",
                         discard=True).well(0))
    reagents = {
        'pnkbuffer': ['rs16pc9rd5sg5d', 3],
        'water': ['rs17gmh5wafm5p', 18],
        'pnk': ['rs16pc9rd5hsf6', 1]
    }
    provision_reagents(reagents, kinase_mix)
    protocol.transfer(atp,
                      kinase_mix,
                      "%s:microliter" %
                      ((len(params.mutants) + 1) * 1 * add_mm),
                      new_group=True)

    protocol.transfer(kinase_mix, wells_to_kinase, "23:microliter",
                      **transfer_kwargs(15, True, True))

    for i, oligo in enumerate(oligo_containers):
        protocol.transfer(
            oligo,
            wells_to_kinase[i],
            "7:microliter",
            mix_after=False,
            new_group=det_new_group(i),
            aspirate_source=aspirate_source(depth=depth(
                "ll_following", lld="pressure", distance="0.0:meter")),
            **transfer_kwargs(10))

    protocol.seal(kinase_oligo_plate)

    protocol.thermocycle(
        kinase_oligo_plate,
        [{
            "cycles": 1,
            "steps": [
                {
                    "temperature": "37:celsius",
                    "duration": "60:minute"
                },
            ]
        }],
        volume="30:microliter")

    # make ssDNA_mastermix
    mix_plate = protocol.ref("mix_plate", None, "96-pcr", discard=True)
    ssDNA_mix = mix_plate.well(0)
    protocol.transfer(
        params.ssDNA, ssDNA_mix,
        "%s:microliter" % ((len(params.mutants) + 1) * 2.0 * add_mm),
        **transfer_kwargs((len(params.mutants) + 1) * 1))
    protocol.provision(
        'rs17sh5rzz79ct', ssDNA_mix,
        "%s:microliter" % ((len(params.mutants) + 1) * 0.2 * add_mm))

    # Dilute
    protocol.unseal(kinase_oligo_plate)

    diluted_oligo_plate = protocol.ref("dilute_oligo_plate",
                                       None,
                                       "96-flat",
                                       discard=True)
    diluted_oligo_wells = diluted_oligo_plate.wells_from(
        0, len(params.mutants))

    water = [
        provision_to_tube(protocol, "water%s" % (i + 1), "micro-2.0",
                          "rs17gmh5wafm5p", 1900)
        for i in range(int(math.ceil(len(params.mutants) / float(9.5))))
    ]

    protocol.transfer(water,
                      diluted_oligo_wells,
                      "200:microliter",
                      disposal_vol="0:microliter",
                      **transfer_kwargs(40, True, True))

    mutants = [m for m in params.mutants if m]
    mutants = sorted(mutants, key=lambda mutant: mutant["mutant_label"])

    for i, m in enumerate(mutants):
        for j, kin_oligo in enumerate(m["oligos"]):
            if i == 0 and j == 0:
                new_group = True
            else:
                new_group = False
            index = next(
                (i for i, olig in enumerate(oligo_containers)
                 if olig.properties["sequence"] == kin_oligo["sequence"]), -1)
            protocol.transfer(kinase_oligo_plate.well(index),
                              diluted_oligo_plate.well(i),
                              "2:microliter",
                              mix_after=True,
                              mix_vol="2:microliter",
                              new_group=new_group,
                              **transfer_kwargs(10))

    protocol.cover(diluted_oligo_plate)
    protocol.spin(diluted_oligo_plate, "700:meter/second^2", "2:minute")
    protocol.uncover(diluted_oligo_plate)

    # Anneal

    annealing_plate = protocol.ref("annealing_oligo_plate",
                                   None,
                                   "384-pcr",
                                   storage="cold_20")
    anneal_wells = annealing_plate.wells_from(0, len(params.mutants))

    protocol.transfer(ssDNA_mix,
                      anneal_wells.wells,
                      "2.2:microliter",
                      dispense_speed="50:microliter/second",
                      **transfer_kwargs(7, True, True))

    for i, oligo_reaction in enumerate(
            zip(diluted_oligo_wells.wells, anneal_wells.wells)):
        protocol.transfer(oligo_reaction[0],
                          oligo_reaction[1],
                          "2:microliter",
                          aspirate_source=aspirate_source(
                              depth("ll_bottom", distance=".001:meter")),
                          mix_after=True,
                          mix_vol="2:microliter",
                          flowrate="50:microliter/second",
                          repetitions=2,
                          new_group=det_new_group(i),
                          **transfer_kwargs(5))

    protocol.seal(annealing_plate)
    protocol.spin(annealing_plate, "700:meter/second^2", "2:minute")
    protocol.thermocycle(annealing_plate, [{
        "cycles":
        1,
        "steps":
        thermocycle_ramp("95:celsius", "25:celsius", "60:minute", "4:minute")
    }],
                         volume="5:microliter",
                         dataref=None,
                         dyes=None)

    # Step 4 - Polymerize

    protocol.unseal(annealing_plate)
    polymerize_MM = mix_plate.well(12)
    reagents = {
        "buffer": ['rs17sh5rzz79ct', 0.6],
        "t4ligase": ['rs16pc8krr6ag7', 0.4],
        "t7polymerase": ['rs16pca2urcz74', 0.4],
        "dntp": ['rs16pcb542c5rd', 0.4]
    }
    provision_reagents(reagents, polymerize_MM)
    protocol.transfer(atp,
                      polymerize_MM,
                      "%s:microliter" %
                      ((len(params.mutants) + 1) * 0.4 * add_mm),
                      new_group=True)

    for reaction in anneal_wells.wells:
        protocol.transfer(polymerize_MM,
                          reaction,
                          "2.2:microliter",
                          mix_after=False,
                          **transfer_kwargs(10))

    protocol.seal(annealing_plate)
    protocol.incubate(annealing_plate, "ambient", "1.5:hour")

    # Transformation using Zymo 10B Competent Cells
    transformation_cells = []
    for i in range(len(params["mutants"])):
        transformation_cells.append(
            provision_to_tube(protocol, "cell_%s" % (i), "micro-1.5",
                              "rs16pbjc4r7vvz", 50))

    num_colonies = params["num_colonies"]
    assert len(params["mutants"]) * num_colonies <= 96, (
        "This protocol is limited to 96 sequenced colonies, please "
        "submit additional runs if needed.")
    transformation_plate = protocol.ref("transformation_plate",
                                        None,
                                        "96-pcr",
                                        discard=True)
    protocol.incubate(transformation_plate, "cold_20", "10:minute")
    transformation_wells = transformation_plate.wells_from(0,
                                                           len(params.mutants),
                                                           columnwise=False)

    for i, tube in enumerate(transformation_cells):
        protocol.transfer(tube,
                          transformation_wells[i],
                          "50:microliter",
                          mix_after=False)

    protocol.unseal(annealing_plate)

    for i, rxt in enumerate(anneal_wells):
        protocol.transfer(anneal_wells[i],
                          transformation_wells[i],
                          "2.0:microliter",
                          dispense_speed="10:microliter/second",
                          mix_after=False,
                          new_group=det_new_group(i))

    protocol.cover(transformation_plate, lid="universal")
    protocol.incubate(transformation_plate,
                      "cold_4",
                      "20:minute",
                      shaking=False,
                      co2=0)
    protocol.uncover(transformation_plate)

    agar_plates = []
    assert len(mutants) == len(transformation_wells), (
        "Sanity check failed. There is an issue with the number of"
        "mutants and the number of transformations.")
    for well in range(0, len(transformation_wells), 6):
        agar_plate = ref_kit_container(
            protocol,
            "agar-%s_%d_%s" % (params["antibiotic"].split("_")[-1], well + 1,
                               printdatetime(time=False)),
            "6-flat",
            return_media('solid')[params["antibiotic"]],
            discard=False,
            store='cold_4')
        agar_plates.append(agar_plate)
        for i, well in enumerate(transformation_wells[well:well + 6]):
            protocol.spread(well, agar_plate.well(i), "50:microliter")
        protocol.incubate(agar_plate, "warm_37", "18:hour")

    growth_plate = protocol.ref("growth_plate_%s" % printdatetime(time=False),
                                None,
                                "96-flat",
                                discard=True)

    cols = int(math.ceil(len(params.mutants) * num_colonies / float(8)))
    columns = [{
        "column": i,
        "volume": "150:microliter"
    } for i in range(0, cols)]

    protocol.dispense(growth_plate,
                      return_media('liquid')[params["antibiotic"]], columns)

    growth_wells = growth_plate.wells_from(0,
                                           num_colonies * len(params.mutants),
                                           columnwise=True)

    i = 0
    for k, plate in enumerate(agar_plates):
        for j in range(6):
            if plate.well(j).volume:
                protocol.autopick(plate.well(j),
                                  growth_wells[i:i + num_colonies],
                                  min_count=1,
                                  dataref=mutants[k * 6 + j]['mutant_label'])
                i = i + num_colonies

    protocol.cover(growth_plate, lid="low_evaporation")
    protocol.incubate(growth_plate, "warm_37", "24:hour", shaking=True, co2=0)
    protocol.uncover(growth_plate)

    if params.t7pro:
        seq_plate = protocol.ref("sequencing_plate_t7pro_%s" %
                                 printdatetime(time=False),
                                 cont_type="96-pcr",
                                 storage="cold_4")
        seq_well_group = seq_plate.wells_from(0,
                                              num_colonies *
                                              len(params.mutants),
                                              columnwise=True)
        t7pro_primer = protocol.ref("t7promoter",
                                    cont_type="micro-1.5",
                                    storage="cold_4")
        protocol.provision("rs17tcpekfy7v9", t7pro_primer.well(0),
                           "1:microliter")
        protocol.provision(
            "rs17gmh5wafm5p", t7pro_primer.well(0),
            "%s:microliter" % (num_colonies * (len(params.mutants) + 2)))
        protocol.transfer(growth_wells, seq_well_group, "30:microliter")
        protocol.seal(seq_plate)
        protocol.sangerseq(seq_plate,
                           seq_well_group.indices(),
                           "Seq_primer_T7promoter",
                           type="rca",
                           primer=t7pro_primer)

    if params.t7term:
        seq_plate = protocol.ref("sequencing_plate_t7term_%s" %
                                 printdatetime(time=False),
                                 cont_type="96-pcr",
                                 storage="cold_4")
        seq_well_group = seq_plate.wells_from(0,
                                              num_colonies *
                                              len(params.mutants),
                                              columnwise=True)
        t7term_primer = protocol.ref("t7terminator",
                                     cont_type="micro-1.5",
                                     storage="cold_4")
        protocol.provision("rs17tcpwfbgzqd", t7term_primer.well(0),
                           "1:microliter")
        protocol.provision(
            "rs17gmh5wafm5p", t7term_primer.well(0),
            "%s:microliter" % (num_colonies * (len(params.mutants) + 2)))
        protocol.transfer(growth_wells, seq_well_group, "30:microliter")
        protocol.seal(seq_plate)
        protocol.sangerseq(seq_plate,
                           seq_well_group.indices(),
                           "Seq_primer_t7terminator",
                           type="rca",
                           primer=t7term_primer)

    if not (params.t7pro or params.t7term):
        seq_plate = protocol.ref("sequencing_plate_%s" %
                                 printdatetime(time=False),
                                 cont_type="96-pcr",
                                 storage="cold_4")
        seq_well_group = seq_plate.wells_from(0,
                                              num_colonies *
                                              len(params.mutants),
                                              columnwise=True)
        j = 0
        seq_primers = {}
        mutant_well_table = {}
        for seq_set in mutants:
            seq_wells = WellGroup(seq_well_group[j:j + num_colonies])
            protocol.transfer(growth_wells[j:j + num_colonies], seq_wells,
                              "30:microliter")
            if seq_set["sequencing_primer"] not in seq_primers:
                seq_primers[seq_set["sequencing_primer"]] = seq_wells.indices()
                mutant_well_table[seq_set["sequencing_primer"]] = {
                    seq_set["mutant_label"]: seq_wells.indices()
                }
            else:
                seq_primers[seq_set["sequencing_primer"]].extend(
                    seq_wells.indices())
                if seq_set["mutant_label"] not in mutant_well_table[
                        seq_set["sequencing_primer"]]:
                    mutant_well_table[seq_set["sequencing_primer"]].update(
                        {seq_set["mutant_label"]: seq_wells.indices()})
                else:
                    mutant_well_table[seq_set["sequencing_primer"]][
                        seq_set["mutant_label"]].extend(seq_wells.indices())
            j += num_colonies

        protocol.seal(seq_plate)

        for primer, wells in seq_primers.iteritems():
            dataref = "Seq_primer_%s" % (primer.container.name)
            assert primer.volume - Unit("1.1", "microliter").__mul__(
                len(wells)
            ) > Unit(
                "0", "microliter"
            ), "You must have at least 1.1uL of sequencing primer per reaction well."
            protocol.sangerseq(seq_plate,
                               wells,
                               dataref,
                               type="rca",
                               primer=primer.container)
Example #11
0
#0:lb 1:amp 2:amp/ara
#3:lb 4:amp 5:amp/ara

#0:no_pglo 1:pglo 2:pglo
#3:no_pglo 4:no_pglo 5:pglo

p.transfer(transform_sln.well(0), transformation_plate.wells_from(0, 2),
           "150:ul")
p.incubate(transformation_plate, "cold_4", "5:minute")
p.autopick(ecoli_source.all_wells(), transformation_plate.wells_from(0, 2))
p.transfer(pglo.well(0), transformation_plate.well(0), "10:ul")

for w in transformation_plate.wells_from(0, 2):
    p.mix(w, volume="75:microliter")

sources = WellGroup([transformation_plate.well(0)] * 2 +
                    [transformation_plate.well(1)] * 2)
dests = WellGroup(
    transformation_plate.wells_from(12, 2, columnwise=True) +
    transformation_plate.wells_from(13, 2, columnwise=True))
p.transfer(sources, dests, "50:ul")
p.thermocycle(transformation_plate, [{
    "cycles":
    1,
    "steps": [{
        "temperature": "4:celsius",
        "duration": "10:minute"
    }, {
        "temperature": "42:celsius",
        "duration": "50:second"
    }, {
        "temperature": "4:celsius",
Example #12
0
def kunkel_mutagenesis(protocol, params):
    def find_part(part_name, check_primer=False):
        if check_primer and (params.t7pro or params.t7term):
            return 'primer'
        else:
            aq = find_aliquot_by_name(part_name)
            if not aq:
                raise ValueError(
                    "Couldn't find aliquot with name '%s'" % part_name)
            container = None
            for r in protocol.refs.itervalues():
                if r.opts.get('id') == aq['container']['id']:
                    container = r.container
                    break
            if container is None:
                container = protocol.ref(
                    aq['container']['label'] or aq['container']['id'],
                    aq['container']['id'],
                    aq['container']['container_type']['shortname'],
                    discard=False,
                    storage="cold_20"
                    )
            return container.well(aq['well_idx']).set_volume("%s:microliter" % aq['volume_ul'])

    def make_10_atp(vol):
        # account for tube dead_vol
        vol = vol + 15
        atp = protocol.ref("atp_10mM", cont_type='micro-1.5', discard=True).well(0)
        protocol.provision('rs16pccshb6cb4', atp, "%s:microliter" % (vol/10))
        protocol.provision('rs17gmh5wafm5p', atp, "%s:microliter" % (vol - (vol/10)))
        return atp

    def provision_reagents(reagents, dest):
        for key, reagent in reagents.iteritems():
            protocol.provision(reagent[0],
                               dest,
                               "%s:microliter" % ((len(params.mutants) + 1.0) * reagent[1] * add_mm))

    def isLast(itr):
        old = itr.next()
        for new in itr:
            yield False, old
            old = new
        yield True, old

    params = make_dottable_dict(params)
    params.ssDNA = find_part(params.ssDNA)
    params.mutants = []
    # read in oligos and mutants
    with open('kunkel_mutants.csv', 'rU') as rxtmap:
        reader = csv.reader(rxtmap)
        current_mutant_label = ''
        current_sequencing_primer = ''

        for idx, (is_last, row) in enumerate(isLast(reader)):
            if idx == 0 and row[0] == 'mutant_label':
                continue
            if row[0] != current_mutant_label:
                if current_mutant_label != '':
                    params.mutants.append({
                        'sequencing_primer': find_part(current_sequencing_primer, True),
                        'mutant_label': current_mutant_label,
                        'oligos': my_oligos
                    })
                current_mutant_label = row[0]
                current_sequencing_primer = row[1]
                my_oligos = []

            my_oligos.append({"oligo_label": row[2],
                              "sequence": row[3],
                              "scale": row[4],
                              "purification": row[5]})
            if is_last:
                params.mutants.append({
                        'sequencing_primer': find_part(current_sequencing_primer, True),
                        'mutant_label': current_mutant_label,
                        'oligos': my_oligos
                    })

    # mastermix vol to make - needs to be adjusted based on testing
    add_mm = 1.3
    # Get unique set of oligos based on sequence data
    # Oligosynthesize
    oligos_to_synthesize = []
    for i, mutant in enumerate(params.mutants):
        mutant["mutant_label"] = mutant["mutant_label"] or "mutant_%s" % (i + 1)
        oligos_to_synthesize.append(mutant["oligos"])
    flattened = [val for sublist in oligos_to_synthesize for val in sublist]
    oligos_to_synthesize = list({v['sequence']: v for v in flattened}.values())

    # re-factor to remove add_properites
    oligo_containers = []
    oligos = []
    for i, oligo in enumerate(oligos_to_synthesize):
        label = oligo["oligo_label"] or "seq_%s" % i
        oligo_containers.append(protocol.ref(label, None, "micro-2.0",
                                storage="cold_4").well(0))
        oligo_containers[i].add_properties({"sequence": oligo["sequence"]})
        oligos.append({"sequence": oligo["sequence"],
                       "destination": oligo_containers[i],
                       "scale": oligo["scale"],
                       "purification": oligo["purification"]})

    protocol.oligosynthesize(oligos)

    # Kinase
    kinase_oligo_plate = protocol.ref("kinase_oligo_plate", None, "96-pcr",
                                      storage="cold_20")
    wells_to_kinase = kinase_oligo_plate.wells_from("A1", len(oligos))

    # provision atp for entire protocol
    atp_needed = ((len(oligos) * add_mm) + (len(params.mutants) + 1) * 0.4 * add_mm)
    atp = make_10_atp(atp_needed)

    kinase_mix = []
    for i in range(int(math.ceil(len(oligos)/60.0))):
        kinase_mix.append(protocol.ref("kinase_mix-%s" % (i + 1), None, "micro-1.5", discard=True).well(0))
    reagents = {'pnkbuffer': ['rs16pc9rd5sg5d', 3],
                'water': ['rs17gmh5wafm5p', 18],
                'pnk': ['rs16pc9rd5hsf6', 1]}
    provision_reagents(reagents, kinase_mix)
    protocol.transfer(atp, kinase_mix, "%s:microliter" % ((len(params.mutants) + 1) * 1 * add_mm), new_group=True)

    protocol.transfer(kinase_mix,
                      wells_to_kinase,
                      "23:microliter",
                      **transfer_kwargs(15, True, True))

    for i, oligo in enumerate(oligo_containers):
        protocol.transfer(oligo,
                          wells_to_kinase[i],
                          "7:microliter",
                          mix_after=False,
                          new_group=det_new_group(i),
                          aspirate_source=aspirate_source(depth=depth("ll_following",
                                                          lld="pressure",
                                                          distance="0.0:meter")),
                          **transfer_kwargs(10))

    protocol.seal(kinase_oligo_plate)

    protocol.thermocycle(kinase_oligo_plate,
                         [{"cycles": 1, "steps": [
                             {"temperature": "37:celsius",
                              "duration": "60:minute"},
                             ]}
                          ], volume="30:microliter")

    # make ssDNA_mastermix
    mix_plate = protocol.ref("mix_plate", None, "96-pcr", discard=True)
    ssDNA_mix = mix_plate.well(0)
    protocol.transfer(params.ssDNA,
                      ssDNA_mix,
                      "%s:microliter" % ((len(params.mutants) + 1) * 2.0 * add_mm),
                      **transfer_kwargs((len(params.mutants) + 1) * 1))
    protocol.provision('rs17sh5rzz79ct', ssDNA_mix, "%s:microliter" % ((len(params.mutants) + 1) * 0.2 * add_mm))

    # Dilute
    protocol.unseal(kinase_oligo_plate)

    diluted_oligo_plate = protocol.ref("dilute_oligo_plate", None, "96-flat", discard=True)
    diluted_oligo_wells = diluted_oligo_plate.wells_from(0, len(params.mutants))

    water = [provision_to_tube(protocol, "water%s" % (i + 1), "micro-2.0", "rs17gmh5wafm5p", 1900)
             for i in range(int(math.ceil(len(params.mutants)/float(9.5))))
             ]

    protocol.transfer(water,
                      diluted_oligo_wells,
                      "200:microliter",
                      disposal_vol="0:microliter",
                      **transfer_kwargs(40, True, True))

    mutants = [m for m in params.mutants if m]
    mutants = sorted(mutants, key=lambda mutant: mutant["mutant_label"])

    for i, m in enumerate(mutants):
        for j, kin_oligo in enumerate(m["oligos"]):
            if i == 0 and j == 0:
                new_group = True
            else:
                new_group = False
            index = next((i for i, olig in enumerate(oligo_containers) if olig.properties["sequence"] == kin_oligo["sequence"]), -1)
            protocol.transfer(kinase_oligo_plate.well(index),
                              diluted_oligo_plate.well(i),
                              "2:microliter",
                              mix_after=True,
                              mix_vol="2:microliter",
                              new_group=new_group,
                              **transfer_kwargs(10))

    protocol.cover(diluted_oligo_plate)
    protocol.spin(diluted_oligo_plate, "700:meter/second^2", "2:minute")
    protocol.uncover(diluted_oligo_plate)

    # Anneal

    annealing_plate = protocol.ref("annealing_oligo_plate", None, "384-pcr", storage="cold_20")
    anneal_wells = annealing_plate.wells_from(0, len(params.mutants))

    protocol.transfer(ssDNA_mix,
                      anneal_wells.wells,
                      "2.2:microliter",
                      dispense_speed="50:microliter/second",
                      **transfer_kwargs(7, True, True))

    for i, oligo_reaction in enumerate(zip(diluted_oligo_wells.wells, anneal_wells.wells)):
        protocol.transfer(oligo_reaction[0],
                          oligo_reaction[1],
                          "2:microliter",
                          aspirate_source=aspirate_source(depth("ll_bottom", distance=".001:meter")),
                          mix_after=True,
                          mix_vol="2:microliter",
                          flowrate="50:microliter/second",
                          repetitions=2,
                          new_group=det_new_group(i),
                          **transfer_kwargs(5))

    protocol.seal(annealing_plate)
    protocol.spin(annealing_plate, "700:meter/second^2", "2:minute")
    protocol.thermocycle(annealing_plate, [{
        "cycles": 1,
        "steps": thermocycle_ramp("95:celsius", "25:celsius", "60:minute", "4:minute")
        }],
        volume="5:microliter",
        dataref=None,
        dyes=None)

    # Step 4 - Polymerize

    protocol.unseal(annealing_plate)
    polymerize_MM = mix_plate.well(12)
    reagents = {"buffer": ['rs17sh5rzz79ct', 0.6],
                "t4ligase": ['rs16pc8krr6ag7', 0.4],
                "t7polymerase": ['rs16pca2urcz74', 0.4],
                "dntp": ['rs16pcb542c5rd', 0.4]
                }
    provision_reagents(reagents, polymerize_MM)
    protocol.transfer(atp, polymerize_MM, "%s:microliter" % ((len(params.mutants) + 1) * 0.4 * add_mm), new_group=True)

    for reaction in anneal_wells.wells:
        protocol.transfer(polymerize_MM,
                          reaction,
                          "2.2:microliter",
                          mix_after=False,
                          **transfer_kwargs(10))

    protocol.seal(annealing_plate)
    protocol.incubate(annealing_plate, "ambient", "1.5:hour")

    # Transformation using Zymo 10B Competent Cells
    transformation_cells = []
    for i in range(len(params["mutants"])):
        transformation_cells.append(provision_to_tube(protocol, "cell_%s" % (i), "micro-1.5",
                                                      "rs16pbjc4r7vvz", 50))

    num_colonies = params["num_colonies"]
    assert len(params["mutants"]) * num_colonies <= 96, ("This protocol is limited to 96 sequenced colonies, please "
                                                         "submit additional runs if needed.")
    transformation_plate = protocol.ref("transformation_plate", None, "96-pcr", discard=True)
    protocol.incubate(transformation_plate, "cold_20", "10:minute")
    transformation_wells = transformation_plate.wells_from(0, len(params.mutants), columnwise=False)

    for i, tube in enumerate(transformation_cells):
        protocol.transfer(tube, transformation_wells[i], "50:microliter", mix_after=False)

    protocol.unseal(annealing_plate)

    for i, rxt in enumerate(anneal_wells):
        protocol.transfer(anneal_wells[i], transformation_wells[i], "2.0:microliter",
                          dispense_speed="10:microliter/second",
                          mix_after=False,
                          new_group=det_new_group(i))

    protocol.cover(transformation_plate, lid="universal")
    protocol.incubate(transformation_plate, "cold_4", "20:minute", shaking=False, co2=0)
    protocol.uncover(transformation_plate)

    agar_plates = []
    assert len(mutants) == len(transformation_wells), ("Sanity check failed. There is an issue with the number of"
                                                       "mutants and the number of transformations.")
    for well in range(0, len(transformation_wells), 6):
        agar_plate = ref_kit_container(protocol,
                                       "agar-%s_%d_%s" % (params["antibiotic"].split("_")[-1],
                                                          well + 1,
                                                          printdatetime(time=False)),
                                       "6-flat",
                                       return_media('solid')[params["antibiotic"]],
                                       discard=False, store='cold_4')
        agar_plates.append(agar_plate)
        for i, well in enumerate(transformation_wells[well:well + 6]):
            protocol.spread(well, agar_plate.well(i), "50:microliter")
        protocol.incubate(agar_plate, "warm_37", "18:hour")

    growth_plate = protocol.ref("growth_plate_%s" % printdatetime(time=False), None, "96-flat", discard=True)

    cols = int(math.ceil(len(params.mutants) * num_colonies / float(8)))
    columns = [{"column": i, "volume": "150:microliter"} for i in range(0, cols)]

    protocol.dispense(growth_plate, return_media('liquid')[params["antibiotic"]], columns)

    growth_wells = growth_plate.wells_from(0, num_colonies*len(params.mutants), columnwise=True)

    i = 0
    for k, plate in enumerate(agar_plates):
        for j in range(6):
            if plate.well(j).volume:
                protocol.autopick(plate.well(j),
                                  growth_wells[i:i+num_colonies],
                                  min_count=1,
                                  dataref=mutants[k * 6 + j]['mutant_label'])
                i = i + num_colonies

    protocol.cover(growth_plate, lid="low_evaporation")
    protocol.incubate(growth_plate, "warm_37", "24:hour", shaking=True, co2=0)
    protocol.uncover(growth_plate)

    if params.t7pro:
        seq_plate = protocol.ref("sequencing_plate_t7pro_%s" % printdatetime(time=False),
                                 cont_type="96-pcr",
                                 storage="cold_4")
        seq_well_group = seq_plate.wells_from(0, num_colonies*len(params.mutants), columnwise=True)
        t7pro_primer = protocol.ref("t7promoter",
                                    cont_type="micro-1.5",
                                    storage="cold_4")
        protocol.provision("rs17tcpekfy7v9", t7pro_primer.well(0), "1:microliter")
        protocol.provision("rs17gmh5wafm5p", t7pro_primer.well(0), "%s:microliter" % (num_colonies*(len(params.mutants)+2)))
        protocol.transfer(growth_wells, seq_well_group, "30:microliter")
        protocol.seal(seq_plate)
        protocol.sangerseq(seq_plate, seq_well_group.indices(), "Seq_primer_T7promoter", type="rca", primer=t7pro_primer)

    if params.t7term:
        seq_plate = protocol.ref("sequencing_plate_t7term_%s" % printdatetime(time=False),
                                 cont_type="96-pcr",
                                 storage="cold_4")
        seq_well_group = seq_plate.wells_from(0, num_colonies*len(params.mutants), columnwise=True)
        t7term_primer = protocol.ref("t7terminator",
                                    cont_type="micro-1.5",
                                    storage="cold_4")
        protocol.provision("rs17tcpwfbgzqd", t7term_primer.well(0), "1:microliter")
        protocol.provision("rs17gmh5wafm5p", t7term_primer.well(0), "%s:microliter" % (num_colonies*(len(params.mutants)+2)))
        protocol.transfer(growth_wells, seq_well_group, "30:microliter")
        protocol.seal(seq_plate)
        protocol.sangerseq(seq_plate, seq_well_group.indices(), "Seq_primer_t7terminator", type="rca", primer=t7term_primer)

    if not (params.t7pro or params.t7term):
        seq_plate = protocol.ref("sequencing_plate_%s" % printdatetime(time=False),
                                 cont_type="96-pcr",
                                 storage="cold_4")
        seq_well_group = seq_plate.wells_from(0, num_colonies*len(params.mutants), columnwise=True)
        j = 0
        seq_primers = {}
        mutant_well_table = {}
        for seq_set in mutants:
            seq_wells = WellGroup(seq_well_group[j:j+num_colonies])
            protocol.transfer(growth_wells[j:j+num_colonies], seq_wells, "30:microliter")
            if seq_set["sequencing_primer"] not in seq_primers:
                seq_primers[seq_set["sequencing_primer"]] = seq_wells.indices()
                mutant_well_table[seq_set["sequencing_primer"]] = {seq_set["mutant_label"]: seq_wells.indices()}
            else:
                seq_primers[seq_set["sequencing_primer"]].extend(seq_wells.indices())
                if seq_set["mutant_label"] not in mutant_well_table[seq_set["sequencing_primer"]]:
                    mutant_well_table[seq_set["sequencing_primer"]].update({seq_set["mutant_label"]: seq_wells.indices()})
                else:
                    mutant_well_table[seq_set["sequencing_primer"]][seq_set["mutant_label"]].extend(seq_wells.indices())
            j += num_colonies

        protocol.seal(seq_plate)

        for primer, wells in seq_primers.iteritems():
            dataref = "Seq_primer_%s" % (primer.container.name)
            assert primer.volume - Unit("1.1", "microliter").__mul__(len(wells)) > Unit("0", "microliter"), "You must have at least 1.1uL of sequencing primer per reaction well."
            protocol.sangerseq(seq_plate, wells, dataref, type="rca", primer=primer.container)