RESULT-CHANGING: Refinement: fewer displacement-model and NCS-ladder trials, none that changed a choice
Displacement models (after the final ladder): - No separate isotropic trial. It was a further 3 macro-cycles at the same weights, never adopted on 49 refinements (always worse than where the weights ended); the chain now starts where the weights ended, its free -ln L scored once. - TLSMD cuts: one body per chain and the finest cut run first; the cuts between them only where the finest fits the free set better (lower free -ln L) than one per chain. - Per-atom U at 1/4 and 1 times its balanced weight; the x4 trial is dropped. Replayed on the logs of 49 refinements (21 battery sets, 12 twin sets, 4YBB), neither rule changed an adopted choice; a strict "stop at the first cut that does not beat the previous" did (5 of them) and was rejected. NCS ladder: the rungs with NCS run only at the B weight the rungs without chose - NCS moved the chosen X-ray weight a rung up in 11 of 39 refinements with copies, the B choice in none. 4YBB (RTX 5080, one slot): refinement 826 -> 641 s, 4661 -> 3490 evaluations, ADP stage 329 -> 173 s, R-free 0.2402 unchanged, same TLS 108-group model. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HVeDQqN9qRD57vnShzTC37
This commit is contained in:
1 parent
89b37f9bc4
commit
f8e3bb4734
2 files changed
+111
-53
No files matched your search
@@ -304,24 +304,28 @@ are:
|
||||
whose free set the depositor's refinement has already fitted, R-work falls while R-free rises, and the
|
||||
trajectory ends where it began.
|
||||
3. **The final ladder**: the trajectory's weights times $\{0.5, 1, 2\}$, kept where one displaces it.
|
||||
4. **The displacement model**, from where the weights ended, each trial a macro-cycle longer than a step: the B
|
||||
factors refined on as they are (isotropic, or the model's U held); TLS groups with a residual B - the model's own,
|
||||
one per chain of at least 50 refinable atoms, and the chains cut into 2, 4, 8 and 16 contiguous segments of at
|
||||
least 10 residues as TLSMD cuts them (by dynamic programming over the least-squares fit of an isotropic TLS model,
|
||||
a quadratic B(r), to the refined B factors), each cut where it gives more groups than the one before; and a U per
|
||||
atom, at the U weight balanced as $w_{B,0}$ is (on the U shaken by 20% of its B) times $\{1/4, 1, 4\}$. A trial
|
||||
displaces the one before it only where its geometry is within bounds and both its R-free (beyond the tie) and the
|
||||
$-\ln L$ of the free reflections are lower: the free set tests the parameters a model adds, so the choice is made
|
||||
on the evidence of each run, not at a resolution (Merritt 2012). The refined U are written as ANISOU and the TLS
|
||||
groups as `_pdbx_refine_tls*` and `REMARK 3` (`REFINE_ADP_MODEL`, `REFINE_ANISO_ATOMS`, `REFINE_TLS_GROUPS`).
|
||||
It is decided after the solvent build (§15.10), on the model with its solvent: a water a round put in refines a U
|
||||
of its own in the per-atom trial as every refinable atom does, and no TLS group holds a water.
|
||||
4. **The displacement model**, from where the weights ended (the B factors as they are: isotropic, or the model's U
|
||||
held), each trial a macro-cycle longer than a step: TLS groups with a residual B - the model's own, one per chain
|
||||
of at least 50 refinable atoms, and the chains cut into 2, 4, 8 and 16 contiguous segments of at least 10 residues
|
||||
as TLSMD cuts them (by dynamic programming over the least-squares fit of an isotropic TLS model, a quadratic B(r),
|
||||
to the refined B factors), each cut where it gives more groups than the one before; and a U per atom, at the U
|
||||
weight balanced as $w_{B,0}$ is (on the U shaken by 20% of its B) times $\{1/4, 1\}$. The cuts between one group
|
||||
per chain and the finest run only where the finest fits the free set better (lower $-\ln L$) than one per chain;
|
||||
on 49 refinements of 33 structures neither this nor leaving out the U weight $\times 4$ changed a choice taken. A
|
||||
trial displaces the one before it (the first: where the weights ended) only where its geometry is within bounds
|
||||
and both its R-free (beyond the tie) and the $-\ln L$ of the free reflections are lower: the free set tests the
|
||||
parameters a model adds, so the choice is made on the evidence of each run, not at a resolution (Merritt 2012).
|
||||
The refined U are written as ANISOU and the TLS groups as `_pdbx_refine_tls*` and `REMARK 3` (`REFINE_ADP_MODEL`,
|
||||
`REFINE_ANISO_ATOMS`, `REFINE_TLS_GROUPS`). It is decided after the solvent build (§15.10), on the model with its
|
||||
solvent: a water a round put in refines a U of its own in the per-atom trial as every refinable atom does, and no
|
||||
TLS group holds a water.
|
||||
|
||||
Where the model has copies (§15.5), the NCS restraints are one more weight: every rung of the first ladder is run
|
||||
without them and then with them at $\sigma = 0.1$ Å, and every step of the trajectory also tries them changed -
|
||||
switched on where they are off, and in turn tightened ($\sigma$ halved) and loosened ($\sigma$ doubled, off beyond
|
||||
0.4 Å) where they are on. Listed after their twin without, the restraints are kept only where they lower R-free by
|
||||
more than the tie. A model without copies runs exactly the trials it ran before.
|
||||
without them, and then with them at $\sigma = 0.1$ Å at the B factors' weight the rungs without chose (NCS moves the
|
||||
X-ray weight a rung up as often as not, the B factors' choice it never changed on 39 refinements), and every step of
|
||||
the trajectory also tries them changed - switched on where they are off, and in turn tightened ($\sigma$ halved) and
|
||||
loosened ($\sigma$ doubled, off beyond 0.4 Å) where they are on. Listed after their twin without, the restraints are
|
||||
kept only where they lower R-free by more than the tie. A model without copies runs exactly the trials it ran before.
|
||||
|
||||
$w$ never exceeds $w_0/8$. The trials of one set run side by side - on one GPU, on several, or on the CPU's
|
||||
threads - each from the same start and taking nothing from the one before it, so the result does not depend
|
||||
|
||||
@@ -1467,6 +1467,7 @@ struct AdpHypothesis {
|
||||
std::vector<TlsBody> bodies; // Tls, with the part of each atom's B they hold at the start (Context::tls_b)
|
||||
std::vector<double> tls_b;
|
||||
std::vector<std::pair<int, int>> pairs; // Anisotropic: the pairs of the U restraints
|
||||
int segments = 0; // Tls: the TLSMD cut (segments per chain at most), 0 the model's own
|
||||
};
|
||||
|
||||
// One weight trial: `cycles` macro-cycles from pos0 and b0, of the positions at X-ray weight w and, where adp_w is
|
||||
@@ -1873,6 +1874,7 @@ std::vector<AdpHypothesis> AdpHypotheses(const Context &ctx, const RefinementTop
|
||||
std::string name = k == 1 ? fmt::format("TLS, {} groups (one per chain)", groups.size())
|
||||
: fmt::format("TLS, {} groups (chains in up to {} segments)", groups.size(), k);
|
||||
out.push_back(TlsHypothesis(ctx, std::move(name), std::move(groups)));
|
||||
out.back().segments = k;
|
||||
}
|
||||
}
|
||||
AdpHypothesis aniso;
|
||||
@@ -2313,24 +2315,27 @@ RefinementResult RefineOnce(const gemmi::Structure &placed, const std::vector<Me
|
||||
};
|
||||
// Of a set of trials, the one kept: they come in order of trust, the first kept unless a later one displaces
|
||||
// it. -1: none ran.
|
||||
auto choose = [&](std::vector<TrialOutcome> &outcomes, const char *stage) {
|
||||
auto best_of = [&](const std::vector<TrialOutcome> &outcomes) {
|
||||
int best = -1;
|
||||
for (size_t k = 0; k < outcomes.size(); k++) {
|
||||
const TrialOutcome &o = outcomes[k];
|
||||
if (!o.ran)
|
||||
continue;
|
||||
logger.Info("Refinement, {}: {}", stage, o.line);
|
||||
result.trials.push_back(o.trial);
|
||||
if (best < 0 || displaces(o.trial, outcomes[best].trial))
|
||||
for (size_t k = 0; k < outcomes.size(); k++)
|
||||
if (outcomes[k].ran && (best < 0 || displaces(outcomes[k].trial, outcomes[best].trial)))
|
||||
best = static_cast<int>(k);
|
||||
}
|
||||
return best;
|
||||
};
|
||||
auto choose = [&](std::vector<TrialOutcome> &outcomes, const char *stage) {
|
||||
for (const TrialOutcome &o : outcomes)
|
||||
if (o.ran) {
|
||||
logger.Info("Refinement, {}: {}", stage, o.line);
|
||||
result.trials.push_back(o.trial);
|
||||
}
|
||||
return best_of(outcomes);
|
||||
};
|
||||
const double w_max = w0 * settings.max_weight;
|
||||
|
||||
// 1. The weights from the placed model: the ladder's rungs, tighter geometry first, each with the B factors
|
||||
// held and refined at their own balanced weight; where there are copies, each without NCS restraints and
|
||||
// then with them.
|
||||
// held and refined at their own balanced weight; where there are copies, each rung without NCS restraints
|
||||
// and then with them - those with them at the B factors' weight the rungs without chose, which NCS does
|
||||
// not change (on 39 refinements of 21 structures with copies it never did; the X-ray weight it does).
|
||||
std::vector<TrialWeights> ladder;
|
||||
for (double rung : settings.weight_ladder)
|
||||
for (double adp : settings.adp_ladder) {
|
||||
@@ -2339,8 +2344,23 @@ RefinementResult RefineOnce(const gemmi::Structure &placed, const std::vector<Me
|
||||
ladder.push_back({w0 * rung, adp_w0 * adp, settings.ncs_sigma});
|
||||
}
|
||||
const std::vector<AtomAniso> aniso0 = ctx.aniso;
|
||||
std::vector<TrialOutcome> outcomes = RunTrials(trial_slots, ladder, refinable, pos0, b0, aniso0, nullptr,
|
||||
settings.macro_cycles, settings, ncs_p);
|
||||
std::vector<TrialOutcome> outcomes(ladder.size());
|
||||
auto run_ladder = [&](const std::function<bool(const TrialWeights &)> &these) {
|
||||
std::vector<TrialWeights> t;
|
||||
for (const TrialWeights &l : ladder)
|
||||
if (these(l))
|
||||
t.push_back(l);
|
||||
std::vector<TrialOutcome> ran = RunTrials(trial_slots, t, refinable, pos0, b0, aniso0, nullptr,
|
||||
settings.macro_cycles, settings, ncs_p);
|
||||
for (size_t i = 0, m = 0; i < ladder.size(); i++)
|
||||
if (these(ladder[i]))
|
||||
outcomes[i] = std::move(ran[m++]);
|
||||
};
|
||||
run_ladder([](const TrialWeights &l) { return l.ncs == 0; });
|
||||
if (const int b = best_of(outcomes); ncs_p != nullptr && b >= 0) {
|
||||
const double adp = outcomes[b].trial.adp_weight;
|
||||
run_ladder([&](const TrialWeights &l) { return l.ncs > 0 && l.adp == adp; });
|
||||
}
|
||||
int k = choose(outcomes, "ladder");
|
||||
TrialOutcome state;
|
||||
if (k >= 0)
|
||||
@@ -2655,12 +2675,16 @@ RefinementResult RefineOnce(const gemmi::Structure &placed, const std::vector<Me
|
||||
if (k >= 0 && displaces(outcomes[k].trial, state.trial))
|
||||
state = std::move(outcomes[k]);
|
||||
}
|
||||
// 4. The displacement model, decided late, on the free set: from where the weights ended, the B factors refined
|
||||
// on as they are, beside TLS bodies (the model's own groups, one per chain, the chains in TLSMD segments) with a
|
||||
// residual B, and a U per atom at three weights - each trial a macro-cycle longer than a step. One displaces
|
||||
// the one before it only where its geometry is within bounds and both its R-free (beyond the tie) and the -ln L
|
||||
// of the free reflections are lower: the free set is the test of the parameters it adds.
|
||||
// 4. The displacement model, decided late, on the free set: from where the weights ended, TLS bodies (the
|
||||
// model's own groups, one per chain, the chains in TLSMD segments) with a residual B, and a U per atom at
|
||||
// its balanced weight and a quarter of it - each trial a macro-cycle longer than a step. One displaces the one before it (the first
|
||||
// where the weights ended, the B factors as they are) only where its geometry is within bounds and both its
|
||||
// R-free (beyond the tie) and the -ln L of the free reflections are lower: the free set is the test of the
|
||||
// parameters it adds.
|
||||
// Following Merritt (2012) Acta Cryst. D68, 468-477 (the displacement model the data support, decided by test)
|
||||
// The trials that would not change the choice are left out: the TLS cuts between one body per chain and the
|
||||
// finest are tried only where the finest fits the free set better than one body per chain, and the U at four
|
||||
// times its balanced weight not at all (on 49 refinements of 33 structures, no choice taken changed).
|
||||
if (settings.adp_hypotheses && state.ran && !ctx.Cancelled()) {
|
||||
const RefinementStage adp_stage("adp_hypotheses");
|
||||
ctx.SetPositions(state.pos);
|
||||
@@ -2668,9 +2692,8 @@ RefinementResult RefineOnce(const gemmi::Structure &placed, const std::vector<Me
|
||||
ctx.SetAniso(state.aniso);
|
||||
ctx.Restore(state.fit);
|
||||
PlaceRiders(ctx, topo);
|
||||
state.trial.nll_free = ctx.Score().nll_free;
|
||||
std::vector<AdpHypothesis> hyps = AdpHypotheses(ctx, topo, input_tls);
|
||||
AdpHypothesis iso;
|
||||
iso.name = result.adp_input == "isotropic" ? "isotropic" : "the model's U held";
|
||||
const double w = state.trial.weight, adp = state.trial.adp_weight > 0 ? state.trial.adp_weight : adp_w0;
|
||||
// the U weight balanced on the model with every refinable atom given a U
|
||||
double u_w0 = adp;
|
||||
@@ -2690,37 +2713,68 @@ RefinementResult RefineOnce(const gemmi::Structure &placed, const std::vector<Me
|
||||
ctx.SetAniso(keep);
|
||||
}
|
||||
const double ncs_s = state.trial.ncs_sigma;
|
||||
std::vector<TrialWeights> trials = {{w, adp, ncs_s}};
|
||||
std::vector<const AdpHypothesis *> which = {&iso};
|
||||
// every trial in order of trust; those between one TLS body per chain and the finest cut run after the
|
||||
// others where those ask for them
|
||||
std::vector<TrialWeights> trials;
|
||||
std::vector<const AdpHypothesis *> which;
|
||||
int coarsest = -1, finest = -1;
|
||||
for (const AdpHypothesis &h : hyps) {
|
||||
if (h.kind == AdpHypothesis::Kind::Anisotropic) {
|
||||
for (double f : {0.25, 1.0, 4.0}) {
|
||||
for (double f : {0.25, 1.0}) {
|
||||
trials.push_back({w, u_w0 * f, ncs_s});
|
||||
which.push_back(&h);
|
||||
}
|
||||
} else {
|
||||
if (h.segments > 0) {
|
||||
if (coarsest < 0)
|
||||
coarsest = static_cast<int>(trials.size());
|
||||
finest = static_cast<int>(trials.size());
|
||||
}
|
||||
trials.push_back({w, adp, ncs_s});
|
||||
which.push_back(&h);
|
||||
}
|
||||
}
|
||||
outcomes = RunTrials(trial_slots, trials, refinable, state.pos, state.b, state.aniso, &state.fit,
|
||||
settings.macro_cycles + 1, settings, ncs_p, which);
|
||||
int best = -1;
|
||||
std::vector<char> later(trials.size(), 0);
|
||||
for (int k = coarsest + 1; k < finest; k++)
|
||||
later[k] = 1;
|
||||
outcomes.assign(trials.size(), TrialOutcome());
|
||||
auto run = [&](const std::vector<char> &these) {
|
||||
std::vector<TrialWeights> t;
|
||||
std::vector<const AdpHypothesis *> h;
|
||||
for (size_t k = 0; k < trials.size(); k++)
|
||||
if (these[k]) {
|
||||
t.push_back(trials[k]);
|
||||
h.push_back(which[k]);
|
||||
}
|
||||
std::vector<TrialOutcome> ran = RunTrials(trial_slots, t, refinable, state.pos, state.b, state.aniso,
|
||||
&state.fit, settings.macro_cycles + 1, settings, ncs_p, h);
|
||||
for (size_t k = 0, m = 0; k < trials.size(); k++)
|
||||
if (these[k])
|
||||
outcomes[k] = std::move(ran[m++]);
|
||||
};
|
||||
std::vector<char> now(trials.size());
|
||||
for (size_t k = 0; k < trials.size(); k++)
|
||||
now[k] = !later[k];
|
||||
run(now);
|
||||
auto fits_better = [&](int a, int b) {
|
||||
return outcomes[a].ran && outcomes[b].ran && outcomes[a].trial.nll_free < outcomes[b].trial.nll_free;
|
||||
};
|
||||
if (finest > coarsest + 1 && fits_better(finest, coarsest))
|
||||
run(later);
|
||||
int best = -1; // where the weights ended
|
||||
auto trial = [&](int k) -> const RefinementWeightTrial & { return k < 0 ? state.trial : outcomes[k].trial; };
|
||||
for (size_t k = 0; k < outcomes.size(); k++) {
|
||||
const TrialOutcome &o = outcomes[k];
|
||||
if (!o.ran)
|
||||
const RefinementWeightTrial &t = outcomes[k].trial;
|
||||
if (!outcomes[k].ran)
|
||||
continue;
|
||||
logger.Info("Refinement, displacements: {}", o.line);
|
||||
result.adp_trials.push_back(o.trial);
|
||||
if (best < 0 || (o.trial.within_bounds && (!outcomes[best].trial.within_bounds ||
|
||||
(o.trial.r_free < outcomes[best].trial.r_free - R_FREE_TIE &&
|
||||
o.trial.nll_free < outcomes[best].trial.nll_free))))
|
||||
logger.Info("Refinement, displacements: {}", outcomes[k].line);
|
||||
result.adp_trials.push_back(t);
|
||||
if (t.within_bounds && (!trial(best).within_bounds ||
|
||||
(t.r_free < trial(best).r_free - R_FREE_TIE && t.nll_free < trial(best).nll_free)))
|
||||
best = static_cast<int>(k);
|
||||
}
|
||||
// Each is a step further on the same weights: the one chosen is kept where it displaces where the weights
|
||||
// ended, as any step (at low resolution the B factors refined on may all be worse than B held).
|
||||
result.adp_model = iso.name;
|
||||
if (best >= 0 && displaces(outcomes[best].trial, state.trial)) {
|
||||
result.adp_model = result.adp_input == "isotropic" ? "isotropic" : "the model's U held";
|
||||
if (best >= 0) {
|
||||
result.adp_model = outcomes[best].trial.adp;
|
||||
state = std::move(outcomes[best]);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user