Publication-quality figures of molecular interactions:
small molecules, peptides, RNA, DNA and proteins, from one structure to an ensemble.
A structure in, one SVG out. Python and command line.
Install · Quick start · Figures · Getting started · Manual · API · Reference
- Every contact ends on what makes it: a halogen bond on its fluorine, stacking on the ring, a salt bridge at the charged group.
- Honest about the model: pLDDT, PAE and shares of an ensemble are drawn into the figure, or stay out when the file does not declare them.
- Legible or refused: nothing overlaps, and the smallest text is checked against the page you print on.
- Yours to change: every place, colour and setting; by its words, or by dragging in a browser.
pip install bindviewNeeds Python 3.12 or newer, on macOS or Linux; RDKit and NumPy come with it. Detecting contacts with
PLIP is optional (GPL-2.0): pip install "bindview[plip]". Without PLIP, bindview
finds contacts from distances, or draws a table of contacts you give it.
Fetch an entry from the PDB and draw its ligand. You need the file, the ligand's residue name and its SMILES:
from urllib.request import urlretrieve
from bindview import Diagram
urlretrieve("https://files.rcsb.org/download/1T46.cif.gz", "1T46.cif.gz") # c-Kit with imatinib
dia = Diagram.from_structure("1T46.cif.gz", ligand="STI", interactions="distances",
smiles="Cc1ccc(cc1Nc2nccc(n2)c3cccnc3)NC(=O)c4ccc(cc4)CN5CCN(CC5)C")
dia.render_svg("imatinib.svg")Or from the command line, on the same file:
bindview render 1T46.cif.gz --ligand STI --distances-only -o imatinib.svg \
--smiles "Cc1ccc(cc1Nc2nccc(n2)c3cccnc3)NC(=O)c4ccc(cc4)CN5CCN(CC5)C"Getting started continues from here in five short steps, each with its picture. To see
what a file of your own holds, run bindview report model.cif -o report.html: it draws every figure it can, each
with the code that draws it.
Each picture is drawn by the code under it, run from the root of a clone of this repository
(git clone https://github.com/jakob-steuer/bindview), without the text around the figure (bare=True). Click a
picture to open it; most then respond to the pointer. case() loads a folder of testdata: a PDB entry,
its ligand's SMILES and the contacts PLIP found.
import json, sys
from bindview import (BasePairs, Comparison, Diagram, Ensemble, Interface, Structure, read_models,
read_rnapolis_pairs, read_rnapolis_stacks, read_structure)
from bindview.distance_table import interface_contacts
def case(slug, model=None, interactions=None, **options):
folder = f"testdata/{slug}"
lig = json.load(open(f"{folder}/meta.json"))["ligand"]
return Diagram.from_structure(model or f"{folder}/model.cif.gz", lig["residue_name_in_cif"], lig["smiles"],
interactions or f"{folder}/interactions.tsv", name=lig["name"], **options)Detailed the atoms that make the contacts |
Schematic residues as bubbles, the pocket lined by its contacts |
kit = case("kit_imatinib") # imatinib in c-Kit (1T46)
kit.render()
kit.render(style="schematic")On the left, imatinib in c-Kit as Boltz-2 predicts it; on the right, two domains of an AlphaFold database model. The manual shows the other ways to draw pLDDT and PAE.
pLDDT as a glow Boltz-2's model of 1T46: every atom at 90 or more |
ipSAE on the opened interface two domains the model places with confidence |
boltz = case("kit_imatinib", "testdata/kit_imatinib_boltz2/model.cif.gz", "distances") # 1T46 by Boltz-2
boltz.render(plddt_colors=True)
fah = "testdata/interface_pae/afdb_fah" # fumarylacetoacetase, cut between its domains
model = read_structure(f"{fah}/model.cif.gz").split("A", {"N": (18, 115), "C": (123, 412)})
domains = Interface(model, ["N-terminal domain=N", "catalytic domain=C"], interface_contacts(model, ["N"], ["C"]),
pae=f"{fah}/predicted_aligned_error.json.gz", ipsae=True)
domains.book(colour="ipsae")Predicted water marked as predicted, in a model without waters |
An ion that bridges celecoxib on the zinc of carbonic anhydrase II |
r1881 = read_structure("testdata/ar_r1881/model.cif.gz") # R1881 in the androgen receptor (2AO6)
dry = Structure([a for a in r1881.atoms if a.resname != "HOH"]) # its crystal waters taken out
case("ar_r1881", dry, "distances").render(solvent_sites=True)
case("ca2_celecoxib", ions=True).render() # 1OQ5Opened like a book the ligand, both halves of the pocket, and a flat map |
An enclosed ligand cut along its own plane |
kit.book() # Interface.book() opens two proteins the same way
case("ar_r1881").pocket() # Diagram.sticks(): the contacts as sticks, under the diagramWhat differs a steroid and bicalutamide on one frame of residues |
In 3D (a sketch) three corticosteroids in one pocket, and what they share |
Comparison([case("ar_r1881"), case("ar_bicalutamide")]).render(view="difference")
sys.path.insert(0, "prototype/ppi_openbook") # a sketch, not part of the package
import interact3d
interact3d.several([case(s) for s in ("gr_dexamethasone", "gr_mometasone", "gr_budesonide")])Samples of a prediction 20 of BioEmu 2, each ring the share that touches its residue |
One frame, with the shares of all each contact with the share of 4,001 frames that make it |
ap5a = ("Nc1ncnc2n(cnc12)[C@@H]3O[C@H](COP(O)(=O)OP(O)(=O)OP(O)(=O)OP(O)(=O)OP(O)(=O)OC[C@H]4O[C@H]([C@H](O)"
"[C@@H]4O)n5cnc6c(N)ncnc56)[C@@H](O)[C@H]3O")
samples = read_models("testdata/ensemble_bioemu2/ake_ap5a.pdb.gz") # adenylate kinase with AP5A
Ensemble.from_structures(samples, "AP5", ap5a, "distances", ensemble="20 samples of BioEmu 2").consensus().render()
sys.path.insert(0, "prototype/md_occupancy") # bindview reads no trajectory: a sketch counts the contacts
import occupancy
md = occupancy.load("testdata/md/riboswitch_bisguanidine/simulation_1.json")
frames = md.state("all")
Diagram.from_structure(frames.frame, "BGD", md.smiles, frames.records, ensemble=frames.of).render()A ligand in RNA a riboswitch, down to its bases |
Base pairs two hairpins, and the ligand between their loops |
folder = "testdata/nucleic/riboswitch_bisguanidine"
model = read_structure(f"{folder}/model.pdb")
smiles = json.load(open(f"{folder}/meta.json"))["ligand"]["smiles"]
Diagram.from_structure(model, "BGD", smiles, f"{folder}/interactions.tsv").render()
found = f"{folder}/basepairs.rnapolis.json"
BasePairs(model, ["A", "B"], read_rnapolis_pairs(found), stacks=read_rnapolis_stacks(found),
contacts=interface_contacts(model, ["A"], ["B"], stacking=True),
ligand="BGD", ligand_contacts=f"{folder}/interactions.tsv").render()Interface.book() opens two chains like a book. The second picture, how an interface falls into regions, is a sketch.
A peptide in its groove HLA-A2 with a nonamer (3MRE), opened like a book |
An interface in regions HyHEL-10 on lysozyme (3D9A), and how its regions are found |
mhc = read_structure("testdata/mhc_peptide/model.cif.gz")
Interface(mhc, ["HLA-A2=A", "peptide GLCTLVAML=P"], interface_contacts(mhc, ["A"], ["P"])).book()
import book, regions # the sketch, in prototype/ppi_openbook
regions.figure(book.load("testdata/fab_lysozyme/model.cif.gz", ["H", "L"], ["C"], names=("HyHEL-10 Fab", "lysozyme")))| I want to … | |
|---|---|
| draw my first figure, step by step | Getting started |
| do one task: contacts, predictions, interfaces, variants, ensembles, RNA, 3D, the look | Manual |
| see every option and what it does | API, or bindview.options() in Python |
| know the rules, the thresholds and the limits | Reference |
| read or write a figure's layout as JSON | Graph schema |
| draw from the command line | bindview --help, bindview render --help |
- Give the SMILES where you can: coordinates alone do not say which bond is double.
- A figure shows what the model has. It cannot know of a missing cofactor, partner chain or water.
- bindview computes no score. Thin lines mean weak support, not weak binding.
result.statussays how it went (ok,empty,degraded,unreadable) andresult.warningswhy, in words.
MIT (LICENSE). The core needs only RDKit, NumPy (both BSD) and Pillow (MIT-CMU); PLIP (GPL-2.0) is imported only when you ask for it. The test data are open, and NOTICE names their sources. Cite bindview by its DOI, 10.5281/zenodo.24568132, or with CITATION.cff. Changes: CHANGELOG.md.