Files
leonarski_fandClaude Fable 5.1 2676b22312 Refinement: the side-chain rotamer helpers of ClashRelief in a header of their own
MakeSideChain, SideChain::Build, the staggered rotamer list and the overlap against the rest of the model move from
ClashRelief.cpp to SideChainRotamers.{h,cpp}, unchanged, so that the side-chain field can turn side chains and
score their contacts the same way. RelieveSideChainClashes is as it was.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UqXYdJDrM65gxsCn2PrbfK
2026-11-14 16:53:42 +01:00

51 lines
2.6 KiB
C++

// SPDX-FileCopyrightText: 2026 Filip Leonarski, Paul Scherrer Institute <filip.leonarski@psi.ch>
// 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 <array>
#include <optional>
#include <string>
#include <vector>
#include <gemmi/model.hpp>
#include <gemmi/neighbor.hpp>
#include <gemmi/unitcell.hpp>
// 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<gemmi::Position> pos; // the residue's atoms, as given
std::vector<int> depth;
std::vector<std::array<int, 4>> chi; // atom indices of each chi
double Dihedral(const std::vector<gemmi::Position> &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<gemmi::Position> Build(const std::vector<double> &chis) const;
std::vector<double> 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<SideChain> 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<std::vector<double>> 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<gemmi::Position> &p, const std::vector<const gemmi::Atom *> &linked);