Skip to content

Instantly share code, notes, and snippets.

@JustABiologist
Created August 9, 2026 14:39
Show Gist options
  • Select an option

  • Save JustABiologist/1fa7042327db4c3c6f616e4f445d48ca to your computer and use it in GitHub Desktop.

Select an option

Save JustABiologist/1fa7042327db4c3c6f616e4f445d48ca to your computer and use it in GitHub Desktop.
GRASP One-Shot Designer (Colab / PyPI)
Display the source blob
Display the rendered blob
Raw
{
"nbformat": 4,
"nbformat_minor": 5,
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"name": "python",
"pygments_lexer": "ipython3"
},
"colab": {
"provenance": [],
"toc_visible": true
}
},
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# GRASP One-Shot Designer\n",
"\n",
"Design Golden Gate oligos for a binder that recognizes **one target RNA**.\n",
"\n",
"Flow: RNA → protein → free cut sites → optimized oligos.\n",
"\n",
"1. Run **0 · Install** once \n",
"2. Fill the forms below and run each cell top → bottom \n",
"\n",
"Code is hidden by default (Colab Forms). Cell ⋮ → **Form → Hide code** if needed.\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"#@title 0 · Install (PyPI) { display-mode: \"form\" }\n",
"#@markdown Installs everything from PyPI. No GitHub token needed. Re-run if imports fail after a runtime restart.\n",
"\n",
"%pip install -q -U \"grasp-library-designer>=0.1.0\"\n",
"\n",
"import importlib\n",
"import grasp_library\n",
"from importlib.metadata import version\n",
"\n",
"print(\"grasp-library-designer\", version(\"grasp-library-designer\"))\n",
"print(\"import ok:\", grasp_library.__name__)\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"#@title 1 · Settings { display-mode: \"form\" }\n",
"#@markdown Choose organism, synthesis, ligation, and target RNA — then run this cell.\n",
"\n",
"target_rna = \"UUACACGUG\" #@param {type:\"string\"}\n",
"organism = \"Escherichia coli (Kazusa)\" #@param [\"Escherichia coli (Kazusa)\", \"Saccharomyces cerevisiae (Kazusa)\", \"Homo sapiens (Kazusa)\", \"Euglena gracilis nuclear (Kazusa)\", \"Chlamydomonas reinhardtii nuclear (Kazusa)\", \"Chlamydomonas reinhardtii chloroplast (Kazusa)\"]\n",
"genetic_code = 1 #@param {type:\"integer\"}\n",
"synthesis_vendor = \"Twist · Standard gene guidelines\" #@param [\"Twist · Express / Low complexity\", \"Twist · Standard gene guidelines\", \"Twist · Complex Genes tolerant\", \"IDT · gBlocks / eBlocks conservative\", \"Generic · conservative (default)\"]\n",
"assembly_enzyme = \"GRASP default · BsaI + BpiI + BsmBI\" #@param [\"GRASP default · BsaI + BpiI + BsmBI\", \"BsaI (GGTCTC)\", \"BpiI / BbsI (GAAGAC)\", \"BsmBI / Esp3I (CGTCTC)\", \"None (no enzyme filter)\"]\n",
"ligation_table = \"T4 · 18 h · 25 °C (Potapov)\" #@param [\"T4 · 18 h · 25 °C (Potapov)\", \"T4 · 18 h · 37 °C (Potapov)\", \"T4 · 1 h · 25 °C (Potapov)\", \"BsaI-HFv2 · constant 37 °C\", \"BsmBI-v2 · constant 42 °C\"]\n",
"optimize_depth = 2000 #@param {type:\"integer\"}\n",
"n_fragments = 0 #@param {type:\"integer\"}\n",
"#@markdown `n_fragments = 0` means auto (from oligo length limits).\n",
"\n",
"from grasp_library import build_default_config, materialize_project\n",
"from grasp_library.colab_forms import apply_form_settings\n",
"from grasp_library import notebook_ui as ui\n",
"\n",
"PROJECT_DIR = materialize_project()\n",
"INPUT_DIR = PROJECT_DIR / \"input\"\n",
"OUTPUT_ROOT = PROJECT_DIR / \"output\" / \"oneshot\"\n",
"OUTPUT_ROOT.mkdir(parents=True, exist_ok=True)\n",
"\n",
"CONFIG = build_default_config(INPUT_DIR)\n",
"CONFIG[\"project_name\"] = \"GRASP_oneshot_colab\"\n",
"\n",
"applied = apply_form_settings(\n",
" CONFIG,\n",
" organism=organism,\n",
" genetic_code=int(genetic_code),\n",
" target_rna=target_rna,\n",
" synthesis_vendor=synthesis_vendor,\n",
" assembly_enzyme=assembly_enzyme,\n",
" ligation_table=ligation_table,\n",
" optimize_depth=int(optimize_depth),\n",
" n_fragments=int(n_fragments) if int(n_fragments) > 0 else None,\n",
" overhang_redesign=False,\n",
")\n",
"CONFIG = applied[\"config\"]\n",
"CODON_DATA = applied[\"codon_data\"]\n",
"ONESHOT = None\n",
"\n",
"ui.status(\n",
" f\"Target <b>{CONFIG['target_rna']}</b> · organism <b>{organism}</b> · \"\n",
" f\"depth <b>{CONFIG['optimizer']['iterations_per_part']:,}</b> · \"\n",
" f\"vendor <b>{CONFIG['synthesis_vendor']}</b><br/>\"\n",
" f\"Project → <code>{PROJECT_DIR}</code>\"\n",
")\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"#@title 2 · Preview binder protein { display-mode: \"form\" }\n",
"\n",
"from grasp_library import describe_binder, suggest_fragment_count\n",
"from grasp_library import notebook_ui as ui\n",
"\n",
"info = describe_binder(CONFIG[\"target_rna\"])\n",
"n_auto = suggest_fragment_count(info[\"cds_length\"])\n",
"ui.status(\n",
" f\"<b>{info['target_rna']}</b> · PPR <code>{info['ppr_code']}</code> · \"\n",
" f\"<b>{info['aa_length']}</b> aa · <b>{info['cds_length']}</b> nt · \"\n",
" f\"auto fragments ≈ <b>{n_auto}</b>\"\n",
")\n",
"print(info[\"aa_sequence\"])\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"#@title 3 · Design oligos { display-mode: \"form\" }\n",
"#@markdown Re-run after changing settings. Files appear under `grasp_library_project/output/oneshot/`.\n",
"\n",
"RUN_ONESHOT = True #@param {type:\"boolean\"}\n",
"SEED = 42 #@param {type:\"integer\"}\n",
"\n",
"import random\n",
"import numpy as np\n",
"from IPython.display import display\n",
"from grasp_library import LigationFidelityCalculator, run_oneshot_design, sanitize_rna_name\n",
"from grasp_library import notebook_ui as ui\n",
"\n",
"random.seed(int(SEED))\n",
"np.random.seed(int(SEED))\n",
"\n",
"ONESHOT = None\n",
"if not RUN_ONESHOT:\n",
" ui.note(\"RUN_ONESHOT is off.\")\n",
"elif not CODON_DATA:\n",
" ui.note(\"Run the Settings cell first.\")\n",
"else:\n",
" rna = sanitize_rna_name(CONFIG[\"target_rna\"])\n",
" out_dir = OUTPUT_ROOT / rna\n",
" lig = CONFIG[\"ligation\"]\n",
" fidelity = LigationFidelityCalculator(\n",
" temperature=lig[\"temperature\"],\n",
" hours=lig[\"hours\"],\n",
" ligation_table=lig.get(\"ligation_table\"),\n",
" min_efficiency=lig.get(\"min_efficiency\", 0.25),\n",
" min_fidelity=lig.get(\"min_fidelity\", 0.9),\n",
" )\n",
" n_frag = CONFIG.get(\"oneshot_n_fragments\")\n",
" ONESHOT = run_oneshot_design(\n",
" target_rna=CONFIG[\"target_rna\"],\n",
" codon_data=CODON_DATA,\n",
" config=CONFIG,\n",
" output_dir=out_dir,\n",
" seed=int(SEED),\n",
" n_fragments=n_frag,\n",
" fidelity=fidelity,\n",
" log=print,\n",
" )\n",
" display(ONESHOT[\"gga_plan\"][\n",
" [\"fragment_id\", \"aa_start_0based\", \"aa_end_0based\", \"oh5\", \"oh3\", \"ligation_fidelity_set\"]\n",
" ])\n",
" cols = [c for c in [\n",
" \"fragment_id\", \"assembly_order\", \"oligo_length\", \"oligo_gc\",\n",
" \"qc_passed\", \"oligo_sequence_5to3\",\n",
" ] if c in ONESHOT[\"oligos\"].columns]\n",
" display(ONESHOT[\"oligos\"][cols])\n",
" asm = ONESHOT[\"assembled\"]\n",
" ui.status(\n",
" f\"Translation verified: <b>{asm['translation_verified']}</b> · \"\n",
" f\"ligation fidelity <b>{asm['ligation_fidelity']:.4f}</b> · \"\n",
" f\"oligos → <code>{ONESHOT['oligo_csv']}</code>\"\n",
" )\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"#@title 4 · Export Excel { display-mode: \"form\" }\n",
"\n",
"import pandas as pd\n",
"from grasp_library import notebook_ui as ui\n",
"\n",
"if ONESHOT is None:\n",
" ui.note(\"Run Design first.\")\n",
"else:\n",
" out = ONESHOT[\"output_dir\"]\n",
" xlsx = out / f\"oneshot_{ONESHOT['target_rna']}.xlsx\"\n",
" with pd.ExcelWriter(xlsx) as writer:\n",
" pd.DataFrame([ONESHOT[\"binder\"]]).to_excel(writer, sheet_name=\"binder\", index=False)\n",
" ONESHOT[\"gga_plan\"].to_excel(writer, sheet_name=\"gga_plan\", index=False)\n",
" ONESHOT[\"oligos\"].to_excel(writer, sheet_name=\"oligos\", index=False)\n",
" pd.DataFrame([ONESHOT[\"summary\"]]).to_excel(writer, sheet_name=\"summary\", index=False)\n",
" ui.status(f\"Wrote <code>{xlsx}</code>\")\n",
" if \"google.colab\" in __import__(\"sys\").modules:\n",
" from google.colab import files\n",
" files.download(str(xlsx))\n",
" for p in sorted(out.glob(\"*\")):\n",
" if p.is_file():\n",
" print(p.name)\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Notes\n",
"\n",
"| Step | What happens |\n",
"|---|---|\n",
"| Install | `pip install grasp-library-designer` from PyPI |\n",
"| RNA → protein | PPR code into GRASP repeat scaffold |\n",
"| Optimize | Full CDS codon + synthesis fitness |\n",
"| Cuts | Codon-aligned overhangs for ligation fidelity |\n",
"| Export | Flanked oligos for Golden Gate |\n",
"\n",
"For the **42-module combinatorial library**, open `grasp_library_designer.ipynb`.\n",
"\n",
"Package: https://pypi.org/project/grasp-library-designer/\n"
]
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment