// SPDX-FileCopyrightText: 2026 Filip Leonarski, Paul Scherrer Institute // SPDX-License-Identifier: GPL-3.0-only #pragma once // A residue's side chain turned about its chi bonds, and its overlap with the rest of the model: what ClashRelief // (the side chains turned clear of another residue before refining) and SideChainField (the side chains searched // against the likelihood) share. #include #include #include #include #include #include #include // How far along the side chain an atom is, hydrogens by their parent's letter: CB 1, gamma 2, delta 3, epsilon 4, // zeta 5, eta 6; the main chain and its hydrogens 0. int SideChainDepth(const std::string &name); struct SideChain { std::vector pos; // the residue's atoms, as given std::vector depth; std::vector> chi; // atom indices of each chi double Dihedral(const std::vector &p, size_t k) const; // The residue's atoms with the side chain at these chi angles (degrees), turned from the given ones. std::vector Build(const std::vector &chis) const; std::vector Chis() const; }; // The residue's chi atoms, found by name; none for a residue without chi angles (Gly, Ala, Pro, Cys and anything // but an amino acid), where any is missing (an incomplete side chain stays as it is) or the residue has alternative // conformations (its atoms would be found by name once, for both). std::optional MakeSideChain(const gemmi::Residue &res); // The rotamers tried: each chi at the staggered angles, the last one of a planar group every 30 degrees. std::vector> SideChainRotamers(const std::string &resname, size_t n_chi); // The overlaps of a residue's turned atoms (depth 2 and beyond, heavy) with the rest of the model: the sum of // squared overlaps and the deepest one. Its own atoms, hydrogens, absent atoms (occupancy 0), metals and the // other conformations of an alternative are no contact; nor is a covalent partner (`linked`: a LINK's, or a // disulfide's). Polar pairs may come to the hydrogen-bond distance, others to the sum of their van der Waals radii. struct SideChainOverlap { double sum = 0, deepest = 0; }; SideChainOverlap OverlapOf(gemmi::NeighborSearch &ns, const gemmi::Model &model, const gemmi::UnitCell &cell, const gemmi::Residue &res, int chain_idx, int residue_idx, const SideChain &sc, const std::vector &p, const std::vector &linked);