cgback 1.0.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 (55) hide show
  1. cgback-1.0.0/.gitignore +20 -0
  2. cgback-1.0.0/.python-version +1 -0
  3. cgback-1.0.0/LICENSE +21 -0
  4. cgback-1.0.0/MANIFEST.in +1 -0
  5. cgback-1.0.0/PKG-INFO +323 -0
  6. cgback-1.0.0/README.md +282 -0
  7. cgback-1.0.0/pylock.toml +557 -0
  8. cgback-1.0.0/pyproject.toml +47 -0
  9. cgback-1.0.0/src/cgback/__init__.py +0 -0
  10. cgback-1.0.0/src/cgback/backmapper.py +618 -0
  11. cgback-1.0.0/src/cgback/backmapper_app.py +50 -0
  12. cgback-1.0.0/src/cgback/checkpoints/protein-carbon-alpha-cutoff-008-steps-010-layers-003-hidden-128.pt +0 -0
  13. cgback-1.0.0/src/cgback/checkpoints/protein-carbon-alpha-cutoff-008-steps-020-layers-002-hidden-128.pt +0 -0
  14. cgback-1.0.0/src/cgback/checkpoints/protein-carbon-alpha-cutoff-008-steps-020-layers-003-hidden-128.pt +0 -0
  15. cgback-1.0.0/src/cgback/checkpoints/protein-carbon-alpha-cutoff-008-steps-020-layers-004-hidden-128.pt +0 -0
  16. cgback-1.0.0/src/cgback/clash.py +82 -0
  17. cgback-1.0.0/src/cgback/dataloader.py +46 -0
  18. cgback-1.0.0/src/cgback/dataset.py +268 -0
  19. cgback-1.0.0/src/cgback/diffuser.py +144 -0
  20. cgback-1.0.0/src/cgback/egnn.py +243 -0
  21. cgback-1.0.0/src/cgback/hydrogen.py +599 -0
  22. cgback-1.0.0/src/cgback/minimization.py +94 -0
  23. cgback-1.0.0/src/cgback/parser.py +590 -0
  24. cgback-1.0.0/src/cgback/penetration.py +447 -0
  25. cgback-1.0.0/src/cgback/schedulers.py +106 -0
  26. cgback-1.0.0/src/cgback/system.py +40 -0
  27. cgback-1.0.0/tests/__init__.py +0 -0
  28. cgback-1.0.0/tests/data/aa_1a0s.pdb +6192 -0
  29. cgback-1.0.0/tests/data/aa_1a0s_with_penetration.pdb +6192 -0
  30. cgback-1.0.0/tests/data/aa_1a0s_without_penetration.pdb +6192 -0
  31. cgback-1.0.0/tests/data/aa_1yiw.cif +1180 -0
  32. cgback-1.0.0/tests/data/aa_2lcn.pdb +306 -0
  33. cgback-1.0.0/tests/data/aa_2lcn_model_l.pdb +306 -0
  34. cgback-1.0.0/tests/data/aa_2lcn_model_m.pdb +306 -0
  35. cgback-1.0.0/tests/data/aa_2lcn_model_s.pdb +306 -0
  36. cgback-1.0.0/tests/data/aa_2lcn_seed_0.pdb +306 -0
  37. cgback-1.0.0/tests/data/aa_2lcn_seed_1.pdb +306 -0
  38. cgback-1.0.0/tests/data/aa_his.pdb +74 -0
  39. cgback-1.0.0/tests/data/aa_ignore.pdb +306 -0
  40. cgback-1.0.0/tests/data/aa_partial.pdb +60 -0
  41. cgback-1.0.0/tests/data/cg_1a0s.pdb +415 -0
  42. cgback-1.0.0/tests/data/cg_1yiw.cif +344 -0
  43. cgback-1.0.0/tests/data/cg_2lcn.pdb +19 -0
  44. cgback-1.0.0/tests/data/cg_his.pdb +34 -0
  45. cgback-1.0.0/tests/data/cg_ignore.pdb +306 -0
  46. cgback-1.0.0/tests/data/cg_partial.pdb +33 -0
  47. cgback-1.0.0/tests/test_backmapper.py +458 -0
  48. cgback-1.0.0/tests/test_dataset.py +90 -0
  49. cgback-1.0.0/tests/test_diffuser.py +237 -0
  50. cgback-1.0.0/tests/test_egcl.py +156 -0
  51. cgback-1.0.0/tests/test_egnn.py +182 -0
  52. cgback-1.0.0/tests/test_parser.py +506 -0
  53. cgback-1.0.0/tests/test_penetration.py +55 -0
  54. cgback-1.0.0/tests/test_schedulers.py +220 -0
  55. cgback-1.0.0/uv.lock +706 -0
@@ -0,0 +1,20 @@
1
+ # Python-generated files
2
+ __pycache__/
3
+ *.py[oc]
4
+ build/
5
+ dist/
6
+ wheels/
7
+ *.egg-info
8
+
9
+ # Virtual environments
10
+ .venv
11
+
12
+ # Editors
13
+ .idea
14
+ .vscode
15
+
16
+ # macOS
17
+ .DS_Store
18
+
19
+ # External packages
20
+ pdbfixer
@@ -0,0 +1 @@
1
+ 3.10
cgback-1.0.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Diego Renato Ugarte La Torre
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.
@@ -0,0 +1 @@
1
+ recursive-include src/cgback/checkpoints *
cgback-1.0.0/PKG-INFO ADDED
@@ -0,0 +1,323 @@
1
+ Metadata-Version: 2.4
2
+ Name: cgback
3
+ Version: 1.0.0
4
+ Summary: Deep learning tool for backmapping coarse-grained to all-atom
5
+ Project-URL: Repository, https://github.com/bondrewd/cgback
6
+ Author-email: Diego Ugarte <diego.ugarte@outlook.com>
7
+ License: MIT License
8
+
9
+ Copyright (c) 2025 Diego Renato Ugarte La Torre
10
+
11
+ Permission is hereby granted, free of charge, to any person obtaining a copy
12
+ of this software and associated documentation files (the "Software"), to deal
13
+ in the Software without restriction, including without limitation the rights
14
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15
+ copies of the Software, and to permit persons to whom the Software is
16
+ furnished to do so, subject to the following conditions:
17
+
18
+ The above copyright notice and this permission notice shall be included in all
19
+ copies or substantial portions of the Software.
20
+
21
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
27
+ SOFTWARE.
28
+ License-File: LICENSE
29
+ Classifier: Operating System :: OS Independent
30
+ Classifier: Programming Language :: Python :: 3
31
+ Requires-Python: >=3.10.0
32
+ Requires-Dist: numpy>=2.1.0
33
+ Requires-Dist: rich>=13.9.4
34
+ Requires-Dist: scipy>=1.15.0
35
+ Requires-Dist: torch>=2.5.0
36
+ Provides-Extra: openmm
37
+ Requires-Dist: openmm>=8.2.0; extra == 'openmm'
38
+ Provides-Extra: openmm-cuda12
39
+ Requires-Dist: openmm[cuda12]>=8.2.0; extra == 'openmm-cuda12'
40
+ Description-Content-Type: text/markdown
41
+
42
+ # CGBack
43
+
44
+ CGBack is a Python tool for backmapping coarse-grained structures
45
+ into all-atom models using a diffusion-based generative model. It supports
46
+ various model sizes, GPU acceleration, energy minimization with OpenMM, and
47
+ reproducibility features.
48
+
49
+ ---
50
+
51
+ ## 📦 Installation
52
+
53
+ You can install CGBack using pip:
54
+
55
+ ```bash
56
+ pip install cgback
57
+ ```
58
+
59
+ or using uv:
60
+
61
+ ```bash
62
+ uv tool install cgback
63
+ ```
64
+
65
+ ### 🧩 Dependencies
66
+
67
+ CGBack requires **Python 3.10 or higher** and the following Python packages:
68
+
69
+ | Package | Version | Description |
70
+ |----------|----------|---------------------------------|
71
+ | `numpy` | ≥ 2.1.0 | Numerical computations |
72
+ | `scipy` | ≥ 1.15.0 | Scientific computing utilities |
73
+ | `torch` | ≥ 2.5.0 | PyTorch deep learning framework |
74
+ | `rich` | ≥ 13.9.4 | Pretty terminal output |
75
+
76
+ Additionally, to enable energy minimization, CGBack requires the following Python package:
77
+
78
+ | Package | Version | Description |
79
+ |----------|----------|---------------------------------|
80
+ | `openmm` | ≥ 8.2.0 | Molecular dynamics |
81
+
82
+ ### 🔧 Specific Sources (optional)
83
+
84
+ To install PyTorch for a specific CUDA version, please use the appropriate index:
85
+
86
+ For **CUDA 11.8**:
87
+ ```bash
88
+ # using pip
89
+ pip install cgback --index-url https://download.pytorch.org/whl/cu118
90
+
91
+ # using uv
92
+ uv tool install cgback --index pytorch=https://download.pytorch.org/whl/cu118
93
+ ```
94
+
95
+ For **CUDA 12.1**:
96
+ ```bash
97
+ # using pip
98
+ pip install cgback --index-url https://download.pytorch.org/whl/cu121
99
+
100
+ # using uv
101
+ uv tool install cgback --index pytorch=https://download.pytorch.org/whl/cu121
102
+ ```
103
+
104
+ For **CUDA 12.4**:
105
+ ```bash
106
+ # using pip
107
+ pip install cgback --index-url https://download.pytorch.org/whl/cu124
108
+
109
+ # using uv
110
+ uv tool install cgback --index pytorch=https://download.pytorch.org/whl/cu124
111
+ ```
112
+
113
+ For **CUDA 12.6**:
114
+ ```bash
115
+ # using pip
116
+ pip install cgback --index-url https://download.pytorch.org/whl/cu126
117
+
118
+ # using uv
119
+ uv tool install cgback --index pytorch=https://download.pytorch.org/whl/cu126
120
+ ```
121
+
122
+ For **CUDA 12.8**:
123
+ ```bash
124
+ # using pip
125
+ pip install cgback --index-url https://download.pytorch.org/whl/cu128
126
+
127
+ # using uv
128
+ uv tool install cgback --index pytorch=https://download.pytorch.org/whl/cu128
129
+ ```
130
+
131
+ To enable energy minimization, please add OpenMM support.
132
+
133
+ For OpenMM with **CPU** and **OpenCL** support:
134
+
135
+ ```bash
136
+ # using pip
137
+ pip install 'cgback[openmm]'
138
+
139
+ # using uv
140
+ uv tool install 'cgback[openmm]'
141
+ ```
142
+
143
+ For OpenMM with **CUDA 12** support:
144
+ ```bash
145
+ # using pip
146
+ pip install 'cgback[openmm-cuda12]'
147
+
148
+ # using uv
149
+ uv tool install 'cgback[openmm-cuda12]'
150
+ ```
151
+
152
+ > ❗**Note:** `When running CGBack with OpenMM support enable for the first time, you may encounter
153
+ > several warnings.` These messages are generated by the OpenMM package and do not indicate a problem
154
+ > with CGBack itself. The OpenMM team is expected to resolve them in a future update. `You
155
+ > can safely ignore these warnings.`The installation and functionality of CGBack remain unaffected.
156
+
157
+ ### ⚙️ Installation examples
158
+
159
+ Example of an installation using PyTorch and OpenMM, both only with CPU support:
160
+
161
+ ```bash
162
+ # using pip
163
+ pip install 'cgback[openmm]' --index-url https://download.pytorch.org/whl/cpu
164
+
165
+ # using uv
166
+ uv tool install 'cgback[openmm]' --index pytorch=https://download.pytorch.org/whl/cpu
167
+ ```
168
+
169
+ Example of an installation using PyTorch with CUDA 12.6 and OpenMM with CUDA 12:
170
+
171
+ ```bash
172
+ # using pip
173
+ pip install 'cgback[openmm-cuda12]' --index-url https://download.pytorch.org/whl/cu126
174
+
175
+ # using uv
176
+ uv tool install 'cgback[openmm-cuda12]' --index pytorch=https://download.pytorch.org/whl/cu126
177
+ ```
178
+
179
+ ## 🚀 Quick Start
180
+
181
+ The basic usage is very simple, just pass the coarse-grained structure to CGBack:
182
+
183
+ ```bash
184
+ cgback input.pdb
185
+ ```
186
+
187
+ The all-atom structure will be saved as out.pdb
188
+
189
+ ## 📚 Examples
190
+
191
+ Basic backmapping:
192
+
193
+ ```bash
194
+ cgback input.pdb # PDB format
195
+ cgback input.cif # PDBx/mmCIF format
196
+ ```
197
+
198
+ Backmapping using different output formats:
199
+
200
+ ```bash
201
+ cgback input.pdb -o out.pdb # Input in PDB format, output in PDB format
202
+ cgback input.cif -o out.cif # Input in PDBx/mmCIF format, output in PDBx/mmCIF format
203
+ cgback input.pdb -o out.cif # Input in PDB, output in PDBx/mmCIF format
204
+ cgback input.cif -o out.pdb # Input in PDBx/mmCIF format, output in PDB format
205
+ ```
206
+
207
+ Backmapping using GPU:
208
+
209
+ ```bash
210
+ cgback input.pdb -d cuda # on CUDA systems
211
+ cgback input.pdb -d mps # on Apple systems
212
+ ```
213
+
214
+ Backmapping using different models:
215
+
216
+ ```bash
217
+ cgback input.pdb -m S # Small model
218
+ cgback input.pdb -m M # Medium model (default)
219
+ cgback input.pdb -m L # Large model
220
+ ```
221
+
222
+ Verbose output and logging:
223
+
224
+ ```bash
225
+ cgback input.pdb -v
226
+ ```
227
+
228
+ Save intermediate files:
229
+
230
+ ```bash
231
+ cgback input.pdb -k
232
+ ```
233
+
234
+ Energy Minimization with OpenMM (requires enabling support for OpenMM):
235
+
236
+ ```bash
237
+ cgback input.pdb -e
238
+ ```
239
+
240
+ ## 🧪 Advanced Usage
241
+
242
+ Generate different outputs with controlled random seeds:
243
+
244
+ ```bash
245
+ cgback input.pdb -s 1
246
+ cgback input.pdb -s 2
247
+ ```
248
+
249
+ Specify the number of diffusion steps manually:
250
+
251
+ ```bash
252
+ cgback input.pdb -n 150
253
+ ```
254
+
255
+ Change batch size for larger or smaller memory usage:
256
+
257
+ ```bash
258
+ cgback input.pdb -b 128
259
+ ```
260
+
261
+ Customize energy minimization tolerance and iterations (in this case with a tolerance of 5.0 kJ/mol and 1000 minimization iterations):
262
+
263
+ ```bash
264
+ cgback input.pdb -e --energy-minimization-tolerance 5.0 --energy-minimization-max-iterations 1000
265
+ ```
266
+
267
+ Skip fixing atomic clashes during refinement:
268
+
269
+ ```bash
270
+ cgback input.pdb --skip-fix-structure-clashes
271
+ ```
272
+
273
+ Perform only backmapping, skipping adding hydrogen atoms, and skipping the whole refinement step:
274
+
275
+ ```bash
276
+ cgback input.pdb --skip-add-hydrogen --skip-fix-structure
277
+ ```
278
+
279
+ ## ✨ Extra Usage
280
+
281
+ CGBack can act as a lightweight structure‑repair tool, no coarse‑grained input required.
282
+ Here are four handy one‑liners you can drop into your workflow:
283
+
284
+ 1. Add missing hydrogen atoms:
285
+
286
+ ```bash
287
+ # input.pdb is a heavy‑atom model that lacks H-atoms
288
+ cgback input.pdb # out.pdb with idealised H‑atoms added
289
+ ```
290
+
291
+ Hydrogen atoms are placed according to standard protonation states at pH7±0.5.
292
+ Combine with -e (energy minimization) if you want a quick local relaxation.
293
+
294
+ 2. Mutate a residue in‑place:
295
+
296
+ ```bash
297
+ # Prepare input.pdb so the target residue:
298
+ # • is renamed to the desired three‑letter code (e.g. ALA → LYS)
299
+ # • keeps only its CA atom
300
+ cgback input.pdb # out.pdb with the rebuilt target residue
301
+ ```
302
+
303
+ CGBack reconstructs the full side‑chain, stitches it into the existing backbone,
304
+ and removes clashes.
305
+
306
+ 3. Fix structural artifacts:
307
+
308
+ ```bash
309
+ # input.pdb has atoms poking through aromatic rings
310
+ cgback input.pdb # out.pdb with penetrations resolved and stereochemistry repaired
311
+ ```
312
+
313
+ CGBack detects atoms that intrude an aromatic ring plane and re‑positions them to a clash‑free site.
314
+ It also scans all chiral centers and regenerates one in the canonical form. Combine with -e
315
+ (energy minimization) if you want a quick local relaxation.
316
+
317
+ ## 🧬 Citation
318
+
319
+ If you use CGBack in your research, please cite the corresponding paper (coming soon).
320
+
321
+ ## 📫 Contact
322
+
323
+ For bug reports or feature requests, please open an issue on GitHub.
cgback-1.0.0/README.md ADDED
@@ -0,0 +1,282 @@
1
+ # CGBack
2
+
3
+ CGBack is a Python tool for backmapping coarse-grained structures
4
+ into all-atom models using a diffusion-based generative model. It supports
5
+ various model sizes, GPU acceleration, energy minimization with OpenMM, and
6
+ reproducibility features.
7
+
8
+ ---
9
+
10
+ ## 📦 Installation
11
+
12
+ You can install CGBack using pip:
13
+
14
+ ```bash
15
+ pip install cgback
16
+ ```
17
+
18
+ or using uv:
19
+
20
+ ```bash
21
+ uv tool install cgback
22
+ ```
23
+
24
+ ### 🧩 Dependencies
25
+
26
+ CGBack requires **Python 3.10 or higher** and the following Python packages:
27
+
28
+ | Package | Version | Description |
29
+ |----------|----------|---------------------------------|
30
+ | `numpy` | ≥ 2.1.0 | Numerical computations |
31
+ | `scipy` | ≥ 1.15.0 | Scientific computing utilities |
32
+ | `torch` | ≥ 2.5.0 | PyTorch deep learning framework |
33
+ | `rich` | ≥ 13.9.4 | Pretty terminal output |
34
+
35
+ Additionally, to enable energy minimization, CGBack requires the following Python package:
36
+
37
+ | Package | Version | Description |
38
+ |----------|----------|---------------------------------|
39
+ | `openmm` | ≥ 8.2.0 | Molecular dynamics |
40
+
41
+ ### 🔧 Specific Sources (optional)
42
+
43
+ To install PyTorch for a specific CUDA version, please use the appropriate index:
44
+
45
+ For **CUDA 11.8**:
46
+ ```bash
47
+ # using pip
48
+ pip install cgback --index-url https://download.pytorch.org/whl/cu118
49
+
50
+ # using uv
51
+ uv tool install cgback --index pytorch=https://download.pytorch.org/whl/cu118
52
+ ```
53
+
54
+ For **CUDA 12.1**:
55
+ ```bash
56
+ # using pip
57
+ pip install cgback --index-url https://download.pytorch.org/whl/cu121
58
+
59
+ # using uv
60
+ uv tool install cgback --index pytorch=https://download.pytorch.org/whl/cu121
61
+ ```
62
+
63
+ For **CUDA 12.4**:
64
+ ```bash
65
+ # using pip
66
+ pip install cgback --index-url https://download.pytorch.org/whl/cu124
67
+
68
+ # using uv
69
+ uv tool install cgback --index pytorch=https://download.pytorch.org/whl/cu124
70
+ ```
71
+
72
+ For **CUDA 12.6**:
73
+ ```bash
74
+ # using pip
75
+ pip install cgback --index-url https://download.pytorch.org/whl/cu126
76
+
77
+ # using uv
78
+ uv tool install cgback --index pytorch=https://download.pytorch.org/whl/cu126
79
+ ```
80
+
81
+ For **CUDA 12.8**:
82
+ ```bash
83
+ # using pip
84
+ pip install cgback --index-url https://download.pytorch.org/whl/cu128
85
+
86
+ # using uv
87
+ uv tool install cgback --index pytorch=https://download.pytorch.org/whl/cu128
88
+ ```
89
+
90
+ To enable energy minimization, please add OpenMM support.
91
+
92
+ For OpenMM with **CPU** and **OpenCL** support:
93
+
94
+ ```bash
95
+ # using pip
96
+ pip install 'cgback[openmm]'
97
+
98
+ # using uv
99
+ uv tool install 'cgback[openmm]'
100
+ ```
101
+
102
+ For OpenMM with **CUDA 12** support:
103
+ ```bash
104
+ # using pip
105
+ pip install 'cgback[openmm-cuda12]'
106
+
107
+ # using uv
108
+ uv tool install 'cgback[openmm-cuda12]'
109
+ ```
110
+
111
+ > ❗**Note:** `When running CGBack with OpenMM support enable for the first time, you may encounter
112
+ > several warnings.` These messages are generated by the OpenMM package and do not indicate a problem
113
+ > with CGBack itself. The OpenMM team is expected to resolve them in a future update. `You
114
+ > can safely ignore these warnings.`The installation and functionality of CGBack remain unaffected.
115
+
116
+ ### ⚙️ Installation examples
117
+
118
+ Example of an installation using PyTorch and OpenMM, both only with CPU support:
119
+
120
+ ```bash
121
+ # using pip
122
+ pip install 'cgback[openmm]' --index-url https://download.pytorch.org/whl/cpu
123
+
124
+ # using uv
125
+ uv tool install 'cgback[openmm]' --index pytorch=https://download.pytorch.org/whl/cpu
126
+ ```
127
+
128
+ Example of an installation using PyTorch with CUDA 12.6 and OpenMM with CUDA 12:
129
+
130
+ ```bash
131
+ # using pip
132
+ pip install 'cgback[openmm-cuda12]' --index-url https://download.pytorch.org/whl/cu126
133
+
134
+ # using uv
135
+ uv tool install 'cgback[openmm-cuda12]' --index pytorch=https://download.pytorch.org/whl/cu126
136
+ ```
137
+
138
+ ## 🚀 Quick Start
139
+
140
+ The basic usage is very simple, just pass the coarse-grained structure to CGBack:
141
+
142
+ ```bash
143
+ cgback input.pdb
144
+ ```
145
+
146
+ The all-atom structure will be saved as out.pdb
147
+
148
+ ## 📚 Examples
149
+
150
+ Basic backmapping:
151
+
152
+ ```bash
153
+ cgback input.pdb # PDB format
154
+ cgback input.cif # PDBx/mmCIF format
155
+ ```
156
+
157
+ Backmapping using different output formats:
158
+
159
+ ```bash
160
+ cgback input.pdb -o out.pdb # Input in PDB format, output in PDB format
161
+ cgback input.cif -o out.cif # Input in PDBx/mmCIF format, output in PDBx/mmCIF format
162
+ cgback input.pdb -o out.cif # Input in PDB, output in PDBx/mmCIF format
163
+ cgback input.cif -o out.pdb # Input in PDBx/mmCIF format, output in PDB format
164
+ ```
165
+
166
+ Backmapping using GPU:
167
+
168
+ ```bash
169
+ cgback input.pdb -d cuda # on CUDA systems
170
+ cgback input.pdb -d mps # on Apple systems
171
+ ```
172
+
173
+ Backmapping using different models:
174
+
175
+ ```bash
176
+ cgback input.pdb -m S # Small model
177
+ cgback input.pdb -m M # Medium model (default)
178
+ cgback input.pdb -m L # Large model
179
+ ```
180
+
181
+ Verbose output and logging:
182
+
183
+ ```bash
184
+ cgback input.pdb -v
185
+ ```
186
+
187
+ Save intermediate files:
188
+
189
+ ```bash
190
+ cgback input.pdb -k
191
+ ```
192
+
193
+ Energy Minimization with OpenMM (requires enabling support for OpenMM):
194
+
195
+ ```bash
196
+ cgback input.pdb -e
197
+ ```
198
+
199
+ ## 🧪 Advanced Usage
200
+
201
+ Generate different outputs with controlled random seeds:
202
+
203
+ ```bash
204
+ cgback input.pdb -s 1
205
+ cgback input.pdb -s 2
206
+ ```
207
+
208
+ Specify the number of diffusion steps manually:
209
+
210
+ ```bash
211
+ cgback input.pdb -n 150
212
+ ```
213
+
214
+ Change batch size for larger or smaller memory usage:
215
+
216
+ ```bash
217
+ cgback input.pdb -b 128
218
+ ```
219
+
220
+ Customize energy minimization tolerance and iterations (in this case with a tolerance of 5.0 kJ/mol and 1000 minimization iterations):
221
+
222
+ ```bash
223
+ cgback input.pdb -e --energy-minimization-tolerance 5.0 --energy-minimization-max-iterations 1000
224
+ ```
225
+
226
+ Skip fixing atomic clashes during refinement:
227
+
228
+ ```bash
229
+ cgback input.pdb --skip-fix-structure-clashes
230
+ ```
231
+
232
+ Perform only backmapping, skipping adding hydrogen atoms, and skipping the whole refinement step:
233
+
234
+ ```bash
235
+ cgback input.pdb --skip-add-hydrogen --skip-fix-structure
236
+ ```
237
+
238
+ ## ✨ Extra Usage
239
+
240
+ CGBack can act as a lightweight structure‑repair tool, no coarse‑grained input required.
241
+ Here are four handy one‑liners you can drop into your workflow:
242
+
243
+ 1. Add missing hydrogen atoms:
244
+
245
+ ```bash
246
+ # input.pdb is a heavy‑atom model that lacks H-atoms
247
+ cgback input.pdb # out.pdb with idealised H‑atoms added
248
+ ```
249
+
250
+ Hydrogen atoms are placed according to standard protonation states at pH7±0.5.
251
+ Combine with -e (energy minimization) if you want a quick local relaxation.
252
+
253
+ 2. Mutate a residue in‑place:
254
+
255
+ ```bash
256
+ # Prepare input.pdb so the target residue:
257
+ # • is renamed to the desired three‑letter code (e.g. ALA → LYS)
258
+ # • keeps only its CA atom
259
+ cgback input.pdb # out.pdb with the rebuilt target residue
260
+ ```
261
+
262
+ CGBack reconstructs the full side‑chain, stitches it into the existing backbone,
263
+ and removes clashes.
264
+
265
+ 3. Fix structural artifacts:
266
+
267
+ ```bash
268
+ # input.pdb has atoms poking through aromatic rings
269
+ cgback input.pdb # out.pdb with penetrations resolved and stereochemistry repaired
270
+ ```
271
+
272
+ CGBack detects atoms that intrude an aromatic ring plane and re‑positions them to a clash‑free site.
273
+ It also scans all chiral centers and regenerates one in the canonical form. Combine with -e
274
+ (energy minimization) if you want a quick local relaxation.
275
+
276
+ ## 🧬 Citation
277
+
278
+ If you use CGBack in your research, please cite the corresponding paper (coming soon).
279
+
280
+ ## 📫 Contact
281
+
282
+ For bug reports or feature requests, please open an issue on GitHub.