@@ -47,7 +47,8 @@ const option::Descriptor Usage[] = {
47
47
{ Stats, 0 , " " , " stats" , Arg::Optional,
48
48
" --stats[=N] \t Print data metrics in N resol. shells (default: 10)."
49
49
" \n\t Add U (e.g. =10U or =U) for unweighted metrics."
50
- " \n\t Add X for XDS-like weighted metrics (details in docs)." },
50
+ " \n\t Add X for XDS-like weighted metrics (details in docs)."
51
+ " \n\t Add s or e for different binning (more in docs)." },
51
52
{ Compare, 0 , " " , " compare" , Arg::None,
52
53
" --compare \t Compare unmerged and merged data (no output file)." },
53
54
{ PrintAll, 0 , " " , " print-all" , Arg::None,
@@ -257,22 +258,15 @@ double take_average(const std::vector<MergingStats>& stats,
257
258
return sum / count;
258
259
}
259
260
260
- void print_merging_statistics (const Intensities& intensities, int nbins, char use_weights) {
261
- gemmi::Binner binner;
262
- const gemmi::Binner* binner_ptr = nullptr ;
263
- if (nbins > 1 ) {
264
- auto method = gemmi::Binner::Method::Dstar3;
265
- binner.setup (nbins, method, gemmi::IntensitiesDataProxy{intensities});
266
- binner_ptr = &binner;
267
- }
268
- auto stats = intensities.calculate_merging_stats (binner_ptr, use_weights);
269
- if (nbins > 1 ) {
261
+ void print_merging_statistics (const std::vector<MergingStats>& stats,
262
+ const gemmi::Binner* binner) {
263
+ if (binner) {
270
264
printf (" In resolution shells:\n "
271
265
" d_max d_min #obs #uniq #used Rmerge Rmeas Rpim CC1/2\n " );
272
- for (int i = 0 ; i < nbins ; ++i) {
266
+ for (size_t i = 0 ; i < binner-> size () ; ++i) {
273
267
const MergingStats& ms = stats[i];
274
268
printf (" %7.3f %5.3f %7d %6d %6d %7.3f %7.3f %7.3f %8.4f\n " ,
275
- binner. dmax_of_bin (i), binner. dmin_of_bin (i),
269
+ binner-> dmax_of_bin (i), binner-> dmin_of_bin (i),
276
270
ms.all_refl , ms.unique_refl , ms.stats_refl ,
277
271
ms.r_merge (), ms.r_meas (), ms.r_pim (), ms.cc_half ());
278
272
}
@@ -284,16 +278,23 @@ void print_merging_statistics(const Intensities& intensities, int nbins, char us
284
278
printf (" \n Observations (all reflections): %d\n " , total.all_refl );
285
279
printf (" Unique reflections: %d\n " , total.unique_refl );
286
280
printf (" Used refl. (those with multiplicity 2+): %d\n " , total.stats_refl );
287
- printf (" Overall Avg of %d shells weighted by #used\n " , nbins);
288
- printf (" R-merge: %7.4f %7.4f\n " ,
289
- total.r_merge (), take_average (stats, &MergingStats::r_merge));
290
- printf (" R-meas: %7.4f %7.4f\n " ,
291
- total.r_meas (), take_average (stats, &MergingStats::r_meas));
292
- printf (" R-pim: %7.4f %7.4f\n " ,
293
- total.r_pim (), take_average (stats, &MergingStats::r_pim));
281
+ printf (" Overall" );
282
+ if (binner)
283
+ printf (" Avg of %zu shells weighted by #used" , binner->size ());
284
+ printf (" \n R-merge: %7.4f" , total.r_merge ());
285
+ if (binner)
286
+ printf (" %7.4f" , take_average (stats, &MergingStats::r_merge));
287
+ printf (" \n R-meas: %7.4f" , total.r_meas ());
288
+ if (binner)
289
+ printf (" %7.4f" , take_average (stats, &MergingStats::r_meas));
290
+ printf (" \n R-pim: %7.4f" , total.r_pim ());
291
+ if (binner)
292
+ printf (" %7.4f" , take_average (stats, &MergingStats::r_pim));
294
293
// xdscc12 prints CC1/2 with 5 significant digits, do the same for easy comparison
295
- printf (" CC1/2: %8.5f %8.5f\n " ,
296
- total.cc_half (), take_average (stats, &MergingStats::cc_half));
294
+ printf (" \n CC1/2: %8.5f" , total.cc_half ());
295
+ if (binner)
296
+ printf (" %8.5f" , take_average (stats, &MergingStats::cc_half));
297
+ printf (" \n " );
297
298
}
298
299
299
300
} // anonymous namespace
@@ -340,6 +341,7 @@ int GEMMI_MAIN(int argc, char **argv) {
340
341
if (verbose)
341
342
output_intensity_statistics (intensities);
342
343
344
+ auto binning_method = gemmi::Binner::Method::Dstar3;
343
345
if (p.options [Stats]) {
344
346
int nbins = 10 ;
345
347
char use_weights = ' Y' ;
@@ -354,19 +356,47 @@ int GEMMI_MAIN(int argc, char **argv) {
354
356
}
355
357
}
356
358
for (; *endptr != ' \0 ' ; ++endptr) {
357
- if (*endptr == ' U' || *endptr == ' X' ) {
358
- use_weights = *endptr;
359
+ char c = *endptr;
360
+ if (c == ' U' || c == ' X' ) {
361
+ use_weights = c;
362
+ } else if (c == ' e' ) {
363
+ binning_method = gemmi::Binner::Method::EqualCount;
364
+ } else if (c == ' s' ) {
365
+ binning_method = gemmi::Binner::Method::Dstar2;
359
366
} else {
360
- fprintf (stderr, " Wrong argument for option --stats: %s\n " , arg);
367
+ fprintf (stderr, " Unexpected character '%c' in option --stats: %s\n " , c , arg);
361
368
return 1 ;
362
369
}
363
370
}
364
371
}
372
+ if (verbose) {
373
+ if (use_weights == ' Y' )
374
+ printf (" Using weights for R-metrics like Aimless\n " );
375
+ else if (use_weights == ' X' )
376
+ printf (" Using weights for R-metrics like XDS\n " );
377
+ else if (use_weights == ' U' )
378
+ printf (" NOT using weights for R-metrics.\n " );
379
+ }
365
380
try {
366
381
if (to_anom)
367
382
intensities.set_isigns (DataType::Anomalous);
368
383
intensities.sort ();
369
- print_merging_statistics (intensities, nbins, use_weights);
384
+ gemmi::Binner binner;
385
+ const gemmi::Binner* binner_ptr = nullptr ;
386
+ if (nbins > 1 ) {
387
+ if (verbose) {
388
+ const char * binning_desc = " equal volumes (equispaced in d*^3)" ;
389
+ if (binning_method == gemmi::Binner::Method::Dstar2)
390
+ binning_desc = " increasing volumes (equispaced in d*^2)" ;
391
+ else if (binning_method == gemmi::Binner::Method::EqualCount)
392
+ binning_desc = " equal reflection count" ;
393
+ printf (" Setting up resolution shells with %s.\n " , binning_desc);
394
+ }
395
+ binner.setup (nbins, binning_method, gemmi::IntensitiesDataProxy{intensities});
396
+ binner_ptr = &binner;
397
+ }
398
+ auto stats = intensities.calculate_merging_stats (binner_ptr, use_weights);
399
+ print_merging_statistics (stats, binner_ptr);
370
400
} catch (std::exception& e) {
371
401
std::fprintf (stderr, " ERROR: %s\n " , e.what ());
372
402
return 1 ;
0 commit comments