Files
Jungfraujoch/gemmi_gph/mmread_gz.cpp
T
leonarski_fandClaude Opus 5 2e8040c60c
Build Packages / build:windows:nocuda (push) Successful in 16m47s
Build Packages / build:windows:cuda (push) Successful in 19m11s
Build Packages / build:rugnux:windows (push) Successful in 11m15s
Build Packages / build:rugnux:aarch64 (cross) (push) Successful in 7m54s
Build Packages / build:viewer-tgz:cpu (push) Successful in 14m55s
Build Packages / build:rugnux-tgz (x86_64) (push) Successful in 14m27s
Build Packages / build:viewer-tgz:cuda (push) Successful in 15m36s
Build Packages / build:rpm (rocky9_nocuda) (push) Successful in 15m39s
Build Packages / build:rpm (rocky8_nocuda) (push) Successful in 19m59s
Build Packages / build:rpm (ubuntu2404_nocuda) (push) Successful in 16m7s
Build Packages / build:rpm (ubuntu2204_nocuda) (push) Successful in 19m47s
Build Packages / build:rpm (rocky8_sls9) (push) Successful in 21m51s
Build Packages / build:rpm (rocky9_sls9) (push) Successful in 17m18s
Build Packages / build:rpm (rocky8) (push) Successful in 20m37s
Build Packages / build:rpm (rocky9) (push) Successful in 18m21s
Build Packages / build:rpm (ubuntu2204) (push) Successful in 20m0s
Build Packages / Generate python client (push) Successful in 32s
Build Packages / build:rpm (ubuntu2404) (push) Successful in 18m23s
Build Packages / Build documentation (push) Successful in 1m0s
Build Packages / Create release (push) Skipped
Build Packages / XDS test (durin plugin) (push) Successful in 9m20s
Build Packages / XDS test (JFJoch plugin) (push) Successful in 9m21s
Build Packages / XDS test (neggia plugin) (push) Successful in 7m43s
Build Packages / DIALS test (push) Successful in 19m58s
Build Packages / Unit tests (push) Successful in 2h48m45s
rugnux: read mmCIF models with --model, and say when a model could not be used
--model called gemmi::read_pdb unconditionally, so a coordinate file in mmCIF -
which is how the PDB serves coordinates by default - was refused outright:

  Model validation: cannot read model 6G8A.cif:
  Incorrect file format (perhaps it is cif not pdb?)

Worse than the refusal was what followed it. ValidateAgainstModel logged,
returned an empty result, and the run went on to finish with exit code 0, no
R-free, no maps and nothing in the report - indistinguishable from a run that was
never given --model at all. A script that passed a .cif, checked the exit code
and grepped for R-free simply got nothing back.

Both read sites now go through read_structure_gz with CoorFormat::Detect, so PDB,
mmCIF and mmJSON are all read, gzipped or not, and the format comes from the
file's content rather than from its name. Detect is passed explicitly: GEMMI
otherwise takes the extension and only falls back to the content when it does not
recognise one, and a model arrives named however whoever produced it named it.

That needed a part of GEMMI the vendored subset had trimmed away. mmread.hpp was
already here but its CIF parser was not, so this restores what upstream GEMMI
ships: read_cif/mmcif/json/mmread_gz, plus GEMMI's own copies of PEGTL (MIT,
Colin Hirsch and Daniel Frey; 155 headers, 672 kB) and sajson (MIT, Chad Austin;
one header). Both are listed in THIRD_PARTY_NOTICES.md with their own licence
texts, PEGTL's collected by COLLECT.sh and sajson's kept by hand, its terms being
a comment block rather than a file. json.cpp carries a one-line change: upstream
keeps sajson at the root of its repository, outside the include tree this subset
copies, so the include points at where the other bundled headers live.

ModelValidationResult gains failure_reason, and a model that was asked for and
could not be used now reaches the results report as

  WARNING: Model validation did not run: model bogus.pdb has no atoms or no unit cell

in --mode mx and --mode scale alike. The run still succeeds - a merge that is good
is not made bad by a model that was not - but it no longer does so quietly.

One log line was making a claim it could not support: the indexing-ambiguity
message said the ambiguity was "resolved against the supplied model" while being
printed before the model is read, so it announced a resolution that a failed model
never performed. It now says the model will be used; the reference branch, where
the work really has already happened, keeps the past tense.

Verified on the rotation test dataset with a deposited mmCIF, the same file
gzipped, an mmCIF under a .pdb name, a PDB, and an unreadable file.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016WmryXe8ASbNi632sUMfsa
2026-08-27 13:42:48 +02:00

30 lines
976 B
C++

// Copyright 2021 Global Phasing Ltd.
#include <gemmi/mmread_gz.hpp>
#include <gemmi/mmread.hpp> // for read_structure
#include <gemmi/pdb.hpp> // for read_pdb
#include <gemmi/gz.hpp> // for MaybeGzipped
#include <gemmi/read_cif.hpp> // for read_cif_gz
namespace gemmi {
Structure read_structure_gz(const std::string& path, CoorFormat format,
cif::Document* save_doc) {
return read_structure(MaybeGzipped(path), format, save_doc);
}
Structure read_pdb_gz(const std::string& path, PdbReadOptions options) {
return read_pdb(MaybeGzipped(path), options);
}
Structure read_structure_from_chemcomp_gz(const std::string& path,
cif::Document* save_doc, int which) {
return make_structure_from_chemcomp_doc(read_cif_gz(path), save_doc, which);
}
CoorFormat coor_format_from_ext_gz(const std::string& path) {
return coor_format_from_ext(MaybeGzipped(path).basepath());
}
} // namespace gemmi