290 lines
6.2 KiB
Plaintext
290 lines
6.2 KiB
Plaintext
{
|
|
"cells": [
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "913fbbd3",
|
|
"metadata": {},
|
|
"source": [
|
|
"# JSON"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 3,
|
|
"id": "e23193bb",
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"data": {
|
|
"application/vnd.jupyter.widget-view+json": {
|
|
"model_id": "4c030553429b482b8a3a0d24347f745c",
|
|
"version_major": 2,
|
|
"version_minor": 0
|
|
},
|
|
"text/plain": [
|
|
"Button(description='Output JSON', style=ButtonStyle())"
|
|
]
|
|
},
|
|
"metadata": {},
|
|
"output_type": "display_data"
|
|
},
|
|
{
|
|
"data": {
|
|
"application/vnd.jupyter.widget-view+json": {
|
|
"model_id": "31ece561ecab413f832f1d5033de4194",
|
|
"version_major": 2,
|
|
"version_minor": 0
|
|
},
|
|
"text/plain": [
|
|
"Output()"
|
|
]
|
|
},
|
|
"execution_count": 3,
|
|
"metadata": {},
|
|
"output_type": "execute_result"
|
|
}
|
|
],
|
|
"source": [
|
|
"from ipywidgets import Button, Output\n",
|
|
"from IPython import display\n",
|
|
"\n",
|
|
"button = Button(description='Output JSON')\n",
|
|
"output = Output()\n",
|
|
"obj = {\n",
|
|
" \"abcde\": 1234,\n",
|
|
" \"nested\": list(range(10))\n",
|
|
"}\n",
|
|
"\n",
|
|
"@output.capture()\n",
|
|
"def on_click(change):\n",
|
|
" display.display(display.JSON(obj))\n",
|
|
" \n",
|
|
" \n",
|
|
"button.on_click(on_click)\n",
|
|
"display.display(button)\n",
|
|
"output"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 4,
|
|
"id": "690bd908",
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"data": {
|
|
"application/json": {
|
|
"abcde": 1234,
|
|
"nested": [
|
|
0,
|
|
1,
|
|
2,
|
|
3,
|
|
4,
|
|
5,
|
|
6,
|
|
7,
|
|
8,
|
|
9
|
|
]
|
|
},
|
|
"text/plain": [
|
|
"<IPython.core.display.JSON object>"
|
|
]
|
|
},
|
|
"execution_count": 4,
|
|
"metadata": {
|
|
"application/json": {
|
|
"expanded": false,
|
|
"root": "root"
|
|
}
|
|
},
|
|
"output_type": "execute_result"
|
|
}
|
|
],
|
|
"source": [
|
|
"display.JSON(obj)"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "97caeade",
|
|
"metadata": {},
|
|
"source": [
|
|
"# Fasta"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 5,
|
|
"id": "27bbbb6c",
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"data": {
|
|
"application/vnd.jupyter.widget-view+json": {
|
|
"model_id": "60c37cb6500547cf81751809d825af34",
|
|
"version_major": 2,
|
|
"version_minor": 0
|
|
},
|
|
"text/plain": [
|
|
"Button(description='Output FASTA', style=ButtonStyle())"
|
|
]
|
|
},
|
|
"metadata": {},
|
|
"output_type": "display_data"
|
|
},
|
|
{
|
|
"data": {
|
|
"application/vnd.jupyter.widget-view+json": {
|
|
"model_id": "0cfaf056ab234c0c8c4ff914d8334efb",
|
|
"version_major": 2,
|
|
"version_minor": 0
|
|
},
|
|
"text/plain": [
|
|
"Output()"
|
|
]
|
|
},
|
|
"execution_count": 5,
|
|
"metadata": {},
|
|
"output_type": "execute_result"
|
|
}
|
|
],
|
|
"source": [
|
|
"fasta_button = Button(description='Output FASTA')\n",
|
|
"fasta_output = Output()\n",
|
|
"\n",
|
|
"\n",
|
|
"def Fasta(data=''):\n",
|
|
" bundle = {}\n",
|
|
" bundle['application/vnd.fasta.fasta'] = data\n",
|
|
" bundle['text/plain'] = data\n",
|
|
" display.display(bundle, raw=True)\n",
|
|
" \n",
|
|
" \n",
|
|
"@fasta_output.capture()\n",
|
|
"def on_click(change):\n",
|
|
" Fasta(\"\"\">SEQUENCE_1\n",
|
|
"MTEITAAMVKELRESTGAGMMDCKNALSETNGDFDKAVQLLREKGLGKAAKKADRLAAEG\n",
|
|
"LVSVKVSDDFTIAAMRPSYLSYEDLDMTFVENEYKALVAELEKENEERRRLKDPNKPEHK\n",
|
|
"IPQFASRKQLSDAILKEAEEKIKEELKAQGKPEKIWDNIIPGKMNSFIADNSQLDSKLTL\n",
|
|
"MGQFYVMDDKKTVEQVIAEKEKEFGGKIKIVEFICFEVGEGLEKKTEDFAAEVAAQL\n",
|
|
">SEQUENCE_2\n",
|
|
"SATVSEINSETDFVAKNDQFIALTKDTTAHIQSNSLQSVEELHSSTINGVKFEEYLKSQI\n",
|
|
"ATIGENLVVRRFATLKAGANGVVNGYIHTNGRVGVVIAAACDSAEVASKSRDLLRQICMH\"\"\")\n",
|
|
"\n",
|
|
"\n",
|
|
"fasta_button.on_click(on_click)\n",
|
|
"display.display(fasta_button)\n",
|
|
"fasta_output"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "a441bd16",
|
|
"metadata": {},
|
|
"source": [
|
|
"# GeoJSON"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 6,
|
|
"id": "31371b2f",
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"data": {
|
|
"application/vnd.jupyter.widget-view+json": {
|
|
"model_id": "093f167a6c8642ca9e9bc1cdda6e73d1",
|
|
"version_major": 2,
|
|
"version_minor": 0
|
|
},
|
|
"text/plain": [
|
|
"Button(description='Output GeoJSON', style=ButtonStyle())"
|
|
]
|
|
},
|
|
"metadata": {},
|
|
"output_type": "display_data"
|
|
},
|
|
{
|
|
"data": {
|
|
"application/vnd.jupyter.widget-view+json": {
|
|
"model_id": "d78a22c950e34fd48c514bddad9c444b",
|
|
"version_major": 2,
|
|
"version_minor": 0
|
|
},
|
|
"text/plain": [
|
|
"Output()"
|
|
]
|
|
},
|
|
"execution_count": 6,
|
|
"metadata": {},
|
|
"output_type": "execute_result"
|
|
}
|
|
],
|
|
"source": [
|
|
"from IPython.display import GeoJSON\n",
|
|
"\n",
|
|
"\n",
|
|
"geojson_button = Button(description='Output GeoJSON')\n",
|
|
"geojson_output = Output()\n",
|
|
"\n",
|
|
" \n",
|
|
"@geojson_output.capture()\n",
|
|
"def on_click(change):\n",
|
|
" obj = GeoJSON({\n",
|
|
" \"type\": \"Feature\",\n",
|
|
" \"geometry\": {\n",
|
|
" \"type\": \"Point\",\n",
|
|
" \"coordinates\": [-118.4563712, 34.0163116]\n",
|
|
" }\n",
|
|
" })\n",
|
|
" display.display(obj)\n",
|
|
" \n",
|
|
"\n",
|
|
"geojson_button.on_click(on_click)\n",
|
|
"display.display(geojson_button)\n",
|
|
"geojson_output"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "9c0381b4",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": []
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "4099a46a",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": []
|
|
}
|
|
],
|
|
"metadata": {
|
|
"kernelspec": {
|
|
"display_name": "Python 3 (ipykernel)",
|
|
"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.10.8"
|
|
}
|
|
},
|
|
"nbformat": 4,
|
|
"nbformat_minor": 5
|
|
}
|