{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# High-level interface for users" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Users primarily interested in using cameo as a tool\n", "for enumerating metabolic engineering strategies have access to cameo's advanced programming interface via `cameo.api`\n", "that provides access to potential products (`cameo.api.products`), host organisms (`cameo.api.hosts`) and\n", "a configurable design function (`cameo.api.design`). Running `cameo.api.design` requires only minimal input." ] }, { "cell_type": "code", "execution_count": 1, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/html": [] }, "metadata": {}, "output_type": "display_data" }, { "data": { "application/javascript": [ "\n", "(function(global) {\n", " function now() {\n", " return new Date();\n", " }\n", "\n", " if (typeof (window._bokeh_onload_callbacks) === \"undefined\") {\n", " window._bokeh_onload_callbacks = [];\n", " }\n", "\n", " function run_callbacks() {\n", " window._bokeh_onload_callbacks.forEach(function(callback) { callback() });\n", " delete window._bokeh_onload_callbacks\n", " console.info(\"Bokeh: all callbacks have finished\");\n", " }\n", "\n", " function load_libs(js_urls, callback) {\n", " window._bokeh_onload_callbacks.push(callback);\n", " if (window._bokeh_is_loading > 0) {\n", " console.log(\"Bokeh: BokehJS is being loaded, scheduling callback at\", now());\n", " return null;\n", " }\n", " if (js_urls == null || js_urls.length === 0) {\n", " run_callbacks();\n", " return null;\n", " }\n", " console.log(\"Bokeh: BokehJS not loaded, scheduling load and callback at\", now());\n", " window._bokeh_is_loading = js_urls.length;\n", " for (var i = 0; i < js_urls.length; i++) {\n", " var url = js_urls[i];\n", " var s = document.createElement('script');\n", " s.src = url;\n", " s.async = false;\n", " s.onreadystatechange = s.onload = function() {\n", " window._bokeh_is_loading--;\n", " if (window._bokeh_is_loading === 0) {\n", " console.log(\"Bokeh: all BokehJS libraries loaded\");\n", " run_callbacks()\n", " }\n", " };\n", " s.onerror = function() {\n", " console.warn(\"failed to load library \" + url);\n", " };\n", " console.log(\"Bokeh: injecting script tag for BokehJS library: \", url);\n", " document.getElementsByTagName(\"head\")[0].appendChild(s);\n", " }\n", " };\n", "\n", " var js_urls = ['https://cdn.pydata.org/bokeh/release/bokeh-0.11.1.min.js', 'https://cdn.pydata.org/bokeh/release/bokeh-widgets-0.11.1.min.js', 'https://cdn.pydata.org/bokeh/release/bokeh-compiler-0.11.1.min.js'];\n", "\n", " var inline_js = [\n", " function(Bokeh) {\n", " Bokeh.set_log_level(\"info\");\n", " },\n", " \n", " function(Bokeh) {\n", " Bokeh.$(\"#e4d46c63-ae51-419c-87be-80901d7aee92\").text(\"BokehJS successfully loaded\");\n", " },\n", " function(Bokeh) {\n", " console.log(\"Bokeh: injecting CSS: https://cdn.pydata.org/bokeh/release/bokeh-0.11.1.min.css\");\n", " Bokeh.embed.inject_css(\"https://cdn.pydata.org/bokeh/release/bokeh-0.11.1.min.css\");\n", " console.log(\"Bokeh: injecting CSS: https://cdn.pydata.org/bokeh/release/bokeh-widgets-0.11.1.min.css\");\n", " Bokeh.embed.inject_css(\"https://cdn.pydata.org/bokeh/release/bokeh-widgets-0.11.1.min.css\");\n", " }\n", " ];\n", "\n", " function run_inline_js() {\n", " for (var i = 0; i < inline_js.length; i++) {\n", " inline_js[i](window.Bokeh);\n", " }\n", " }\n", "\n", " if (window._bokeh_is_loading === 0) {\n", " console.log(\"Bokeh: BokehJS loaded, going straight to plotting\");\n", " run_inline_js();\n", " } else {\n", " load_libs(js_urls, function() {\n", " console.log(\"Bokeh: BokehJS plotting callback run at\", now());\n", " run_inline_js();\n", " });\n", " }\n", "}(this));" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "from cameo import api" ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "collapsed": false, "scrolled": false }, "outputs": [ { "data": { "text/html": [ "Starting searching for compound vanillin" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "Found 2 compounds that match query 'vanillin'" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "\n", " \n", "
IdNameFormula
MNXM754vanillinC8H8O3
MNXM741anilineC6H7N
\n", " " ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "Choosing best match (vanillin) ... please interrupt if this is not the desired compound." ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "\n", "

\n", " \n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "CH\n", "3\n", "O\n", "HO\n", "O\n", "\n", " - OBDepict\n", "\n", "\n", "

\n", " " ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "\n", " \n", " " ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "Predicting pathways for product vanillin in Escherichia coli (using model iJO1366)." ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "application/javascript": [ "\n", " jQuery(\"#cc4c525c-ac33-4073-89ef-740372ea8cc9\").remove();\n", " " ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "\n", "\n", "
\n", "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "\n", " \n", " " ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "Predicting pathways for product vanillin in Saccharomyces cerevisiae (using model iMM904)." ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "application/javascript": [ "\n", " jQuery(\"#2c6d50ad-2157-47be-a3d9-e6bd62f9021a\").remove();\n", " " ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "\n", "\n", "
\n", "" ] }, "metadata": {}, "output_type": "display_data" }, { "name": "stdout", "output_type": "stream", "text": [ "Optimizing 8 pathways\n", "Starting optimization at Tue, 24 May 2016 12:00:41\n", "Finished after 00:02:56\n", "Starting optimization at Tue, 24 May 2016 12:04:07\n", "Finished after 00:03:40\n", "Starting optimization at Tue, 24 May 2016 12:08:26\n", "Finished after 00:04:09\n", "Starting optimization at Tue, 24 May 2016 12:12:53\n", "Finished after 00:01:57\n", "Starting optimization at Tue, 24 May 2016 12:15:11\n", "Finished after 00:01:27\n", "Starting optimization at Tue, 24 May 2016 12:16:49\n", "Finished after 00:01:22\n", "Starting optimization at Tue, 24 May 2016 12:18:22\n", "Finished after 00:01:09\n", "Starting optimization at Tue, 24 May 2016 12:19:40\n", "Finished after 00:02:31\n" ] } ], "source": [ "report = api.design(product='vanillin')" ] }, { "cell_type": "code", "execution_count": 3, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "[(,\n", " +MNXR5336+MNXR5340+MNXR7229+MNXR68718),\n", " (,\n", " +MNXR230+MNXR640+MNXR5336+MNXR5340),\n", " (,\n", " +MNXR640+MNXR5336+MNXR5340+MNXR68718),\n", " (,\n", " +MNXR5336+MNXR5340+MNXR7734+MNXR68718),\n", " (,\n", " +MNXR5336+MNXR5340+MNXR68718),\n", " (,\n", " +MNXR5336+MNXR5340+MNXR14769),\n", " (,\n", " +MNXR230+MNXR5336+MNXR5340),\n", " (,\n", " +MNXR5336+MNXR5340+MNXR5836+MNXR7067)]" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "report" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### IPython notebook" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Click [here](http://nbviewer.ipython.org/github/biosustain/cameo/blob/devel/docs/cameo_high_level_interface.ipynb) to download this page as an IPython notebook." ] } ], "metadata": { "kernelspec": { "display_name": "IPython (Python 3)", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.4.2" } }, "nbformat": 4, "nbformat_minor": 0 }