How to use the autoprotocol.container.WellGroup 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 / container.py View on Github external
WellGroup
            WellGroup of all Wells in Container

        """
        if columnwise:
            num_cols = self.container_type.col_count
            num_rows = self.container_type.well_count // num_cols
            return WellGroup(
                [
                    self._wells[row * num_cols + col]
                    for col in range(num_cols)
                    for row in range(num_rows)
                ]
            )
        else:
            return WellGroup(self._wells)
github autoprotocol / autoprotocol-python / autoprotocol / container.py View on Github external
Parameters
        ----------
        columnwise : bool, optional
            returns the WellGroup columnwise instead of rowwise (ordered by
            well index).

        Returns
        -------
        WellGroup
            WellGroup of all Wells in Container

        """
        if columnwise:
            num_cols = self.container_type.col_count
            num_rows = self.container_type.well_count // num_cols
            return WellGroup(
                [
                    self._wells[row * num_cols + col]
                    for col in range(num_cols)
                    for row in range(num_rows)
                ]
            )
        else:
            return WellGroup(self._wells)
github autoprotocol / autoprotocol-python / autoprotocol / builders.py View on Github external
Raises
        ------
        TypeError
            Invalid input types, e.g. settle_time is not of type Unit(second)
        ValueError
            Gain is not between 0 and 1

        """
        if not is_valid_well(wells):
            raise ValueError(
                f"Invalid wells {wells}, must be an iterable of wells or a "
                f"WellGroup."
            )

        if isinstance(wells, Well):
            wells = WellGroup([wells])

        if num_flashes is not None and not isinstance(num_flashes, int):
            raise TypeError(f"Invalid num_flashes {num_flashes}, must be an int")

        if settle_time is not None:
            settle_time = parse_unit(settle_time, "second")

        if integration_time is not None:
            integration_time = parse_unit(integration_time, "second")

        if gain is not None:
            if not isinstance(gain, (int, float)):
                raise TypeError(f"Invalid gain {gain}, must be an int")
            gain = float(gain)
            if not 0 <= gain <= 1:
                raise ValueError(
github autoprotocol / autoprotocol-python / autoprotocol / protocol.py View on Github external
volumes.append(vol_d)
                                vol -= vol_d
                                vol.value = round(vol.value, max_decimal_places)
                                vol_d -= vol_d
                                vol_d.value = round(vol_d.value, max_decimal_places)
                            else:
                                sources.append(s)
                                destinations.append(d)
                                volumes.append(vol)
                                vol_d -= vol
                                vol_d.value = round(vol_d.value, max_decimal_places)
                                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")
github autoprotocol / autoprotocol-python / autoprotocol / protocol.py View on Github external
volumes.append(vol_d)
                                vol -= vol_d
                                vol.value = round(vol.value, max_decimal_places)
                                vol_d -= vol_d
                                vol_d.value = round(vol_d.value, max_decimal_places)
                            else:
                                sources.append(s)
                                destinations.append(d)
                                volumes.append(vol)
                                vol_d -= vol
                                vol_d.value = round(vol_d.value, max_decimal_places)
                                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.")




        # Initializing transfer dictionary
        xfer = {}
        xfer["to"] = dest_origin
        xfer["from"] = source_origin
        xfer["volume"] = Unit.fromstring(volume)
github autoprotocol / autoprotocol-python / autoprotocol / container.py View on Github external
def __init__(self, wells):
        if isinstance(wells, Well):
            wells = [wells]
        elif isinstance(wells, WellGroup):
            wells = wells.wells
        elif isinstance(wells, list):
            if not all(isinstance(well, Well) for well in wells):
                raise TypeError("All elements in list must be wells")
        else:
            raise TypeError("Wells must be Well, list of wells, WellGroup.")

        self.wells = wells
        self.name = None
github autoprotocol / autoprotocol-python / autoprotocol / protocol.py View on Github external
dispense volume. Cannot be true if disposal_vol is specified.
        tip_type : str, optional
            Type of tip to be used for the transfer operation.
        new_group : bool, optional

        Raises
        ------
        RuntimeError
            If more than one volume is specified as a list but the list length
            does not match the number of destination wells given.
        RuntimeError
            If transferring from WellGroup to WellGroup that have different
            number of wells and one_source is not True.

        """
        source = WellGroup(source)
        dest = WellGroup(dest)
        opts = []
        len_source = len(source.wells)
        len_dest = len(dest.wells)

        # Auto-generate well-group if only 1 well specified and using >1 source
        if not one_source:
            if len_dest > 1 and len_source == 1:
                source = WellGroup(source.wells * len_dest)
                len_source = len(source.wells)
            if len_dest == 1 and len_source > 1:
                dest = WellGroup(dest.wells * len_source)
                len_dest = len(dest.wells)
            if len_source != len_dest:
                raise RuntimeError("To transfer liquid from one well or "
                                   "multiple wells  containing the same "
github autoprotocol / autoprotocol-python / autoprotocol / protocol.py View on Github external
does not match the number of destination wells given.
        RuntimeError
            If transferring from WellGroup to WellGroup that have different
            number of wells and one_source is not True.

        """
        source = WellGroup(source)
        dest = WellGroup(dest)
        opts = []
        len_source = len(source.wells)
        len_dest = len(dest.wells)

        # Auto-generate well-group if only 1 well specified and using >1 source
        if not one_source:
            if len_dest > 1 and len_source == 1:
                source = WellGroup(source.wells * len_dest)
                len_source = len(source.wells)
            if len_dest == 1 and len_source > 1:
                dest = WellGroup(dest.wells * len_source)
                len_dest = len(dest.wells)
            if len_source != len_dest:
                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
github autoprotocol / autoprotocol-python / autoprotocol / protocol.py View on Github external
the column number and the volume to be dispensed to that column.
            Columns are expressed as integers indexed from 0.
            [{"column": , "volume": }, ...]
        speed_percentage : int, optional
            Integer between 1 and 100 that represents the percentage of the
            maximum speed at which liquid is dispensed from the reagent
            dispenser.

        """
        if (speed_percentage != None and
           (speed_percentage > 100 or speed_percentage < 1)):
            raise RuntimeError("Invalid speed percentage specified.")
        if not isinstance(columns, list):
            raise TypeError("Columns is not of type 'list'.")
        for c in columns:
            wells = WellGroup(ref.wells_from(c["column"], ref.container_type.row_count(),
                              columnwise=True))
            for w in wells:
                if w.volume:
                    w.volume += Unit.fromstring(c["volume"])
                else:
                    w.set_volume(c["volume"])

        self.instructions.append(Dispense(ref, reagent, columns, speed_percentage))
github autoprotocol / autoprotocol-python / autoprotocol / protocol.py View on Github external
List of distribute groups

        Raises
        ------
        RuntimeError
            if source wells run out of liquid before distributing to all
            designated destination wells
        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: