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 "merge.hpp" // for Intensities
17
18namespace gemmi {
19
21public:
22 // options that can be set directly
23 std::vector<std::string> spec_lines; // conversion specification (cf. default_spec)
24 const char* block_name = nullptr; // NAME in data_NAME
25 std::string entry_id = "xxxx"; // _entry.id
26 bool with_comments = true; // write comments
27 bool with_history = true; // write MTZ history in comments
28 bool skip_empty = false; // skip reflections with no values
29 bool skip_negative_sigi = false; // skip refl. with sigma(I) < 0 in unmerged
30 bool enable_UB = false; // write _diffrn_orient_matrix.UB
31 bool write_staraniso_tensor = true; // write _reflns.pdbx_aniso_B_tensor_*
32 bool write_special_marker_for_pdb = false;
33 int less_anomalous = 0; // skip (+)/(-) columns even if in spec
34 std::string skip_empty_cols; // columns used to determine "emptiness"
35 double wavelength = NAN; // user-specified wavelength
36 int trim = 0; // output only reflections -N<=h,k,l<=N
37 int free_flag_value = -1; // -1 = auto: 0 or (if we have >50% of 0's) 1
38 std::string staraniso_version; // for _software.version in "special_marker"
39 std::string gemmi_run_from; // added to gemmi as _software.description
40
41 static const char** default_spec(bool for_merged) {
42 static const char* merged[] = {
43 "H H index_h",
44 "K H index_k",
45 "L H index_l",
46 "? FREE|RFREE|FREER|FreeR_flag|R-free-flags|FreeRflag I status S",
47 "? IMEAN|I|IOBS|I-obs J intensity_meas",
48 "& SIG{prev} Q intensity_sigma",
49 "? I(+)|IOBS(+)|I-obs(+) K pdbx_I_plus",
50 "& SIG{prev} M pdbx_I_plus_sigma",
51 "? I(-)|IOBS(-)|I-obs(-) K pdbx_I_minus",
52 "& SIG{prev} M pdbx_I_minus_sigma",
53 // TODO: FP from Refmac should show warning or error
54 "? F|FP|FOBS|F-obs F F_meas_au",
55 "& SIG{prev} Q F_meas_sigma_au",
56 "? F(+)|FOBS(+)|F-obs(+) G pdbx_F_plus",
57 "& SIG{prev} L pdbx_F_plus_sigma",
58 "? F(-)|FOBS(-)|F-obs(-) G pdbx_F_minus",
59 "& SIG{prev} L pdbx_F_minus_sigma",
60 "? DP D pdbx_anom_difference",
61 "& SIGDP Q pdbx_anom_difference_sigma",
62 "? FC F F_calc",
63 "? PHIC P phase_calc",
64 "? FOM W fom",
65 "? HLA A pdbx_HL_A_iso",
66 "& HLB A pdbx_HL_B_iso",
67 "& HLC A pdbx_HL_C_iso",
68 "& HLD A pdbx_HL_D_iso",
69 "? FWT|2FOFCWT F pdbx_FWT",
70 "& PHWT|PH2FOFCWT P pdbx_PHWT .3f",
71 "? DELFWT|FOFCWT F pdbx_DELFWT",
72 "& DELPHWT|PHDELWT|PHFOFCWT P pdbx_DELPHWT .3f",
73 nullptr
74 };
75 static const char* unmerged[] = {
76 "$dataset diffrn_id", // diffrn_id - sweep id deduced from BATCH
77 "$counter id", // reflection counter (1, 2, ...)
78 "H H index_h",
79 "K H index_k",
80 "L H index_l",
81 "? I J intensity_net",
82 "& SIGI Q intensity_sigma .5g",
83 // new! https://github.com/wwpdb-dictionaries/mmcif_pdbx/pull/33
84 "?ROT R pdbx_scan_angle",
85 "$image pdbx_image_id",
86 nullptr
87 };
88 return for_merged ? merged : unmerged;
89 }
90
91 void write_cif(const Mtz& mtz, const Mtz* mtz2,
92 SMat33<double>* staraniso_b, std::ostream& os);
93 void write_cif_from_xds(const XdsAscii& xds, std::ostream& os);
94};
95
97 const std::string& entry_id,
98 char* buf, std::ostream& os);
99
102
104
105// note: both mi and ui get modified
107 bool relaxed_check, std::ostream& out);
108
109} // namespace gemmi
110#endif
static const char ** default_spec(bool for_merged)
Definition mtz2cif.hpp:41
std::string gemmi_run_from
Definition mtz2cif.hpp:39
std::string staraniso_version
Definition mtz2cif.hpp:38
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:23
void write_cif_from_xds(const XdsAscii &xds, std::ostream &os)
std::string skip_empty_cols
Definition mtz2cif.hpp:34
#define GEMMI_DLL
Definition fail.hpp:53
GEMMI_DLL void remove_appendix_from_column_names(Mtz &mtz, std::ostream &out)
remove '_dataset_name' that can be appended to column names in ccp4i
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, std::ostream &out)
GEMMI_DLL bool validate_merged_mtz_deposition_columns(const Mtz &mtz, std::ostream &out)