{ "cells": [ { "cell_type": "markdown", "id": "ntr-intro", "metadata": {}, "source": [ "# Nested tip racks\n", "\n", "A nested tip rack (NTR) is a tip rack that stacks on top of another rack of the same type. A stack\n", "of nested racks takes the deck space of one rack. When the top rack is used up, it is removed, and\n", "the rack below it becomes reachable.\n", "\n", "In PyLabRobot, a nested tip rack is a {class}`~pylabrobot.resources.tip_rack.StandingTipRack` with\n", "a `stacking_z_height`: the height, in mm, that one rack adds to a stack of identical racks. A\n", "standing rack stands on its own frame. An {class}`~pylabrobot.resources.tip_rack.EmbeddedTipRack`\n", "sits down in a carrier site and does not nest.\n", "\n", "```{note}\n", "`NestedTipRack` is deprecated. Use\n", "{class}`~pylabrobot.resources.tip_rack.StandingTipRack` with a `stacking_z_height` instead.\n", "```" ] }, { "cell_type": "markdown", "id": "predefined-rack", "metadata": {}, "source": [ "## A predefined nested tip rack\n", "\n", "The resource library has nested tip racks, for example the Hamilton 10, 50 and 300 uL NTRs. Each\n", "one is a `StandingTipRack`:" ] }, { "cell_type": "code", "execution_count": null, "id": "predefined-rack-code", "metadata": {}, "outputs": [], "source": [ "from pylabrobot.resources import StandingTipRack, hamilton_96_tiprack_50uL_NTR\n", "\n", "rack = hamilton_96_tiprack_50uL_NTR(name=\"ntr\")\n", "\n", "assert isinstance(rack, StandingTipRack)\n", "assert rack.get_size_z() == 55.0\n", "assert rack.stacking_z_height == 16.0" ] }, { "cell_type": "markdown", "id": "stacking", "metadata": {}, "source": [ "## Stacking nested tip racks\n", "\n", "Put nested racks in a {class}`~pylabrobot.resources.ResourceStack` with\n", "`direction=\"z\"`. A standing rack that has a `stacking_z_height` and is placed on another such rack\n", "nests into it: it stands `stacking_z_height` above the rack below, not `size_z` above it. A stack\n", "of `N` identical racks is `size_z + (N - 1) * stacking_z_height` tall." ] }, { "cell_type": "code", "execution_count": null, "id": "stacking-code", "metadata": {}, "outputs": [], "source": [ "from pylabrobot.resources import ResourceStack\n", "\n", "stack = ResourceStack(name=\"ntr_stack\", direction=\"z\")\n", "racks = [hamilton_96_tiprack_50uL_NTR(name=f\"ntr_{i}\") for i in range(3)]\n", "for r in racks:\n", " stack.assign_child_resource(r)\n", "\n", "assert [r.location.z for r in racks] == [0, 16.0, 32.0]\n", "assert stack.get_size_z() == 55.0 + 2 * 16.0" ] }, { "cell_type": "markdown", "id": "top-rack", "metadata": {}, "source": [ "Only the top rack of a stack is available for tip handling. A rack with another rack on top of it,\n", "or with a lid on it, is not. The Hamilton STAR and Prep drivers and the legacy `LiquidHandler`\n", "check `available_for_tip_handling`, and refuse to pick up tips from such a rack or to drop tips\n", "into it. Remove the top rack to make the rack below it available:" ] }, { "cell_type": "code", "execution_count": null, "id": "top-rack-code", "metadata": {}, "outputs": [], "source": [ "assert [r.available_for_tip_handling for r in racks] == [False, False, True]\n", "\n", "stack.unassign_child_resource(racks[-1])\n", "\n", "assert racks[1].available_for_tip_handling\n", "assert stack.get_size_z() == 55.0 + 16.0" ] }, { "cell_type": "markdown", "id": "lids", "metadata": {}, "source": [ "A rack does not nest into a rack that has a lid on it. The upper rack stands on the lid instead." ] }, { "cell_type": "markdown", "id": "carrier", "metadata": {}, "source": [ "## Nested tip racks on a carrier\n", "\n", "A carrier for nested tip racks holds a z `ResourceStack` on each site. For example, each site of\n", "`hamilton_tip_carrier_L5_ntr_a00` (Hamilton `TIP_CAR_NTR_A00`) holds a stack. Assigning a rack to\n", "a site puts the rack on top of the stack on that site:" ] }, { "cell_type": "code", "execution_count": null, "id": "carrier-code", "metadata": {}, "outputs": [], "source": [ "from pylabrobot.resources import hamilton_tip_carrier_L5_ntr_a00\n", "\n", "carrier = hamilton_tip_carrier_L5_ntr_a00(name=\"ntr_carrier\")\n", "carrier[0] = hamilton_96_tiprack_50uL_NTR(name=\"lower\")\n", "carrier[0] = hamilton_96_tiprack_50uL_NTR(name=\"upper\")\n", "\n", "site_stack = carrier[0].resource\n", "assert isinstance(site_stack, ResourceStack)\n", "assert [r.name for r in site_stack.children] == [\"lower\", \"upper\"]\n", "assert carrier.get_resource(\"upper\").location.z == 16.0" ] }, { "cell_type": "markdown", "id": "custom", "metadata": {}, "source": [ "## Defining a nested tip rack\n", "\n", "To define a nested tip rack, create a `StandingTipRack` and give it a `stacking_z_height`. To\n", "measure it, stack two racks and measure the height of the pair:\n", "\n", "```\n", "stacking_z_height = height_of_two_stacked_racks - size_z\n", "```\n", "\n", "The other arguments are the same as for any tip rack (see the {doc}`TipSpot guide `).\n", "`frame_height` is `0` for a rack that holds its tips on its top face:" ] }, { "cell_type": "code", "execution_count": null, "id": "custom-code", "metadata": {}, "outputs": [], "source": [ "from pylabrobot.resources import TipSpot, create_ordered_items_2d, hamilton_tip_50uL\n", "\n", "custom_rack = StandingTipRack(\n", " name=\"custom_ntr\",\n", " size_x=127.76,\n", " size_y=85.48,\n", " size_z=55.0,\n", " stacking_z_height=16.0,\n", " ordered_items=create_ordered_items_2d(\n", " TipSpot,\n", " num_items_x=12,\n", " num_items_y=8,\n", " dx=10.78,\n", " dy=7.64,\n", " dz=55.0,\n", " item_dx=9.0,\n", " item_dy=9.0,\n", " size_x=7.2,\n", " size_y=7.2,\n", " make_tip=hamilton_tip_50uL,\n", " name_prefix=\"custom_ntr\",\n", " ),\n", " frame_height=0.0,\n", ")\n", "\n", "assert custom_rack.num_items == 96\n", "assert custom_rack.stacking_z_height == 16.0" ] }, { "cell_type": "markdown", "id": "custom-serialize", "metadata": {}, "source": [ "`stacking_z_height` is part of the serialized rack, so a deserialized rack nests the same way:" ] }, { "cell_type": "code", "execution_count": null, "id": "custom-serialize-code", "metadata": {}, "outputs": [], "source": [ "from pylabrobot.resources import Resource\n", "\n", "loaded_rack = Resource.deserialize(custom_rack.serialize())\n", "\n", "assert isinstance(loaded_rack, StandingTipRack)\n", "assert loaded_rack.stacking_z_height == 16.0" ] }, { "cell_type": "markdown", "id": "api", "metadata": {}, "source": [ "See {class}`~pylabrobot.resources.tip_rack.StandingTipRack` and\n", "{class}`~pylabrobot.resources.ResourceStack` for the API reference." ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "name": "python" } }, "nbformat": 4, "nbformat_minor": 5 }