Gemmi C++ API
Loading...
Searching...
No Matches
mmcif_impl.hpp
Go to the documentation of this file.
1// Copyright 2019 Global Phasing Ltd.
2//
3// Functions used in both mmcif.hpp and refln.hpp (for coordinate and
4// reflection mmCIF files).
5
6#ifndef GEMMI_MMCIF_IMPL_HPP_
7#define GEMMI_MMCIF_IMPL_HPP_
8
9#include "cifdoc.hpp" // for cif::Block
10#include "numb.hpp" // for cif::as_number
11#include "unitcell.hpp" // for UnitCell
12
13namespace gemmi {
14namespace impl {
15
16inline void set_cell_from_mmcif(cif::Block& block, UnitCell& cell,
17 bool mmcif=true) {
18 cif::Table tab = block.find((mmcif ? "_cell." : "_cell_"),
19 {"length_a", "length_b", "length_c",
20 "angle_alpha", "angle_beta", "angle_gamma"});
21 if (tab.ok()) {
22 auto c = tab.one();
23 if (!cif::is_null(c[0]) && !cif::is_null(c[1]) && !cif::is_null(c[2]))
24 cell.set(cif::as_number(c[0]), cif::as_number(c[1]), cif::as_number(c[2]),
25 cif::as_number(c[3]), cif::as_number(c[4]), cif::as_number(c[5]));
26 }
27}
28
29inline const std::string* find_spacegroup_hm_value(const cif::Block& block) {
30 const char* hm_tag = "_symmetry.space_group_name_H-M";
31 return block.find_value(hm_tag);
32}
33
34} // namespace impl
35} // namespace gemmi
36
37#endif
struct Document that represents the CIF file (but can also be read from a different representation,...
double as_number(const std::string &s, double nan=NAN)
Definition numb.hpp:19
bool is_null(const std::string &value)
Definition cifdoc.hpp:76
Utilities for parsing CIF numbers (the CIF spec calls them 'numb').
Unit cell.