# Rugnux validation battery `battery.py` is the one way to run the Rugnux validation battery: run `rugnux` over a fixed list of rotation datasets, score each result against a reference, and write a standard report. Two runs of the same manifests with the same options give results you can compare set by set. Do not use ad-hoc runner scripts instead. The old ones (`rugnux_vs_xds.py`, `battery_run.py`, `battery2_serial.py`, `batstats.py`, ...) are retired because their numbers could not be compared with each other. ## Arms | arm | datasets | reference | manifest | |---|---|---|---| | **open** | public PDB depositions of raw diffraction data, plus a few published small-molecule sets | the deposited space group, cell and resolution | `open.json` (committed) | | **inhouse** | standard test crystals measured at the SLS (lysozyme, thaumatin, insulin, cytochrome C, myoglobin), plus no-crystal controls | XDS, from the `CORRECT.LP` beside each dataset | `inhouse.json` (committed) | | **private** | user data | XDS, like inhouse | outside the repository; the local site config gives its path | Scoring checks four things in order, and the first one that fails decides the verdict: did it run, is the lattice right, is the symmetry right, is the merge usable (R_meas at most 60%, CC1/2 at least 0.5). The lattice test compares Niggli-reduced primitive cells: the primitive volume ratio must be 0.95-1.05 and the reduced edges must agree within 2%. On the open arm the space group is scored with `sgequiv`. On the XDS arms only the point group is scored, because XDS never tests a screw axis. A no-crystal control (`"expect": "no_lattice"`) passes only if no lattice is reported. `score.py` has the details. ## Variants Every set is run more than once, with different settings, and each run is a **variant**. The variants of one set run straight after each other, before the next set starts. The battery is limited by reading images from disk, and this way only the first variant reads them; the others find them in the page cache. | arm (reference) | variants, in the order they run | |---|---| | open (deposition) | `bare`, then `model` | | inhouse, private (XDS) | `bare`, then `xds` | - **`bare`**: plain `rugnux ` and nothing else (no `-A`, no resolution range). This is what a user gets. It is scored against the reference like the others, and its d_min ratio against the reference is plotted. - **`model`** (open arm): `rugnux --model `. The coordinates (`.cif.gz`) and the published R-free come from the RCSB and are cached in the site's `pdb_cache` (default `/data/battery/pdb_cache`), so the first run of a new entry needs network access. The entry is the set id up to the first `_`, so `6h2p_native` uses `6h2p`. A set with no PDB entry (small molecules) or whose coordinates cannot be downloaded gets a `not_run` row with cause `no_model`. The row records the R-free and R-work that rugnux reports for the model, the published R-free and their ratio, which the report plots. rugnux's R-free is that of a rigid-body placement against its own merge, and the published one comes from full refinement against the depositor's own data, so the ratio is not a like-for-like score; watch how it moves between runs. - **`xds`** (XDS arms): XDS's reference settings. XDS's resolution range is forced (see "The XDS reference d_min" below), and where XDS merged with `FRIEDEL'S_LAW=FALSE` (`"anomalous": true` in the manifest) rugnux gets `-A`. Both programs then merge the same reflections the same way. The variants are defined in one place, `VARIANTS` in `battery.py`. `--variants` runs a subset, for example `--variants bare`, and they always run in the table's order. `--unforced` is gone: `--variants bare` gives rugnux its own resolution cut (and, unlike `--unforced`, no `-A`). **Order and timing.** `bare` goes first on every arm. So its time always includes reading the data from disk (unless the images were still cached from before the run), whichever variants a run selects, and it is the time a user sees. The time of a later variant is taken on cached images. Each row records whether it was its set's `first_read`, and the report's timing table says which variant carries the disk reads. Compare times of one variant between runs only, never across variants. The private arm is never mixed with the others. A private run gets its own run directory (suffix `_private`) and its own report (`report_PRIVATE.*`), and it cannot be the baseline of a public report or be written into the repository. Its names, paths and values never go into a commit, an issue or a public report. ## Getting the data Each manifest row gives an `input` path relative to that arm's **data root**. The data root is set in the site config, and the first directory of each input is the dataset's directory: ``` /11if/BopeA_18500_a_B2-PEF_11if/data/PSL-1503_13949_master.h5 /lyso_ref/hewl_35_001_master.h5 ``` To move the battery to another machine, copy the two data roots and point the new site config at the copies. The paths inside the manifests do not change. - **open**: every dataset is listed with its source repository and dataset DOI in [`docs/EXTERNAL_TEST_DATA.md`](../../docs/EXTERNAL_TEST_DATA.md). The sources are IRRMC (proteindiffraction.org), SBGrid Data Bank, Zenodo and a few others, and the page also says what each archive holds. Please cite those DOIs. At PSI the data root is `/home/data/open`, a symlink to `/home/data/nonsls/raw`. 51 of the dataset directories in it are themselves symlinks into `/data/scout_staging2`, so **copy with symlinks followed**: `rsync -aL` or `cp -rL`. A plain `rsync -a` copies dangling links. The open arm is about 1.7 TB. - **inhouse**: these are our own measurements and cannot be downloaded publicly. Ask the maintainers for a copy. Each dataset directory holds the images and the XDS output (`CORRECT.LP`, `XDS_ASCII.HKL`, ...) that the reference comes from. At PSI the data root is `/home/data/inhouse` (about 130 GB). **Leave out `.master_backups_kek`** when copying it (`rsync -a --exclude .master_backups_kek`): it holds backups of private masters, not battery data. - **private**: its data root and manifest are named only in the local site config. ## Prerequisites - Python 3.9 or newer, with `gemmi` (scoring). `h5py` is needed only by `discover`. - A `rugnux` binary. Build it with the flags CI uses (`-march=x86-64-v3`, see `CLAUDE.md`), because CPU-bound results and timings differ between builds. The runner records the build flags from the `CMakeCache.txt` above the binary, or from the tree given with `--build-dir`. - XDS is not needed. The XDS references are already in the manifests (`refs` re-reads them from `CORRECT.LP`). ## Site config Machine-specific settings live in a site config: the data roots, the runs root, the lock file, an optional GPU-queue wrapper, the private arm, and the persisted baselines. The runner looks for it in this order: 1. `--site PATH` 2. `$JFJOCH_BATTERY_SITE` 3. `tools/battery/site.json` (git-ignored) `site.example.json` is the committed template. Copy it and fill in your paths. The local file is kept out of git because it names the private manifest. At PSI the config is `/data/battery/site.json`: link it (`ln -s /data/battery/site.json tools/battery/site.json`) or export `JFJOCH_BATTERY_SITE=/data/battery/site.json`. ```json { "runs_root": "/data/battery/runs", "lock_file": "/data/battery/full_run.lock", "gpulock": "/data/tmp/gpulock", "baseline": "/data/battery/runs/", "baseline_private": null, "pdb_cache": "/data/battery/pdb_cache", "arms": { "open": {"manifest": "open.json", "reference": "deposition", "data_root": "/home/data/open"}, "inhouse": {"manifest": "inhouse.json", "reference": "xds", "data_root": "/home/data/inhouse"}, "private": {"manifest": "/path/to/private.json", "reference": "xds", "data_root": "/path/to/private/data", "private": true} } } ``` A relative `manifest` path is resolved against `tools/battery/`. `gpulock` is a command that `rugnux` is prefixed with under `--gpulock`. At PSI it is a wrapper script that queues for one of the shared GPU slots. Set it to `null` if you have no such wrapper. `pdb_cache` (optional) is where the deposited models and their metadata are cached for the `model` variant and the REFMAC check. ## Running ``` B=tools/battery/battery.py R=build/rugnux/rugnux $B run --rugnux $R # full battery: open + inhouse $B run --rugnux $R --tier smoke # 22 sets covering readers, symmetry, known hard cases $B run --rugnux $R --only 5reo,lyso_ref # named sets $B run --rugnux $R --arm private # the private arm, on its own $B run --rugnux $R --variants bare # only what a user gets (no model, no XDS settings) ``` Useful options: - `--label` names the run. By default the label is the rugnux version. - `--threads N` passes `-N` to rugnux. - `--gpulock` queues every rugnux behind the site's GPU wrapper. - `--extra ""` adds rugnux arguments to every set. - `--baseline RUN|none` sets the run the report is compared against. - `--variants bare,model,xds` runs a subset of the variants (default: all of them). - `--model-check` adds the REFMAC check to the open arm's `bare` rows (off by default, see below). A run prints one line per set and ends by writing its report. The **smoke** tier is marked in the manifests (`"tiers": {"smoke": ""}`). **Full runs.** A run without `--only` or `--tier` takes the site lock (`flock`, non-blocking), so two full runs cannot overlap. Do not start one without the owner's go-ahead: it takes hours, and everything else on the machine competes with it. ### The REFMAC model check (open arm, opt-in) The `model` variant is the battery's R-free check. `--model-check` adds a second, independent one that needs CCP4: `tools/battery/model_check.py` scores each open-arm `bare` merge (`p.mtz`) against the deposited model, unmodified (ligands, waters and hydrogens kept): REFMAC's rigid-body mode, R-factors taken before any shift, the data reindexed into the model's setting and reduced to the deposited space group. Our own free set was mostly work reflections for the depositor, so `refmac_rfree` reads low. The fair comparison is `refmac_rfree_depflags` (our data on the depositor's free set) against `refmac_rfree_depdata` (the depositor's structure factors, same free set, same protocol); `refmac_rfree_ratio` is that ratio, and the report plots it. It is null when the entry deposited no structure factors with a free set. The runner records `refmac_rfree`, `refmac_rwork`, `refmac_rfree_depflags`, `refmac_rfree_depdata`, `refmac_rfree_ratio`, `refmac_status` and `refmac_reason`. Small-molecule sets are skipped. `model_sweep.py`, which ran `rugnux --model` over the open arm as a separate sweep, is retired. The `model` variant does the same inside the battery. ## A run directory `/__