Build Packages / Create release (push) Successful in 9s
Build Packages / build:portable:macos-arm64:nocuda (push) Successful in 5m19s
Build Packages / build:rugnux:linux-aarch64:cuda (push) Successful in 10m26s
Build Packages / build:portable:linux-x86_64:nocuda (push) Successful in 19m33s
Build Packages / build:portable:windows-x86_64:nocuda (push) Successful in 23m17s
Build Packages / build:portable:linux-x86_64:cuda (push) Successful in 23m28s
Build Packages / build:jfjoch:ubuntu2204:nocuda (push) Successful in 24m38s
Build Packages / build:portable:windows-x86_64:cuda (push) Successful in 27m30s
Build Packages / HDF5 consumer tests (DIALS, XDS) (push) Successful in 29m4s
Build Packages / build:jfjoch:rocky8:nocuda (push) Successful in 29m19s
Build Packages / build:jfjoch:rocky9:nocuda (push) Successful in 29m31s
Build Packages / build:jfjoch:ubuntu2404:nocuda (push) Successful in 23m19s
Build Packages / Generate python client (push) Successful in 28s
Build Packages / Build documentation (push) Successful in 1m22s
Build Packages / build:jfjoch:rocky8:cuda-sls9 (push) Successful in 24m39s
Build Packages / build:jfjoch:rocky9:cuda-sls9 (push) Successful in 29m40s
Build Packages / build:jfjoch:rocky8:cuda (push) Successful in 28m31s
Build Packages / build:jfjoch:ubuntu2204:cuda (push) Successful in 24m33s
Build Packages / build:jfjoch:ubuntu2404:cuda (push) Successful in 27m45s
Build Packages / build:jfjoch:rocky9:cuda (push) Successful in 29m25s
Build Packages / Unit tests (push) Successful in 1h35m24s
Build Packages / Validation Battery (push) Successful in 35m45s
* Rugnux: A placed model is refined by default - restrained maximum-likelihood refinement on the GPU (CPU without one), writing `<prefix>_refined_model.cif`, `<prefix>_refined_maps.mtz` and the difference-map blobs in `<prefix>_blobs.json`; `--no-refine` skips it. * Rugnux: `--mode refine` refines a model against merged structure factors from an MTZ or mmCIF file. * Rugnux: The embedded restraint dictionary covers amino acids, nucleotides including common modified RNA nucleotides, common cofactors, crystallisation additives, waters and ions, with metal sites restrained from the model's LINK records. * Rugnux: A model or reference file can be given among the inputs in any order, recognised by its contents. * Rugnux: The geometry refinement algorithm option is now `-r, --geom-refine` (was `--refine`). * Rugnux: Serial stills resolve the indexing ambiguity from the data when no model or reference is given, reject merge outliers by default, follow the run's measured rocking curve in prediction and partiality (also in `--mode scale`), and index reproducibly on the GPU. * Rugnux: Reflections touching the beam-stop shadow are not integrated, reflections coarser than the low-resolution limit are merged and written (but kept out of the scale fit), and the polarisation plane is measured more reliably. * Rugnux: Small-molecule runs report unit-cell e.s.d.s, in a SHELX `.ins` beside the `.hkl` and in the mmCIF. * jfjoch_broker: Live Rugnux refines the uploaded model after placement; the web frontend's Rugnux live page has a hero panel with resolution, ISa, space group, placement and refined R-work/R-free, and its Mol* viewer shows the refined model and maps. * Documentation: A new front page with download pages for Rugnux and the viewer, and the technical reference reorganised below it. * Build: The fast-feedback indexer is part of the source tree instead of being downloaded at build time. Reviewed-on: #91 Co-authored-by: Filip Leonarski <filip.leonarski@psi.ch>
78 lines
5.1 KiB
C++
78 lines
5.1 KiB
C++
// SPDX-FileCopyrightText: 2026 Filip Leonarski, Paul Scherrer Institute <filip.leonarski@psi.ch>
|
|
// SPDX-License-Identifier: GPL-3.0-only
|
|
|
|
#pragma once
|
|
|
|
#include <cmath>
|
|
#include <cstdint>
|
|
#include <vector>
|
|
|
|
#include "gemmi/symmetry.hpp"
|
|
|
|
#include "../../common/DiffractionExperiment.h"
|
|
#include "../IntegrationOutcome.h"
|
|
|
|
// Serial stills with no reference: every crystal is indexed in one of the indexings its lattice allows
|
|
// (the identity and the twin-law operators of ReindexAmbiguityOperators), at random. Which one each
|
|
// crystal is in is decided from the data alone, by putting each crystal into the indexing in which it
|
|
// agrees best with all the others. The overall choice among the equivalent consistent answers is the
|
|
// one that moves the fewest crystals.
|
|
//
|
|
// An operator is only an ambiguity where the crystal's own lattice cannot tell the indexings apart. Where
|
|
// the cell is merely close to a more symmetric one (two axes a few per cent apart, say), the crystals'
|
|
// refined cells already say which axis is which, and the indexer has used that. For such an operator a
|
|
// crystal whose cell prefers the indexing it came in stays there, as an anchor, and only the others are
|
|
// decided by the intensities.
|
|
// An operator whose reindexed cell is the worse fit to the run's cell for at least this share of the
|
|
// crystals is one the cells decide. For a true (merohedral) ambiguity the two fits are equal and the
|
|
// share is a half.
|
|
constexpr double METRIC_DECIDED = 0.9;
|
|
|
|
// Which indexings each image's own refined cell leaves open. Indexing g is the image as indexed for g = 0
|
|
// and after ops[g - 1] otherwise; `cell` is the run's cell. An operator the cells decide is closed to
|
|
// every image whose cell fits `cell` better as indexed; everything else is open.
|
|
struct MetricAnchors {
|
|
std::vector<double> metric_preference; // per operator: share of the images whose refined cell is
|
|
// closer to `cell` as indexed than after the operator
|
|
std::vector<uint8_t> allowed; // allowed[o * (ops.size() + 1) + g]: indexing g open to image o
|
|
};
|
|
MetricAnchors AnchorOnCells(const std::vector<IntegrationOutcome> &outcomes, const UnitCell &cell,
|
|
const std::vector<gemmi::Op> &ops);
|
|
|
|
// With a reference - a reference MTZ or intensities from the model - each image has been put, image by
|
|
// image, into the indexing that correlates best with it (ReindexAmbiguityResolver, which leaves the scores in
|
|
// IntegrationOutcome::reference_cc, over the same `ops`). The reference knows nothing of the cells, so
|
|
// here the cells have their say first, as above: an image its own cell anchors keeps that indexing,
|
|
// and the reference decides among the indexings left open to the others.
|
|
struct ReferenceAnchorResult {
|
|
std::vector<double> metric_preference; // as in MetricAnchors
|
|
size_t overruled = 0; // images the reference had put into an indexing their cell
|
|
// excludes, now in the best open one instead
|
|
};
|
|
ReferenceAnchorResult AnchorReferenceReindex(std::vector<IntegrationOutcome> &outcomes, const UnitCell &cell,
|
|
const std::vector<gemmi::Op> &ops);
|
|
|
|
struct ReferenceFreeReindexResult {
|
|
size_t crystals = 0; // crystals that took part (enough reflections to say anything, and an
|
|
// indexing their own cell leaves open)
|
|
size_t reindexed = 0; // of them, put into an indexing other than the one they came in
|
|
double median_sigma = NAN; // per crystal, how far its chosen indexing beats the best other one
|
|
// in agreement with the rest of the merge, in sigma; the median
|
|
double decided_fraction = NAN; // share of the crystals for which that margin is over 3 sigma
|
|
double cc_chosen = NAN; // median CC of a crystal with the merge of all the others, as chosen
|
|
double cc_other = NAN; // ... and in the best other indexing
|
|
std::vector<double> metric_preference; // per operator: share of crystals whose refined cell is
|
|
// closer to `cell` as indexed than after the operator
|
|
int sweeps = 0; // passes over the crystals until (almost) none changed (the start kept)
|
|
std::vector<int> choice; // per outcome: -1 did not take part, 0 kept, k reindexed by ops[k - 1]
|
|
};
|
|
|
|
// `cell` is the run's cell, `ops` its twin-law operators (identity excluded). With apply = false nothing is changed - the
|
|
// result then says how many crystals the data alone would put into another indexing than they are in,
|
|
// which, after a reference has resolved them, is the disagreement with the reference.
|
|
ReferenceFreeReindexResult ResolveReindexReferenceFree(std::vector<IntegrationOutcome> &outcomes,
|
|
const DiffractionExperiment &x,
|
|
const UnitCell &cell,
|
|
const std::vector<gemmi::Op> &ops,
|
|
size_t nthreads, bool apply);
|