Files
Jungfraujoch/writer/WriteModel.h
T
leonarski_f 15ca4b329f broker: serve the placed model and its maps of the last rugnux live run (/rugnux/model.cif, /rugnux/map.ccp4)
A rugnux live run that placed a model keeps it, with a copy of its map coefficients, beside the live
status (RugnuxStructure), for as long as /rugnux/status keeps the run. Made in memory on the first
request and cached, never written to disk:
- GET /rugnux/model.cif: the placed model as mmCIF, labelled as WritePlacedModel labels _model.cif
  (PlacedModelMmcif, the labelling factored out of WritePlacedModel; the file output is unchanged).
- GET /rugnux/map.ccp4?type=2fofc|fofc: the 2mFo-DFc / mFo-DFc map as a CCP4 map, FFT of the
  FWT/PHWT or DELFWT/PHDELWT coefficients (get_f_phi_on_grid + MapFromFPhi, sampled as ModelValidation
  samples), cut to the box around the model plus 5 A, with the whole cell's mean and RMS in the header.
- 404 without a placed model or maps, 400 for an unknown map type; both routes protected by the dataset
  bearer token like /rugnux/status. rugnux_live_status gets placed_model.

C++ model, python client docs, TypeScript client and redoc regenerated.

Tests: a point's coefficients give a map peaking at the atom in a cropped box; the mmCIF; the structure
is cleared at the next start; the auth test covers the new routes. End to end (myoglobin 2M replay with
an AlphaFold model): the maps equal gemmi's FFT of the written _maps.mtz to 2.5e-6 rms.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015CeEGgpKdfkCTJb3YNMJcu
(cherry picked from commit 33124c3288ba112def3f51c0d91f5206886f3495)
2026-10-22 20:18:50 +02:00

35 lines
1.8 KiB
C++

// SPDX-FileCopyrightText: 2026 Filip Leonarski, Paul Scherrer Institute <filip.leonarski@psi.ch>
// SPDX-License-Identifier: GPL-3.0-only
#pragma once
#include <string>
#include "gemmi/model.hpp"
#include "gemmi/symmetry.hpp"
#include "../common/UnitCell.h"
class Logger;
// Write `placed` - the atomic model as ValidateAgainstModel left it, re-fractionalized into the data
// cell and moved by the rigid-body step - to `output_prefix`_model.cif, and to `_model.pdb` as well where a PDB can express the cell. Everything the input carried
// comes with it: chains, residues, ligands, waters, B-factors, occupancies, anisotropic Us.
//
// `cell` and `space_group` must be the ones the reflection files beside it are written in, i.e. the
// unit cell and DiffractionExperiment::GetSpaceGroupOrP1() that WriteReflections is given after
// AdoptModelFrame has settled the enantiomorph. The cell is always taken; the group is taken wherever
// the model's coordinates obey it, which is the ordinary case. Where they do not - data merged in a
// supergroup of the model's group, or in the other hand - the model keeps its own group and a warning
// says the two files disagree, because a label whose operations the coordinates contradict makes a
// refinement program build a different structure and say nothing.
void WritePlacedModel(const gemmi::Structure &placed,
const UnitCell &cell,
const gemmi::SpaceGroup &space_group,
const std::string &output_prefix,
Logger &logger);
// The mmCIF text of `placed` exactly as WritePlacedModel writes it to <prefix>_model.cif, in memory.
std::string PlacedModelMmcif(const gemmi::Structure &placed, const UnitCell &cell,
const gemmi::SpaceGroup &space_group);