From bd094e585ff9dd8466396e6ed05a705f26d8d9a0 Mon Sep 17 00:00:00 2001 From: Filip Leonarski Date: Wed, 15 Jul 2026 15:23:31 +0200 Subject: [PATCH] rugnux: accept a space-group symbol for -S, not just a number -S now takes either a number ("92") or a Hermann-Mauguin symbol ("P43212"), resolved via gemmi find_spacegroup_by_name. Previously a non-numeric argument was atoi'd to 0 and tripped the early space-group validation, aborting the run. Co-Authored-By: Claude Opus 4.8 (1M context) --- rugnux/rugnux_cli.cpp | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/rugnux/rugnux_cli.cpp b/rugnux/rugnux_cli.cpp index 80281da0..045c20c7 100644 --- a/rugnux/rugnux_cli.cpp +++ b/rugnux/rugnux_cli.cpp @@ -73,7 +73,7 @@ void print_usage() { std::cout << " --redo-rotation-spots Redo spot finding for two-pass rotation indexing" << std::endl; std::cout << " --force-rotation-lattice Force rotation indexer with external lattice (in Angstrom) : \"a0x,a0y,a0z,a1x,a1y,a1z,a2x,a2y,a2z\" (9 floats, skips first pass)" << std::endl; std::cout << " -X, --indexing-algorithm Indexing algorithm (FFBIDX|FFT|FFTW|Auto|None)" << std::endl; - std::cout << " -S, --space-group Space group number - used for both indexing and scaling" << std::endl; + std::cout << " -S, --space-group Space group number (92) or symbol (P43212) - for indexing and scaling" << std::endl; std::cout << " -C, --unit-cell Fix reference unit cell: \"a,b,c,alpha,beta,gamma\"" << std::endl; std::cout << " -r, --refine Geometry refinement algorithm (none|orientation|beam_and_lattice|flex); flex tries all three per image and keeps whichever indexes the most spots (alias: multi)" << std::endl; std::cout << " --refine-geometry[=N|off] Stills: extra first pass that bundle-adjusts the shared beam/distance/cell from N strongly-indexed frames (default: 200) then re-indexes (lifts weak-stills indexing). Default ON for stills when a reference cell is given (-C / reference MTZ); =off disables" << std::endl; @@ -672,9 +672,20 @@ int main(int argc, char **argv) { case 'B': refine_bfactor = true; break; - case 'S': - space_group_number = atoi(optarg); + case 'S': { + // Accept a space-group number ("92") or a Hermann-Mauguin symbol ("P43212", "P 43 21 2"). + char *end = nullptr; + const long as_number = strtol(optarg, &end, 10); + if (end != optarg && *end == '\0') { + space_group_number = as_number; + } else if (const gemmi::SpaceGroup *sg = gemmi::find_spacegroup_by_name(optarg)) { + space_group_number = sg->number; + } else { + logger.Error("Unknown space group '{}' (use a number like 92 or a symbol like P43212)", optarg); + exit(EXIT_FAILURE); + } break; + } case OPT_SPOT_SIGMA: sigma_spot_finding = atof(optarg); logger.Info("Noise threshold level for spot finding set to {:.2f} sigma", sigma_spot_finding);