How to use the autoprotocol.builders.InstructionBuilders 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 / builders.py View on Github external
raise TypeError(
                    f"Specified gas: {mode_params['gas']} is not included in "
                    f"valid gases: {self.valid_gases}"
                )
            mode_param_output["gas"] = mode_params["gas"]

        if "blow_rate" in mode_params.keys():
            blow_rate = mode_params["blow_rate"]
            if not blow_rate is None:
                blow_rate = parse_unit(blow_rate, "mL/min")
                mode_param_output["blow_rate"] = blow_rate

        return mode_param_output


class GelPurifyBuilders(InstructionBuilders):
    """Helpers for building GelPurify instructions
    """

    def extract(self, source, band_list, lane=None, gel=None):
        """Helper for building extract params for gel_purify

        Parameters
        ----------
        source : Well
            The Well that contains the sample be purified
        band_list : list(dict)
            A list of bands to be extracted from the source sample
        lane : int, optional
            The gel lane for the source sample to be run on
        gel : int, optional
            The number of the gel if using multiple gels
github autoprotocol / autoprotocol-python / autoprotocol / builders.py View on Github external
step_dict["temperature"] = parse_unit(temperature, "celsius")

        duration = parse_unit(duration, "second")
        if duration <= Unit("0:second"):
            raise ValueError("Step `duration` has to be at least 1 second")
        step_dict["duration"] = duration

        if read is not None:
            if not isinstance(read, bool):
                raise TypeError(f"`read` {read} has to be of type bool")
            step_dict["read"] = read

        return step_dict


class SPEBuilders(InstructionBuilders):
    """
    These builders are meant for helping to construct arguments for the
    `SPE` instruction.
    """

    def spe_params(self, params, is_elute=False):
        if not isinstance(params, list):
            raise ValueError("SPE mobile phase parameters {} must be a list.")
        parsed_params = []
        for param in params:
            parsed_params.append(self.mobile_phase_params(is_elute=is_elute, **param))
        return parsed_params

    def mobile_phase_params(
        self,
        volume,
github autoprotocol / autoprotocol-python / autoprotocol / builders.py View on Github external
raise ValueError(
                f"Invalid shake path {path} specified, must be one of "
                f"{self.SHAKE_PATHS}"
            )

        shake_after = {
            "duration": parse_unit(duration, "seconds"),
            "frequency": parse_unit(frequency, "hertz") if frequency else None,
            "path": path,
            "amplitude": parse_unit(amplitude, "mm") if amplitude else None,
        }

        return {k: v for k, v in shake_after.items() if v is not None}


class SpectrophotometryBuilders(InstructionBuilders):
    """
    These builders are meant for helping to construct arguments for the
    `Spectrophotometry` instruction.
    """

    def __init__(self):
        super(SpectrophotometryBuilders, self).__init__()
        self.MODES = {
            "absorbance": self.absorbance_mode_params,
            "fluorescence": self.fluorescence_mode_params,
            "luminescence": self.luminescence_mode_params,
            "shake": self.shake_mode_params,
        }

        self.READ_POSITIONS = ["top", "bottom"]
github autoprotocol / autoprotocol-python / autoprotocol / builders.py View on Github external
raise TypeError(f"magnetize: {magnetize} is not a bool")
        if temperature is not None:
            parse_unit(temperature, "celsius")

        return {
            "object": object,
            "duration": duration,
            "frequency": frequency,
            "center": center,
            "amplitude": amplitude,
            "magnetize": magnetize,
            "temperature": temperature,
        }


class FlowCytometryBuilders(InstructionBuilders):
    """
    Builders for FlowCytometry instructions.
    """

    def __init__(self):
        super(FlowCytometryBuilders, self).__init__()
        self.excitation = None

    def laser(self, excitation, channels, power=None, area_scaling_factor=None):
        """
        Generates a dict of laser parameters.

        Parameters
        ----------
        excitation : Unit or str
            Excitation wavelength.
github autoprotocol / autoprotocol-python / autoprotocol / builders.py View on Github external
if not isinstance(position_z, dict):
            raise TypeError(
                f"Invalid position_z {position_z}, must be a dict. " f"{suggested_msg}"
            )

        if "calculated_from_wells" in position_z:
            return self.position_z_calculated(**position_z["calculated_from_wells"])
        elif "manual" in position_z:
            return self.position_z_manual(**position_z["manual"])
        else:
            raise ValueError(
                f"Invalid position_z {position_z} specified. {suggested_msg}"
            )


class LiquidHandleBuilders(InstructionBuilders):
    """Builders for LiquidHandle Instructions
    """

    def __init__(self):
        super(LiquidHandleBuilders, self).__init__()
        self.liquid_classes = ["air", "default", "viscous"]
        self.xy_max = 1
        self.z_references = [
            "well_top",
            "well_bottom",
            "liquid_surface",
            "preceding_position",
        ]
        self.z_detection_methods = ["capacitance", "pressure", "tracked"]
        self.dispense_modes = ["air_displacement", "positive_displacement"]
github autoprotocol / autoprotocol-python / autoprotocol / builders.py View on Github external
mode_params = {
            "volume": volume,
            "settle_time": settle_time,
            "processing_time": processing_time,
            "flow_pressure": flow_pressure,
            "loading_flowrate": loading_flowrate,
            "resource_id": resource_id,
            "destination_well": destination_well,
        }

        mode_params = {k: v for k, v in mode_params.items() if v is not None}

        return mode_params


class DispenseBuilders(InstructionBuilders):
    """
    These builders are meant for helping to construct arguments in the
    `Protocol.dispense` method.
    """

    def __init__(self):
        super(DispenseBuilders, self).__init__()
        self.SHAKE_PATHS = ["landscape_linear"]

    @staticmethod
    # pragma pylint: disable=unused-argument
    def nozzle_position(position_x=None, position_y=None, position_z=None):
        """
        Generates a validated nozzle_position parameter.

        Parameters
github autoprotocol / autoprotocol-python / autoprotocol / builders.py View on Github external
f"modes: {modes} resulted in an empty set. Make sure valid "
                f"mode is added for each liquid class."
            )
        # return error if there are incompatible liquid_class a set of
        # transports.
        if len(set(modes)) > 1:
            raise ValueError(
                f"There are multiple liquid_class types which could "
                f"potentially have different modes: {set(modes)}. Please "
                f"specify the mode to be used from: {self.dispense_modes}. "
                f"Only one mode is allowed per transfer."
            )
        return list(modes)[0]


class PlateReaderBuilders(InstructionBuilders):
    """Helpers for building parameters for plate reading instructions
    """

    def incubate_params(
        self, duration, shake_amplitude=None, shake_orbital=None, shaking=None
    ):
        """
        Create a dictionary with incubation parameters which can be used as
        input for instructions. Currently supports plate reader instructions and
        could be extended for use with other instructions.

        Parameters
        ----------
        duration: str or Unit
            the duration to shake the plate for
        shake_amplitude: str or Unit, optional
github autoprotocol / autoprotocol-python / autoprotocol / builders.py View on Github external
if not isinstance(max_bp, int):
            raise TypeError(f"max_bp {max_bp} was not an int")

        if not min_bp < max_bp:
            raise ValueError(f"min_bp: {min_bp} is not less than max_bp: {max_bp}")

        return {
            "destination": destination,
            "elution_volume": elution_volume,
            "elution_buffer": elution_buffer,
            "band_size_range": {"min_bp": min_bp, "max_bp": max_bp},
        }


# pylint: disable=redefined-builtin
class MagneticTransferBuilders(InstructionBuilders):
    """Helpers for building MagneticTransfer instruction parameters
    """

    @staticmethod
    def mag_dry(object, duration):
        """Helper for building mag_dry sub operations for MagneticTransfer

        Parameters
        ----------
        object : Container
            The Container to be operated on
        duration : str or Unit
            The duration of the operation

        Returns
        -------
github autoprotocol / autoprotocol-python / autoprotocol / builders.py View on Github external
raise ValueError(
                f"Invalid shape format; format has to be in {self.sbs_shapes}"
            )

        valid_rows = rows <= SBS_FORMAT_SHAPES[format]["rows"]
        valid_columns = columns <= SBS_FORMAT_SHAPES[format]["columns"]
        if not (valid_rows and valid_columns):
            raise ValueError(
                f"rows: {rows} and columns: {columns} are not possible with "
                f"format: {format}."
            )

        return {"rows": rows, "columns": columns, "format": format}


class ThermocycleBuilders(InstructionBuilders):
    """
    These builders are meant for helping to construct the `groups`
    argument in the `Protocol.thermocycle` method
    """

    def __init__(self):
        super(ThermocycleBuilders, self).__init__()
        self.valid_dyes = {
            "FAM",
            "SYBR",  # channel 1
            "VIC",
            "HEX",
            "TET",
            "CALGOLD540",  # channel 2
            "ROX",
            "TXR",
github autoprotocol / autoprotocol-python / autoprotocol / builders.py View on Github external
raise ValueError(f"shake_amplitude: {amplitude} is not positive")
            if not isinstance(orbital, bool):
                raise TypeError(f"shake_orbital: {orbital} is not a bool")
        elif (amplitude is not None) ^ (orbital is not None):
            raise ValueError(
                f"shake_amplitude: {amplitude} and shake_orbital: {orbital} "
                f"must both be specified to shake"
            )

        return {
            "duration": duration,
            "shaking": {"amplitude": amplitude, "orbital": orbital},
        }


class EvaporateBuilders(InstructionBuilders):
    """
    Helpers for building Evaporate instructions
    """

    def __init__(self):
        super(EvaporateBuilders, self).__init__()
        self.valid_modes = ["rotate", "centrifuge", "vortex", "blowdown"]
        self.valid_gases = ["nitrogen", "argon", "helium"]
        self.rotary_params = [
            "flask_volume",
            "rotation_speed",
            "vacuum_pressure",
            "condenser_temperature",
        ]
        self.centrifugal_params = [
            "spin_acceleration",