From a64d3e3c4cf729136297df954a267732963463e9 Mon Sep 17 00:00:00 2001 From: Filip Leonarski Date: Sat, 14 Nov 2026 03:24:01 +0100 Subject: [PATCH] Refinement rounds: no placement in rounds 2-3, no maps for a round not kept A further round starts from the model the round before refined, so the rigid-body and per-residue-B placement is skipped there; and a round whose R-free does not beat the one before is returned before its maps, twin null and blobs (it is discarded anyway). The placement skip changes the path of the later rounds, not the rule: on 22 battery merges with their placed models R-free equal to the rounds without it except lyso_x06da_ref 0.2413 -> 0.2430 and cytc_x06da_1 0.3143 -> 0.3128; from the timing benchmark's AlphaFold models (MR, mx): cytc_x10sa 0.410 -> 0.399, 9zlo 0.283 -> 0.284, myob_x10sa 0.312 -> 0.312, 9s02/9gjx equal; cytochrome C live merge, MR model 0.405 -> 0.400. Saves about 1-2 s of the 7-8 s the rounds add on cytochrome C (wall 15.5 -> 13.6 s). Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01HVeDQsU5a8AJUdJPgWevAK --- image_analysis/structure_refinement/Refinement.cpp | 11 ++++++++++- image_analysis/structure_refinement/Refinement.h | 4 ++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/image_analysis/structure_refinement/Refinement.cpp b/image_analysis/structure_refinement/Refinement.cpp index 7e8c81502..9db12da54 100644 --- a/image_analysis/structure_refinement/Refinement.cpp +++ b/image_analysis/structure_refinement/Refinement.cpp @@ -2563,7 +2563,8 @@ RefinementResult RefineOnce(const gemmi::Structure &placed, const std::vector(std::chrono::steady_clock::now() - start).count(); + return result; + } finish(); logger.Info("Refinement: done in {:.1f} s, {} target evaluations{}", result.seconds, ctx.evaluations, @@ -3350,12 +3357,14 @@ RefinementResult RefineRounds(const gemmi::Structure &placed, const std::vector< null_first, held); RefinementSettings again = settings; again.solvent = false; + again.placement = false; // the chains and the B per residue were placed by the first round for (int round = 2; round <= REFINEMENT_ROUNDS; round++) { if (!result.ok || !result.restrained || result.as_given || result.cancelled || settings.score_only || result.model == nullptr) break; logger.Info("Refinement, round {}: from the model the round before ended with (R-free {:.4f})", round, result.r_free); + again.keep_below = result.r_free - R_FREE_TIE; RefinementResult next = RefineOnce(*result.model, merged, cell, sg, wavelength_A, logger, again, twin_laws, null_first); if (!next.ok || !next.restrained || next.as_given || !(next.r_free < result.r_free - R_FREE_TIE)) { diff --git a/image_analysis/structure_refinement/Refinement.h b/image_analysis/structure_refinement/Refinement.h index c10e6dd84..c5b46c787 100644 --- a/image_analysis/structure_refinement/Refinement.h +++ b/image_analysis/structure_refinement/Refinement.h @@ -84,6 +84,10 @@ struct RefinementSettings { // statistic - false where the model has most likely been refined against the free reflections too (a deposited // model of this crystal scored on a free set drawn here). bool as_given_competes = true; + // For a further round of the refinement (RefineRounds): the placement stage skipped, and the maps, the twin null + // and the blobs made only where R-free ends below keep_below - the round is not kept otherwise. + bool placement = true; + double keep_below = INFINITY; bool gpu = true; size_t nthreads = 1; size_t gpu_resident_bytes = 0; // held on the card by what runs beside