Skip to content

Commit

Permalink
update local data examples
Browse files Browse the repository at this point in the history
  • Loading branch information
Jhsmit committed Apr 25, 2024
1 parent cfc5b7e commit 5ce362d
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 63 deletions.
23 changes: 23 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,29 @@ view = PDBeMolstar(molecule_id='1qyn', theme='light', hide_water=True)
view
```

Loading local data, hiding the buttons:

```python
from pathlib import Path
fpth = Path().resolve() / 'assets' / '6vsb.bcif'
custom_data = {
'data': fpth.read_bytes(),
'format': 'cif',
'binary': True,
}
view = PDBeMolstar(
custom_data=custom_data,
hide_controls_icon=True,
hide_expand_icon=True,
hide_settings_icon=True,
hide_selection_icon=True,
hide_animation_icon=True,
hide_water=True,
hide_carbs=True,
)
view
```

See the example notebook for more advanced usage.

## Cite
Expand Down
Binary file added assets/6vsb.bcif
Binary file not shown.
18 changes: 14 additions & 4 deletions example.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"metadata": {
"scrolled": true
},
"outputs": [],
"source": [
"view = PDBeMolstar(\n",
Expand All @@ -32,10 +34,18 @@
"outputs": [],
"source": [
"# load local files via custom_data\n",
"from pathlib import Path \n",
"fpth = Path().resolve() / 'assets' / '6vsb.bcif'\n",
"custom_data = {\n",
" 'url': 'http://localhost:8888/files/assets/1qyn.pdb',\n",
" 'format': 'pdb'}\n",
"view = PDBeMolstar(custom_data=custom_data)\n",
" 'data': fpth.read_bytes(),\n",
" 'format': 'cif',\n",
" 'binary': True,\n",
" }\n",
"view = PDBeMolstar(\n",
" custom_data=custom_data, \n",
" hide_water=True,\n",
" hide_carbs=True,\n",
")\n",
"view"
]
},
Expand Down
89 changes: 30 additions & 59 deletions tests/test_notebook.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -29,25 +29,9 @@
},
{
"cell_type": "code",
"execution_count": 16,
"execution_count": null,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "c716fd207a7642c3a8148d6429c0f456",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"VBox(children=(PDBeMolstar(bg_color='#F7F7F7', height='200px', molecule_id='1qyn'), PDBeMolstar(bg_color='#F7F…"
]
},
"execution_count": 16,
"metadata": {},
"output_type": "execute_result"
}
],
"outputs": [],
"source": [
"\n",
"v1 = PDBeMolstar(molecule_id='1qyn', height=\"200px\")\n",
Expand All @@ -65,33 +49,17 @@
},
{
"cell_type": "code",
"execution_count": 27,
"execution_count": null,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "f20a9b627be1495a8680c6deb41aecfc",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"PDBeMolstar(bg_color='#F7F7F7', height='150px', molecule_id='1qyn')"
]
},
"execution_count": 27,
"metadata": {},
"output_type": "execute_result"
}
],
"outputs": [],
"source": [
"v = PDBeMolstar(molecule_id='1qyn', height='150px')\n",
"v"
]
},
{
"cell_type": "code",
"execution_count": 28,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -108,25 +76,9 @@
},
{
"cell_type": "code",
"execution_count": 34,
"execution_count": null,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "81d95973cf31465eac4767d2043a203f",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"PDBeMolstar(bg_color='#F7F7F7', custom_data={'url': 'https://www.ebi.ac.uk/pdbe/model-server/v1/1cbs/atoms?lab…"
]
},
"execution_count": 34,
"metadata": {},
"output_type": "execute_result"
}
],
"outputs": [],
"source": [
"custom_data = dict(url='https://www.ebi.ac.uk/pdbe/model-server/v1/1cbs/atoms?label_entity_id=1&auth_asym_id=A&encoding=bcif', format='cif', binary=True)\n",
"v = PDBeMolstar(custom_data=custom_data, height='150px')\n",
Expand All @@ -135,20 +87,39 @@
},
{
"cell_type": "code",
"execution_count": 35,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"new_custom_data = dict(url='https://www.ebi.ac.uk/pdbe/model-server/v1/1qyn/atoms?label_entity_id=1&auth_asym_id=A&encoding=bcif', format='cif', binary=True)\n",
"v.cumstom_data = new_custom_data"
"v.custom_data = new_custom_data"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
"source": [
"from pathlib import Path \n",
"fpth = Path().resolve().parent / 'assets' / '6vsb.bcif'\n",
"custom_data = {\n",
" 'data': fpth.read_bytes(),\n",
" 'format': 'cif',\n",
" 'binary': True,\n",
" }\n",
"view = PDBeMolstar(\n",
" custom_data=custom_data, \n",
" hide_controls_icon=True, \n",
" hide_expand_icon=True, \n",
" hide_settings_icon=True, \n",
" hide_selection_icon=True, \n",
" hide_animation_icon=True,\n",
" hide_water=True,\n",
" hide_carbs=True,\n",
")\n",
"view"
]
}
],
"metadata": {
Expand Down

0 comments on commit 5ce362d

Please sign in to comment.