Skip to main content

Jupyter UI extensions for drug discovery visualization - ADMET, 3D complex viewer, SMILES drawing

Project description

refua-notebook

Jupyter UI extensions for drug discovery visualization. This package provides inline notebook widgets for displaying ADMET properties, 3D molecular structures, and SMILES drawings from Refua objects. It also includes an IPython extension that automatically registers rich HTML representations for Refua objects.

Features

  • IPython Extension: Automatic widget display for Refua SM, Protein, Complex, and FoldResult objects
  • Rich Visualization: 2D structures, 3D Mol* views, and property summaries rendered directly from Refua objects

Installation

pip install refua-notebook

Or with Poetry:

poetry add refua-notebook

refua-notebook depends on Refua directly, so installing this package will also install refua.

Quick Start

Automatic Widget Display (IPython Extension)

The easiest way to use refua-notebook is to load it as an IPython extension. This automatically registers rich HTML representations for Refua objects:

# Option 1: Load as IPython extension
%load_ext refua_notebook

# Option 2: Activate programmatically
import refua_notebook
refua_notebook.activate()

# Now Refua objects display automatically as widgets!
from refua import SM, Protein, Complex

# Proteins show sequence info (and 3D structure if folded)
Protein("MKTAYIAKQRQISFVKSHFSRQLEERLGLIEVQ", ids="A")

# Folded complexes show a tabbed view with 3D structure, affinity, and molecule details
complex = Complex([
    Protein("MKTAYIAKQRQISFVKSHFSRQLEERLGLIEVQ", ids="A"),
    SM("CCO"),
]).request_affinity()
result = complex.fold()
complex  # Shows 3D structure with binding affinity (uses complex.last_fold)

Displaying the Refua objects directly is enough; the extension handles rich HTML rendering automatically.

JupyterLab Renderer (Required for JupyterLab)

JupyterLab blocks inline scripts, so the package ships a prebuilt JupyterLab renderer that loads Mol* and SmilesDrawer locally and renders the application/vnd.refua+json MIME output. With recent JupyterLab versions, no jupyter labextension install or jupyter lab build step is required—installing the Python package is enough.

To rebuild the prebuilt labextension (requires network access for npm packages):

cd labextension
yarn install
yarn build:prod

Refua Integration

refua-notebook is built on top of the Refua drug discovery toolkit:

from refua import Complex, Protein, SM

# Fold a protein-ligand complex
complex = Complex([
    Protein("MKTAYIAKQRQISFVKSHFSRQLEERLGLIEVQ", ids="A"),
    SM("CCO"),
]).request_affinity()
result = complex.fold()

# Display the Refua objects directly
complex
result.affinity

Examples

The examples/ directory includes runnable notebooks:

  • refua_folding.ipynb
  • refua_antibody_design.ipynb
  • refua_peptide_design_mdm2.ipynb
  • refua_peptide_design_glp1r.ipynb
  • refua_peptide_design_integrin_avb3.ipynb

Rebuild all examples (executes and writes outputs in-place):

poetry run jupyter nbconvert --execute --to notebook --inplace examples/*.ipynb

API Reference

Extension Functions

# Load extension (in notebook)
%load_ext refua_notebook

# Programmatic activation
import refua_notebook
refua_notebook.activate()     # Enable automatic widget display
refua_notebook.deactivate()   # Disable automatic widget display
refua_notebook.is_active()    # Check if extension is active

Development

# Clone the repository
git clone <your-repo-url>
cd refua-notebook

# Install dependencies
poetry install

# Run tests
poetry run pytest

# Optional browser-level JupyterLab widget test
poetry run playwright install chromium
REFUA_JLAB_PLAYWRIGHT=1 poetry run pytest tests/test_jupyterlab_playwright.py

# Format code
poetry run black refua_notebook tests

License

MIT License

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

refua_notebook-0.7.0.tar.gz (2.3 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

refua_notebook-0.7.0-py3-none-any.whl (1.6 MB view details)

Uploaded Python 3

File details

Details for the file refua_notebook-0.7.0.tar.gz.

File metadata

  • Download URL: refua_notebook-0.7.0.tar.gz
  • Upload date:
  • Size: 2.3 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.3.2 CPython/3.14.3 Darwin/25.3.0

File hashes

Hashes for refua_notebook-0.7.0.tar.gz
Algorithm Hash digest
SHA256 4e939577d123ef68d2f823389dafd0f2ff22814790e7303bc4bac0e981832495
MD5 5a1eadcde86b77d27d61af5cf3b809bf
BLAKE2b-256 fef17ffd643c72c57d3d79e047b8712b0ccbd1c16bc1a56cb09b3ae80dde5418

See more details on using hashes here.

File details

Details for the file refua_notebook-0.7.0-py3-none-any.whl.

File metadata

  • Download URL: refua_notebook-0.7.0-py3-none-any.whl
  • Upload date:
  • Size: 1.6 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.3.2 CPython/3.14.3 Darwin/25.3.0

File hashes

Hashes for refua_notebook-0.7.0-py3-none-any.whl
Algorithm Hash digest
SHA256 412b2720e9c9ca4b28bd8a7097b3556673a0be93962d3af813386f3217e9a50e
MD5 3257612c5535209565cc010ce53b599c
BLAKE2b-256 f7cc84133e2b9620c9946fbacc6c47b68aee68b6111e64698efa1160aa0d0691

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page