molscope 0.8.1__tar.gz → 0.8.2__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 (157) hide show
  1. {molscope-0.8.1 → molscope-0.8.2}/CITATION.cff +2 -2
  2. {molscope-0.8.1 → molscope-0.8.2}/MANIFEST.in +2 -0
  3. {molscope-0.8.1/molscope.egg-info → molscope-0.8.2}/PKG-INFO +158 -64
  4. {molscope-0.8.1 → molscope-0.8.2}/README.md +152 -61
  5. molscope-0.8.2/docs/api-reference.md +53 -0
  6. molscope-0.8.2/docs/assets/coarsegrain/1fqy-cg-mapping-comparison.png +0 -0
  7. molscope-0.8.2/docs/assets/coarsegrain/1fqy-martini-mapping.png +0 -0
  8. molscope-0.8.2/docs/assets/contactmaps/1aml-contact-frequency.png +0 -0
  9. molscope-0.8.2/docs/assets/contactmaps/1fqy-ca-distance-matrix.png +0 -0
  10. molscope-0.8.2/docs/assets/contactmaps/1fqy-residue-contact-map.png +0 -0
  11. molscope-0.8.2/docs/assets/geometry/1aml-rmsf-profile.png +0 -0
  12. molscope-0.8.2/docs/assets/geometry/1fqy-principal-axes.png +0 -0
  13. molscope-0.8.2/docs/assets/graphs/1fqy-residue-contact-graph.png +0 -0
  14. molscope-0.8.2/docs/benchmarks.md +55 -0
  15. molscope-0.8.2/docs/examples/analyze-contacts.md +42 -0
  16. molscope-0.8.2/docs/examples/binding-site.md +36 -0
  17. {molscope-0.8.1 → molscope-0.8.2}/docs/examples/build-molecular-graph.md +7 -0
  18. molscope-0.8.2/docs/examples/coarse-grain-protein.md +61 -0
  19. {molscope-0.8.1 → molscope-0.8.2}/docs/examples/export-pyg.md +7 -0
  20. molscope-0.8.2/docs/examples/geometry-tour.md +37 -0
  21. molscope-0.8.2/docs/examples/index.md +32 -0
  22. molscope-0.8.2/docs/examples/protein-analysis-from-scratch.md +56 -0
  23. molscope-0.8.2/docs/examples/residue-contact-graphs.md +40 -0
  24. molscope-0.8.2/docs/index.md +56 -0
  25. {molscope-0.8.1 → molscope-0.8.2}/docs/installation.md +5 -4
  26. molscope-0.8.2/docs/limitations.md +191 -0
  27. {molscope-0.8.1 → molscope-0.8.2}/docs/quickstart.md +27 -14
  28. molscope-0.8.2/docs/roadmap.md +56 -0
  29. molscope-0.8.2/docs/tutorials/index.md +16 -0
  30. molscope-0.8.2/docs/tutorials/pdb-to-coarse-grained-beads.md +207 -0
  31. molscope-0.8.2/docs/tutorials/pdb-to-descriptors.md +138 -0
  32. molscope-0.8.2/docs/tutorials/pdb-to-graph-gnn.md +180 -0
  33. molscope-0.8.2/docs/user-guide/coarse-graining.md +210 -0
  34. molscope-0.8.2/docs/user-guide/contact-maps.md +152 -0
  35. molscope-0.8.2/docs/user-guide/coordinate-formats.md +122 -0
  36. molscope-0.8.2/docs/user-guide/geometry.md +123 -0
  37. molscope-0.8.2/docs/user-guide/molecular-graphs.md +121 -0
  38. {molscope-0.8.1 → molscope-0.8.2}/docs/user-guide/plotting.md +6 -0
  39. molscope-0.8.2/docs/user-guide/protein-analysis.md +154 -0
  40. {molscope-0.8.1 → molscope-0.8.2}/docs/user-guide/reading-files.md +3 -0
  41. {molscope-0.8.1 → molscope-0.8.2}/docs/user-guide/selections.md +7 -0
  42. molscope-0.8.2/docs/validation.md +91 -0
  43. molscope-0.8.2/examples/binding_site.py +44 -0
  44. molscope-0.8.2/examples/coarse_graining.py +82 -0
  45. molscope-0.8.2/examples/data/3ptb.pdb +2264 -0
  46. molscope-0.8.2/examples/geometry.py +59 -0
  47. molscope-0.8.2/examples/protein_analysis.py +92 -0
  48. molscope-0.8.2/examples/residue_contact_graph.py +121 -0
  49. {molscope-0.8.1 → molscope-0.8.2}/mkdocs.yml +17 -2
  50. molscope-0.8.2/molscope/__init__.py +158 -0
  51. molscope-0.8.2/molscope/cli.py +330 -0
  52. molscope-0.8.2/molscope/coarsegrain.py +917 -0
  53. molscope-0.8.2/molscope/contactmap.py +182 -0
  54. molscope-0.8.2/molscope/contacts.py +292 -0
  55. {molscope-0.8.1 → molscope-0.8.2}/molscope/descriptors.py +4 -3
  56. molscope-0.8.2/molscope/distance.py +438 -0
  57. {molscope-0.8.1 → molscope-0.8.2}/molscope/dssp.py +135 -12
  58. {molscope-0.8.1 → molscope-0.8.2}/molscope/ensemble.py +15 -3
  59. molscope-0.8.2/molscope/graph.py +1011 -0
  60. {molscope-0.8.1 → molscope-0.8.2}/molscope/io.py +254 -73
  61. {molscope-0.8.1 → molscope-0.8.2}/molscope/molecule.py +447 -108
  62. molscope-0.8.2/molscope/plotting.py +365 -0
  63. {molscope-0.8.1 → molscope-0.8.2/molscope.egg-info}/PKG-INFO +158 -64
  64. {molscope-0.8.1 → molscope-0.8.2}/molscope.egg-info/SOURCES.txt +55 -0
  65. {molscope-0.8.1 → molscope-0.8.2}/molscope.egg-info/requires.txt +4 -0
  66. molscope-0.8.2/notebooks/pdb_to_gnn.ipynb +276 -0
  67. molscope-0.8.2/notebooks/protein_analysis_from_scratch.ipynb +302 -0
  68. {molscope-0.8.1 → molscope-0.8.2}/pyproject.toml +25 -5
  69. molscope-0.8.2/scripts/benchmark_core.py +129 -0
  70. molscope-0.8.2/scripts/build_gnn_notebook.py +242 -0
  71. molscope-0.8.2/scripts/build_protein_analysis_notebook.py +250 -0
  72. molscope-0.8.2/scripts/build_user_guide_pdf.py +73 -0
  73. molscope-0.8.2/scripts/render_coarsegrain_images.py +59 -0
  74. molscope-0.8.2/scripts/render_contact_analysis_images.py +48 -0
  75. molscope-0.8.2/scripts/render_geometry_images.py +81 -0
  76. molscope-0.8.2/tests/fixtures/bad_coord.pdb +3 -0
  77. molscope-0.8.2/tests/fixtures/bad_coord.xyz +4 -0
  78. molscope-0.8.2/tests/fixtures/bad_counts.sdf +6 -0
  79. molscope-0.8.2/tests/fixtures/missing_coord_col.cif +10 -0
  80. molscope-0.8.2/tests/fixtures/no_atom_site.cif +10 -0
  81. molscope-0.8.2/tests/fixtures/no_atoms.pdb +3 -0
  82. molscope-0.8.2/tests/fixtures/short_atom.pdb +3 -0
  83. molscope-0.8.2/tests/fixtures/truncated.sdf +6 -0
  84. molscope-0.8.2/tests/fixtures/truncated.xyz +4 -0
  85. molscope-0.8.2/tests/fixtures/v3000.sdf +15 -0
  86. molscope-0.8.2/tests/fixtures/water.sdf +11 -0
  87. molscope-0.8.2/tests/test_cg_mapping.py +215 -0
  88. molscope-0.8.2/tests/test_cif_validation.py +153 -0
  89. molscope-0.8.2/tests/test_cli.py +48 -0
  90. molscope-0.8.2/tests/test_cli_batch.py +54 -0
  91. {molscope-0.8.1 → molscope-0.8.2}/tests/test_coarsegrain.py +81 -3
  92. molscope-0.8.2/tests/test_contactmap.py +163 -0
  93. molscope-0.8.2/tests/test_contacts.py +122 -0
  94. molscope-0.8.2/tests/test_dssp.py +120 -0
  95. {molscope-0.8.1 → molscope-0.8.2}/tests/test_extras.py +1 -0
  96. {molscope-0.8.1 → molscope-0.8.2}/tests/test_features.py +27 -0
  97. {molscope-0.8.1 → molscope-0.8.2}/tests/test_graph.py +156 -2
  98. {molscope-0.8.1 → molscope-0.8.2}/tests/test_io.py +111 -4
  99. {molscope-0.8.1 → molscope-0.8.2}/tests/test_molecule.py +11 -12
  100. molscope-0.8.2/tests/test_protein_workflows.py +58 -0
  101. molscope-0.8.2/tests/validation/test_chem_ref.py +95 -0
  102. molscope-0.8.2/tests/validation/test_geometry_ref.py +135 -0
  103. molscope-0.8.1/docs/api-reference.md +0 -42
  104. molscope-0.8.1/docs/examples/analyze-contacts.md +0 -22
  105. molscope-0.8.1/docs/examples/coarse-grain-protein.md +0 -20
  106. molscope-0.8.1/docs/examples/index.md +0 -20
  107. molscope-0.8.1/docs/index.md +0 -45
  108. molscope-0.8.1/docs/limitations.md +0 -28
  109. molscope-0.8.1/docs/roadmap.md +0 -17
  110. molscope-0.8.1/docs/user-guide/coarse-graining.md +0 -44
  111. molscope-0.8.1/docs/user-guide/geometry.md +0 -41
  112. molscope-0.8.1/docs/user-guide/molecular-graphs.md +0 -61
  113. molscope-0.8.1/molscope/__init__.py +0 -108
  114. molscope-0.8.1/molscope/cli.py +0 -74
  115. molscope-0.8.1/molscope/coarsegrain.py +0 -411
  116. molscope-0.8.1/molscope/contactmap.py +0 -118
  117. molscope-0.8.1/molscope/graph.py +0 -305
  118. molscope-0.8.1/molscope/plotting.py +0 -196
  119. molscope-0.8.1/tests/test_cif_validation.py +0 -69
  120. molscope-0.8.1/tests/test_contactmap.py +0 -87
  121. molscope-0.8.1/tests/test_dssp.py +0 -67
  122. molscope-0.8.1/tests/validation/test_geometry_ref.py +0 -69
  123. {molscope-0.8.1 → molscope-0.8.2}/LICENSE +0 -0
  124. {molscope-0.8.1 → molscope-0.8.2}/docs/assets/readme/aquaporin-structure-v2.png +0 -0
  125. {molscope-0.8.1 → molscope-0.8.2}/docs/assets/readme/coarse-grained-beads-v2.png +0 -0
  126. {molscope-0.8.1 → molscope-0.8.2}/docs/assets/readme/residue-contact-map.png +0 -0
  127. {molscope-0.8.1 → molscope-0.8.2}/docs/assets/readme/secondary-structure.png +0 -0
  128. {molscope-0.8.1 → molscope-0.8.2}/docs/contributing.md +0 -0
  129. {molscope-0.8.1 → molscope-0.8.2}/docs/examples/compare-nmr-models.md +0 -0
  130. {molscope-0.8.1 → molscope-0.8.2}/docs/examples/pdb-to-graph-cg.md +0 -0
  131. {molscope-0.8.1 → molscope-0.8.2}/docs/examples/pdb-to-pyg-ml.md +0 -0
  132. {molscope-0.8.1 → molscope-0.8.2}/docs/user-guide/chemical-perception.md +0 -0
  133. {molscope-0.8.1 → molscope-0.8.2}/docs/user-guide/descriptors.md +0 -0
  134. {molscope-0.8.1 → molscope-0.8.2}/docs/user-guide/ensembles.md +0 -0
  135. {molscope-0.8.1 → molscope-0.8.2}/examples/data/1aml.pdb +0 -0
  136. {molscope-0.8.1 → molscope-0.8.2}/examples/data/1fqy.pdb +0 -0
  137. {molscope-0.8.1 → molscope-0.8.2}/examples/data/helix_201.xyz +0 -0
  138. {molscope-0.8.1 → molscope-0.8.2}/examples/graph_to_gnn.py +0 -0
  139. {molscope-0.8.1 → molscope-0.8.2}/examples/legacy_utils.py +0 -0
  140. {molscope-0.8.1 → molscope-0.8.2}/examples/pdb_to_pyg_ml.py +0 -0
  141. {molscope-0.8.1 → molscope-0.8.2}/examples/tour.py +0 -0
  142. {molscope-0.8.1 → molscope-0.8.2}/molscope/__main__.py +0 -0
  143. {molscope-0.8.1 → molscope-0.8.2}/molscope/chem.py +0 -0
  144. {molscope-0.8.1 → molscope-0.8.2}/molscope/cif.py +0 -0
  145. {molscope-0.8.1 → molscope-0.8.2}/molscope/elements.py +0 -0
  146. {molscope-0.8.1 → molscope-0.8.2}/molscope.egg-info/dependency_links.txt +0 -0
  147. {molscope-0.8.1 → molscope-0.8.2}/molscope.egg-info/entry_points.txt +0 -0
  148. {molscope-0.8.1 → molscope-0.8.2}/molscope.egg-info/top_level.txt +0 -0
  149. {molscope-0.8.1 → molscope-0.8.2}/notebooks/molscope_tour.ipynb +0 -0
  150. {molscope-0.8.1 → molscope-0.8.2}/requirements.txt +0 -0
  151. {molscope-0.8.1 → molscope-0.8.2}/setup.cfg +0 -0
  152. {molscope-0.8.1 → molscope-0.8.2}/tests/test_chem.py +0 -0
  153. {molscope-0.8.1 → molscope-0.8.2}/tests/test_clustering.py +0 -0
  154. {molscope-0.8.1 → molscope-0.8.2}/tests/test_descriptors.py +0 -0
  155. {molscope-0.8.1 → molscope-0.8.2}/tests/validation/test_bonds_ref.py +0 -0
  156. {molscope-0.8.1 → molscope-0.8.2}/tests/validation/test_dssp_ref.py +0 -0
  157. {molscope-0.8.1 → molscope-0.8.2}/tests/validation/test_invariants.py +0 -0
@@ -5,8 +5,8 @@ title: "MolScope: lightweight molecular structure analysis, visualisation, graph
5
5
  authors:
6
6
  - family-names: Shrestha
7
7
  given-names: Roshan
8
- version: 0.8.1
9
- date-released: "2026-05-26"
8
+ version: 0.8.2
9
+ date-released: "2026-05-28"
10
10
  license: MIT
11
11
  repository-code: "https://github.com/roshan2004/molscope"
12
12
  url: "https://github.com/roshan2004/molscope"
@@ -7,5 +7,7 @@ recursive-include docs *.md *.png
7
7
  recursive-include examples *.py
8
8
  recursive-include examples/data *.pdb *.xyz
9
9
  recursive-include notebooks *.ipynb
10
+ recursive-include scripts *.py
10
11
  recursive-include tests *.py
12
+ recursive-include tests/fixtures *.xyz *.pdb *.cif *.sdf
11
13
  prune notebooks/.ipynb_checkpoints
@@ -1,12 +1,12 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: molscope
3
- Version: 0.8.1
4
- Summary: Lightweight molecular structure analysis, visualisation, graph export, and coarse-graining in Python.
3
+ Version: 0.8.2
4
+ Summary: Lightweight molecular coordinate workflows for descriptors, graph ML, and coarse-grained beads.
5
5
  Author-email: Roshan Shrestha <roshanpra@gmail.com>
6
6
  License-Expression: MIT
7
7
  Project-URL: Homepage, https://github.com/roshan2004/molscope
8
8
  Project-URL: Repository, https://github.com/roshan2004/molscope
9
- Project-URL: Documentation, https://roshan2004.github.io/molscope/
9
+ Project-URL: Documentation, https://molscope.readthedocs.io/
10
10
  Project-URL: Issues, https://github.com/roshan2004/molscope/issues
11
11
  Keywords: chemistry,molecular-structure,pdb,xyz,mmcif,coarse-graining,molecular-graphs,machine-learning,visualization
12
12
  Classifier: Programming Language :: Python :: 3
@@ -19,6 +19,7 @@ Requires-Dist: numpy>=1.21
19
19
  Requires-Dist: matplotlib>=3.5
20
20
  Provides-Extra: test
21
21
  Requires-Dist: pytest>=7; extra == "test"
22
+ Requires-Dist: pytest-cov>=4; extra == "test"
22
23
  Provides-Extra: fast
23
24
  Requires-Dist: scipy>=1.7; extra == "fast"
24
25
  Provides-Extra: viz
@@ -29,6 +30,8 @@ Provides-Extra: chem
29
30
  Requires-Dist: rdkit>=2023.9; extra == "chem"
30
31
  Provides-Extra: cif
31
32
  Requires-Dist: gemmi>=0.7; extra == "cif"
33
+ Provides-Extra: gpu
34
+ Requires-Dist: torch>=2.0; extra == "gpu"
32
35
  Provides-Extra: validation
33
36
  Requires-Dist: mdanalysis>=2.7; extra == "validation"
34
37
  Requires-Dist: rdkit>=2023.9; extra == "validation"
@@ -48,27 +51,35 @@ Dynamic: license-file
48
51
  # MolScope
49
52
 
50
53
  [![CI](https://github.com/roshan2004/molscope/actions/workflows/ci.yml/badge.svg)](https://github.com/roshan2004/molscope/actions/workflows/ci.yml)
51
- [![Docs](https://img.shields.io/badge/docs-MkDocs%20Material-blue)](https://roshan2004.github.io/molscope/)
54
+ [![codecov](https://codecov.io/gh/roshan2004/molscope/branch/main/graph/badge.svg)](https://codecov.io/gh/roshan2004/molscope)
55
+ [![Docs](https://readthedocs.org/projects/molscope/badge/?version=latest)](https://molscope.readthedocs.io/en/latest/)
52
56
  [![PyPI](https://img.shields.io/pypi/v/molscope.svg)](https://pypi.org/project/molscope/)
53
57
  [![Python](https://img.shields.io/badge/python-3.9%20%7C%203.11%20%7C%203.13-blue)](pyproject.toml)
54
58
  [![License: MIT](https://img.shields.io/badge/license-MIT-yellow.svg)](LICENSE)
55
59
  [![Code style: Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
56
60
 
57
- Lightweight molecular structure analysis, visualisation, graph export, and
58
- coarse-graining in Python. Read `.xyz`, `.pdb`, `.cif` and `.sdf` files
59
- (optionally gzip-compressed), select and analyse atoms, and visualise them in
60
- 3D. The `.cif` reader handles standard `_atom_site` coordinate loops, including
61
- quoted values; optional Gemmi-backed validation is available through
62
- `pip install "molscope[cif]"`.
61
+ Lightweight molecular structure analysis, graph export, and coarse-graining in
62
+ Python. MolScope is built around three polished workflows: turn coordinate
63
+ files into descriptor tables, graph-ML inputs, or coarse-grained bead
64
+ representations without pulling in a full simulation stack.
63
65
 
64
- MolScope is a small scientific Python toolkit for turning molecular coordinate
65
- files into inspectable structures, descriptors, ML-ready graphs, and
66
- coarse-grained bead models without pulling in a full simulation stack.
66
+ Read `.xyz`, `.pdb`, `.cif` and `.sdf` files, select and analyse atoms, and
67
+ visualise structures in 3D. Optional extras add Gemmi validation, RDKit chemical
68
+ features, PyTorch Geometric, DGL, and other backend integrations only when a
69
+ workflow needs them.
67
70
 
68
71
  | 3D structure (element) | Secondary structure (DSSP) | Residue contact map | Coarse-grained beads |
69
72
  | --- | --- | --- | --- |
70
73
  | ![Aquaporin-1 rendered as a 3D element-coloured molecular structure](https://raw.githubusercontent.com/roshan2004/molscope/main/docs/assets/readme/aquaporin-structure-v2.png) | ![Aquaporin-1 coloured by DSSP secondary structure: helices red, turns cyan, coil grey](https://raw.githubusercontent.com/roshan2004/molscope/main/docs/assets/readme/secondary-structure.png) | ![Residue-level contact map heatmap for Aquaporin-1](https://raw.githubusercontent.com/roshan2004/molscope/main/docs/assets/readme/residue-contact-map.png) | ![Coarse-grained bead model of Aquaporin-1](https://raw.githubusercontent.com/roshan2004/molscope/main/docs/assets/readme/coarse-grained-beads-v2.png) |
71
74
 
75
+ ## Core workflows
76
+
77
+ | Workflow | Start here | Output |
78
+ | --- | --- | --- |
79
+ | **PDB to descriptors** | [`docs/tutorials/pdb-to-descriptors.md`](docs/tutorials/pdb-to-descriptors.md) | Fixed-width structural and optional RDKit-backed feature tables for screening, QC, and classical ML. |
80
+ | **PDB to graph/GNN** | [`docs/tutorials/pdb-to-graph-gnn.md`](docs/tutorials/pdb-to-graph-gnn.md) | Atom/bond, residue-contact, and PyTorch Geometric-ready graph data for message-passing experiments. |
81
+ | **PDB to coarse-grained beads** | [`docs/tutorials/pdb-to-coarse-grained-beads.md`](docs/tutorials/pdb-to-coarse-grained-beads.md) | Residue, simplified Martini-style, custom, and virtual-site bead models for inspection and graph prototyping. |
82
+
72
83
  ## Who is this for?
73
84
 
74
85
  - Students learning molecular-coordinate formats, structure analysis, and basic
@@ -78,29 +89,22 @@ coarse-grained bead models without pulling in a full simulation stack.
78
89
  - ML-for-molecules learners who need deterministic descriptors and graph exports
79
90
  before moving to larger chemistry or simulation frameworks.
80
91
 
81
- ## What it does
82
-
83
- - **Read and write** XYZ, PDB, mmCIF and SDF (gzip-aware), preserve SDF/PDB
84
- explicit bonds and SDF formal charges where present, fetch structures by id
85
- from RCSB, and load multi-model NMR ensembles.
86
- - **Validate mmCIF** syntax, atom-site coordinate columns, and supplied
87
- dictionary files with optional Gemmi support.
88
- - **Select and measure** by chain, element or residue; compute distances,
89
- angles, dihedrals and Kabsch-aligned RMSD.
90
- - **Analyse** centroids, radius of gyration, the inertia tensor,
91
- explicit/inferred bonds, and contacts.
92
- - **Contact maps** at atom or residue level, with heatmap plots.
93
- - **Secondary structure** via a self-contained, dependency-free DSSP, with
94
- `plot(color_by="ss")`.
95
- - **Ensembles**: pairwise RMSD, RMSF, averaging, and conformer clustering.
96
- - **Export for ML**: flat structural descriptors and molecular graphs for
97
- NetworkX, PyTorch Geometric and DGL.
98
- - **Chemical perception and descriptors**: optional RDKit-backed formal charge,
99
- valence, aromaticity and scalar descriptor features with
100
- `pip install "molscope[chem]"`.
101
- - **Coarse-grain** onto residue, Martini-style or custom bead mappings.
102
- - **Visualise** with 3D matplotlib plots, an interactive py3Dmol viewer, spin
103
- GIFs, and a command-line interface.
92
+ ## Supporting capabilities
93
+
94
+ MolScope keeps the broad feature surface organized around those workflows:
95
+
96
+ - **Input layer**: read and write XYZ, PDB, mmCIF and SDF, preserve explicit
97
+ bonds and charges where present, fetch structures from RCSB, and validate
98
+ mmCIF files with optional Gemmi support.
99
+ - **Structure analysis**: select atoms by metadata, compute geometry, RMSD,
100
+ contacts, contact maps, interfaces, binding sites, and ensemble summaries.
101
+ - **Annotations and descriptors**: run dependency-free secondary-structure
102
+ assignment, native structural descriptors, and optional RDKit-backed
103
+ chemistry descriptors.
104
+ - **Representation outputs**: export descriptor tables, atom/bond graphs,
105
+ residue-contact graphs, and coarse-grained bead graphs to common ML backends.
106
+ - **Inspection and automation**: visualize with Matplotlib or py3Dmol and use
107
+ the CLI for view, analyze, and export workflows.
104
108
 
105
109
  ## Architecture
106
110
 
@@ -116,17 +120,36 @@ graph LR
116
120
 
117
121
  ## Why MolScope?
118
122
 
119
- MolScope is **not** intended to replace full molecular-simulation or
120
- cheminformatics frameworks. It is a lightweight **educational and prototyping**
121
- toolkit for reading common molecular structure files, performing simple
122
- structural analysis, exporting graph representations for ML workflows, and
123
- experimenting with coarse-grained mappings. Its core depends only on NumPy and
124
- Matplotlib, and the API is Python-first and scriptable.
125
-
126
- In particular, the coarse-graining tools are for **educational CG mapping and
127
- bead-graph prototyping**: useful for exploring mappings before moving to a
128
- production Martini workflow. They are not a validated Martini force-field
129
- generator.
123
+ MolScope takes you from a structure file to a descriptor table, a
124
+ machine-learning graph, or a coarse-grained model with the smallest install that
125
+ gets the job done. The core depends only on NumPy and Matplotlib, so
126
+ `pip install molscope` stays light. Everything heavier (RDKit, PyTorch, PyTorch
127
+ Geometric, DGL, MDAnalysis, Gemmi) is an opt-in [extra](#install) you add only
128
+ when one of those workflows needs it.
129
+
130
+ That makes it an on-ramp rather than a framework:
131
+
132
+ - **Structure to ML graph in a few lines.** `mol.to_graph()` runs with zero extra
133
+ dependencies; `mol.to_pyg_data()`, `mol.to_networkx()` and `mol.to_dgl_graph()`
134
+ hand off to the ecosystem when you want it. This is the path MolScope is built
135
+ to make easy.
136
+ - **Descriptor tables without a framework.** Native structural descriptors and
137
+ optional RDKit-backed chemistry descriptors share the same `Molecule` and
138
+ batch-featurization APIs.
139
+ - **CG as a representation tool.** Residue, simplified Martini-style, custom
140
+ bead, and virtual-site mappings are inspectable molecules and bead graphs,
141
+ not hidden simulation setup state.
142
+ - **Light enough to teach and prototype with.** A readable, Python-first API over
143
+ static structures, with no trajectory engine or build step to wrestle.
144
+ - **Honest about its numbers.** Bonds, geometry and DSSP are cross-checked against
145
+ reference tools (MDAnalysis, `mkdssp`) in CI, so you know where the results come
146
+ from.
147
+
148
+ MolScope is **not** a replacement for full molecular-simulation or
149
+ cheminformatics frameworks. In particular, the coarse-graining tools are for
150
+ **educational CG mapping and bead-graph prototyping**: useful for exploring
151
+ mappings before moving to a production Martini workflow, not a validated Martini
152
+ force-field generator.
130
153
 
131
154
  | Tool | Main focus | How MolScope differs |
132
155
  | --- | --- | --- |
@@ -138,8 +161,8 @@ generator.
138
161
  | nglview | Notebook structure viewer | MolScope also does analysis, descriptors, graphs and CG, not just viewing |
139
162
 
140
163
  Reach for those tools when you need their depth and validation. Reach for
141
- MolScope when you want something small, readable, and quick to teach or
142
- prototype with.
164
+ MolScope when you want the shortest path from a structure file to analysis, an
165
+ ML graph, or a CG prototype.
143
166
 
144
167
  ## Install
145
168
 
@@ -177,6 +200,11 @@ python scripts/build_user_guide_pdf.py
177
200
  Docs source lives in `docs/`; the site configuration is `mkdocs.yml`. The PDF
178
201
  builder requires Pandoc and a LaTeX engine such as `xelatex`.
179
202
 
203
+ Scientific validation is documented in
204
+ [`docs/validation.md`](docs/validation.md): reference tools, assumptions,
205
+ failure modes, and tolerances for MDAnalysis, RDKit, `mkdssp`, and invariant
206
+ checks.
207
+
180
208
  ## Quickstart
181
209
 
182
210
  A runnable end-to-end tour over the bundled sample structures lives in
@@ -190,12 +218,24 @@ MPLBACKEND=Agg uv run python examples/tour.py # headless: saves PNGs instead
190
218
  It reads an `.xyz` and a `.pdb`, prints derived properties, compares the NMR
191
219
  models of `1aml`, writes a transformed structure back out, and renders a plot.
192
220
 
193
- For a focused workflow, see
194
- [`docs/examples/pdb-to-graph-cg.md`](docs/examples/pdb-to-graph-cg.md):
195
- from PDB to molecular graph and coarse-grained beads in about 10 minutes.
196
- For an ML-oriented walkthrough, see
197
- [`docs/examples/pdb-to-pyg-ml.md`](docs/examples/pdb-to-pyg-ml.md):
198
- PDB ensemble to PyTorch Geometric classifier/regressor toy model.
221
+ For polished, focused workflows, start with the tutorials:
222
+ [`PDB to descriptors`](docs/tutorials/pdb-to-descriptors.md),
223
+ [`PDB to graph/GNN`](docs/tutorials/pdb-to-graph-gnn.md), and
224
+ [`PDB to coarse-grained beads`](docs/tutorials/pdb-to-coarse-grained-beads.md).
225
+ For coarse-graining as a runnable visual workflow, run
226
+ [`examples/coarse_graining.py`](examples/coarse_graining.py): residue
227
+ center-of-mass beads, residue centroids, and a simplified backbone/sidechain
228
+ mapping with a visual atomistic-to-CG comparison.
229
+
230
+ For protein-coordinate analysis from scratch, see
231
+ [`docs/examples/protein-analysis-from-scratch.md`](docs/examples/protein-analysis-from-scratch.md)
232
+ and [`notebooks/protein_analysis_from_scratch.ipynb`](notebooks/protein_analysis_from_scratch.ipynb):
233
+ backbone atoms, residues, chains, alpha carbons, contact maps, NMR ensemble
234
+ contacts, ligands, waters, binding sites, and simplified DSSP.
235
+
236
+ For a runnable, narrated version of that ML walkthrough, open the notebook
237
+ [`notebooks/pdb_to_gnn.ipynb`](notebooks/pdb_to_gnn.ipynb): structure file to a
238
+ trained GNN, end to end (needs `pip install 'molscope[pyg]'`).
199
239
 
200
240
  ## Library
201
241
 
@@ -235,6 +275,7 @@ mol[mask_or_indices] # subset by numpy mask / index array
235
275
  mol.centroid, mol.center_of_mass # geometric / mass-weighted centre
236
276
  mol.radius_of_gyration # compactness (angstrom)
237
277
  mol.dimensions, mol.formula # bounding box, Hill-order formula
278
+ mol.distance_matrix() # dense pairwise matrix (NumPy, Torch, CuPy)
238
279
  mol.bonds() # inferred bond index pairs (KD-tree if scipy)
239
280
  mol.contacts(cutoff=5.0) # atom pairs within a distance
240
281
  mol.contact_count(cutoff=5.0) # count pairs without returning them
@@ -288,12 +329,14 @@ mol.plot_contact_map(cutoff=8.0) # heatmap
288
329
  mol.contact_map(level="atom") # atom-level map
289
330
  mol.contact_map(level="residue", method="min") # closest inter-residue atom
290
331
  mol.contact_map(level="residue", method="com") # residue centre of mass
332
+ mol.contact_map(level="residue", backend="torch", device="cuda") # optional GPU
291
333
  ```
292
334
 
293
335
  ### Secondary structure (DSSP)
294
336
 
295
337
  Assign protein secondary structure from backbone hydrogen-bond patterns with a
296
- self-contained, pure-NumPy DSSP (no external `mkdssp` binary needed):
338
+ self-contained, pure-NumPy, **simplified DSSP-style** implementation (no
339
+ external `mkdssp` binary needed):
297
340
 
298
341
  ```python
299
342
  mol = ms.read("examples/data/1fqy.pdb")
@@ -306,8 +349,8 @@ ss.summary() # helix/strand/coil counts and fractions
306
349
  mol.plot(color_by="ss") # colour the 3D view by secondary structure
307
350
  ```
308
351
 
309
- Codes follow DSSP: `H`/`G`/`I` helices, `E`/`B` strands, `T` turn, `S` bend,
310
- `-` coil. This is a simplified **educational** implementation of the
352
+ Codes follow DSSP notation: `H`/`G`/`I` helices, `E`/`B` strands, `T` turn, `S`
353
+ bend, `-` coil. This is a simplified **educational** implementation of the
311
354
  Kabsch-Sander hydrogen-bond model: not bit-identical to the reference `mkdssp`
312
355
  on every edge case, but validated against it. A CI cross-check
313
356
  (`tests/validation`) puts it at **~99% per-residue 3-state agreement**
@@ -399,6 +442,18 @@ Graph feature presets are also available through
399
442
  `mol.to_graph(include_chemical_features=True)` to attach optional RDKit-backed
400
443
  aromatic atom and bond flags.
401
444
 
445
+ For protein-scale spatial graphs, build a residue contact graph instead:
446
+
447
+ ```python
448
+ rg = mol.to_residue_contact_graph(cutoff=8.0, method="ca", min_seq_sep=4)
449
+ RG = rg.to_networkx()
450
+ residue_data = rg.to_pyg_data(node_preset="ml", edge_preset="ml")
451
+ ```
452
+
453
+ Use atom/bond graphs when covalent chemistry is the signal. Use residue or
454
+ bead contact graphs when 3D neighborhoods, interfaces, folded shape or
455
+ long-range contacts are the signal.
456
+
402
457
  ### Coarse-graining
403
458
 
404
459
  Map an atomistic structure onto a smaller set of beads. The result is an
@@ -411,6 +466,7 @@ mol = ms.read("examples/data/1fqy.pdb")
411
466
  cg = mol.coarse_grain("residue_com") # one bead per residue (centre of mass)
412
467
  cg = mol.coarse_grain("residue_centroid") # ...or geometric centroid
413
468
  cg = mol.coarse_grain("martini") # simplified backbone + side-chain beads
469
+ cg = mol.coarse_grain("martini", virtual_sites=[{"name": "MID", "parents": [0, 2]}])
414
470
  cg.plot(scale=200) # beads + backbone topology
415
471
  print(cg.mapping_report()) # explain beads, dropped atoms, and bonds
416
472
 
@@ -426,24 +482,61 @@ cg = mol.coarse_grain({"head": [0, 1, 2, 3], "tail": [4, 5, 6, 7]},
426
482
  cg.to_graph() # CG bead network, ready for ML
427
483
  ```
428
484
 
485
+ Visualise the mapping, inspect the per-bead assignment, and export it:
486
+
487
+ ```python
488
+ ms.plot_mapping(mol, cg) # atoms coloured by bead, beads + bonds overlaid
489
+
490
+ report = cg.coarse_grain_report # structured assignment
491
+ print(report.coverage()) # "426 beads from 1661/1661 atoms"
492
+ print(report.beads[0].atom_indices) # source atoms folded into bead 0
493
+
494
+ cg.write_mapping("mapping.json") # round-trippable JSON record
495
+ record = ms.read_cg_mapping("mapping.json")
496
+ cg2 = ms.apply_cg_mapping(mol, record) # rebuild on a matching structure
497
+ cg.write_index("mapping.ndx") # GROMACS-style index, one group per bead
498
+ ```
499
+
429
500
  Bead positions are mass-weighted (or centroids). For residue mappings bonds are
430
501
  generated automatically (within a residue, plus a backbone chain between
431
502
  residues); pass `bonds=` to define them yourself. Name-based bonds are intended
432
503
  for unique bead names such as `head`/`tail`; repeated names such as `BB`/`SC`
433
504
  are ambiguous, so use bead indices for those. Atoms you leave unassigned are
434
- dropped with a warning. This is meant
435
- for teaching and prototyping CG mappings, not as a replacement for production
436
- Martini parameters.
505
+ dropped with a warning. The `"martini"` mapping teaches the idea of backbone and
506
+ sidechain beads. Virtual sites are represented explicitly as derived coordinate
507
+ sites and graph flags, but MolScope does not assign Martini bead types,
508
+ bonded/nonbonded parameters, charges, exclusions, GROMACS virtual-site topology
509
+ sections, or simulation-engine topology files. This is meant for teaching and
510
+ prototyping CG mappings, not as a replacement for production Martini
511
+ preparation: the JSON and `.ndx` exports describe a bead assignment for
512
+ inspection and reuse, not a validated simulation topology.
513
+
514
+ ## Command-line interface
437
515
 
438
- ## Command line
516
+ MolScope provides a powerful CLI for visualization, batch analysis, and ML graph export.
439
517
 
518
+ ### View (default)
519
+ Visualize a structure, apply transformations, and save images or animations.
440
520
  ```bash
441
- molscope examples/data/helix_201.xyz --translate 1 2 -1
442
521
  molscope examples/data/1fqy.pdb --select atom_name=CA --color-by residue --save ca.png
522
+ molscope examples/data/1fqy.pdb --select "chain=A and atom_name=CA" --save chain-a-ca.png
443
523
  molscope --fetch 1aml --center --gif amyloid.gif
444
- python -m molscope examples/data/1fqy.pdb # equivalent if not pip-installed
445
524
  ```
446
525
 
526
+ ### Analyze
527
+ Batch compute molecular descriptors for many files and save to a CSV table.
528
+ ```bash
529
+ molscope analyze examples/data/*.pdb --out results.csv --preset native-3d --jobs 4
530
+ ```
531
+
532
+ ### Export
533
+ Batch export molecular graphs to PyTorch Geometric, DGL, or NetworkX formats.
534
+ ```bash
535
+ molscope export "data/*.cif" --to pyg --out-dir pyg_graphs/ --pe laplacian --jobs 8
536
+ ```
537
+ Supports advanced features like `--self-loops`, `--global-node`, and `--pe` (positional encodings).
538
+
539
+
447
540
  ## Sample structures
448
541
 
449
542
  | File | Contents |
@@ -468,6 +561,7 @@ python -m molscope examples/data/1fqy.pdb # equivalent if not pip-insta
468
561
  - Optional extras: `pip install "molscope[fast]"` (scipy, faster bonds/contacts),
469
562
  `"molscope[viz]"` (py3Dmol, for `Molecule.view`), `"molscope[graph]"`
470
563
  (NetworkX), `"molscope[chem]"` (RDKit), `"molscope[cif]"` (Gemmi),
564
+ `"molscope[gpu]"` (PyTorch dense distance/contact-map backend),
471
565
  `"molscope[pyg]"`, `"molscope[dgl]"`, or `"molscope[gnn]"`. For custom CUDA,
472
566
  ROCm, Apple Silicon, or cluster builds, install the matching PyTorch stack
473
567
  first.