Gemmi C++ API
Loading...
Searching...
No Matches
mtz2cif.hpp
Go to the documentation of this file.
1// Copyright 2020 Global Phasing Ltd.
2//
3// A class for converting MTZ (merged or unmerged) to SF-mmCIF
4
5// TODO:
6// - cell parameters may be different in CELL and DCELL records, check for it
7// - check that the FP column is not from Refmac
8// - should we allow for repeated column names in MTZ?
9
10#ifndef GEMMI_MTZ2CIF_HPP_
11#define GEMMI_MTZ2CIF_HPP_
12
13#include <ostream>
14#include "mtz.hpp" // for Mtz
15#include "xds_ascii.hpp" // for XdsAscii
16#include "intensit.hpp" // for Intensities
17#include "logger.hpp" // for Logger
18#include "metadata.hpp" // for SoftwareItem
19
20namespace gemmi {
21
23public:
24 // options that can be set directly
25 std::vector<std::string> spec_lines; // conversion specification (cf. default_spec)
26 const char* block_name = nullptr; // NAME in data_NAME
27 std::string entry_id = "xxxx"; // _entry.id
28 bool with_comments = true; // write comments
29 bool with_history = true; // write MTZ history in comments
30 bool skip_empty = false; // skip reflections with no values
31 bool skip_negative_sigi = false; // skip refl. with sigma(I) < 0 in unmerged
32 bool enable_UB = false; // write _diffrn_orient_matrix.UB
33 bool write_staraniso_tensor = true; // write _reflns.pdbx_aniso_B_tensor_*
34 bool write_special_marker_for_pdb = false;
35 int less_anomalous = 0; // skip (+)/(-) columns even if in spec
36 std::string skip_empty_cols; // columns used to determine "emptiness"
37 double wavelength = NAN; // user-specified wavelength
38 int trim = 0; // output only reflections -N<=h,k,l<=N
39 int free_flag_value = -1; // -1 = auto: 0 or (if we have >50% of 0's) 1
40 std::string staraniso_version; // for _software.version in "special_marker"
41 std::string gemmi_run_from; // added to gemmi as _software.description
42
43 static const char** default_spec(bool for_merged) {
44 static const char* merged[] = {
45 "H H index_h",
46 "K H index_k",
47 "L H index_l",
48 "? FREE|RFREE|FREER|FreeR_flag|R-free-flags|FreeRflag I status S",
49 "? IMEAN|I|IOBS|I-obs J intensity_meas",
50 "& SIG{prev} Q intensity_sigma",
51 "? I(+)|IOBS(+)|I-obs(+)|Iplus K pdbx_I_plus",
52 "& SIG{prev} M pdbx_I_plus_sigma",
53 "? I(-)|IOBS(-)|I-obs(-)|Iminus K pdbx_I_minus",
54 "& SIG{prev} M pdbx_I_minus_sigma",
55 // TODO: FP from Refmac should show warning or error
56 "? F|FP|FOBS|F-obs F F_meas_au",
57 "& SIG{prev} Q F_meas_sigma_au",
58 "? F(+)|FOBS(+)|F-obs(+)|Fplus G pdbx_F_plus",
59 "& SIG{prev} L pdbx_F_plus_sigma",
60 "? F(-)|FOBS(-)|F-obs(-)|Fminus G pdbx_F_minus",
61 "& SIG{prev} L pdbx_F_minus_sigma",
62 "? DP D pdbx_anom_difference",
63 "& SIGDP Q pdbx_anom_difference_sigma",
64 "? FC F F_calc",
65 "? PHIC P phase_calc",
66 "? FOM W fom",
67 "? HLA A pdbx_HL_A_iso",
68 "& HLB A pdbx_HL_B_iso",
69 "& HLC A pdbx_HL_C_iso",
70 "& HLD A pdbx_HL_D_iso",
71 "? FWT|2FOFCWT F pdbx_FWT",
72 "& PHWT|PH2FOFCWT P pdbx_PHWT .3f",
73 "? DELFWT|FOFCWT F pdbx_DELFWT",
74 "& DELPHWT|PHDELWT|PHFOFCWT P pdbx_DELPHWT .3f",
75 nullptr
76 };
77 static const char* unmerged[] = {
78 "$dataset diffrn_id", // diffrn_id - sweep id deduced from BATCH
79 "$counter id", // reflection counter (1, 2, ...)
80 "H H index_h",
81 "K H index_k",
82 "L H index_l",
83 "? I J intensity_net",
84 "& SIGI Q intensity_sigma .5g",
85 // new! https://github.com/wwpdb-dictionaries/mmcif_pdbx/pull/33
86 "? ROT R pdbx_scan_angle",
87 "$image pdbx_image_id",
88 nullptr
89 };
90 return for_merged ? merged : unmerged;
91 }
92
93 void write_cif(const Mtz& mtz, const Mtz* mtz2,
94 SMat33<double>* staraniso_b, std::ostream& os);
95 void write_cif_from_xds(const XdsAscii& xds, std::ostream& os) const;
96};
97
99 const std::string& entry_id,
100 char* buf, std::ostream& os);
101
104
106
107// note: both mi and ui get modified
109 bool relaxed_check, const Logger& logger);
110
111GEMMI_DLL std::vector<SoftwareItem>
112get_software_from_mtz_history(const std::vector<std::string>& history);
113
114} // namespace gemmi
115#endif
static const char ** default_spec(bool for_merged)
Definition mtz2cif.hpp:43
std::string gemmi_run_from
Definition mtz2cif.hpp:41
std::string staraniso_version
Definition mtz2cif.hpp:40
void write_cif(const Mtz &mtz, const Mtz *mtz2, SMat33< double > *staraniso_b, std::ostream &os)
std::vector< std::string > spec_lines
Definition mtz2cif.hpp:25
void write_cif_from_xds(const XdsAscii &xds, std::ostream &os) const
std::string skip_empty_cols
Definition mtz2cif.hpp:36
#define GEMMI_DLL
Definition fail.hpp:53
Class Intensities that reads multi-record data from MTZ, mmCIF or XDS_ASCII and merges it into mean o...
Logger - a tiny utility for passing messages through a callback.
Metadata from coordinate files.
MTZ reflection file format.
GEMMI_DLL void remove_appendix_from_column_names(Mtz &mtz, const Logger &logger)
remove '_dataset_name' that can be appended to column names in ccp4i
GEMMI_DLL std::vector< SoftwareItem > get_software_from_mtz_history(const std::vector< std::string > &history)
GEMMI_DLL void write_staraniso_b_in_mmcif(const SMat33< double > &b, const std::string &entry_id, char *buf, std::ostream &os)
GEMMI_DLL bool validate_merged_intensities(Intensities &mi, Intensities &ui, bool relaxed_check, const Logger &logger)
GEMMI_DLL bool validate_merged_mtz_deposition_columns(const Mtz &mtz, const Logger &logger)
Passes messages (including warnings/errors) to a callback function.
Definition logger.hpp:23
Read XDS files: XDS_ASCII. HKL and INTEGRATE. HKL.