aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/man/get_hkl.12
-rw-r--r--libcrystfel/src/reflist-utils.c164
-rw-r--r--libcrystfel/src/reflist-utils.h3
-rw-r--r--src/get_hkl.c21
-rw-r--r--src/gui_export.c9
5 files changed, 141 insertions, 58 deletions
diff --git a/doc/man/get_hkl.1 b/doc/man/get_hkl.1
index 071a5b8d..b15a33df 100644
--- a/doc/man/get_hkl.1
+++ b/doc/man/get_hkl.1
@@ -33,7 +33,7 @@ Specify the name of the file containing unit cell information, in PDB or CrystFE
.SH CHOOSING THE OUTPUT FORMAT
.IP \fB--output-format=\fIformat\fR
.PD
-The output file will be written in \fIformat\fR, which can be \fBmtz\fR or \fBxds\fR. If you omit this option, the output will be in the usual CrystFEL reflection list format.
+The output file will be written in \fIformat\fR, which can be \fBmtz\fR, \fBmtz-bij\fR or \fBxds\fR. Use \fBmtz-bij\fR to put Bijvoet pairs together in the same row, suitable for anomalous phasing. Otherwise, use \fBmtz\fR. If you omit this option, the output will be in the usual CrystFEL reflection list format.
.SH EXPANDING REFLECTIONS INTO A POINT GROUP OF LOWER SYMMETRY
.PD 0
diff --git a/libcrystfel/src/reflist-utils.c b/libcrystfel/src/reflist-utils.c
index a2de12d8..952a7882 100644
--- a/libcrystfel/src/reflist-utils.c
+++ b/libcrystfel/src/reflist-utils.c
@@ -1024,62 +1024,16 @@ static CCP4SPG *add_mtz_symmetry_header(MTZ *mtz, const char *spg_name)
#endif
-int write_to_mtz(RefList *reflist,
- SymOpList *sym,
- UnitCell *cell,
- double min_res,
- double max_res,
- const char *filename,
- const char *dataset_name,
- const char *crystal_name,
- const char *project_name)
-{
#ifdef HAVE_LIBCCP4
- MTZ *mtz;
- MTZXTAL *cr;
- MTZSET *ds;
+static void write_mtz_refls_bij(MTZ *mtz, MTZSET *ds, CCP4SPG *spg,
+ RefList *reflist, UnitCell *cell, SymOpList *sym,
+ double min_res, double max_res)
+{
MTZCOL *columns[7];
- double a, b, c, al, be, ga;
- int r;
- char tmp[128];
- float cellp[6];
int refl_i;
Reflection *refl;
RefListIterator *iter;
- CCP4SPG *spg;
- const char *spg_name;
- spg_name = space_group_for_mtz(symmetry_name(sym),
- cell_get_centering(cell));
- if ( spg_name == NULL ) {
- reflist_free(reflist);
- return 1;
- }
-
- mtz = MtzMalloc(0, 0);
-
- snprintf(tmp, 128, "Data exported via CrystFEL version %s",
- libcrystfel_version_string());
- ccp4_lwtitl(mtz, tmp, 0);
-
- mtz->refs_in_memory = 0;
- mtz->fileout = MtzOpenForWrite(filename);
-
- spg = add_mtz_symmetry_header(mtz, spg_name);
- if ( spg == NULL ) {
- return 1;
- }
-
- cell_get_parameters(cell, &a, &b, &c, &al, &be, &ga);
- cellp[0] = a*1e10;
- cellp[1] = b*1e10;
- cellp[2] = c*1e10;
- cellp[3] = rad2deg(al);
- cellp[4] = rad2deg(be);
- cellp[5] = rad2deg(ga);
-
- cr = MtzAddXtal(mtz, crystal_name, project_name, cellp);
- ds = MtzAddDataset(mtz, cr, dataset_name, 0.0);
columns[0] = MtzAddColumn(mtz, ds, "H", "H");
columns[1] = MtzAddColumn(mtz, ds, "K", "H");
columns[2] = MtzAddColumn(mtz, ds, "L", "H");
@@ -1160,6 +1114,116 @@ int write_to_mtz(RefList *reflist,
}
}
+}
+
+
+static void write_mtz_refls_plain(MTZ *mtz, MTZSET *ds, CCP4SPG *spg,
+ RefList *reflist, UnitCell *cell, SymOpList *sym,
+ double min_res, double max_res)
+{
+ MTZCOL *columns[7];
+ int refl_i;
+ Reflection *refl;
+ RefListIterator *iter;
+
+ columns[0] = MtzAddColumn(mtz, ds, "H", "H");
+ columns[1] = MtzAddColumn(mtz, ds, "K", "H");
+ columns[2] = MtzAddColumn(mtz, ds, "L", "H");
+ columns[3] = MtzAddColumn(mtz, ds, "I", "K");
+ columns[4] = MtzAddColumn(mtz, ds, "SIGI", "M");
+
+ refl_i = 1;
+ for ( refl = first_refl(reflist, &iter);
+ refl != NULL;
+ refl = next_refl(refl, iter) )
+ {
+ signed int h, k, l;
+ double one_over_d;
+
+ get_indices(refl, &h, &k, &l);
+
+ one_over_d = 2.0*resolution(cell, h, k, l);
+ if ( (one_over_d > min_res) && (one_over_d < max_res) ) {
+
+ float refldata[5];
+ signed int nh, nk, nl;
+
+ /* Move to CCP4's idea of the ASU */
+ ccp4spg_put_in_asu(spg, h, k, l, &nh, &nk, &nl);
+ refldata[0] = nh;
+ refldata[1] = nk;
+ refldata[2] = nl;
+
+ refldata[3] = get_intensity(refl);
+ refldata[4] = get_esd_intensity(refl);
+
+ ccp4_lwrefl(mtz, refldata, columns, 5, refl_i++);
+
+ }
+ }
+}
+#endif
+
+
+int write_to_mtz(RefList *reflist,
+ SymOpList *sym,
+ UnitCell *cell,
+ double min_res,
+ double max_res,
+ const char *filename,
+ const char *dataset_name,
+ const char *crystal_name,
+ const char *project_name,
+ int bij)
+{
+#ifdef HAVE_LIBCCP4
+ MTZ *mtz;
+ MTZXTAL *cr;
+ MTZSET *ds;
+ double a, b, c, al, be, ga;
+ int r;
+ char tmp[128];
+ float cellp[6];
+ CCP4SPG *spg;
+ const char *spg_name;
+
+ spg_name = space_group_for_mtz(symmetry_name(sym),
+ cell_get_centering(cell));
+ if ( spg_name == NULL ) {
+ reflist_free(reflist);
+ return 1;
+ }
+
+ mtz = MtzMalloc(0, 0);
+
+ snprintf(tmp, 128, "Data exported via CrystFEL version %s",
+ libcrystfel_version_string());
+ ccp4_lwtitl(mtz, tmp, 0);
+
+ mtz->refs_in_memory = 0;
+ mtz->fileout = MtzOpenForWrite(filename);
+
+ spg = add_mtz_symmetry_header(mtz, spg_name);
+ if ( spg == NULL ) {
+ return 1;
+ }
+
+ cell_get_parameters(cell, &a, &b, &c, &al, &be, &ga);
+ cellp[0] = a*1e10;
+ cellp[1] = b*1e10;
+ cellp[2] = c*1e10;
+ cellp[3] = rad2deg(al);
+ cellp[4] = rad2deg(be);
+ cellp[5] = rad2deg(ga);
+
+ cr = MtzAddXtal(mtz, crystal_name, project_name, cellp);
+ ds = MtzAddDataset(mtz, cr, dataset_name, 0.0);
+
+ if ( bij ) {
+ write_mtz_refls_bij(mtz, ds, spg, reflist, cell, sym, min_res, max_res);
+ } else {
+ write_mtz_refls_plain(mtz, ds, spg, reflist, cell, sym, min_res, max_res);
+ }
r = MtzPut(mtz, " ");
ccp4spg_free(&spg);
diff --git a/libcrystfel/src/reflist-utils.h b/libcrystfel/src/reflist-utils.h
index ef65fba8..e853698f 100644
--- a/libcrystfel/src/reflist-utils.h
+++ b/libcrystfel/src/reflist-utils.h
@@ -82,7 +82,8 @@ extern void reflist_add_command_and_version(RefList *list,
extern int write_to_mtz(RefList *reflist, SymOpList *sym, UnitCell *cell,
double min_res, double max_res,
const char *filename, const char *dataset_name,
- const char *crystal_name, const char *project_name);
+ const char *crystal_name, const char *project_name,
+ int bij);
extern int write_to_xds(RefList *reflist, SymOpList *sym, UnitCell *cell,
double min_res, double max_res, const char *filename);
diff --git a/src/get_hkl.c b/src/get_hkl.c
index e80383e5..82bf5815 100644
--- a/src/get_hkl.c
+++ b/src/get_hkl.c
@@ -94,9 +94,10 @@ static void show_help(const char *s)
" equivalent reflections.\n"
"\n"
"Don't forget to specify the output filename:\n"
-" -o, --output=<filename> Output filename (default: stdout).\n"
-" --output-format=mtz Output in MTZ format.\n"
-" --output-format=xds Output in XDS format.\n"
+" -o, --output=<filename> Output filename (default: stdout).\n"
+" --output-format=mtz Output in MTZ format.\n"
+" --output-format=mtz-bij Output in MTZ format, Bijvoet pairs together\n"
+" --output-format=xds Output in XDS format.\n"
);
}
@@ -916,7 +917,19 @@ int main(int argc, char *argv[])
r = 1;
} else {
r = write_to_mtz(input, mero, cell, 0, INFINITY, output,
- "dataset", "crystal", "project");
+ "dataset", "crystal", "project", 0);
+ }
+ } else if ( strcasecmp(output_format_str, "mtz-bij") == 0 ) {
+ if ( !libcrystfel_can_write_mtz() ) {
+ ERROR("Sorry, this version of CrystFEL was compiled "
+ "without MTZ support (libccp4 is required)\n");
+ r = 1;
+ } else if ( output == NULL ) {
+ ERROR("You must provide the MTZ output filename.\n");
+ r = 1;
+ } else {
+ r = write_to_mtz(input, mero, cell, 0, INFINITY, output,
+ "dataset", "crystal", "project", 1);
}
} else if ( strcasecmp(output_format_str, "xds") == 0 ) {
if ( output == NULL ) {
diff --git a/src/gui_export.c b/src/gui_export.c
index 44a6ffc1..b0aef972 100644
--- a/src/gui_export.c
+++ b/src/gui_export.c
@@ -87,7 +87,8 @@ static int export_to_xds(struct gui_merge_result *result,
static int export_to_mtz(struct gui_merge_result *result,
const char *filename, UnitCell *cell,
- double min_res, double max_res)
+ double min_res, double max_res,
+ int bij)
{
RefList *reflist;
char *sym_str;
@@ -174,7 +175,9 @@ static int export_data(struct export_window *win, char *filename)
min_res, max_res);
if ( strcmp(format, "mtz") == 0 ) {
- r = export_to_mtz(result, filename, cell, min_res, max_res);
+ r = export_to_mtz(result, filename, cell, min_res, max_res, 0);
+ } else if ( strcmp(format, "mtz-bij") == 0 ) {
+ r = export_to_mtz(result, filename, cell, min_res, max_res, 1);
} else if ( strcmp(format, "xds") == 0 ) {
r = export_to_xds(result, filename, cell, min_res, max_res);
} else {
@@ -264,6 +267,8 @@ gint export_sig(GtkWidget *widget, struct crystfelproject *proj)
if ( libcrystfel_can_write_mtz() ) {
gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(win->format), "mtz",
"MTZ");
+ gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(win->format), "mtz-bij",
+ "MTZ, Bijvoet pairs together");
}
gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(win->format), "xds",
"XDS ASCII");