// SPDX-FileCopyrightText: 2026 Filip Leonarski, Paul Scherrer Institute // SPDX-License-Identifier: GPL-3.0-only #pragma once #include #include #include #include #include "gemmi/model.hpp" #include "gemmi/symmetry.hpp" #include "../common/MtzTable.h" #include "../common/UnitCell.h" enum class RugnuxMapType { TwoFoFc, FoFc, Anomalous }; // The placed model and the map coefficients of a live rugnux run, for the broker to serve to a viewer: the // model as mmCIF, the same text as _model.cif (PlacedModelMmcif), and the maps as CCP4 map files - made in memory when // first asked for and kept, never written to disk. class RugnuxStructure { std::shared_ptr model; UnitCell cell; gemmi::SpaceGroup space_group; std::optional coefficients; // FWT/PHWT and DELFWT/PHDELWT, as _maps.mtz holds them mutable std::mutex m; mutable std::optional model_cif; mutable std::optional map_2fofc, map_fofc, map_anom; public: // How far the maps reach beyond the model where it is wider than the cell. static constexpr double MAP_MARGIN_A = 5.0; RugnuxStructure(std::shared_ptr model, const UnitCell &cell, const gemmi::SpaceGroup &space_group, std::optional coefficients); bool HasMaps() const; // The coefficients include the anomalous difference map (ANOM/PHANOM): the merge kept the Bijvoet pairs. bool HasAnomalousMap() const; std::string ModelCif() const; // A CCP4 map (mode 2), sampled every d_min/3, on one unit cell centred on the model - along an axis the model // reaches further than the cell, on the model plus MAP_MARGIN_A instead, so that all of it has density. The // header's mean and RMS are those of the cell. Empty where there are no map coefficients, or for the anomalous // map none of its coefficients. std::string Map(RugnuxMapType type) const; };