Build Packages / build:portable:linux-x86_64:nocuda (push) Successful in 16m43s
Build Packages / build:jfjoch:ubuntu2404:nocuda (push) Successful in 28m46s
Build Packages / build:jfjoch:rocky8:cuda-sls9 (push) Successful in 32m5s
Build Packages / build:jfjoch:rocky9:cuda (push) Successful in 39m44s
Build Packages / build:portable:macos-arm64:nocuda (push) Successful in 5m7s
Build Packages / Create release (push) Successful in 8s
Build Packages / Build documentation (push) Successful in 49s
Build Packages / build:portable:linux-x86_64:cuda (push) Successful in 22m30s
Build Packages / build:jfjoch:rocky8:nocuda (push) Successful in 31m54s
Build Packages / build:rugnux:linux-aarch64:cuda (push) Successful in 11m29s
Build Packages / build:portable:windows-x86_64:nocuda (push) Successful in 23m51s
Build Packages / build:jfjoch:ubuntu2204:nocuda (push) Successful in 26m7s
Build Packages / build:jfjoch:ubuntu2204:cuda (push) Successful in 29m38s
Build Packages / build:portable:windows-x86_64:cuda (push) Successful in 28m6s
Build Packages / HDF5 consumer tests (DIALS, XDS) (push) Successful in 29m44s
Build Packages / build:jfjoch:rocky9:nocuda (push) Successful in 33m22s
Build Packages / Generate python client (push) Successful in 47s
Build Packages / build:jfjoch:rocky9:cuda-sls9 (push) Successful in 34m6s
Build Packages / Unit tests (push) Successful in 1h2m47s
Build Packages / build:jfjoch:rocky8:cuda (push) Successful in 35m59s
Build Packages / build:jfjoch:ubuntu2404:cuda (push) Successful in 34m8s
Build Packages / Validation Battery (push) Successful in 38m31s
* Rugnux: Refinement several times faster, one protocol on the CPU and the GPU, parts of it on the Apple GPU; its random draws are the same on every platform. * Rugnux: Refinement follows common practice: the free set decides only the restraint weights and the displacement model (isotropic, TLS or anisotropic, by Hamilton's test), everything else is decided on the working set; lower R-free for placed and predicted models. * Rugnux: Restraint dictionaries via `--restraints` (or among the inputs) and more built-in ligands; a model whose space group is a subgroup of the data's is refined in its own group; reflections plus a model select `--mode refine` on their own. * Rugnux: `-C` fixes the crystal system on the axes as typed; `-S` alone fixes the space group only, the cell is still found and reduced; a space group or cell stored in the input file is ignored, with a line in the log. * Rugnux: More reliable multi-sweep merging; `--mode scale` merges several stills runs as one; `_plot.txt` and the report name each input; a second crystal form is reported for stills given a cell. * jfjoch_broker (experimental): Live Rugnux on FPGA detectors (JUNGFRAU) takes the same path as a DECTRIS stream, rotation and serial alike, model step included, with analysis threads per GPU; frames waiting for the analysis can be viewed; no host stage drops a frame - a source faster than the analysis is held at the card. * jfjoch_broker: Summation of more than 256 frames per image is split between the card and the host (`summation_mode` is then `hybrid`), and live Rugnux runs on such collections; pedestal runs take a receiver of their own. * jfjoch_broker (experimental): `stills_downsample` analyses 1 of every N serial images (chosen by a hash; the first 2000 all; the others written without analysis; reset to 1 by `/initialize`); `max_spot_count` left out means 250 for per-image indexing and up to 1000 for live stills; the live status gives the merge before the model work, the fitted resolution and the anomalous peak height of each unexplained blob. * jfjoch_broker: Without a `pcie` entry the broker runs on a mock of the card instead of the HLS simulation; its spot, ROI and azimuthal results are zero then. * Web frontend: Redesigned Rugnux live page; Vite 8, TypeScript 6, Mol* 5.13 and dependency security updates. * Tools: `jfjoch_fpga_stills_test` measures live stills on the cards with a stored dataset; `jfjoch_fpga_test` loses the HLS-simulation option. * Other: FFTW no longer fetched or linked (the CPU FFT indexer keeps the name `FFTW`); PCIe driver now GPL-2.0-or-later and third-party notices complete; several crash fixes. Reviewed-on: #98 Co-authored-by: Filip Leonarski <filip.leonarski@psi.ch>
102 lines
6.7 KiB
C++
102 lines
6.7 KiB
C++
// SPDX-FileCopyrightText: 2026 Filip Leonarski, Paul Scherrer Institute <filip.leonarski@psi.ch>
|
|
// SPDX-License-Identifier: GPL-3.0-only
|
|
|
|
#include <catch2/catch_all.hpp>
|
|
#include <filesystem>
|
|
#include <fstream>
|
|
#include <zlib.h>
|
|
|
|
#include "../rugnux/RugnuxInputKind.h"
|
|
|
|
namespace {
|
|
const std::string MODEL_CIF = "data_test\n#\n_cell.length_a 50.0\nloop_\n_atom_site.group_PDB\n_atom_site.id\n"
|
|
"ATOM 1\n";
|
|
const std::string SF_CIF = "data_r1abcsf\n_cell.length_a 50.0\nloop_\n_refln.index_h\n_refln.index_k\n"
|
|
"_refln.index_l\n_refln.intensity_meas\n1 0 0 10.0\n";
|
|
const std::string RESTRAINT_CIF = "data_comp_list\nloop_\n_chem_comp.id\n_chem_comp.group\nXYZ non-polymer\n"
|
|
"data_comp_XYZ\nloop_\n_chem_comp_atom.comp_id\n_chem_comp_atom.atom_id\nXYZ C1\n";
|
|
const std::string PDB = "HEADER TEST\nREMARK 1 SYNTHETIC\nCRYST1 50.000 50.000 50.000 90.00 90.00 90.00 P 1\n"
|
|
"ATOM 1 CA ALA A 1 1.000 2.000 3.000 1.00 10.00 C\nEND\n";
|
|
|
|
std::string Write(const std::string &name, const std::string &content) {
|
|
std::ofstream(name, std::ios::binary) << content;
|
|
return name;
|
|
}
|
|
|
|
std::string WriteGz(const std::string &name, const std::string &content) {
|
|
gzFile f = gzopen(name.c_str(), "wb");
|
|
gzwrite(f, content.data(), static_cast<unsigned>(content.size()));
|
|
gzclose(f);
|
|
return name;
|
|
}
|
|
}
|
|
|
|
TEST_CASE("RugnuxInputKind_Classify", "[rugnux_inputs]") {
|
|
using K = RugnuxInputKind;
|
|
CHECK(ClassifyRugnuxInput(Write("ik_model.cif", MODEL_CIF)) == K::Model);
|
|
CHECK(ClassifyRugnuxInput(Write("ik_sf.cif", SF_CIF)) == K::Reflections);
|
|
CHECK(ClassifyRugnuxInput(Write("ik_diffrn.cif", "data_x\nloop_\n_diffrn_refln.index_h\n1\n")) == K::Reflections);
|
|
CHECK(ClassifyRugnuxInput(Write("ik_model.pdb", PDB)) == K::Model);
|
|
CHECK(ClassifyRugnuxInput(WriteGz("ik_model.pdb.gz", PDB)) == K::Model);
|
|
CHECK(ClassifyRugnuxInput(WriteGz("ik_sf.cif.gz", SF_CIF)) == K::Reflections);
|
|
// the name says nothing: a model in a file called .mtz, reflections in one called .pdb
|
|
CHECK(ClassifyRugnuxInput(Write("ik_model_named.mtz", MODEL_CIF)) == K::Model);
|
|
CHECK(ClassifyRugnuxInput(Write("ik_mtz_named.pdb", std::string("MTZ \0\0\0\0", 8) + "binary")) == K::Reflections);
|
|
CHECK(ClassifyRugnuxInput(Write("ik_image.h5", std::string("\x89HDF\r\n\x1a\n\0\0\0\0", 12))) == K::Images);
|
|
CHECK(ClassifyRugnuxInput(Write("ik_image.cbf", "###CBF: VERSION 1.5\ndata_image\n_array_data.data\n")) == K::Images);
|
|
CHECK(ClassifyRugnuxInput(Write("ik_image2.cbf", "data_image\n_array_data.data\n_atom_site.x\n")) == K::Images);
|
|
CHECK(ClassifyRugnuxInput(Write("ik_image.img", "{\nHEADER_BYTES= 512;\nDIM=2;\n}")) == K::Images);
|
|
CHECK(ClassifyRugnuxInput(Write("ik_binary", std::string("\0\1\2\3\4\5\6\7\0\0\0\0\0\0\0\0x", 17))) == K::Images);
|
|
// A PDB file need not start with a title section: a refined model written without one starts with its
|
|
// HELIX or LINK records (the first line decides the format, the atom decides the model)
|
|
const std::string ATOM = "ATOM 1 CA ALA A 1 1.000 2.000 3.000 1.00 10.00 C\nEND\n";
|
|
CHECK(ClassifyRugnuxInput(Write("ik_link_first.pdb",
|
|
"LINK SG CYS A 14 CAB HEC A 201 1555 1555 1.82\n" + ATOM)) == K::Model);
|
|
CHECK(ClassifyRugnuxInput(Write("ik_helix_first.pdb",
|
|
"HELIX 1 1 VAL A 4 LYS A 14 0\nCRYST1 50.000 50.000 50.000 90.00 90.00 90.00 P 1\n" + ATOM))
|
|
== K::Model);
|
|
CHECK(ClassifyRugnuxInput(Write("ik_ssbond_first.pdb",
|
|
"SSBOND 1 CYS A 6 CYS A 127 1555 1555 2.03\n" + ATOM)) == K::Model);
|
|
// A PDB file without an atom is not a model
|
|
CHECK(ClassifyRugnuxInput(Write("ik_noatom.pdb", "HEADER TEST\nEND\n")) == K::Images);
|
|
// A restraint dictionary, a CCD entry and a file of links only
|
|
CHECK(ClassifyRugnuxInput(Write("ik_restraints.cif", RESTRAINT_CIF)) == K::Restraints);
|
|
CHECK(ClassifyRugnuxInput(Write("ik_ccd.cif", "data_XYZ\n_chem_comp.id XYZ\nloop_\n_chem_comp_atom.comp_id\n"
|
|
"_chem_comp_atom.atom_id\nXYZ C1\n")) == K::Restraints);
|
|
CHECK(ClassifyRugnuxInput(Write("ik_links.cif", "data_link_list\nloop_\n_chem_link.id\nAB\n")) == K::Restraints);
|
|
// Both coordinates and reflections: the user has to say
|
|
CHECK(ClassifyRugnuxInput(Write("ik_both.cif", MODEL_CIF + "loop_\n_refln.index_h\n1\n")) == K::Ambiguous);
|
|
for (const char *f: {"ik_model.cif", "ik_sf.cif", "ik_diffrn.cif", "ik_model.pdb", "ik_model.pdb.gz", "ik_sf.cif.gz",
|
|
"ik_model_named.mtz", "ik_mtz_named.pdb", "ik_image.h5", "ik_image.cbf", "ik_image2.cbf",
|
|
"ik_image.img", "ik_binary", "ik_noatom.pdb", "ik_both.cif", "ik_link_first.pdb",
|
|
"ik_helix_first.pdb", "ik_ssbond_first.pdb", "ik_restraints.cif", "ik_ccd.cif", "ik_links.cif"})
|
|
std::filesystem::remove(f);
|
|
}
|
|
|
|
TEST_CASE("RugnuxInputKind_SplitAnyOrder", "[rugnux_inputs]") {
|
|
const std::string img = Write("ik_s_image.h5", std::string("\x89HDF\r\n\x1a\n\0\0\0\0", 12));
|
|
const std::string model = Write("ik_s_model.pdb", PDB);
|
|
const std::string sf = Write("ik_s_sf.cif", SF_CIF);
|
|
const std::string dict1 = Write("ik_s_dict1.cif", RESTRAINT_CIF), dict2 = Write("ik_s_dict2.cif", RESTRAINT_CIF);
|
|
for (const auto &order: std::vector<std::vector<std::string>>{{img, model, sf, dict1, dict2},
|
|
{dict1, model, sf, img, dict2},
|
|
{sf, dict1, img, model, dict2}}) {
|
|
const RugnuxPositionalInputs s = SplitRugnuxInputs(order);
|
|
CHECK(s.images == std::vector<std::string>{img});
|
|
CHECK(s.model == model);
|
|
CHECK(s.reflections == sf);
|
|
CHECK(s.restraints == std::vector<std::string>{dict1, dict2}); // several, in the order given
|
|
}
|
|
// image files keep their order; a path that is no file (yet) is left to the image readers
|
|
const RugnuxPositionalInputs s = SplitRugnuxInputs({"later_master.h5", model, img});
|
|
CHECK(s.images == std::vector<std::string>{"later_master.h5", img});
|
|
|
|
const std::string model2 = Write("ik_s_model2.cif", MODEL_CIF);
|
|
CHECK_THROWS(SplitRugnuxInputs({img, model, model2}));
|
|
CHECK_THROWS(SplitRugnuxInputs({sf, img, sf}));
|
|
const std::string both = Write("ik_s_both.cif", MODEL_CIF + "loop_\n_refln.index_h\n1\n");
|
|
CHECK_THROWS(SplitRugnuxInputs({img, both}));
|
|
for (const auto &f: {img, model, sf, model2, both, dict1, dict2})
|
|
std::filesystem::remove(f);
|
|
}
|