Monomer library subset: state that it is modified, with the LGPL notices

The embedded CCP4 Monomer Library subset is not an unmodified copy:
links_and_mods.cif and ener_lib.cif are cut down and metals.json becomes
metals.cif. The notices entry now says so and states how the LGPL-3.0
obligations are met (modified files stay LGPL, preferred form and the
generating script in the tree, the user can replace the embedded copy).

Each of the three derived files carries a CIF comment at its top naming its
origin, the modification and the date, and update_monomers.py writes that
comment whenever it regenerates them (the files still read with gemmi).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UqXYdJDrM65gxsCn2PrbfK
This commit is contained in:
leonarski_fandClaude Opus 5.5 committed 2026-11-15 16:15:13 +01:00
1 parent d4e07cc489
commit f861a3575d
5 files changed
+48 -10

No files matched your search

+12 -7
View File
@@ -69,7 +69,7 @@ These live in the source tree (see the path) rather than being fetched; traccc,
| [GEMMI](https://github.com/project-gemmi/gemmi) (0.7.5, trimmed) | `gemmi_gph/` | Global Phasing Ltd. | MPL-2.0 | [gemmi.txt](licenses/gemmi.txt) |
| [stb_sprintf](https://github.com/nothings/stb) (v1.10, bundled with GEMMI) | `gemmi_gph/stb/stb_sprintf.h` | Jeff Roberts / RAD Game Tools; Sean Barrett | MIT OR Unlicense | [stb_sprintf.txt](licenses/stb_sprintf.txt) |
| 3x3 symmetric eigensolver (Connelly Barnes, after JAMA; bundled with GEMMI) | `gemmi_gph/eig3.cpp` | — | public domain (no SPDX id) | — |
| [CCP4 Monomer Library](https://github.com/MonomerLibrary/monomers) (subset: restraint dictionary data) | `image_analysis/structure_refinement/monomers/` | CCP4 / the Monomer Library authors (Vagin et al.) | LGPL-3.0-only | [ccp4-monomer-library.txt](licenses/ccp4-monomer-library.txt) |
| [CCP4 Monomer Library](https://github.com/MonomerLibrary/monomers) (modified subset: restraint dictionary data) | `image_analysis/structure_refinement/monomers/` | CCP4 / the Monomer Library authors (Vagin et al.) | LGPL-3.0-only | [ccp4-monomer-library.txt](licenses/ccp4-monomer-library.txt) |
| [Larch](https://github.com/xraypy/xraylarch) (its Cromer-Liberman routines, as GEMMI ports them) | `gemmi_gph/fprime.cpp` | Matthew Newville, The University of Chicago, et al. | MIT | [larch.txt](licenses/larch.txt) |
| [PEGTL](https://github.com/taocpp/PEGTL) | `gemmi_gph/gemmi/third_party/tao/` | Dr. Colin Hirsch and Daniel Frey | MIT | [pegtl.txt](licenses/pegtl.txt) |
| [sajson](https://github.com/chadaustin/sajson) | `gemmi_gph/gemmi/third_party/sajson.h` | Chad Austin | MIT | [sajson.txt](licenses/sajson.txt) |
@@ -167,12 +167,17 @@ served frontend, so the shipped web UI carries its own attribution.
* **Apache-2.0** components: where upstream ships a `NOTICE` file, it is reproduced in the
corresponding `licenses/` text.
* **CCP4 Monomer Library (LGPL-3.0)** is data, not code: the restraint dictionaries of the compounds
rugnux's refinement restrains, copied unmodified per compound into
`image_analysis/structure_refinement/monomers/` (`links_and_mods.cif` and `ener_lib.cif` cut down to
the entries those compounds use, and the library's metal-site distances of `metals.json` for its ions as
`metals.cif`), with the library's own `COPYING`. The build embeds them in the binary
as text, and `image_analysis/structure_refinement/monomers/update_monomers.py` regenerates the subset from the upstream library, so the
copy can be replaced by a user with a version of their own.
rugnux's refinement restrains, in `image_analysis/structure_refinement/monomers/`, with the library's
own `COPYING`. The subset is a **modified** version of the library: the per-compound files are copied
unmodified, while `links_and_mods.cif` and `ener_lib.cif` are cut down to the entries those compounds
use and `metals.json` is converted to `metals.cif` holding only the metal-site distances of its ions.
Each of these three files says so in a comment at its top, with the date it was generated.
`image_analysis/structure_refinement/monomers/update_monomers.py` regenerates the subset from the
upstream library. The build embeds the files in the binary as text. As the LGPL-3.0 requires, the
modified files remain under LGPL-3.0 (with the GPL-3.0 text in `LICENSE`), the source tree carries
them in their preferred (text) form together with the script that makes them, and a user can replace
the embedded copy with a version of their own by replacing the files in that directory (or rerunning
the script on another library version) and rebuilding.
* **Qt (LGPL-3.0)** and **NVIDIA CUDA (EULA)** carry redistribution conditions beyond a copyright
notice; see their dedicated notice files. The verbatim LGPL-3.0 and CUDA EULA texts are bundled
(`licenses/Qt6-LGPL-3.0.txt`, `licenses/NVIDIA-CUDA-EULA.txt`); the CUDA EULA is the one shipped
@@ -1,3 +1,6 @@
# Modified from the CCP4 Monomer Library (https://github.com/MonomerLibrary/monomers),
# LGPL-3.0-only, see COPYING: ener_lib.cif, cut down to its atom-type table (_lib_atom).
# Generated by update_monomers.py on 2026-10-27.
data_energy
loop_
_lib_atom.type
@@ -1,3 +1,6 @@
# Modified from the CCP4 Monomer Library (https://github.com/MonomerLibrary/monomers),
# LGPL-3.0-only, see COPYING: links_and_mods.cif, cut down to the links and modifications that can apply to the compounds of update_monomers.py.
# Generated by update_monomers.py on 2026-11-14.
data_link_list
loop_
_chem_link.id
@@ -1,3 +1,6 @@
# Modified from the CCP4 Monomer Library (https://github.com/MonomerLibrary/monomers),
# LGPL-3.0-only, see COPYING: metals.json, converted to CIF and cut down to the metal ions of update_monomers.py and their donor elements.
# Generated by update_monomers.py on 2026-10-27.
data_metal_coordination
loop_
_metal_coordination.metal
@@ -16,8 +16,11 @@ to its atom-type table (_lib_atom: the van der Waals and ion radii and the hydro
metals.json, the library's statistics of metal-ligand distances, becomes metals.cif: for each metal ion of
COMPOUNDS and each donor element of METAL_LIGANDS, the distance per coordination number (the restraints of
metal sites the links of links_and_mods.cif do not describe).
These three are modified versions of library files, so each is written with a comment at its top that says
so, from what and when (the notice the library's LGPL-3.0 asks of a modified copy).
Requires the gemmi Python module."""
import datetime
import json
import os
import shutil
@@ -55,6 +58,27 @@ METAL_LIGANDS = ["O", "N", "S"]
GROUPS = {".", "peptide", "P-peptide", "M-peptide", "DNA/RNA", "NON-POLYMER", "pyranose"}
MODIFIED = {
"links_and_mods.cif": "links_and_mods.cif, cut down to the links and modifications that can apply to the "
"compounds of update_monomers.py",
"ener_lib.cif": "ener_lib.cif, cut down to its atom-type table (_lib_atom)",
"metals.cif": "metals.json, converted to CIF and cut down to the metal ions of update_monomers.py and their "
"donor elements",
}
def write_modified(doc, out):
"""Write a cut-down library file with the notice of the modification at its top."""
doc.write_file(out)
with open(out) as f:
text = f.read()
notice = ("# Modified from the CCP4 Monomer Library (https://github.com/MonomerLibrary/monomers),\n"
"# LGPL-3.0-only, see COPYING: " + MODIFIED[os.path.basename(out)] + ".\n"
"# Generated by update_monomers.py on " + datetime.date.today().isoformat() + ".\n")
with open(out, "w") as f:
f.write(notice + text)
def compound_path(lib, code):
return os.path.join(lib, code[0].lower(), code + ".cif")
@@ -82,7 +106,7 @@ def trim_links_and_mods(lib, out):
for block in doc:
if block.name in keep:
new.add_copied_block(block)
new.write_file(out)
write_modified(new, out)
return len(keep_links), len(keep_mods)
@@ -94,7 +118,7 @@ def trim_ener_lib(lib, out):
loop = block.init_loop("_lib_atom.", [t[len("_lib_atom."):] for t in atoms.tags])
for i in range(atoms.length()):
loop.add_row([atoms[i, j] for j in range(atoms.width())])
new.write_file(out)
write_modified(new, out)
def trim_metals(lib, out):
@@ -117,7 +141,7 @@ def trim_metals(lib, out):
loop.add_row([metal, ligand, str(row["coord"]), "%.4f" % row["mean"], "%.4f" % row["std"],
str(row["count"])])
n += 1
new.write_file(out)
write_modified(new, out)
return n