A restraint mmCIF (monomer library, AceDRG, grade, eLBOW: data_comp_<CODE>, data_link_*, data_mod_*) is read by the caller (ReadRestraintDictionary, no file I/O in the library) into a RestraintDictionary that RefinementSettings carries; BuildRefinementTopology takes its entries over the embedded library's of the same name. A PDB CCD entry (bonds without lengths) is restrained to its ideal coordinates' bonds, angles and sp2 planes (no torsions, no chiral volumes); without ideal coordinates it is refused. Positional inputs: an mmCIF with _chem_comp_atom/_chem_link/_chem_mod and no atoms or reflections is a restraint file; a model and reflections with no images and no --mode run --mode refine. Embedded: RET (LYS-RET), HC4, CRO, GYS, CR2, NRQ (their pept links), BLA, LBV, CYC (CYS-CYC). CMO stays out (library C-O 1.25 A). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UqXYdJDrM65gxsCn2PrbfK
65 lines
3.6 KiB
C++
65 lines
3.6 KiB
C++
// SPDX-FileCopyrightText: 2026 Filip Leonarski, Paul Scherrer Institute <filip.leonarski@psi.ch>
|
|
// SPDX-License-Identifier: GPL-3.0-only
|
|
|
|
#pragma once
|
|
|
|
#include <cstddef>
|
|
#include <set>
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
#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<gemmi::ChemComp> monomers;
|
|
std::vector<gemmi::ChemLink> links;
|
|
std::vector<gemmi::ChemMod> modifications;
|
|
std::set<std::string> from_coordinates; // the monomers whose restraints were made from their coordinates
|
|
std::vector<std::string> 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_<CODE> blocks, data_link_list and data_link_<ID> 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;
|
|
};
|