// SPDX-FileCopyrightText: 2026 Filip Leonarski, Paul Scherrer Institute // SPDX-License-Identifier: GPL-3.0-only #pragma once #include #include #include #include #include "gemmi/monlib.hpp" // The restraint dictionary refinement uses: the subset of the CCP4 Monomer Library (Vagin et al. 2004, // LGPL-3.0) carried in the binary - the standard amino acids and nucleotides, the common modified RNA nucleotides, // their links and modifications, the common cofactors (NAD(P)(H), FAD, FMN, hemes, SAM/SAH), the chromophores of // the common photoreceptors (retinal, p-coumaric acid, GFP-type, bilins), a few other ligands and additives, water // and ions; monomers/update_monomers.py holds the list. Parsed from memory once per process; // no file is read. const gemmi::MonLib &EmbeddedMonomerLibrary(); // The ideal distance and its sigma of a bond from a metal ion to a donor atom (O, N, S) at a site of `coordination` // donors, from the library's statistics of metal sites (metals.json, embedded as monomers/metals.cif). Only rows // resting on at least METAL_MIN_SITES sites count: the row of that coordination number, else the two nearest // below and above it interpolated linearly, else the nearest one; the sigma is the row's standard deviation, at // least METAL_MIN_SIGMA. False where the pair has no such row. constexpr int METAL_MIN_SITES = 20; constexpr double METAL_MIN_SIGMA = 0.02; // A bool EmbeddedMetalDistance(gemmi::El metal, gemmi::El ligand, int coordination, double &distance, double &sigma); // Whether `code` (a residue name) has a description in it. bool InEmbeddedMonomerLibrary(const std::string &code); // A restraint dictionary given by the user (rugnux --restraints): monomers, links and modifications that the // refinement takes over the embedded library's of the same name (BuildRefinementTopology). The caller reads it // from its files (ReadRestraintDictionary); a later entry of the same name replaces an earlier one. struct RestraintDictionary { std::vector monomers; std::vector links; std::vector modifications; std::set from_coordinates; // the monomers whose restraints were made from their coordinates std::vector names; // of the texts read, as given to ReadRestraintDictionary }; // Appends the contents of a restraint mmCIF to `dict`: a monomer-library, AceDRG or grade file (data_comp_list and // data_comp_ blocks, data_link_list and data_link_ blocks, data_mod_list ...), or an entry of the PDB // Chemical Component Dictionary. A CCD entry carries no restraint values: its bonds, the angles at each atom with // two or more bonds and a plane through each atom with a double or aromatic bond and its neighbours are restrained // to the geometry of its ideal coordinates, at the sigmas below - no torsions and no chiral volumes. `name` labels // the messages. Throws where the text holds no monomer, link or modification, or a CCD entry lacks an atom's ideal // coordinates. constexpr double DERIVED_BOND_SIGMA = 0.02; // A constexpr double DERIVED_ANGLE_SIGMA = 3.0; // degrees constexpr double DERIVED_PLANE_SIGMA = 0.02; // A void ReadRestraintDictionary(const std::string &text, const std::string &name, RestraintDictionary &dict); // The embedded library with `user` taken over it. gemmi::MonLib MonomerLibraryWith(const RestraintDictionary &user); // One .cif of monomers/, as CMakeLists.txt embeds it: its name and its text in pieces. struct EmbeddedMonomerFile { const char *name; const char *const *pieces; size_t n_pieces; };