mmcif-tools 0.1.1__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 (79) hide show
  1. mmcif_tools-0.1.1/CHANGELOG.md +78 -0
  2. mmcif_tools-0.1.1/CITATION.cff +38 -0
  3. mmcif_tools-0.1.1/LICENSE +201 -0
  4. mmcif_tools-0.1.1/MANIFEST.in +3 -0
  5. mmcif_tools-0.1.1/NOTICE +12 -0
  6. mmcif_tools-0.1.1/PKG-INFO +265 -0
  7. mmcif_tools-0.1.1/README.md +233 -0
  8. mmcif_tools-0.1.1/docs/about.md +20 -0
  9. mmcif_tools-0.1.1/docs/changelog.md +80 -0
  10. mmcif_tools-0.1.1/docs/index.md +68 -0
  11. mmcif_tools-0.1.1/docs/installation.md +40 -0
  12. mmcif_tools-0.1.1/docs/mmcif.md +17 -0
  13. mmcif_tools-0.1.1/docs/pdb-tools.md +13 -0
  14. mmcif_tools-0.1.1/docs/tools.md +1501 -0
  15. mmcif_tools-0.1.1/docs/usage.md +83 -0
  16. mmcif_tools-0.1.1/mmcif_tools.egg-info/PKG-INFO +265 -0
  17. mmcif_tools-0.1.1/mmcif_tools.egg-info/SOURCES.txt +77 -0
  18. mmcif_tools-0.1.1/mmcif_tools.egg-info/dependency_links.txt +1 -0
  19. mmcif_tools-0.1.1/mmcif_tools.egg-info/entry_points.txt +54 -0
  20. mmcif_tools-0.1.1/mmcif_tools.egg-info/top_level.txt +1 -0
  21. mmcif_tools-0.1.1/mmciftools/__init__.py +3 -0
  22. mmcif_tools-0.1.1/mmciftools/_atoms.py +627 -0
  23. mmcif_tools-0.1.1/mmciftools/_cif.py +1249 -0
  24. mmcif_tools-0.1.1/mmciftools/_cli.py +181 -0
  25. mmcif_tools-0.1.1/mmciftools/mmcif_assembly.py +285 -0
  26. mmcif_tools-0.1.1/mmciftools/mmcif_auth2label.py +115 -0
  27. mmcif_tools-0.1.1/mmciftools/mmcif_b.py +76 -0
  28. mmcif_tools-0.1.1/mmciftools/mmcif_blocks.py +80 -0
  29. mmcif_tools-0.1.1/mmciftools/mmcif_cat.py +97 -0
  30. mmcif_tools-0.1.1/mmciftools/mmcif_chain.py +59 -0
  31. mmcif_tools-0.1.1/mmciftools/mmcif_chkensemble.py +105 -0
  32. mmcif_tools-0.1.1/mmciftools/mmcif_delcat.py +76 -0
  33. mmcif_tools-0.1.1/mmciftools/mmcif_delchain.py +69 -0
  34. mmcif_tools-0.1.1/mmciftools/mmcif_delelem.py +68 -0
  35. mmcif_tools-0.1.1/mmciftools/mmcif_delentity.py +68 -0
  36. mmcif_tools-0.1.1/mmciftools/mmcif_delhetatm.py +60 -0
  37. mmcif_tools-0.1.1/mmciftools/mmcif_delinsertion.py +45 -0
  38. mmcif_tools-0.1.1/mmciftools/mmcif_delmeta.py +382 -0
  39. mmcif_tools-0.1.1/mmciftools/mmcif_delres.py +90 -0
  40. mmcif_tools-0.1.1/mmciftools/mmcif_delresname.py +69 -0
  41. mmcif_tools-0.1.1/mmciftools/mmcif_element.py +111 -0
  42. mmcif_tools-0.1.1/mmciftools/mmcif_fetch.py +141 -0
  43. mmcif_tools-0.1.1/mmciftools/mmcif_fixinsert.py +219 -0
  44. mmcif_tools-0.1.1/mmciftools/mmcif_frompdb.py +268 -0
  45. mmcif_tools-0.1.1/mmciftools/mmcif_gap.py +100 -0
  46. mmcif_tools-0.1.1/mmciftools/mmcif_head.py +80 -0
  47. mmcif_tools-0.1.1/mmciftools/mmcif_info.py +190 -0
  48. mmcif_tools-0.1.1/mmciftools/mmcif_intersect.py +91 -0
  49. mmcif_tools-0.1.1/mmciftools/mmcif_keepcat.py +65 -0
  50. mmcif_tools-0.1.1/mmciftools/mmcif_keepcoord.py +61 -0
  51. mmcif_tools-0.1.1/mmciftools/mmcif_label2auth.py +186 -0
  52. mmcif_tools-0.1.1/mmciftools/mmcif_merge.py +142 -0
  53. mmcif_tools-0.1.1/mmciftools/mmcif_mkensemble.py +115 -0
  54. mmcif_tools-0.1.1/mmciftools/mmcif_occ.py +74 -0
  55. mmcif_tools-0.1.1/mmciftools/mmcif_reatom.py +83 -0
  56. mmcif_tools-0.1.1/mmciftools/mmcif_reres.py +136 -0
  57. mmcif_tools-0.1.1/mmciftools/mmcif_rplchain.py +65 -0
  58. mmcif_tools-0.1.1/mmciftools/mmcif_rplresname.py +74 -0
  59. mmcif_tools-0.1.1/mmciftools/mmcif_selaltloc.py +248 -0
  60. mmcif_tools-0.1.1/mmciftools/mmcif_selatom.py +69 -0
  61. mmcif_tools-0.1.1/mmciftools/mmcif_selchain.py +68 -0
  62. mmcif_tools-0.1.1/mmciftools/mmcif_selelem.py +69 -0
  63. mmcif_tools-0.1.1/mmciftools/mmcif_selentity.py +129 -0
  64. mmcif_tools-0.1.1/mmciftools/mmcif_selhetatm.py +62 -0
  65. mmcif_tools-0.1.1/mmciftools/mmcif_selmodel.py +90 -0
  66. mmcif_tools-0.1.1/mmciftools/mmcif_selres.py +109 -0
  67. mmcif_tools-0.1.1/mmciftools/mmcif_selresname.py +68 -0
  68. mmcif_tools-0.1.1/mmciftools/mmcif_shiftres.py +77 -0
  69. mmcif_tools-0.1.1/mmciftools/mmcif_sort.py +138 -0
  70. mmcif_tools-0.1.1/mmciftools/mmcif_splitchain.py +218 -0
  71. mmcif_tools-0.1.1/mmciftools/mmcif_splitmodel.py +93 -0
  72. mmcif_tools-0.1.1/mmciftools/mmcif_tidy.py +137 -0
  73. mmcif_tools-0.1.1/mmciftools/mmcif_tofasta.py +180 -0
  74. mmcif_tools-0.1.1/mmciftools/mmcif_topdb.py +165 -0
  75. mmcif_tools-0.1.1/mmciftools/mmcif_uniqname.py +153 -0
  76. mmcif_tools-0.1.1/mmciftools/mmcif_validate.py +194 -0
  77. mmcif_tools-0.1.1/mmciftools/mmcif_wc.py +150 -0
  78. mmcif_tools-0.1.1/pyproject.toml +99 -0
  79. mmcif_tools-0.1.1/setup.cfg +4 -0
@@ -0,0 +1,78 @@
1
+ # Changelog
2
+
3
+ All notable changes to mmcif-tools. Versions follow [semantic versioning](https://semver.org/); before 1.0,
4
+ command names and options may still change.
5
+
6
+ ## 0.1.1 (2026-10-29): on PyPI
7
+
8
+ No changes to the tools.
9
+
10
+ - **On PyPI:** `python -m pip install mmcif-tools`. Releases are built, checked and uploaded by
11
+ `.github/workflows/release.yml`, with PyPI's Trusted Publishing.
12
+ - **Documentation website:** <https://matteo-cagiada.github.io/mmcif-tools/>, made from the README, the help texts
13
+ and this changelog.
14
+ - The README installs from PyPI first, and its links are full URLs, so they also work on PyPI.
15
+
16
+ ## 0.1.0 (2026-10-28): first test release
17
+
18
+ The first version for testers. It is not on PyPI or conda-forge yet; install it from the repository.
19
+
20
+ - **53 command-line tools** (`mmcif_*`), in seven groups: fetch and convert, select and delete, edit,
21
+ identifiers, models/files/assemblies, categories and data blocks, inspect and format. See
22
+ [docs/tools.md](docs/tools.md).
23
+ - **mmCIF-specific tools:**
24
+ - `mmcif_selentity` / `mmcif_delentity`: select by entity number or type (polymer, non-polymer, branched,
25
+ macrolide, water). Modified residues stay with their chain.
26
+ - `mmcif_assembly`: build a biological assembly from `_pdbx_struct_oper_list` and
27
+ `_pdbx_struct_assembly_gen`, including product expressions such as `(1-60)(61-88)`. The chain names follow
28
+ the RCSB's assembly files.
29
+ - `mmcif_info`: title, method, resolution, R-factors, dates, organisms, model quality, entities, assemblies.
30
+ - `mmcif_label2auth` / `mmcif_auth2label`: copy one identifier scheme onto the other.
31
+ - `mmcif_cat`, `mmcif_delcat`, `mmcif_keepcat`, `mmcif_blocks`: work on categories and data blocks.
32
+ - **Tools inspired by pdb-tools**, with the same options where they apply. Author identifiers by default,
33
+ `--label` for the PDB's label identifiers.
34
+ - **A streaming mmCIF reader and writer** (standard library only). Rows a tool does not change are copied
35
+ byte-for-byte. `_atom_site_anisotrop` and `_struct_conn` follow edits to the atoms.
36
+ - **Tested** on hand-written fixtures and 12 real entries (X-ray, NMR, cryo-EM, ribosomes, an AlphaFold DB model),
37
+ with a cross-check against pdb-tools. Every tool's output on these entries was also checked against the
38
+ PDBx/mmCIF (or ModelCIF) dictionary with gemmi, and has no error that its input does not have
39
+ (outside the test suite).
40
+ - **Python 3.9 to 3.15**, on Linux, macOS and Windows.
41
+ - **Fixed after a 200-system stress test** (PDB entries of every method and size, AlphaFold DB models, PDBe
42
+ files, an integrative model):
43
+ - `mmcif_splitchain`: chains whose ids differ only in case (`A` and `a`) overwrote each other's files on macOS
44
+ and Windows; such files now get a number (`1abc_a~2.cif`). It also writes up to 100 chains per reading of
45
+ the input instead of one, with the same output: 1792 chains no longer take hours.
46
+ - `mmcif_fixinsert` / `mmcif_delinsertion`: a file without an insertion code column is written unchanged
47
+ (it was an error).
48
+ - `mmcif_label2auth`: adds `auth_asym_id` / `auth_seq_id` when a file lacks them (integrative models).
49
+ - `mmcif_tofasta -seqres`: reads `_entity_poly_seq` when a file has no `_pdbx_poly_seq_scheme`, writes one
50
+ residue per position where two residue types share it, and explains when a file has no polymer.
51
+ - **Fixed after a second, targeted stress test** (100 systems: integrative models, ModelArchive and PDBe files,
52
+ chemical component files, entries chosen for one weak spot each, and modified copies of entries):
53
+ - `mmcif_reres` / `mmcif_fixinsert`: in files whose models hold different residues (4PTJ), the anisotropic
54
+ rows of later models got model 1's numbers; they now follow their own atom.
55
+ - `mmcif_merge` (and every tool that adds rows to a loop): with upper-case tags (`_ATOM_SITE.ID`), atom ids
56
+ were not renumbered; tags are case-insensitive, as in CIF.
57
+ - Edits with `--label` on a file without label columns (or without `--label` on one without author
58
+ columns) changed the other scheme's columns; they now stop with a clear message.
59
+ - `mmcif_fixinsert`: links whose rows have no residue name (as gemmi writes them) were not renumbered.
60
+ - `mmcif_head` counted the atoms of each data block separately; it now counts over the whole file, as its
61
+ help says.
62
+ - `mmcif_selaltloc` writes a file without an altloc column unchanged; `mmcif_b` / `mmcif_occ` add their
63
+ column when it is missing; "missing column" errors name the mmCIF column (`type_symbol`, `group_PDB`, ...).
64
+ - `mmcif_merge`, `mmcif_mkensemble` and `mmcif_topdb` say in their help that they use the first data block.
65
+ - **`mmcif_delmeta`** deletes the metadata that edits make stale (validation reports, secondary structure, sites,
66
+ assemblies, ...) and keeps the atoms, links, entry, method and resolution, release dates, unit cell, entities,
67
+ chains (`_struct_asym`), sequences, ligands (`_pdbx_entity_nonpoly`), modified residues and chemical components
68
+ with their atoms and bonds: what structure prediction programs (AlphaFold 2 and 3, ColabFold, OpenFold3, Boltz,
69
+ Chai-1, Protenix, BioEmu) and MD preparation programs (OpenMM, PDBFixer) read. The kept tables follow the atoms:
70
+ chains, entities and modified residues with no atoms left are removed, modified residues get their current
71
+ author numbers, the number of molecules and the chains of each entity are recomputed, and `_pdbx_poly_seq_scheme`
72
+ is rebuilt (OpenFold3 needs it). So it is the last step of a pipeline. `-all` keeps only the atoms and links.
73
+ (A first version deleted `_struct_asym`, and ColabFold rejected its files as templates.)
74
+ - **Checking an installation:** `python tools/smoke_test.py` runs every command and a few pipelines. The full test
75
+ suite stays with the developers and is not part of the public repository.
76
+ - **Known limitation:** after an edit, categories other than `_atom_site`, `_atom_site_anisotrop` and
77
+ `_struct_conn` that refer to atoms or residues (`_struct_conf`, `_pdbx_poly_seq_scheme`, `_pdbx_validate_*`,
78
+ ...) are left as they were. A tool to bring them back in step is planned.
@@ -0,0 +1,38 @@
1
+ cff-version: 1.2.0
2
+ message: "If you use mmcif-tools, please cite it as below."
3
+ title: "mmcif-tools: command-line tools for mmCIF files"
4
+ type: software
5
+ version: 0.1.1
6
+ date-released: "2026-10-29"
7
+ license: Apache-2.0
8
+ repository-code: "https://github.com/matteo-cagiada/mmcif-tools"
9
+ abstract: >-
10
+ Small, single-purpose command-line tools to select, edit, convert and inspect
11
+ macromolecular structures in the mmCIF (PDBx/mmCIF) format, chained with Unix
12
+ pipes. Standard library Python only. Inspired by pdb-tools.
13
+ keywords:
14
+ - mmCIF
15
+ - PDBx
16
+ - Protein Data Bank
17
+ - structural biology
18
+ - command line
19
+ authors:
20
+ - family-names: Cagiada
21
+ given-names: Matteo
22
+ references:
23
+ - type: article
24
+ title: "pdb-tools: a swiss army knife for molecular structures"
25
+ authors:
26
+ - family-names: Rodrigues
27
+ given-names: João P. G. L. M.
28
+ - family-names: Teixeira
29
+ given-names: João M. C.
30
+ - family-names: Trellet
31
+ given-names: Mikaël
32
+ - family-names: Bonvin
33
+ given-names: Alexandre M. J. J.
34
+ journal: F1000Research
35
+ volume: 7
36
+ start: 1961
37
+ year: 2018
38
+ doi: 10.12688/f1000research.17456.1
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2018 João Pedro Rodrigues
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
@@ -0,0 +1,3 @@
1
+ include CHANGELOG.md CITATION.cff
2
+ recursive-include docs *.md
3
+ prune tests
@@ -0,0 +1,12 @@
1
+ mmcif-tools
2
+ Copyright 2026 the mmcif-tools authors
3
+
4
+ mmcif-tools is an independent project, inspired by pdb-tools
5
+ (https://github.com/haddocking/pdb-tools). Its command-line conventions, its
6
+ tool set and parts of its help texts follow pdb-tools, which is Copyright the
7
+ pdb-tools authors (Rodrigues JPGLM, Teixeira JMC, Trellet M, Bonvin AMJJ) and
8
+ is distributed under the Apache License, Version 2.0.
9
+
10
+ Rodrigues JPGLM, Teixeira JMC, Trellet M and Bonvin AMJJ.
11
+ pdb-tools: a swiss army knife for molecular structures.
12
+ F1000Research 2018, 7:1961 (https://doi.org/10.12688/f1000research.17456.1)
@@ -0,0 +1,265 @@
1
+ Metadata-Version: 2.4
2
+ Name: mmcif-tools
3
+ Version: 0.1.1
4
+ Summary: Small, pipeable command-line tools to select, edit and inspect mmCIF files (standard library only).
5
+ Author: Matteo Cagiada
6
+ License-Expression: Apache-2.0
7
+ Project-URL: Homepage, https://github.com/matteo-cagiada/mmcif-tools
8
+ Project-URL: Documentation, https://matteo-cagiada.github.io/mmcif-tools/
9
+ Project-URL: Changelog, https://github.com/matteo-cagiada/mmcif-tools/blob/main/CHANGELOG.md
10
+ Project-URL: Issues, https://github.com/matteo-cagiada/mmcif-tools/issues
11
+ Keywords: mmCIF,PDBx,PDB,protein structure,structural biology,command line
12
+ Classifier: Development Status :: 3 - Alpha
13
+ Classifier: Environment :: Console
14
+ Classifier: Intended Audience :: Science/Research
15
+ Classifier: Operating System :: OS Independent
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Programming Language :: Python :: 3 :: Only
18
+ Classifier: Programming Language :: Python :: 3.9
19
+ Classifier: Programming Language :: Python :: 3.10
20
+ Classifier: Programming Language :: Python :: 3.11
21
+ Classifier: Programming Language :: Python :: 3.12
22
+ Classifier: Programming Language :: Python :: 3.13
23
+ Classifier: Programming Language :: Python :: 3.14
24
+ Classifier: Programming Language :: Python :: 3.15
25
+ Classifier: Topic :: Scientific/Engineering :: Bio-Informatics
26
+ Classifier: Topic :: Scientific/Engineering :: Chemistry
27
+ Requires-Python: >=3.9
28
+ Description-Content-Type: text/markdown
29
+ License-File: LICENSE
30
+ License-File: NOTICE
31
+ Dynamic: license-file
32
+
33
+ # mmcif-tools
34
+
35
+ mmcif-tools is an independent project whose style and much of its tool set are inspired by
36
+ [pdb-tools](https://www.bonvinlab.org/pdb-tools/) (Rodrigues JPGLM, Teixeira JMC, Trellet M and Bonvin AMJJ,
37
+ *F1000Research* 2018, 7:1961). mmcif-tools ports and expands the pdb-tools functionality to the mmCIF (PDBx/mmCIF)
38
+ format.
39
+
40
+ As pdb-tools, it is a set of small, single-purpose command-line tools that read and write mmCIF files and chain
41
+ together with Unix pipes: select, delete, edit, convert and inspect structures without leaving the shell. The
42
+ package needs only the Python standard library (Python 3.9 or newer).
43
+
44
+ ```bash
45
+ mmcif_fetch 1brs | mmcif_selchain -A,D | mmcif_delentity -non-polymer,water | mmcif_reres -1 | mmcif_delmeta > clean.cif
46
+ ```
47
+
48
+ **CURRENT VERSION: Version 0.1.1, pre-release: 53 available tools**
49
+
50
+
51
+ ## Tools
52
+
53
+ mmcif-tools reads the mmCIF text format, as written by the PDB (wwPDB, RCSB, PDBe), the AlphaFold DB (ModelCIF),
54
+ structure prediction and modelling programs and viewers, plain or gzip-compressed. BinaryCIF is currently not
55
+ supported.
56
+
57
+ The full `--help` text of every tool is in the [tool reference](https://matteo-cagiada.github.io/mmcif-tools/tools/).
58
+
59
+ | Group | Tool | What it does |
60
+ |---|---|---|
61
+ | Fetch / convert | `mmcif_fetch` | Download an entry from the RCSB (or `-biounit`), or an AlphaFold DB model (`AF-P69905-F1`) |
62
+ | | `mmcif_topdb` / `mmcif_frompdb` | Convert to / from the PDB format (`mmcif_frompdb` assigns label identifiers) |
63
+ | Select / delete | `mmcif_selchain` / `mmcif_delchain` | Keep / remove chains (`-A,B`) |
64
+ | | `mmcif_selres` / `mmcif_delres` | Keep / remove residues by number (`-1:10,20:30`, `-::5`) |
65
+ | | `mmcif_selresname` / `mmcif_delresname` | Keep / remove residues by name (`-HOH`) |
66
+ | | `mmcif_selatom` | Keep atoms by name (`-CA,C,N,O`) |
67
+ | | `mmcif_selelem` / `mmcif_delelem` | Keep / remove atoms by element (`-C,N`, `-H`) |
68
+ | | `mmcif_selentity` / `mmcif_delentity` | Keep / remove entities by number or type (`-polymer`, `-non-polymer,water`) |
69
+ | | `mmcif_selhetatm` / `mmcif_delhetatm` | Keep / remove HETATM records (ligands, ions, waters, and modified residues) |
70
+ | | `mmcif_selaltloc` | Keep one alternate location (highest occupancy, or `-A`) |
71
+ | | `mmcif_selmodel` | Keep models (`-1,3`) |
72
+ | | `mmcif_head` | Keep the first N atoms (`-100`) |
73
+ | | `mmcif_delmeta` | Delete the metadata that edits make stale; keep the rest (entry, method, entities, chains, ...) in step with the atoms (`-all`: atoms only) |
74
+ | | `mmcif_keepcoord` | Keep only the coordinates (`_atom_site`, `_struct_conn`), as `pdb_keepcoord` |
75
+ | | `mmcif_intersect` | Keep the atoms of the first file found in all the others |
76
+ | Edit | `mmcif_chain` / `mmcif_rplchain` | Set all chains (`-C`) / rename one chain (`-A:B`) |
77
+ | | `mmcif_reres` / `mmcif_shiftres` | Renumber residues from a number / shift them by a number |
78
+ | | `mmcif_fixinsert` (`mmcif_delinsertion`) | Remove insertion codes, shifting the numbering |
79
+ | | `mmcif_reatom` | Renumber atom ids |
80
+ | | `mmcif_rplresname` | Rename a residue type (`-HIP:HIS`) |
81
+ | | `mmcif_uniqname` | Rename ligand atoms C1, C2, O1, … |
82
+ | | `mmcif_element` | Assign elements from atom names (`-all` to redo all) |
83
+ | | `mmcif_b` / `mmcif_occ` | Set B-factors / occupancies |
84
+ | Identifiers | `mmcif_label2auth` | Copy label chains and residue numbers onto the author ones (`-chain`, `-res`) |
85
+ | | `mmcif_auth2label` | Copy author chains onto the label chains of polymers |
86
+ | Models, files, assemblies | `mmcif_splitchain` / `mmcif_splitmodel` | Write one file per chain / model |
87
+ | | `mmcif_mkensemble` / `mmcif_chkensemble` | Build a multi-model file / check its models match |
88
+ | | `mmcif_merge` | Merge the atoms of several files into one |
89
+ | | `mmcif_assembly` | Build a biological assembly from the file's symmetry operations (`-1`) |
90
+ | Categories / blocks | `mmcif_cat` | Print one category as a table (TSV): `-_atom_site.id,Cartn_x` |
91
+ | | `mmcif_delcat` / `mmcif_keepcat` | Remove / keep whole categories (`-_struct_conf`, `'-_pdbx_validate*'`) |
92
+ | | `mmcif_blocks` | List the data blocks, or extract some (`-ATP`) |
93
+ | Inspect / format | `mmcif_info` | Title, method, resolution, organisms, entities, assemblies |
94
+ | | `mmcif_wc` | Counts: models, chains, residues, atoms, … |
95
+ | | `mmcif_tofasta` | Sequence in FASTA format (`-multi`, `-seqres`) |
96
+ | | `mmcif_gap` | Report chain breaks |
97
+ | | `mmcif_sort` | Sort atoms by chain and residue |
98
+ | | `mmcif_tidy` | Rewrite in a uniform, aligned layout |
99
+ | | `mmcif_validate` | Check syntax, coordinates and consistency |
100
+
101
+ ## Usage examples and tips
102
+
103
+ ### Command examples
104
+
105
+ ```bash
106
+ # A clean protein for docking or simulations: one conformer, no ligands or waters, an aligned layout
107
+ mmcif_fetch 4hhb | mmcif_selaltloc | mmcif_delentity -non-polymer,water | mmcif_delmeta | mmcif_tidy > 4hhb_protein.cif
108
+
109
+ # Chain A with its heme, numbered from 1, as a PDB file for programs that need one
110
+ mmcif_fetch 4hhb | mmcif_selchain -A | mmcif_delentity -water | mmcif_reres -1 | mmcif_topdb > 4hhb_A.pdb
111
+
112
+ # The biological assembly, built from the symmetry operations in the file (chains A, A-2, A-3, A-4)
113
+ mmcif_fetch 1stp | mmcif_assembly > 1stp_tetramer.cif
114
+
115
+ # What an entry holds: method, resolution, organisms, entities, assemblies (and the pLDDT of AlphaFold models)
116
+ mmcif_fetch 4hhb | mmcif_info
117
+ mmcif_fetch AF-P69905-F1 | mmcif_info
118
+
119
+ # A table of atoms for awk, R or pandas (tab-separated, one header line)
120
+ mmcif_cat -_atom_site.auth_asym_id,auth_seq_id,label_comp_id,B_iso_or_equiv 4hhb.cif > atoms.tsv
121
+
122
+ # Residues numbered along the deposited sequence, and one author chain per molecule
123
+ mmcif_label2auth 4hhb.cif > 4hhb_by_sequence.cif
124
+
125
+ # Delete only some categories: here the PDB's validation reports and secondary structure
126
+ mmcif_delcat '-_pdbx_validate*,_struct_conf,_struct_sheet_range' 4hhb.cif > 4hhb_lean.cif
127
+ ```
128
+
129
+ ### `mmcif_delmeta`
130
+
131
+ A PDB entry is mostly metadata: 4HHB has 72 categories, and only a few of them hold the atoms. Most of the rest
132
+ refers to residues by chain and number: validation reports, secondary structure, sequence schemes, binding sites,
133
+ assemblies, and more. The edit tools keep the atoms and their links consistent, but not these tables, so after
134
+ renumbering or deleting residues they describe a structure that is no longer there. Simulation and prediction
135
+ programs rarely read them anyway.
136
+
137
+ `mmcif_delmeta` deletes that metadata and keeps what is fundamental: the atoms, their links and anisotropic B-factors;
138
+ the entry id, method, resolution and release dates; the unit cell and space group; the entities, chains and
139
+ sequences; the ligands and modified residues; and the chemical components with their atoms and bonds. It also
140
+ brings these tables in step with the atoms: chains, entities and modified residues with no atoms left are removed,
141
+ the number of molecules and the chains of each entity are recomputed, modified residues get their current author
142
+ numbers, and the table that places each chain's residues on its sequence (`_pdbx_poly_seq_scheme`) is rebuilt.
143
+ For 4HHB that is 18 categories instead of 72, and the file is still valid mmCIF.
144
+
145
+ ```bash
146
+ mmcif_fetch 4hhb | mmcif_delentity -non-polymer,water | mmcif_reres -10 | mmcif_reatom -4 | mmcif_delmeta > 4hhb_clean.cif
147
+ ```
148
+
149
+ We suggest running `mmcif_delmeta` as the last step, after you have completed the structure manipulations.
150
+
151
+ The kept categories are also those that structure prediction programs read from template or input files (AlphaFold 2
152
+ and 3, ColabFold, OpenFold3, Boltz, Chai-1, Protenix, BioEmu), and MD preparation programs from structures (OpenMM,
153
+ PDBFixer).
154
+
155
+ `mmcif_delmeta -all` keeps only the atoms and links, and `mmcif_keepcat` keeps exactly the categories you list.
156
+
157
+ ### Tips
158
+
159
+ - Each tool takes at most one option (starting with `-`) and one file, and reads stdin when no file is given, so
160
+ tools chain with pipes. Negative numbers need a double dash (`mmcif_shiftres --5`).
161
+ - `--help` prints a tool's usage (not `-h`, which is a real option of some tools, e.g. `mmcif_wc -h`).
162
+ - Errors go to stderr as `ERROR!! ...`, with exit status 1.
163
+ - Rows a tool does not change are written back byte-for-byte. In changed rows, only the edited values are
164
+ rewritten, and the other columns keep their alignment.
165
+ - To remove ligands and waters, select by entity (`mmcif_delentity -non-polymer,water`) rather than by HETATM
166
+ record: `mmcif_delhetatm` also removes modified residues inside chains (selenomethionine, modified nucleotides).
167
+ - Quote options that contain `*`, so that the shell does not expand them: `'-_pdbx_validate*'`.
168
+ - Input files can be gzip-compressed (`.cif.gz`); outputs are plain text, so pipe them to `gzip` to compress.
169
+ - After editing, `mmcif_validate` checks the syntax, the coordinates and the links between tables.
170
+
171
+ #### Files for prediction and MD programs
172
+
173
+ - **AlphaFold 3** templates must hold a single protein chain: select it with `mmcif_selchain` (ligands may stay).
174
+ - **Boltz-2 and OpenFold3** name template chains by their label id (`_struct_asym.id`), not the author chain. To
175
+ see which is which: `mmcif_cat -_atom_site.label_asym_id,auth_asym_id file.cif | sort -u`.
176
+ - **Renumber the author numbers only** (the default of `mmcif_reres` and `mmcif_shiftres`). These programs place
177
+ residues on the sequence by `label_seq_id`, which `--label` renumbering changes.
178
+ - **Residues deleted inside a chain are still in the sequence**: prediction programs treat them as unresolved, and
179
+ PDBFixer rebuilds them as missing residues. `mmcif_delmeta -all` drops the sequences as well.
180
+ - **OpenMM takes `_cell` as the periodic box.** Cryo-EM and NMR entries often carry a placeholder cell of 1 Å;
181
+ remove it with `mmcif_delcat -_cell,_symmetry`, or set the box when solvating.
182
+
183
+ ## Coming from pdb-tools
184
+
185
+ Most tools have the pdb-tools name with `mmcif_` for `pdb_` and the same options. The differences:
186
+
187
+ - `pdb_tocif` / `pdb_fromcif` are `mmcif_frompdb` / `mmcif_topdb`.
188
+ - The segment tools (`pdb_seg`, `pdb_selseg`, `pdb_splitseg`) have no counterpart: mmCIF has no segment identifier,
189
+ and `label_asym_id` names each molecule (`mmcif_selchain --label`, `mmcif_splitchain --label`).
190
+ - `pdb_chainbows`, `pdb_chainxseg` and `pdb_segxchain` have no counterpart: mmCIF has no TER records. `mmcif_frompdb`
191
+ uses the TER records of a PDB file to separate molecules and names blank chains, and `mmcif_label2auth -chain`
192
+ gives each molecule its own author chain.
193
+ - Where pdb-tools behaves differently (or has a bug), the tool's `--help` says so.
194
+
195
+ ## Things to know about mmCIF
196
+
197
+ - **Two sets of identifiers.** mmCIF names chains and residues twice: author names (`auth_*`, what papers and
198
+ viewers show) and the PDB's own names (`label_*`, one label chain per molecule, residues numbered along the
199
+ sequence). Tools use author names by default; pass `--label` to use `label_*` instead, or set
200
+ `MMCIFTOOLS_SCHEME=label` for every tool. Edits change one scheme only. Residue and atom names are the same in
201
+ both, so `mmcif_rplresname` and `mmcif_uniqname` change both name columns.
202
+ - **Related tables stay in step.** Removing atoms also removes their rows in `_atom_site_anisotrop` and
203
+ `_struct_conn`; renaming chains or renumbering residues updates the same two tables. Other categories that
204
+ mention chains or residues (`_struct_conf`, `_pdbx_poly_seq_scheme`, ...) are left as they were.
205
+ - **Entities.** Every molecule belongs to an entity: polymer, non-polymer, branched (glycans) or water.
206
+ `mmcif_selentity` / `mmcif_delentity` select by entity, which keeps modified residues (HETATM records inside a
207
+ chain, such as MSE or the modified nucleotides of a tRNA) with their chain; `mmcif_delhetatm` removes them.
208
+ - **No fixed columns.** Chain identifiers can be longer than one character, and there are no limits on atom or
209
+ residue numbers. `mmcif_topdb` refuses structures that do not fit the PDB format.
210
+
211
+ ## Installation
212
+
213
+ ```bash
214
+ python -m pip install mmcif-tools
215
+ ```
216
+
217
+ There are no runtime dependencies. For tab completion of the `mmcif_*` commands, open a new terminal after
218
+ installing (or run `rehash` in an open zsh terminal).
219
+
220
+ The extra tools below are in the repository, not in the package. To install from the repository instead,
221
+ `python tools/smoke_test.py` then checks the installation: every command runs, and a few pipelines give the
222
+ expected results.
223
+
224
+ ```bash
225
+ git clone https://github.com/matteo-cagiada/mmcif-tools.git
226
+ cd mmcif-tools
227
+ python -m pip install .
228
+ python tools/smoke_test.py
229
+ ```
230
+
231
+ ## Extra tools
232
+
233
+ `tools/` holds scripts that are not part of mmcif-tools and are not installed with it.
234
+
235
+ - **`tools/check_with_gemmi.py`** checks CIF files with [gemmi](https://github.com/project-gemmi/gemmi), an
236
+ independent CIF reader: the syntax, and optionally a dictionary such as the PDBx/mmCIF one (`--dict`). It runs the
237
+ gemmi program, which you install yourself (e.g. `pip install gemmi-program`); give its path with `--gemmi` if it
238
+ is not on the PATH:
239
+
240
+ ```bash
241
+ python tools/check_with_gemmi.py --gemmi /path/to/gemmi out.cif
242
+ mmcif_selchain -A 1abc.cif | python tools/check_with_gemmi.py --dict mmcif_pdbx_v50.dic -
243
+ ```
244
+
245
+ - **`tools/make_docs.py`** writes the [tool reference](https://matteo-cagiada.github.io/mmcif-tools/tools/) and
246
+ the other pages of the [documentation website](https://matteo-cagiada.github.io/mmcif-tools/).
247
+ - **`tools/smoke_test.py`** checks an installation (see
248
+ [Installation](https://matteo-cagiada.github.io/mmcif-tools/installation/)).
249
+
250
+ ## Citation and changes
251
+
252
+ How to cite mmcif-tools is in [CITATION.cff](https://github.com/matteo-cagiada/mmcif-tools/blob/main/CITATION.cff);
253
+ the changes between versions are in the [changelog](https://matteo-cagiada.github.io/mmcif-tools/changelog/).
254
+ [PLAN.md](https://github.com/matteo-cagiada/mmcif-tools/blob/main/PLAN.md) records the design decisions and the test
255
+ results.
256
+
257
+ ## Acknowledgements
258
+
259
+ Most of the code of mmcif-tools has been written with [Claude Code](https://claude.com/claude-code),
260
+ Anthropic's AI coding assistant. The author designed the project, tools and tests to guarantee the quality of the tool.
261
+ We thank the Bonvin Lab for developing and releasing pdb-tools, a fundamental tool for the authors' academic work.
262
+
263
+ ## License
264
+
265
+ Apache-2.0. See [LICENSE](https://github.com/matteo-cagiada/mmcif-tools/blob/main/LICENSE).