How to use the autoprotocol.unit.Unit.fromstring function in autoprotocol

To help you get started, we’ve selected a few autoprotocol examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github autoprotocol / autoprotocol-python / autoprotocol / protocols / bead_purification.py View on Github external
"te": "resource_plate/A2"
        }
    }


    '''
    params = make_dottable_dict(params)
    refs = make_dottable_dict(params.refs)

    samples = refs.sample_plate.wells_from(
        params.sample_start,
        params.sample_number
    ).set_volume(params.sample_volume)
    destinations = refs.sample_plate.wells_from(
        params.destination_start, params.sample_number)
    bead_volume = Unit.fromstring(
        params.sample_volume) * Unit(1.8, "microliter")

    # Allow beads to come to room temperature

    # Resuspend the beads
    protocol.mix(refs.beads.well(0), volume="500:microliter")

    protocol.transfer(
        refs.beads.well(0),
        samples,
        bead_volume,
        mix_after=True,
        repetitions=20,
        mix_vol=bead_volume)

    # Let sit at RT for 10min, important, maybe longer, e.g. 20min
github autoprotocol / autoprotocol-python / autoprotocol / protocol.py View on Github external
source_counter += 1
                                if source_counter < len_source:
                                    s = source.wells[source_counter]
                                    vol = s.volume
                source = WellGroup(sources)
                dest = WellGroup(destinations)
                volume = volumes
            except (ValueError, AttributeError):
                raise RuntimeError("When transferring liquid from multiple wells containing the same substance to "
                                   "multiple other wells, each source Well must have a volume attribute (aliquot) "
                                   "associated with it.")

        for s, d, v in list(zip(source.wells, dest.wells, volume)):
            v = convert_to_ul(v)
            if v > Unit(750, "microliter"):
                diff = Unit.fromstring(v)
                while diff > Unit(750, "microliter"):
                    # Organize transfer options into dictionary (for json parsing)

                    v = Unit(750, "microliter")

                    xfer = {
                        "from": s,
                        "to": d,
                        "volume": v
                    }
                    # Volume accounting
                    if d.volume:
                        d.volume += v
                    else:
                        d.volume = v
                    if s.volume:
github autoprotocol / autoprotocol-python / autoprotocol / protocols / golden_braid.py View on Github external
"buffer_vol": "1:microliter",
            "fragment_vol": "3:microliter",
            "water_vol": "2:microliter",
            "ligation_time": "10:minute",
            "deactivation_time": "5:minute",
            "deactivation_temp": "65:celsius",
        }
    }
    '''

    params = make_dottable_dict(params)
    refs = make_dottable_dict(params.refs)

    MM_vol = Unit.fromstring(params.backbone_vol) + Unit.fromstring(params.enzyme_vol) + Unit.fromstring(params.buffer_vol) + Unit.fromstring(params.ligase_vol) + Unit.fromstring(params.fragment_vol) + Unit.fromstring(params.water_vol)
    # make master mix
    protocol.transfer(params.backbone, params.MM_loc, Unit.fromstring(params.backbone_vol) * Unit((params.reaction_number + 2),"microliter"))
    protocol.transfer(params.T4_ligase, params.MM_loc, Unit.fromstring(params.ligase_vol) * Unit((params.reaction_number + 2),"microliter"))
    protocol.transfer(params.enzyme, params.MM_loc, Unit.fromstring(params.enzyme_vol) * Unit((params.reaction_number + 2),"microliter"))
    protocol.transfer(params.buffer, params.MM_loc, Unit.fromstring(params.buffer_vol) * Unit((params.reaction_number + 2),"microliter"))

    # distribute master mix
    protocol.distribute(params.MM_loc,
        refs.destination_plate.wells_from(params.reaction_start,
        params.reaction_number), MM_vol )

    protocol.seal("destination_plate")

    protocol.thermocycle("destination_plate", [
        {"cycles": 1, "steps": [
            {"temperature": "37:celsius", "duration": "2:minute"},
        ]},
        {"cycles": 1, "steps":[
github autoprotocol / autoprotocol-python / autoprotocol / protocols / golden_braid.py View on Github external
"enzyme_vol": "0.3:microliter",
            "ligase_vol": "0.6:microliter",
            "buffer_vol": "1:microliter",
            "fragment_vol": "3:microliter",
            "water_vol": "2:microliter",
            "ligation_time": "10:minute",
            "deactivation_time": "5:minute",
            "deactivation_temp": "65:celsius",
        }
    }
    '''

    params = make_dottable_dict(params)
    refs = make_dottable_dict(params.refs)

    MM_vol = Unit.fromstring(params.backbone_vol) + Unit.fromstring(params.enzyme_vol) + Unit.fromstring(params.buffer_vol) + Unit.fromstring(params.ligase_vol) + Unit.fromstring(params.fragment_vol) + Unit.fromstring(params.water_vol)
    # make master mix
    protocol.transfer(params.backbone, params.MM_loc, Unit.fromstring(params.backbone_vol) * Unit((params.reaction_number + 2),"microliter"))
    protocol.transfer(params.T4_ligase, params.MM_loc, Unit.fromstring(params.ligase_vol) * Unit((params.reaction_number + 2),"microliter"))
    protocol.transfer(params.enzyme, params.MM_loc, Unit.fromstring(params.enzyme_vol) * Unit((params.reaction_number + 2),"microliter"))
    protocol.transfer(params.buffer, params.MM_loc, Unit.fromstring(params.buffer_vol) * Unit((params.reaction_number + 2),"microliter"))

    # distribute master mix
    protocol.distribute(params.MM_loc,
        refs.destination_plate.wells_from(params.reaction_start,
        params.reaction_number), MM_vol )

    protocol.seal("destination_plate")

    protocol.thermocycle("destination_plate", [
        {"cycles": 1, "steps": [
            {"temperature": "37:celsius", "duration": "2:minute"},
github autoprotocol / autoprotocol-python / autoprotocol / protocol.py View on Github external
RuntimeError
            if length of list of volumes does not match the number of
            destination wells to be distributed to

        """

        src = None
        distributes = []
        src_group = WellGroup(src_group)
        dst_group = WellGroup(dst_group)
        if isinstance(volume, list):
            if len(volume) != len(dst_group.wells):
                raise RuntimeError("List length of volumes provided for "
                                   "distribution does not match the number of "
                                   " destination wells")
            volume = [Unit.fromstring(x) for x in volume]
        else:
            volume = [Unit.fromstring(volume)]*len(dst_group.wells)
        for d, v in list(zip(dst_group.wells, volume)):
            v = convert_to_ul(v)
            if len(distributes) == 0 or src.volume < v:
                # find a src well with enough volume
                src = next(
                    (w for w in src_group.wells if w.volume >= v), None)
                if src is None:
                    raise RuntimeError(
                        "no well in source group has more than %s %s(s)" %
                        (str(v).rsplit(":")[0], str(v).rsplit(":")[1]))
                distributes.append({
                    "from": src,
                    "to": []
                })
github autoprotocol / autoprotocol-python / autoprotocol / protocol.py View on Github external
            volume = list(map(lambda x: Unit.fromstring(x), volume))
        else:
github autoprotocol / autoprotocol-python / autoprotocol / protocol.py View on Github external
dest_wells = dest_plate.wells_from(dest_origin, columns*rows, columnWise)
        if src_plate_type.col_count == 24:
            if columnWise:
                source_wells = [source_plate.wells_from(source_origin, columns*rows*4, columnWise)[x] for x in range(columns*rows*4) if (x % 2) == (x//16) % 2 == 0]
            else:
                source_wells = [source_plate.wells_from(source_origin, columns*rows*4, columnWise)[x] for x in range(columns*rows*4) if (x % 2) == (x//24) % 2 == 0]
        else:
            source_wells = source_plate.wells_from(source_origin, columns*rows, columnWise)
        for well in source_wells:
            if well.volume:
                well.volume -= Unit.fromstring(volume)
        for well in dest_wells:
            if well.volume:
                well.volume += Unit.fromstring(volume)
            else:
                well.volume = Unit.fromstring(volume)


        # Set maximum parameters which are defined due to TCLE limitations
        maxContainers = 3
        if stamp_type == "full":
            maxTransfers = 4
        elif stamp_type == "col":
            maxTransfers = 12
        else:
            maxTransfers = 8
        # Set volume at which tip volume type changes defined by TCLE - hardcoded for the two current tip volume types
        volumeSwitch = Unit.fromstring("31:microliter")

        trans = {}
        assign(trans, "shape", shape)
        assign(trans, "tip_layout", 96)
github autoprotocol / autoprotocol-python / autoprotocol / protocol.py View on Github external
            volume = list(map(lambda x: Unit.fromstring(x), volume))
        else:
github autoprotocol / autoprotocol-python / autoprotocol / protocol.py View on Github external
raise RuntimeError("To transfer liquid from one well or "
                                   "multiple wells  containing the same "
                                   "source, set one_source to True. To "
                                   "transfer liquid from multiple wells to a "
                                   "single destination well, specify only one "
                                   "destination well. Otherwise, you must "
                                   "specify the same number of source and "
                                   "destination wells to do a one-to-one "
                                   "transfer.")

        # Auto-generate list from single volume, check if list length matches
        if isinstance(volume, basestring) or isinstance(volume, Unit):
            if len_dest == 1 and not one_source:
                volume = [Unit.fromstring(volume)] * len_source
            else:
                volume = [Unit.fromstring(volume)] * len_dest
        elif isinstance(volume, list) and len(volume) == len_dest:
            volume = list(map(lambda x: Unit.fromstring(x), volume))
        else:
            raise RuntimeError("Unless the same volume of liquid is being "
                               "transferred to each destination well, each "
                               "destination well must have a corresponding "
                               "volume in the form of a list.")

        # Ensure enough volume in single well to transfer to all dest wells
        if one_source:
            try:
                source_vol = [s.volume for s in source.wells]
                if sum([a.value for a in volume]) > sum([a.value for a in source_vol]):
                    raise RuntimeError("There is not enough volume in the source well(s) specified to complete "
                                       "the transfers.")
                if len_source >= len_dest and all(i > j for i, j in zip(source_vol, volume)):