Refinement restraints: the CCP4 Monomer Library subset embedded in rugnux, read through gemmi's MonLib
A restraint dictionary carried in the binary, so refinement reads nothing from disk and needs no CLIBD_MON: the 20 amino acids and MSE, the DNA/RNA nucleotides, ATP/ADP/AMP/GTP/GDP/GMP, DMSO, PEG fragments (PEG, PGE, PG4, 1PE), GOL, EDO, SO4, PO4, ACT, MPD, water and common ions - copied verbatim from the CCP4 Monomer Library (LGPL-3.0) - plus links_and_mods.cif cut down to the links and modifications those compounds can take (peptide, cis-peptide, proline, N-methyl, disulfide, nucleic-acid backbone, termini, metal-Cys/His) and ener_lib.cif cut to its atom-type table. monomers/update_monomers.py holds the compound list and regenerates the subset; CMake embeds every .cif of the directory as string pieces under MSVC's literal limit; EmbeddedMonomerLibrary() parses them from memory into a gemmi::MonLib once per process. About 0.7 MB of text in the binary. gemmi v0.7.5's monlib.cpp, topo.cpp and riding_h.cpp vendored verbatim (prepare_topology). Licence text in licenses/, rows and a note in THIRD_PARTY_NOTICES.md. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015CeEGgpKdfkCTJb3YNMJcu (cherry picked from commit 38034718052c4a300691393b5b817f476c83dfc2)
This commit is contained in:
1 parent
8ff2abf3aa
commit
e58453a693
77 files changed
+18293
-1
No files matched your search
@@ -0,0 +1,41 @@
|
||||
// SPDX-FileCopyrightText: 2026 Filip Leonarski, Paul Scherrer Institute <filip.leonarski@psi.ch>
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
#include "MonomerLibrary.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
#include "gemmi/read_cif.hpp" // read_cif_from_memory
|
||||
|
||||
// Generated by CMakeLists.txt from monomers/*.cif (MonomerLibraryData.cpp in the build tree).
|
||||
extern const EmbeddedMonomerFile embedded_monomer_files[];
|
||||
extern const size_t embedded_monomer_file_count;
|
||||
|
||||
namespace {
|
||||
|
||||
gemmi::MonLib ReadEmbeddedMonomerLibrary() {
|
||||
gemmi::MonLib monlib;
|
||||
for (size_t i = 0; i < embedded_monomer_file_count; i++) {
|
||||
const EmbeddedMonomerFile &f = embedded_monomer_files[i];
|
||||
std::string text;
|
||||
for (size_t k = 0; k < f.n_pieces; k++)
|
||||
text += f.pieces[k];
|
||||
const gemmi::cif::Document doc = gemmi::read_cif_from_memory(text.data(), text.size(), f.name);
|
||||
if (std::strcmp(f.name, "ener_lib.cif") == 0)
|
||||
monlib.ener_lib.read(doc);
|
||||
else
|
||||
monlib.read_monomer_doc(doc);
|
||||
}
|
||||
return monlib;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
const gemmi::MonLib &EmbeddedMonomerLibrary() {
|
||||
static const gemmi::MonLib monlib = ReadEmbeddedMonomerLibrary();
|
||||
return monlib;
|
||||
}
|
||||
|
||||
bool InEmbeddedMonomerLibrary(const std::string &code) {
|
||||
return EmbeddedMonomerLibrary().monomers.count(code) > 0;
|
||||
}
|
||||
Reference in new issue
Block a user