Loading files
This file is pinned to the selected release. Download the original to open it in your design tool.
{
"cells": [
{
"cell_type": "code",
"execution_count": 21,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"{\n",
" \"refs\": {\n",
" \"plate2\": {\n",
" \"new\": \"96-deep\", \n",
" \"discard\": true\n",
" }, \n",
" \"plate1\": {\n",
" \"new\": \"96-deep\", \n",
" \"discard\": true\n",
" }\n",
" }, \n",
" \"instructions\": [\n",
" {\n",
" \"groups\": [\n",
" {\n",
" \"transfer\": [\n",
" {\n",
" \"volume\": \"10.0:microliter\", \n",
" \"to\": \"plate2/62\", \n",
" \"from\": \"plate1/28\"\n",
" }\n",
" ]\n",
" }, \n",
" {\n",
" \"transfer\": [\n",
" {\n",
" \"volume\": \"19.0:microliter\", \n",
" \"to\": \"plate1/0\", \n",
" \"from\": \"plate1/62\"\n",
" }\n",
" ]\n",
" }, \n",
" {\n",
" \"transfer\": [\n",
" {\n",
" \"volume\": \"112.0:microliter\", \n",
" \"to\": \"plate1/72\", \n",
" \"from\": \"plate1/0\"\n",
" }\n",
" ]\n",
" }\n",
" ], \n",
" \"op\": \"pipette\"\n",
" }\n",
" ]\n",
"}\n"
]
}
],
"source": [
"from autoprotocol import Protocol\n",
"p = Protocol()\n",
"\n",
"plate1 = p.ref( 'plate1', cont_type='96-deep', discard=True ) \n",
"plate2 = p.ref( 'plate2', cont_type='96-deep', discard=True ) \n",
"p.transfer( plate1.well('C5'), plate2.well('F3'), '10:microliter' )\n",
"p.transfer( plate1.well('F3'), plate1.well('A1'), '19:microliter' )\n",
"p.transfer( plate1.well('A1'), plate1.well('G1'), '112:microliter' )\n",
"\n",
"import json\n",
"print json.dumps( p.as_dict(), indent=2 )"
]
},
{
"cell_type": "code",
"execution_count": 22,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"(begin transfer)\n",
"G1 Z34.0 F400 (clear the plate)\n",
"G1 X36.0 Y27.0 F400 (go to source well)\n",
"G1 Z4.0 F400 (dive)\n",
"G1 A10.000000 F100 (aspirate)\n",
"G1 Z34.0 F400 (clear the source plate)\n",
"G1 X18.0 Y63.0 F400 (go to dest well)\n",
"G1 Z4.0 F400 (dive into dest)\n",
"G1 A10.000000 (dispense)\n",
"(begin transfer)\n",
"G1 Z34.0 F400 (clear the plate)\n",
"G1 X18.0 Y63.0 F400 (go to source well)\n",
"G1 Z4.0 F400 (dive)\n",
"G1 A19.000000 F100 (aspirate)\n",
"G1 Z34.0 F400 (clear the source plate)\n",
"G1 X0.0 Y0.0 F400 (go to dest well)\n",
"G1 Z4.0 F400 (dive into dest)\n",
"G1 A19.000000 (dispense)\n",
"(begin transfer)\n",
"G1 Z34.0 F400 (clear the plate)\n",
"G1 X0.0 Y0.0 F400 (go to source well)\n",
"G1 Z4.0 F400 (dive)\n",
"G1 A112.000000 F100 (aspirate)\n",
"G1 Z34.0 F400 (clear the source plate)\n",
"G1 X0.0 Y81.0 F400 (go to dest well)\n",
"G1 Z4.0 F400 (dive into dest)\n",
"G1 A112.000000 (dispense)\n"
]
}
],
"source": [
"# supported container types \n",
"# just one for now \n",
"cont_types = {\n",
" '96-deep': {\n",
" 'plate_height': 34,\n",
" 'well_bottom_height': 4, \n",
" 'x_spacing': 9,\n",
" 'y_spacing': 9, \n",
" 'num_rows': 8,\n",
" 'num_cols': 12, \n",
" },\n",
"}\n",
"\n",
"# define our plate class \n",
"class Plate():\n",
" def __init__( self, cont_type=None, spot=None ):\n",
" # fill these in from container type \n",
" self.plate_height = cont_types[ cont_type ]['plate_height']\n",
" self.well_bottom_height = cont_types[ cont_type ]['well_bottom_height']\n",
" self.x_spacing = cont_types[ cont_type ]['x_spacing'] \n",
" self.y_spacing = cont_types[ cont_type ]['y_spacing']\n",
" self.num_rows = cont_types[ cont_type ]['num_rows']\n",
" self.num_cols = cont_types[ cont_type ]['num_cols']\n",
"\n",
" # from provided spot, calculate offsets\n",
" self.spot = spot\n",
" self.rot = 0 \n",
" self.x, self.y = 0, 0 \n",
" \n",
" def well_id_to_coord( self, well_id ):\n",
" if type( well_id ) is str:\n",
" row = { j: i for i, j in enumerate('ABCDEFGH') }[ well_id[0] ]\n",
" col = int( well_id[1:].strip() ) - 1\n",
" else:\n",
" row = ( well_id / self.num_rows ) \n",
" col = ( well_id % self.num_cols ) \n",
"\n",
" x = col * self.x_spacing \n",
" y = row * self.y_spacing \n",
" \n",
" return ( self.x + x, self.y + y )\n",
"\n",
"# split up refs and instructions\n",
"refs = p.as_dict()['refs'] \n",
"inst = [ inst for inst in p.as_dict()['instructions'] ]\n",
"\n",
"# make objects\n",
"refs_dict = { }\n",
"for index, ( ref, dic ) in enumerate( refs.iteritems() ):\n",
" refs_dict.update( { ref: Plate( cont_type=dic['new'], spot=index ) } )\n",
"\n",
"# compile autoprotocol to gcode \n",
"gcode = []\n",
"blowout = 3 \n",
"transfer_stack = []\n",
"for instruction in inst:\n",
" #print instruction\n",
" for group in instruction['groups']:\n",
" #print group\n",
" for transfer in group['transfer']:\n",
" transfer_stack.append( transfer )\n",
" \n",
"for transfer in transfer_stack:\n",
" volume, unit = transfer['volume'].split( ':' )\n",
" dest_plate, dest_well = transfer['to'].split( '/' )\n",
" source_plate, source_well = transfer['from'].split( '/' )\n",
" \n",
" print '(begin transfer)'\n",
" print 'G1 Z%0.1f F400 (clear the plate)' % refs_dict[ source_plate ].plate_height\n",
" print 'G1 X%0.1f Y%0.1f F400 (go to source well)' % refs_dict[ source_plate ].well_id_to_coord( int( source_well ) )\n",
" print 'G1 Z%0.1f F400 (dive)' % refs_dict[ source_plate ].well_bottom_height\n",
" print 'G1 A%f F100 (aspirate)' % float( volume )\n",
" print 'G1 Z%0.1f F400 (clear the source plate)' % refs_dict[ source_plate ].plate_height\n",
" print 'G1 X%0.1f Y%0.1f F400 (go to dest well)' % refs_dict[ dest_plate ].well_id_to_coord( int( dest_well ) )\n",
" print 'G1 Z%0.1f F400 (dive into dest)' % refs_dict[ dest_plate ].well_bottom_height\n",
" print 'G1 A%f (dispense)' % float( volume )"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 2",
"language": "python",
"name": "python2"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 2
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython2",
"version": "2.7.10"
}
},
"nbformat": 4,
"nbformat_minor": 0
}
526d19316This file is pinned to the selected release. Download the original to open it in your design tool.