bindview 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (142) hide show
  1. bindview-0.1.0/.gitignore +24 -0
  2. bindview-0.1.0/CHANGELOG.md +14 -0
  3. bindview-0.1.0/CITATION.cff +24 -0
  4. bindview-0.1.0/LICENSE +21 -0
  5. bindview-0.1.0/NOTICE +48 -0
  6. bindview-0.1.0/PKG-INFO +270 -0
  7. bindview-0.1.0/README.md +239 -0
  8. bindview-0.1.0/docs/api.md +606 -0
  9. bindview-0.1.0/docs/graph-schema.md +330 -0
  10. bindview-0.1.0/docs/images/absent.dark.svg +473 -0
  11. bindview-0.1.0/docs/images/absent.light.svg +473 -0
  12. bindview-0.1.0/docs/images/absent_faint.dark.svg +420 -0
  13. bindview-0.1.0/docs/images/absent_faint.light.svg +420 -0
  14. bindview-0.1.0/docs/images/arranged.dark.svg +418 -0
  15. bindview-0.1.0/docs/images/arranged.light.svg +418 -0
  16. bindview-0.1.0/docs/images/badges/licence.svg +1 -0
  17. bindview-0.1.0/docs/images/badges/numpy.svg +1 -0
  18. bindview-0.1.0/docs/images/badges/python.svg +1 -0
  19. bindview-0.1.0/docs/images/badges/rdkit.svg +1 -0
  20. bindview-0.1.0/docs/images/badges/version.svg +1 -0
  21. bindview-0.1.0/docs/images/basepairs.dark.svg +312 -0
  22. bindview-0.1.0/docs/images/basepairs.light.svg +312 -0
  23. bindview-0.1.0/docs/images/covalent.dark.svg +238 -0
  24. bindview-0.1.0/docs/images/covalent.light.svg +238 -0
  25. bindview-0.1.0/docs/images/detailed.dark.svg +418 -0
  26. bindview-0.1.0/docs/images/detailed.light.svg +418 -0
  27. bindview-0.1.0/docs/images/ensemble.dark.svg +634 -0
  28. bindview-0.1.0/docs/images/ensemble.light.svg +634 -0
  29. bindview-0.1.0/docs/images/mixed.dark.svg +365 -0
  30. bindview-0.1.0/docs/images/mixed.light.svg +365 -0
  31. bindview-0.1.0/docs/images/plddt_bonds.dark.svg +456 -0
  32. bindview-0.1.0/docs/images/plddt_bonds.light.svg +456 -0
  33. bindview-0.1.0/docs/images/plddt_lines.dark.svg +443 -0
  34. bindview-0.1.0/docs/images/plddt_lines.light.svg +443 -0
  35. bindview-0.1.0/docs/images/readme/basepairs.dark.svg +376 -0
  36. bindview-0.1.0/docs/images/readme/basepairs.light.svg +376 -0
  37. bindview-0.1.0/docs/images/readme/basepairs.live.svg +378 -0
  38. bindview-0.1.0/docs/images/readme/detailed.dark.svg +418 -0
  39. bindview-0.1.0/docs/images/readme/detailed.light.svg +418 -0
  40. bindview-0.1.0/docs/images/readme/detailed.live.svg +707 -0
  41. bindview-0.1.0/docs/images/readme/difference.dark.svg +504 -0
  42. bindview-0.1.0/docs/images/readme/difference.light.svg +504 -0
  43. bindview-0.1.0/docs/images/readme/difference.live.svg +506 -0
  44. bindview-0.1.0/docs/images/readme/enclosed.svg +464 -0
  45. bindview-0.1.0/docs/images/readme/groove.svg +1 -0
  46. bindview-0.1.0/docs/images/readme/ion.dark.svg +261 -0
  47. bindview-0.1.0/docs/images/readme/ion.light.svg +261 -0
  48. bindview-0.1.0/docs/images/readme/ion.live.svg +440 -0
  49. bindview-0.1.0/docs/images/readme/opened.svg +1 -0
  50. bindview-0.1.0/docs/images/readme/pae.dark.svg +186 -0
  51. bindview-0.1.0/docs/images/readme/pae.light.svg +186 -0
  52. bindview-0.1.0/docs/images/readme/pae.live.svg +204 -0
  53. bindview-0.1.0/docs/images/readme/plddt.dark.svg +258 -0
  54. bindview-0.1.0/docs/images/readme/plddt.light.svg +258 -0
  55. bindview-0.1.0/docs/images/readme/plddt.live.svg +276 -0
  56. bindview-0.1.0/docs/images/readme/regions.svg +1 -0
  57. bindview-0.1.0/docs/images/readme/rna.dark.svg +235 -0
  58. bindview-0.1.0/docs/images/readme/rna.light.svg +235 -0
  59. bindview-0.1.0/docs/images/readme/rna.live.svg +293 -0
  60. bindview-0.1.0/docs/images/readme/schematic.dark.svg +334 -0
  61. bindview-0.1.0/docs/images/readme/schematic.light.svg +334 -0
  62. bindview-0.1.0/docs/images/readme/schematic.live.svg +825 -0
  63. bindview-0.1.0/docs/images/readme/several.svg +1 -0
  64. bindview-0.1.0/docs/images/readme/trajectory.dark.svg +251 -0
  65. bindview-0.1.0/docs/images/readme/trajectory.light.svg +251 -0
  66. bindview-0.1.0/docs/images/readme/trajectory.live.svg +312 -0
  67. bindview-0.1.0/docs/images/readme/water.dark.svg +297 -0
  68. bindview-0.1.0/docs/images/readme/water.light.svg +297 -0
  69. bindview-0.1.0/docs/images/readme/water.live.svg +546 -0
  70. bindview-0.1.0/docs/images/rna.dark.svg +235 -0
  71. bindview-0.1.0/docs/images/rna.light.svg +235 -0
  72. bindview-0.1.0/docs/images/schematic.dark.svg +334 -0
  73. bindview-0.1.0/docs/images/schematic.light.svg +334 -0
  74. bindview-0.1.0/docs/images/water.dark.svg +297 -0
  75. bindview-0.1.0/docs/images/water.light.svg +297 -0
  76. bindview-0.1.0/docs/manual.md +545 -0
  77. bindview-0.1.0/docs/reference.md +781 -0
  78. bindview-0.1.0/pyproject.toml +82 -0
  79. bindview-0.1.0/src/bindview/__init__.py +88 -0
  80. bindview-0.1.0/src/bindview/__main__.py +6 -0
  81. bindview-0.1.0/src/bindview/align.py +493 -0
  82. bindview-0.1.0/src/bindview/arrange.js +347 -0
  83. bindview-0.1.0/src/bindview/arrange.py +248 -0
  84. bindview-0.1.0/src/bindview/backends.py +290 -0
  85. bindview-0.1.0/src/bindview/basepairs.py +1711 -0
  86. bindview-0.1.0/src/bindview/chains.py +264 -0
  87. bindview-0.1.0/src/bindview/chem.py +57 -0
  88. bindview-0.1.0/src/bindview/clearance.py +123 -0
  89. bindview-0.1.0/src/bindview/cli.py +990 -0
  90. bindview-0.1.0/src/bindview/compare.py +1854 -0
  91. bindview-0.1.0/src/bindview/confidence.py +531 -0
  92. bindview-0.1.0/src/bindview/consensus.py +303 -0
  93. bindview-0.1.0/src/bindview/covalent.py +220 -0
  94. bindview-0.1.0/src/bindview/depict.py +790 -0
  95. bindview-0.1.0/src/bindview/detect.py +378 -0
  96. bindview-0.1.0/src/bindview/diagram.py +1891 -0
  97. bindview-0.1.0/src/bindview/distance_table.py +589 -0
  98. bindview-0.1.0/src/bindview/ensemble.py +787 -0
  99. bindview-0.1.0/src/bindview/errors.py +47 -0
  100. bindview-0.1.0/src/bindview/exposure.py +207 -0
  101. bindview-0.1.0/src/bindview/features.py +179 -0
  102. bindview-0.1.0/src/bindview/fingerprint.py +469 -0
  103. bindview-0.1.0/src/bindview/fragments.py +304 -0
  104. bindview-0.1.0/src/bindview/geometry.py +482 -0
  105. bindview-0.1.0/src/bindview/graph.py +611 -0
  106. bindview-0.1.0/src/bindview/graphbuild.py +431 -0
  107. bindview-0.1.0/src/bindview/interactions.py +418 -0
  108. bindview-0.1.0/src/bindview/interactive.py +334 -0
  109. bindview-0.1.0/src/bindview/interface.py +1329 -0
  110. bindview-0.1.0/src/bindview/ions.py +155 -0
  111. bindview-0.1.0/src/bindview/layout/__init__.py +15 -0
  112. bindview-0.1.0/src/bindview/layout/body.py +421 -0
  113. bindview-0.1.0/src/bindview/layout/engine.py +1084 -0
  114. bindview-0.1.0/src/bindview/layout/field.py +261 -0
  115. bindview-0.1.0/src/bindview/ligand.py +583 -0
  116. bindview-0.1.0/src/bindview/near.py +67 -0
  117. bindview-0.1.0/src/bindview/options.py +92 -0
  118. bindview-0.1.0/src/bindview/pae.py +991 -0
  119. bindview-0.1.0/src/bindview/peptide.py +610 -0
  120. bindview-0.1.0/src/bindview/plane.py +320 -0
  121. bindview-0.1.0/src/bindview/polymer.py +678 -0
  122. bindview-0.1.0/src/bindview/py.typed +0 -0
  123. bindview-0.1.0/src/bindview/report.py +1407 -0
  124. bindview-0.1.0/src/bindview/residues.py +296 -0
  125. bindview-0.1.0/src/bindview/resolve.py +493 -0
  126. bindview-0.1.0/src/bindview/scene.py +239 -0
  127. bindview-0.1.0/src/bindview/solvent.py +254 -0
  128. bindview-0.1.0/src/bindview/structure.py +1145 -0
  129. bindview-0.1.0/src/bindview/styles/__init__.py +2 -0
  130. bindview-0.1.0/src/bindview/styles/absence.py +180 -0
  131. bindview-0.1.0/src/bindview/styles/base.py +2128 -0
  132. bindview-0.1.0/src/bindview/styles/closeup.py +146 -0
  133. bindview-0.1.0/src/bindview/styles/detailed.py +690 -0
  134. bindview-0.1.0/src/bindview/styles/ligand_draw.py +289 -0
  135. bindview-0.1.0/src/bindview/styles/mixed.py +70 -0
  136. bindview-0.1.0/src/bindview/styles/polymer_draw.py +354 -0
  137. bindview-0.1.0/src/bindview/styles/rings.py +75 -0
  138. bindview-0.1.0/src/bindview/styles/schematic.py +311 -0
  139. bindview-0.1.0/src/bindview/styles/summary.py +147 -0
  140. bindview-0.1.0/src/bindview/svg.py +310 -0
  141. bindview-0.1.0/src/bindview/textmetrics.py +64 -0
  142. bindview-0.1.0/src/bindview/theme.py +317 -0
@@ -0,0 +1,24 @@
1
+ __pycache__/
2
+ *.py[cod]
3
+ *.egg-info/
4
+ build/
5
+ dist/
6
+ .pytest_cache/
7
+ .mypy_cache/
8
+ .coverage
9
+ htmlcov/
10
+ .venv*/
11
+ .DS_Store
12
+
13
+ # Structures that are listed in the repository and fetched (scripts/fetch_structures.py); the lists are kept.
14
+ testdata/astex/
15
+ testdata/waters/*
16
+ !testdata/waters/manifest.json
17
+ testdata/ensemble/*/structure/
18
+
19
+ # Trajectories of a riboswitch and their contacts frame by frame (testdata/md/*/manifest.json names the source).
20
+ testdata/md/*/trajectory/
21
+ testdata/md/*/contacts/
22
+
23
+ # The pages that the sketches in prototype/ write.
24
+ prototype/*/*.html
@@ -0,0 +1,14 @@
1
+ # Changelog
2
+
3
+ ## 0.1.0 - 2026-11-26
4
+
5
+ bindview draws molecular interaction diagrams as SVG, from a structure file and a table of contacts ([manual](docs/manual.md)).
6
+
7
+ - A ligand in its pocket, in a detailed style (the atoms that make each contact) and a schematic one (residues as bubbles), or residue by residue in either. Every figure is checked for overlaps and for legible text on the page it is for; one that cannot be read is replaced by a table of its contacts that says why.
8
+ - Contacts from a table (tab, comma or semicolon between the fields), from PLIP where it is installed (optional, GPL-2.0, `bindview[plip]`), or from a plain table of heavy-atom distances that needs nothing else (`interactions="distances"`).
9
+ - Peptides and strands of RNA or DNA as ligands drawn as chains, ligands in RNA or DNA, covalent ligands, ions that bridge ligand and protein, and predicted water sites, marked as predicted.
10
+ - The interface of two chains (`Interface`), with the predicted aligned error of each contact (AlphaFold 3, Boltz, the AlphaFold database with its complexes) and ipSAE; a chain found by the UniProt accession its mmCIF file assigns it (`Structure.chain_of`); two strands of RNA or DNA and their base pairs (`BasePairs`).
11
+ - The confidence of a predicted model where the file declares it: pLDDT by line weight or in AlphaFold's colours, ipTM, PAE. The ligand's buried fraction.
12
+ - Several ligands of one pocket (`Comparison`: what differs, what they share, fingerprints as CSV) and several models of one complex (`Ensemble`: the share of the models that make each contact, all of them in one figure).
13
+ - The layout of a figure as a graph, written as JSON; that of a ligand diagram or of base pairs can be changed and drawn again (`render(graph=...)`, or by dragging in a browser with `Diagram.arrange()`). Figures that answer the pointer (`interactive=True`), light, dark or following the reader (`theme="auto"`), in two colour schemes (`colors="contrast"`).
14
+ - The command `bindview`: `render`, `interface`, `basepairs`, `compare`, `fingerprint` and `report`.
@@ -0,0 +1,24 @@
1
+ cff-version: 1.2.0
2
+ message: "If you use bindview, please cite it as below."
3
+ type: software
4
+ title: "bindview"
5
+ abstract: >-
6
+ Publication-quality figures of molecular interactions, as SVG: small molecules, peptides, RNA, DNA and
7
+ proteins, from one structure to an ensemble, with the atoms that make each contact and the confidence of the model.
8
+ authors:
9
+ - family-names: "Steuer"
10
+ given-names: "Jakob"
11
+ orcid: "https://orcid.org/0000-0003-3437-2075"
12
+ affiliation: >-
13
+ FHNW University of Applied Sciences and Arts Northwestern Switzerland, School of Life Sciences,
14
+ Institute for Chemistry and Bioanalytics, Data Science in Life Sciences
15
+ repository-code: "https://github.com/jakob-steuer/bindview"
16
+ version: "0.1.0"
17
+ date-released: "2026-11-26"
18
+ license: MIT
19
+ keywords:
20
+ - cheminformatics
21
+ - structural biology
22
+ - protein-ligand interactions
23
+ - interaction diagram
24
+ - SVG
bindview-0.1.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Jakob Steuer
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
bindview-0.1.0/NOTICE ADDED
@@ -0,0 +1,48 @@
1
+ bindview
2
+ Copyright (c) 2026 Jakob Steuer
3
+ Licence: MIT (see LICENSE)
4
+
5
+ This file names what the package and its repository hold of others' work.
6
+
7
+ In the package
8
+ --------------
9
+
10
+ Advance widths of Helvetica and Helvetica-Bold (src/bindview/textmetrics.py), from the font metrics of the
11
+ 14 PDF core fonts:
12
+
13
+ Copyright (c) 1985, 1987, 1989, 1990, 1997 Adobe Systems Incorporated. All Rights Reserved.
14
+
15
+ This file and the 14 PostScript(R) AFM files it accompanies may be used, copied, and distributed for any
16
+ purpose and without charge, with or without modification, provided that all copyright notices are retained;
17
+ that the AFM files are not distributed without this file; that all modifications to this file or any of the
18
+ AFM files are prominently noted in the modified file(s); and that this paragraph is not modified. Adobe
19
+ Systems has no responsibility or obligation to support the use of the AFM files.
20
+
21
+ The widths are held as a table of numbers; those of a few characters that the two fonts do not have (a pi, a
22
+ prime, an arrow, subscript digits) were added.
23
+
24
+ Residue templates (src/bindview/residues.py) follow the wwPDB Chemical Component Dictionary, which is in the
25
+ public domain (CC0 1.0).
26
+
27
+ In the repository, not in the package
28
+ -------------------------------------
29
+
30
+ Structures under testdata/ are entries of the RCSB Protein Data Bank, whose data are in the public domain
31
+ (CC0 1.0); each folder's meta.json names its entry. Berman et al., Nucleic Acids Res. 2000, 28, 235.
32
+
33
+ testdata/interface_pae: models and predicted aligned errors of the AlphaFold Protein Structure Database
34
+ (CC BY 4.0; Jumper et al., Nature 2021, 596, 583; Varadi et al., Nucleic Acids Res. 2024, 52, D368). The files
35
+ are the database's, packed. The domain borders are from The Encyclopedia of Domains (CC BY 4.0).
36
+
37
+ scripts/solvent_validation_set.tsv lists the Astex Diverse Set (Hartshorn et al., J. Med. Chem. 2007, 50, 726)
38
+ with the ligand of each entry as PoseBusters names it (Buttenschoen et al., Chem. Sci. 2024, 15, 3130).
39
+
40
+ testdata/nucleic/riboswitch_bisguanidine and testdata/md/riboswitch_bisguanidine: a frame and contact tables of
41
+ the molecular dynamics simulations of a guanidine-II riboswitch with a bivalent ligand by the author of bindview
42
+ (Steuer et al., NAR Genom. Bioinform. 2024, 6, lqae132; https://doi.org/10.1093/nargab/lqae132), taken from
43
+ https://github.com/jakob-steuer/FHNW-Summer-School-2025-MolSim-Analysis (MIT).
44
+
45
+ testdata/ensemble_bioemu2: samples of BioEmu 2 (Microsoft), whose code and checkpoint are under the MIT licence.
46
+
47
+ testdata/*/interactions.tsv were written by PLIP (Adasme et al., Nucleic Acids Res. 2021, 49, W530), which is
48
+ GPL-2.0 and not part of this repository.
@@ -0,0 +1,270 @@
1
+ Metadata-Version: 2.5
2
+ Name: bindview
3
+ Version: 0.1.0
4
+ Summary: Publication-quality figures of molecular interactions: small molecules, peptides, RNA, DNA and proteins, from one structure to an ensemble.
5
+ Project-URL: Homepage, https://github.com/jakob-steuer/bindview
6
+ Project-URL: Repository, https://github.com/jakob-steuer/bindview
7
+ Project-URL: Issues, https://github.com/jakob-steuer/bindview/issues
8
+ Project-URL: Changelog, https://github.com/jakob-steuer/bindview/blob/main/CHANGELOG.md
9
+ Author: Jakob Steuer
10
+ License-Expression: MIT
11
+ License-File: LICENSE
12
+ License-File: NOTICE
13
+ Keywords: cheminformatics,interaction-diagram,protein-ligand,structural-biology,svg
14
+ Classifier: Development Status :: 3 - Alpha
15
+ Classifier: Intended Audience :: Science/Research
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Programming Language :: Python :: 3 :: Only
18
+ Classifier: Programming Language :: Python :: 3.12
19
+ Classifier: Topic :: Scientific/Engineering :: Bio-Informatics
20
+ Classifier: Topic :: Scientific/Engineering :: Chemistry
21
+ Classifier: Typing :: Typed
22
+ Requires-Python: >=3.12
23
+ Requires-Dist: numpy>=2.0
24
+ Requires-Dist: rdkit>=2026.9.1
25
+ Provides-Extra: dev
26
+ Requires-Dist: mypy>=1.8; extra == 'dev'
27
+ Requires-Dist: pytest>=7; extra == 'dev'
28
+ Provides-Extra: plip
29
+ Requires-Dist: plip>=2.3; extra == 'plip'
30
+ Description-Content-Type: text/markdown
31
+
32
+ <h1 align="center">bindview</h1>
33
+
34
+ <p align="center">
35
+ <img src="https://raw.githubusercontent.com/jakob-steuer/bindview/main/docs/images/badges/version.svg" alt="version"> <img src="https://raw.githubusercontent.com/jakob-steuer/bindview/main/docs/images/badges/python.svg" alt="Python">
36
+ <img src="https://raw.githubusercontent.com/jakob-steuer/bindview/main/docs/images/badges/rdkit.svg" alt="RDKit"> <img src="https://raw.githubusercontent.com/jakob-steuer/bindview/main/docs/images/badges/numpy.svg" alt="NumPy">
37
+ <img src="https://raw.githubusercontent.com/jakob-steuer/bindview/main/docs/images/badges/licence.svg" alt="licence">
38
+ </p>
39
+
40
+ <p align="center">
41
+ <b>Publication-quality figures of molecular interactions:<br>small molecules, peptides, RNA, DNA and proteins, from one structure to an ensemble.</b><br>
42
+ A structure in, one SVG out. Python and command line.
43
+ </p>
44
+
45
+ <p align="center">
46
+ <a href="#install">Install</a> · <a href="#quick-start">Quick start</a> · <a href="#figures">Figures</a> ·
47
+ <a href="https://github.com/jakob-steuer/bindview/blob/main/docs/manual.md">Manual</a> · <a href="https://github.com/jakob-steuer/bindview/blob/main/docs/api.md">API</a> · <a href="https://github.com/jakob-steuer/bindview/blob/main/docs/reference.md">Reference</a>
48
+ </p>
49
+
50
+ - **Every contact ends on what makes it**: a halogen bond on its fluorine, stacking on the ring, a salt bridge at the charged group.
51
+ - **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.
52
+ - **Legible or refused**: nothing overlaps, and the smallest text is checked against the page you print on.
53
+ - **Yours to change**: every place, colour and setting; by its words, or by dragging in a browser.
54
+
55
+ ## Install
56
+
57
+ ```bash
58
+ git clone https://github.com/jakob-steuer/bindview && cd bindview
59
+ pip install . # RDKit and NumPy, nothing else
60
+ ```
61
+
62
+ Python 3.12 or newer, tested on 3.12 on macOS and Linux. Detecting contacts with [PLIP](https://github.com/pharmai/plip)
63
+ is optional and GPL-2.0 (`pip install ".[plip]"`). Without it, bindview makes a plain table of contacts itself, or
64
+ draws the one you give it.
65
+
66
+ ## Quick start
67
+
68
+ ```python
69
+ from bindview import Diagram
70
+
71
+ dia = Diagram.from_structure(
72
+ "testdata/egfr_osimertinib/model.cif.gz", ligand="YY3", # a residue name, "chain:number", or a peptide's chain
73
+ smiles="Cn1cc(c2c1cccc2)c3ccnc(n3)Nc4cc(c(cc4OC)N(C)CCN(C)C)NC(=O)C=C",
74
+ interactions="distances", # or a table, a list of records, or None to detect with PLIP
75
+ covalent=True) # the bond to Cys797 that the file declares
76
+ dia.render_svg("osimertinib.svg")
77
+ ```
78
+
79
+ The same from the command line:
80
+
81
+ ```bash
82
+ bindview render testdata/egfr_osimertinib/model.cif.gz --ligand YY3 --distances-only --covalent -o osimertinib.svg \
83
+ --smiles "Cn1cc(c2c1cccc2)c3ccnc(n3)Nc4cc(c(cc4OC)N(C)CCN(C)C)NC(=O)C=C"
84
+ ```
85
+
86
+ Not sure what is in a file? `bindview report testdata/kit_imatinib -o report.html` looks, draws every figure the input
87
+ has, and prints the call under each.
88
+
89
+ ## Figures
90
+
91
+ The code under each picture draws it from the root of the repository (here without its words: `bare=True`). A figure
92
+ of the library, opened by a click, answers the pointer. `case` reads a folder of [`testdata`](https://github.com/jakob-steuer/bindview/blob/main/testdata): a PDB entry,
93
+ its ligand's SMILES, and the contacts that PLIP found.
94
+
95
+ <!-- runs -->
96
+ ```python
97
+ import json, sys
98
+ from bindview import (BasePairs, Comparison, Diagram, Interface, Structure, read_rnapolis_pairs,
99
+ read_rnapolis_stacks, read_structure)
100
+ from bindview.distance_table import interface_contacts
101
+
102
+ def case(slug, model=None, interactions=None, **options):
103
+ folder = f"testdata/{slug}"
104
+ lig = json.load(open(f"{folder}/meta.json"))["ligand"]
105
+ return Diagram.from_structure(model or f"{folder}/model.cif.gz", lig["residue_name_in_cif"], lig["smiles"],
106
+ interactions or f"{folder}/interactions.tsv", name=lig["name"], **options)
107
+ ```
108
+
109
+ ### A ligand in its pocket
110
+
111
+ <table><tr>
112
+ <td width="50%" align="center" valign="top"><a href="https://github.com/jakob-steuer/bindview/blob/main/docs/images/readme/detailed.live.svg?raw=true"><picture><source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/jakob-steuer/bindview/main/docs/images/readme/detailed.dark.svg"><img src="https://raw.githubusercontent.com/jakob-steuer/bindview/main/docs/images/readme/detailed.light.svg" alt="imatinib in c-Kit, with the atoms that make the contacts"></picture></a><br><b>Detailed</b><br><sub>the atoms that make the contacts</sub></td>
113
+ <td width="50%" align="center" valign="top"><a href="https://github.com/jakob-steuer/bindview/blob/main/docs/images/readme/schematic.live.svg?raw=true"><picture><source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/jakob-steuer/bindview/main/docs/images/readme/schematic.dark.svg"><img src="https://raw.githubusercontent.com/jakob-steuer/bindview/main/docs/images/readme/schematic.light.svg" alt="the same with residues as bubbles"></picture></a><br><b>Schematic</b><br><sub>residues as bubbles, the pocket lined by its contacts</sub></td>
114
+ </tr></table>
115
+
116
+ <!-- draws: detailed schematic -->
117
+ ```python
118
+ kit = case("kit_imatinib") # imatinib in c-Kit (1T46)
119
+ kit.render()
120
+ kit.render(style="schematic")
121
+ ```
122
+
123
+ ### Confidence of a prediction
124
+
125
+ The repository holds no predicted complex with a ligand: these are two domains of an AlphaFold database model, with
126
+ its own pLDDT and predicted aligned error (PAE).
127
+
128
+ <table><tr>
129
+ <td width="50%" align="center" valign="top"><a href="https://github.com/jakob-steuer/bindview/blob/main/docs/images/readme/pae.live.svg?raw=true"><picture><source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/jakob-steuer/bindview/main/docs/images/readme/pae.dark.svg"><img src="https://raw.githubusercontent.com/jakob-steuer/bindview/main/docs/images/readme/pae.light.svg" alt="contacts between two domains, each with its PAE"></picture></a><br><b>PAE on the contacts</b><br><sub>written from 5 Å; pLDDT by line weight</sub></td>
130
+ <td width="50%" align="center" valign="top"><a href="https://github.com/jakob-steuer/bindview/blob/main/docs/images/readme/plddt.live.svg?raw=true"><picture><source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/jakob-steuer/bindview/main/docs/images/readme/plddt.dark.svg"><img src="https://raw.githubusercontent.com/jakob-steuer/bindview/main/docs/images/readme/plddt.light.svg" alt="the same with residues in the colours of pLDDT"></picture></a><br><b>pLDDT in AlphaFold's colours</b><br><sub>read only where the file declares it</sub></td>
131
+ </tr></table>
132
+
133
+ <!-- draws: pae plddt -->
134
+ ```python
135
+ afdb = "testdata/interface_pae/afdb_tectb" # beta-tectorin, cut between its domains
136
+ model = read_structure(f"{afdb}/model.cif.gz").split("A", {"N": (28, 124), "Z": (126, 269)})
137
+ domains = Interface(model, ["N-terminal domain=N", "ZP domain=Z"], interface_contacts(model, ["N"], ["Z"]),
138
+ pae=f"{afdb}/predicted_aligned_error.json.gz")
139
+ domains.render()
140
+ domains.render(plddt_colors=True)
141
+ ```
142
+
143
+ ### Waters and ions
144
+
145
+ <table><tr>
146
+ <td width="50%" align="center" valign="top"><a href="https://github.com/jakob-steuer/bindview/blob/main/docs/images/readme/water.live.svg?raw=true"><picture><source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/jakob-steuer/bindview/main/docs/images/readme/water.dark.svg"><img src="https://raw.githubusercontent.com/jakob-steuer/bindview/main/docs/images/readme/water.light.svg" alt="a steroid with a predicted water between ligand and protein"></picture></a><br><b>Predicted water</b><br><sub>marked as predicted, in a model without waters</sub></td>
147
+ <td width="50%" align="center" valign="top"><a href="https://github.com/jakob-steuer/bindview/blob/main/docs/images/readme/ion.live.svg?raw=true"><picture><source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/jakob-steuer/bindview/main/docs/images/readme/ion.dark.svg"><img src="https://raw.githubusercontent.com/jakob-steuer/bindview/main/docs/images/readme/ion.light.svg" alt="celecoxib held by a zinc ion and three histidines"></picture></a><br><b>An ion that bridges</b><br><sub>celecoxib on the zinc of carbonic anhydrase II</sub></td>
148
+ </tr></table>
149
+
150
+ <!-- draws: water ion -->
151
+ ```python
152
+ r1881 = read_structure("testdata/ar_r1881/model.cif.gz") # R1881 in the androgen receptor (2AO6)
153
+ dry = Structure([a for a in r1881.atoms if a.resname != "HOH"]) # its crystal waters taken out
154
+ case("ar_r1881", dry, "distances").render(solvent_sites=True)
155
+ case("ca2_celecoxib", ions=True).render() # 1OQ5
156
+ ```
157
+
158
+ ### The pocket in 3D
159
+
160
+ A sketch: [`prototype/ppi_openbook`](https://github.com/jakob-steuer/bindview/blob/main/prototype/ppi_openbook), not part of the package.
161
+
162
+ <table><tr>
163
+ <td width="50%" align="center" valign="top"><a href="https://github.com/jakob-steuer/bindview/blob/main/docs/images/readme/opened.svg"><img src="https://raw.githubusercontent.com/jakob-steuer/bindview/main/docs/images/readme/opened.svg" alt="c-Kit cut open along imatinib"></a><br><b>Opened like a book</b><br><sub>the ligand, both halves of the pocket, and a flat map</sub></td>
164
+ <td width="50%" align="center" valign="top"><a href="https://github.com/jakob-steuer/bindview/blob/main/docs/images/readme/enclosed.svg"><img src="https://raw.githubusercontent.com/jakob-steuer/bindview/main/docs/images/readme/enclosed.svg" alt="the pocket of R1881, cut through"></a><br><b>An enclosed ligand</b><br><sub>cut along its own plane</sub></td>
165
+ </tr></table>
166
+
167
+ <!-- draws: opened enclosed -->
168
+ ```python
169
+ sys.path.insert(0, "prototype/ppi_openbook")
170
+ import ligandbook, pocket
171
+
172
+ ligandbook.panels(kit)
173
+ pocket.figure(case("ar_r1881"))
174
+ ```
175
+
176
+ ### Several ligands
177
+
178
+ <table><tr>
179
+ <td width="50%" align="center" valign="top"><a href="https://github.com/jakob-steuer/bindview/blob/main/docs/images/readme/difference.live.svg?raw=true"><picture><source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/jakob-steuer/bindview/main/docs/images/readme/difference.dark.svg"><img src="https://raw.githubusercontent.com/jakob-steuer/bindview/main/docs/images/readme/difference.light.svg" alt="two ligands of the androgen receptor, compared residue by residue"></picture></a><br><b>What differs</b><br><sub>a steroid and bicalutamide on one frame of residues</sub></td>
180
+ <td width="50%" align="center" valign="top"><a href="https://github.com/jakob-steuer/bindview/blob/main/docs/images/readme/several.svg?raw=true"><img src="https://raw.githubusercontent.com/jakob-steuer/bindview/main/docs/images/readme/several.svg" alt="three steroids in one pocket as sticks"></a><br><b>In 3D (a sketch)</b><br><sub>three corticosteroids in one pocket, and what they share</sub></td>
181
+ </tr></table>
182
+
183
+ <!-- draws: difference several -->
184
+ ```python
185
+ Comparison([case("ar_r1881"), case("ar_bicalutamide")]).render(view="difference")
186
+
187
+ import interact3d
188
+ interact3d.several([case(s) for s in ("gr_dexamethasone", "gr_mometasone", "gr_budesonide")])
189
+ ```
190
+
191
+ ### A trajectory
192
+
193
+ <table><tr>
194
+ <td width="50%" align="center" valign="top"><a href="https://github.com/jakob-steuer/bindview/blob/main/docs/images/readme/trajectory.live.svg?raw=true"><picture><source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/jakob-steuer/bindview/main/docs/images/readme/trajectory.dark.svg"><img src="https://raw.githubusercontent.com/jakob-steuer/bindview/main/docs/images/readme/trajectory.light.svg" alt="a ligand in RNA with the share of the frames on every contact"></picture></a><br><b>One frame, with the shares of all</b><br><sub>each contact with the share of 4,001 frames that make it</sub></td>
195
+ </tr></table>
196
+
197
+ <!-- draws: trajectory -->
198
+ ```python
199
+ sys.path.insert(0, "prototype/md_occupancy") # bindview reads no trajectory: a sketch counts the contacts
200
+ import occupancy
201
+
202
+ md = occupancy.load("testdata/md/riboswitch_bisguanidine/simulation_1.json")
203
+ frames = md.state("all")
204
+ Diagram.from_structure(frames.frame, "BGD", md.smiles, frames.records, ensemble=frames.of).render()
205
+ ```
206
+
207
+ ### RNA and DNA
208
+
209
+ <table><tr>
210
+ <td width="50%" align="center" valign="top"><a href="https://github.com/jakob-steuer/bindview/blob/main/docs/images/readme/rna.live.svg?raw=true"><picture><source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/jakob-steuer/bindview/main/docs/images/readme/rna.dark.svg"><img src="https://raw.githubusercontent.com/jakob-steuer/bindview/main/docs/images/readme/rna.light.svg" alt="a ligand in a riboswitch, with bases and phosphates"></picture></a><br><b>A ligand in RNA</b><br><sub>a riboswitch, down to its bases</sub></td>
211
+ <td width="50%" align="center" valign="top"><a href="https://github.com/jakob-steuer/bindview/blob/main/docs/images/readme/basepairs.live.svg?raw=true"><picture><source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/jakob-steuer/bindview/main/docs/images/readme/basepairs.dark.svg"><img src="https://raw.githubusercontent.com/jakob-steuer/bindview/main/docs/images/readme/basepairs.light.svg" alt="two RNA hairpins with the ligand between them"></picture></a><br><b>Base pairs</b><br><sub>two hairpins, and the ligand between their loops</sub></td>
212
+ </tr></table>
213
+
214
+ <!-- draws: rna basepairs -->
215
+ ```python
216
+ folder = "testdata/nucleic/riboswitch_bisguanidine"
217
+ model = read_structure(f"{folder}/model.pdb")
218
+ smiles = json.load(open(f"{folder}/meta.json"))["ligand"]["smiles"]
219
+ Diagram.from_structure(model, "BGD", smiles, f"{folder}/interactions.tsv").render()
220
+
221
+ found = f"{folder}/basepairs.rnapolis.json"
222
+ BasePairs(model, ["A", "B"], read_rnapolis_pairs(found), stacks=read_rnapolis_stacks(found),
223
+ contacts=interface_contacts(model, ["A"], ["B"], stacking=True),
224
+ ligand="BGD", ligand_contacts=f"{folder}/interactions.tsv").render()
225
+ ```
226
+
227
+ ### Peptides and proteins
228
+
229
+ Sketches. The package itself draws a peptide as a chain of its residues, and two chains with `Interface`.
230
+
231
+ <table><tr>
232
+ <td width="50%" align="center" valign="top"><a href="https://github.com/jakob-steuer/bindview/blob/main/docs/images/readme/groove.svg"><img src="https://raw.githubusercontent.com/jakob-steuer/bindview/main/docs/images/readme/groove.svg" alt="a peptide in the groove of HLA-A2, opened"></a><br><b>A peptide in its groove</b><br><sub>HLA-A2 with a nonamer (3MRE), opened like a book</sub></td>
233
+ <td width="50%" align="center" valign="top"><a href="https://github.com/jakob-steuer/bindview/blob/main/docs/images/readme/regions.svg"><img src="https://raw.githubusercontent.com/jakob-steuer/bindview/main/docs/images/readme/regions.svg" alt="an antibody on lysozyme, the interface in regions"></a><br><b>An interface in regions</b><br><sub>HyHEL-10 on lysozyme (3D9A), and how its regions are found</sub></td>
234
+ </tr></table>
235
+
236
+ <!-- draws: groove regions -->
237
+ ```python
238
+ import book, openbook, regions
239
+
240
+ openbook.panels(book.load("testdata/mhc_peptide/model.cif.gz", ["A"], ["P"], names=("HLA-A2", "peptide GLCTLVAML")))
241
+ regions.figure(book.load("testdata/fab_lysozyme/model.cif.gz", ["H", "L"], ["C"], names=("HyHEL-10 Fab", "lysozyme")))
242
+ ```
243
+
244
+ Also in the manual: [arranging by hand](https://github.com/jakob-steuer/bindview/blob/main/docs/manual.md#arranging-by-hand) (`dia.arrange()`),
245
+ [residues a shorter construct lacks](https://github.com/jakob-steuer/bindview/blob/main/docs/manual.md#residues-an-isoform-lacks),
246
+ [ensembles of models](https://github.com/jakob-steuer/bindview/blob/main/docs/manual.md#several-models), [a page that drives its figures](https://github.com/jakob-steuer/bindview/blob/main/docs/manual.md#figures-in-a-web-page),
247
+ [dark mode](https://github.com/jakob-steuer/bindview/blob/main/docs/manual.md#colours-and-themes), [fingerprints as CSV](https://github.com/jakob-steuer/bindview/blob/main/docs/manual.md#several-ligands).
248
+
249
+ ## Where to look
250
+
251
+ | I want to … | |
252
+ |---|---|
253
+ | draw my first figure, pass in contacts, change its look | [Manual](https://github.com/jakob-steuer/bindview/blob/main/docs/manual.md) |
254
+ | see every option and what it does | [API](https://github.com/jakob-steuer/bindview/blob/main/docs/api.md), or `bindview.options()` in Python |
255
+ | know the rules, the thresholds and the limits | [Reference](https://github.com/jakob-steuer/bindview/blob/main/docs/reference.md) |
256
+ | read or write a figure's layout as JSON | [Graph schema](https://github.com/jakob-steuer/bindview/blob/main/docs/graph-schema.md) |
257
+ | draw from the command line | `bindview --help`, `bindview render --help` |
258
+
259
+ ## Good to know
260
+
261
+ - Give the **SMILES** where you can: coordinates alone do not say which bond is double.
262
+ - A figure shows **what the model has**. It cannot know of a missing cofactor, partner chain or water.
263
+ - bindview computes **no score**. Thin lines mean weak support, not weak binding.
264
+ - `result.status` says how it went (`ok`, `empty`, `degraded`, `unreadable`) and `result.warnings` why, in words.
265
+
266
+ ## Licence and citation
267
+
268
+ MIT ([LICENSE](https://github.com/jakob-steuer/bindview/blob/main/LICENSE)). The core imports RDKit and NumPy (both BSD) and nothing else; one module imports PLIP, when
269
+ asked to. The test data are open: each folder says where it is from, and [NOTICE](https://github.com/jakob-steuer/bindview/blob/main/NOTICE) names the work of others
270
+ in the repository. Cite with [CITATION.cff](https://github.com/jakob-steuer/bindview/blob/main/CITATION.cff). Changes: [CHANGELOG.md](https://github.com/jakob-steuer/bindview/blob/main/CHANGELOG.md).