Loading files
This file is pinned to the selected release. Download the original to open it in your design tool.
526d19316This file is pinned to the selected release. Download the original to open it in your design tool.
{
"cells": [
{
"cell_type": "code",
"execution_count": 10,
"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/0\", \n",
" \"from\": \"plate1/0\"\n",
" }\n",
" ]\n",
" }\n",
" ], \n",
" \"op\": \"pipette\"\n",
" }\n",
" ]\n",
"}\n"
]
}
],
"source": [
"from autoprotocol import Protocol\n",
"\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",
"\n",
"plate1.well(0).set_volume( '100:microliter' )\n",
"\n",
"p.transfer( plate1.well(0), plate2.well(0), '10:microliter' )\n",
"\n",
"import json\n",
"print json.dumps( p.as_dict(), indent=2 )"
]
},
{
"cell_type": "code",
"execution_count": 30,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"place plate plate2 with {'new': '96-deep', 'discard': True} at index 0 with xy coords 0.000000, 0.000000\n",
"place plate plate1 with {'new': '96-deep', 'discard': True} at index 1 with xy coords 69.000000, 69.000000\n"
]
}
],
"source": [
"# handle refs \n",
"d = p.as_dict()\n",
"for index, plate in enumerate( d['refs'] ):\n",
" print 'place plate %s with %s at index %d with xy coords %f, %f' % ( plate, d['refs'][ plate ], index, 69*index, 69*index ) "
]
},
{
"cell_type": "code",
"execution_count": 65,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"# compile autoprotocol to gcode \n",
"gcode = []\n",
"compiler_stack = []\n",
"for instruction in p.as_dict()['instructions']:\n",
" #print instruction\n",
" for group in instruction['groups']:\n",
" #print group\n",
" for transfer in group['transfer']:\n",
" compiler_stack.append( transfer )"
]
},
{
"cell_type": "code",
"execution_count": 68,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"['G1 X0.000000 Y0.000000 Z0.000000 F400', 'G1 A10.000000 F500', 'G1 X0.000000 Y0.000000 Z0.000000 F400', 'G1 A10.000000 F500', 'G1 X0.000000 Y0.000000 Z0.000000 F400', 'G1 A10.000000 F500', 'G1 X0.000000 Y0.000000 Z0.000000 F400', 'G1 A10.000000 F500', 'G1 X0.000000 Y0.000000 Z0.000000 F400', 'G1 A10.000000 F500', 'G1 X0.000000 Y0.000000 Z0.000000 F400', 'G1 A-10.000000 F500']\n"
]
}
],
"source": [
"def a1_of_plate( plate ):\n",
" return (0,0,0)\n",
"\n",
"def offset_of_well( well ):\n",
" return (0,0,0)\n",
"\n",
"for transfer in compiler_stack:\n",
" asp_vol = dis_vol = float( transfer['volume'].split( ':' )[0] )\n",
" dis_xyz = tuple([ x + y for (x, y) in zip( a1_of_plate( transfer['to'] ), offset_of_well( transfer['to'].split( '/' )[-1] ) ) ])\n",
" asp_xyz = tuple([ x + y for (x, y) in zip( a1_of_plate( transfer['from'] ), offset_of_well( transfer['from'].split( '/' )[-1] ) ) ] )\n",
" \n",
" gcode.append( 'G1 X%f Y%f Z%f F400' % dis_xyz )\n",
" gcode.append( 'G1 A%f F500' % asp_vol )\n",
" gcode.append( 'G1 X%f Y%f Z%f F400' % asp_xyz )\n",
" gcode.append( 'G1 A-%f F500' % dis_vol )\n",
" \n",
"\n",
"print gcode"
]
},
{
"cell_type": "code",
"execution_count": 64,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"[2, 4, 6]"
]
},
"execution_count": 64,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"[ x + y for (x, y) in zip( (1, 2, 3), (1, 2, 3) ) ] "
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": []
}
],
"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
}