def runTest(self):
        p1 = Protocol()
        p2 = Protocol()

        p1.spin("dummy_ref", "2000:rpm", "560:second")
        self.assertEqual(len(p2.instructions), 0,
                         "incorrect number of instructions in empty protocol")
 def test_duplicates_not_allowed(self):
     p = Protocol()
     p.ref("test", None, "96-flat", discard=True)
     with self.assertRaises(AssertionError):
         p.ref("test", None, "96-flat", storage="cold_20")
     self.assertTrue(p.refs["test"].opts["discard"])
     self.assertFalse("where" in p.refs["test"].opts)
def generate_autoprotocol(instructions_dict):
    p = Protocol()
    part_ref_dict = {}  # ref name: ref_object
    # add destination plate to ref dict
    moclo_dest_plate_name = 'MoCloDestinationPlate'
    moclo_dest_plate_ref = p.ref(moclo_dest_plate_name,
                                 cont_type="96-pcr",
                                 discard=True)
    part_ref_dict[moclo_dest_plate_name] = moclo_dest_plate_ref

    # create refs
    for num, part_name in instructions_dict['parts'].items():
        part_ref = p.ref(part_name, cont_type="96-pcr", discard=True)
        part_ref_dict[part_name] = part_ref

    # create instructions
    for x in range(0, len(instructions_dict['source_wells'])):
        from_well = instructions_dict['source_wells'][x]
        part_name = instructions_dict['parts'][
            from_well]  # get part name in that well
        source_plate = part_ref_dict[part_name]  # get ref object
        volume = instructions_dict['volumes'][x]  # get volume
        volume_str = str(volume) + ':microliter'
        to_well = instructions_dict['dest_wells'][
            x]  # get destination well num

        p.transfer(source_plate.wells_from(from_well, 1),
                   moclo_dest_plate_ref.wells_from(to_well, 1), volume_str)

    return p.as_dict()
 def test_single_transfer(self):
     p = Protocol()
     c = p.ref("test", None, "96-flat", discard=True)
     p.transfer(c.well(0), c.well(1), "20:microliter")
     self.assertEqual(Unit(20, "microliter"), c.well(1).volume)
     self.assertEqual(None, c.well(0).volume)
     self.assertTrue("transfer" in p.instructions[-1].groups[-1])
    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 runTest(self):
        p = Protocol()
        self.assertEqual(
            len(p.instructions), 0,
            "should not be any instructions before appending to empty protocol"
        )

        p.append(Spin("dummy_ref", "100:meter/second^2", "60:second"))
        self.assertEqual(
            len(p.instructions), 1,
            "incorrect number of instructions after single instruction append")
        self.assertEqual(p.instructions[0].op, "spin",
                         "incorrect instruction appended")

        p.append([
            Incubate("dummy_ref", "ambient", "30:second"),
            Spin("dummy_ref", "2000:rpm", "120:second")
        ])
        self.assertEqual(
            len(p.instructions), 3,
            "incorrect number of instructions after appending instruction list"
        )
        self.assertEqual(p.instructions[1].op, "incubate",
                         "incorrect instruction order after list append")
        self.assertEqual(p.instructions[2].op, "spin",
                         "incorrect instruction at end after list append.")
 def test_echo_max_vol(self):
     from autoprotocol.protocol import Protocol
     p = Protocol()
     echo_w = p.ref("echo", None, "384-echo", discard=True).well(0)
     echo_w.set_volume("135:microliter")
     assert echo_w.volume == Unit(135, "microliter")
     with pytest.raises(ValueError):
         echo_w.set_volume("136:microliter")
 def test_one_tip(self):
     p = Protocol()
     c = p.ref("test", None, "96-flat", discard=True)
     p.transfer(c.wells_from(0, 2),
                c.wells_from(2, 2),
                "20:microliter",
                one_tip=True)
     self.assertEqual(c.well(2).volume, c.well(3).volume)
     self.assertEqual(1, len(p.instructions[0].groups))
    def test_all_container_types(self):
        from autoprotocol.container_type import _CONTAINER_TYPES
        from autoprotocol.protocol import Protocol
        p = Protocol()

        for k, v in _CONTAINER_TYPES.items():
            p.ref(k, None, v.shortname, discard=True)

        assert (len(p.refs) == len(_CONTAINER_TYPES))
Пример #10
0
 def test_distribute_one_well(self):
     p = Protocol()
     c = p.ref("test", None, "96-flat", discard=True)
     p.distribute(
         c.well(0).set_volume("20:microliter"), c.well(1), "5:microliter")
     self.assertEqual(1, len(p.instructions))
     self.assertEqual("distribute",
                      p.as_dict()["instructions"][0]["groups"][0].keys()[0])
     self.assertTrue(5, c.well(1).volume.value)
     self.assertTrue(15, c.well(0).volume.value)
Пример #11
0
    def test_sequence_cover_instructions2(self):
        p = Protocol()
        cont1 = p.ref("c1", None, "96-pcr", storage="cold_4")
        p.incubate(cont1, "ambient", duration="1:minute")
        assert (p.instructions[0].op == "seal")

        cont2 = p.ref("c2", None, "96-pcr", storage="cold_4")
        p.incubate(cont2, "ambient", duration="1:minute", uncovered=True)
        assert (p.instructions[-2].op == "incubate")
        with pytest.raises(RuntimeError):
            p.incubate(cont1, "cold_4", duration="1:minute", uncovered=True)
 def test_multiple_sources(self):
     p = Protocol()
     c = p.ref("test", None, "96-flat", discard=True)
     with self.assertRaises(AssertionError):
         p.consolidate(c.wells_from(0, 3), c.wells_from(2, 3),
                       "10:microliter")
         p.consolidate(c.wells_from(0, 3), c.well(4), ["10:microliter"])
     p.consolidate(c.wells_from(0, 3), c.well(4), "10:microliter")
     self.assertEqual(Unit(30, "microliter"), c.well(4).volume)
     self.assertEqual(
         3, len(p.instructions[0].groups[0]["consolidate"]["from"]))
Пример #13
0
    def __init__(self,
                 protocol=Protocol(),
                 items=Items(),
                 db=SolutionDB(),
                 logger=init_logging(),
                 rprotocol=RProtocol()):

        self.protocol = protocol
        self.items = items
        self.db = db
        self.logger = logger
        self.rprotocol = rprotocol
 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_distribute_multiple_wells(self):
     p = Protocol()
     c = p.ref("test", None, "96-flat", discard=True)
     p.distribute(
         c.well(0).set_volume("20:microliter"), c.wells_from(1, 3),
         "5:microliter")
     self.assertEqual(1, len(p.instructions))
     self.assertEqual(
         "distribute",
         list(p.as_dict()["instructions"][0]["groups"][0].keys())[0])
     for w in c.wells_from(1, 3):
         self.assertTrue(5, w.volume.value)
     self.assertTrue(5, c.well(0).volume.value)
 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
Пример #18
0
    def test_stamp_384_well_to_single_well_reservoir_and_reverse(self):
        p = Protocol()
        source = p.ref("destination", cont_type="384-flat", discard=True)
        destination = p.ref("source", cont_type="res-sw384-lp", discard=True)
        p.transfer(
            source=source.well(0),
            destination=destination.well(0),
            volume="10:microliter",
            rows=16,
            columns=24,
        )
        assert p.instructions[-1].op == "liquid_handle"

        p = Protocol()
        source = p.ref("destination", cont_type="res-sw384-lp", discard=True)
        destination = p.ref("source", cont_type="384-flat", discard=True)
        p.transfer(
            source=source.well(0),
            destination=destination.well(0),
            volume="10:microliter",
            rows=16,
            columns=24,
        )
        assert p.instructions[-1].op == "liquid_handle"
Пример #19
0
    def test_stamp_384_reservoir_and_384_well_plate_to_96_well_plate(self):
        p = Protocol()
        source = p.ref("destination", cont_type="384-flat", discard=True)
        destination = p.ref("source", cont_type="96-flat", discard=True)
        with pytest.raises(ValueError):
            p.transfer(
                source=source.well(0),
                destination=destination.well(0),
                volume="10:microliter",
                rows=16,
                columns=24,
            )

        p = Protocol()
        source = p.ref("destination", cont_type="res-sw384-lp", discard=True)
        destination = p.ref("source", cont_type="96-flat", discard=True)
        with pytest.raises(ValueError):
            p.transfer(
                source=source.well(0),
                destination=destination.well(0),
                volume="10:microliter",
                rows=16,
                columns=24,
            )
Пример #20
0
def get_synthesized_oligo_tube_protocol(tube_name, sequence):
    """

    Synthesize and prepare an oligo tube
    25nm seems to be more than enough for most downstream work (25pmol seems to be all that is used for transcriptic's pcr)
    
    """
    global inv

    scale = '25nm'

    p = Protocol()

    dna_tube = p.ref(tube_name,
                     cont_type="micro-1.5",
                     storage="cold_20",
                     discard=False)

    dna_tube.well(0).properties = {
        'Molar Concentration': '100uM',
        'original moles': '25nm'
    }

    p.oligosynthesize([{
        "sequence": sequence,
        "destination": dna_tube.well(0),
        "scale": scale,
        "purification": "standard"
    }])

    #spin
    p.spin(dna_tube, '2000:g', '30:second')

    #dilute to 100uM
    #safe min volume of 1.5uL is 20uL so we want a lot more than this so we don't lose too much
    #how do you go from scale and desired concentration to volume --> n = CV --> V = n/C --> V = 25nmol / 100uM = 25nmol / (100E3 nmol / 1L)
    #          = 2.5E-4 L = 250 uL

    #convert 100uM to nM #convert to uL
    te_volume = 25 / (100 * pow(10, 3)) * pow(10, 6)

    #add 250uL
    p.provision(inv["te"], dna_tube.well(0), ul(te_volume))

    #spin
    p.spin(dna_tube, '2000:g', '30:second')

    return json.dumps(p.as_dict(), indent=2)
Пример #21
0
 def __init__(self, barcode, well_count, part_num):
     """
     Initializes the class values and populates the
     plate information (e.g. barcode, no of wells, part no.)
     """
     self.barcode = barcode
     self.well_count = well_count
     self.part_num = part_num
     # define the REFs elements
     self.p = Protocol()
     self.id = self.p.ref(self.barcode,
                          id=self.barcode,
                          cont_type="96-pcr",
                          storage=None,
                          discard=True)
     self.plate_protocol()
Пример #22
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
 def test_one_source(self):
     p = Protocol()
     c = p.ref("test", None, "96-flat", discard=True)
     with self.assertRaises(ValueError):
         p.transfer(c.wells_from(0, 2),
                    c.wells_from(2, 2),
                    "40:microliter",
                    one_source=True)
     with self.assertRaises(RuntimeError):
         p.transfer(c.wells_from(0, 2).set_volume("1:microliter"),
                    c.wells_from(1, 5),
                    "10:microliter",
                    one_source=True)
     p.transfer(c.wells_from(0, 2).set_volume("50:microliter"),
                c.wells_from(2, 2),
                "40:microliter",
                one_source=True)
     self.assertEqual(2, len(p.instructions[0].groups))
     self.assertFalse(p.instructions[0].groups[0]["transfer"][0]["from"] ==
                      p.instructions[0].groups[1]["transfer"][0]["from"])
Пример #24
0
 def test_info_wells_checker(self):
     p = Protocol()
     cont1 = p.ref("cont1", None, "6-flat", discard=True)
     compd = Compound("Daylight Canonical SMILES", "CN1C=NC2=C1C(=O)N(C(=O)N2C)C")
     example_data = {"objects": [cont1.well(0), cont1.well(1)], "some_int": 1}
     instr = Instruction(
         op="test_instruction",
         data=example_data,
         informatics=[AttachCompounds(cont1.well(0), [compd])],
     )
     avail_wells = instr.get_wells(instr.data)
     with pytest.raises(ValueError):
         instr.informatics[0].wells = None
         instr._check_info_wells(instr.informatics[0], avail_wells)
     with pytest.raises(TypeError):
         instr.informatics[0].wells = "cont1/0"
         instr._check_info_wells(instr.informatics[0], avail_wells)
     with pytest.raises(ValueError):
         instr.informatics[0].wells = cont1.well(10)
         instr._check_info_wells(instr.informatics[0], avail_wells)
Пример #25
0
    def test_refifying_various(self):
        p = Protocol()
        # refify container
        refs = {"plate": p.ref("test", None, "96-flat", "cold_20")}
        self.assertEqual(p._refify(refs["plate"]), "test")
        # refify dict
        self.assertEqual(p._refify(refs), {"plate": "test"})

        # refify Well
        well = refs["plate"].well("A1")
        self.assertEqual(p._refify(well), "test/0")

        # refify WellGroup
        wellgroup = refs["plate"].wells_from("A2", 3)
        self.assertEqual(p._refify(wellgroup), ["test/1", "test/2", "test/3"])

        # refify other
        s = "randomstring"
        i = 24
        self.assertEqual("randomstring", p._refify(s))
        self.assertEqual(24, p._refify(i))
Пример #26
0
    def test_fill_wells(self):
        p = Protocol()
        c = p.ref("test", None, "96-flat", discard=True)
        srcs = c.wells_from(1, 2).set_volume("100:microliter")
        dests = c.wells_from(7, 4)
        p.distribute(srcs, dests, "30:microliter", allow_carryover=True)
        self.assertEqual(2, len(p.instructions[0].groups))

        #track source vols
        self.assertEqual(10, c.well(1).volume.value)
        self.assertEqual(70, c.well(2).volume.value)

        # track dest vols
        self.assertEqual(30, c.well(7).volume.value)
        self.assertIs(None, c.well(6).volume)

        #test distribute from Well to Well
        p.distribute(
            c.well("A1").set_volume("20:microliter"), c.well("A2"),
            "5:microliter")
        self.assertTrue("distribute" in p.instructions[-1].groups[-1])
Пример #27
0
    def test_informatics():
        p = Protocol()
        cont1 = p.ref("cont1", None, "6-flat", discard=True)
        compd = Compound("Daylight Canonical SMILES", "CN1C=NC2=C1C(=O)N(C(=O)N2C)C")
        example_data = {
            "wells": [cont1.well(0), cont1.well(1)],
            "some_int": 1,
        }
        example_informatics = [AttachCompounds(cont1.well(0), [compd])]
        instr = Instruction(
            op="test_instruction", data=example_data, informatics=example_informatics
        )
        assert isinstance(instr.informatics[0], AttachCompounds)
        assert instr.informatics[0].compounds[0].value == "CN1C=NC2=C1C(=O)N(C(=O)N2C)C"

        instr_multi = Instruction(
            op="test_instruction",
            data=example_data,
            informatics=[
                AttachCompounds(cont1.well(0), [compd]),
                AttachCompounds(cont1.well(1), [compd]),
            ],
        )
        assert len(instr_multi.informatics) == 2
import json
from autoprotocol.protocol import Protocol
from utils import ul

inv = {
    'gblock_dna': 'ct18vs7cmjat2c',  # my inventory
    'te': 'rs17pwyc754v9t',  # catalog; TE
}

p = Protocol()

#existing inventory
dna_sample = p.ref("gblock_dna",
                   id=inv['gblock_dna'],
                   cont_type="micro-1.5",
                   storage='cold_20')

#tubes are thawed before being placed into workcell

#Centrifuge the tube for 3-5 sec at a minimum of 3000 x g to pellet the material to the bottom of the tube.
p.spin(dna_sample, '3000:g', '5:second')

#Add 500uL TE (to reach 1 ng/uL)
p.provision(inv["te"], dna_sample.well(0), ul(500))

#Briefly vortex (here we have to use mix) and centrifuge

p.mix(dna_sample.well(0),
      '480:microliter',
      speed='480:microliter/second',
      repetitions=10)
Пример #29
0
 def setup(self):
     # pylint: disable=attribute-defined-outside-init
     self.p = Protocol()
     # pylint: disable=attribute-defined-outside-init
     self.w1 = (self.p.ref("w1", None, cont_type="96-pcr",
                           discard=True).well(0).set_volume("2:microliter"))
Пример #30
0
 def setup(self):
     self.p = Protocol()
     self.flat = self.p.ref("flat", cont_type="96-flat", discard=True)
     self.deep = self.p.ref("deep", cont_type="96-deep", discard=True)