From a067e3d756866e0335b564a9472223b46665f091 Mon Sep 17 00:00:00 2001 From: amyjaynethompson <52806925+amyjaynethompson@users.noreply.github.com> Date: Thu, 19 Feb 2026 15:36:59 +0000 Subject: [PATCH 1/3] custom spotfinding parameters for VMXm --- src/dlstbx/mimas/core.py | 15 +++++++++++++++ src/dlstbx/wrapper/xia2.py | 21 ++++++++++++++++++--- 2 files changed, 33 insertions(+), 3 deletions(-) diff --git a/src/dlstbx/mimas/core.py b/src/dlstbx/mimas/core.py index dacdafb9b..47e1ebb4b 100644 --- a/src/dlstbx/mimas/core.py +++ b/src/dlstbx/mimas/core.py @@ -44,6 +44,19 @@ mimas.MimasISPyBParameter(key="ice_rings.filter", value="true"), ) +XIA2_DIALS_VMXM_SPOTFINDING_PARAMS: Tuple[mimas.MimasISPyBParameter, ...] = ( + mimas.MimasISPyBParameter(key="spotfinder.filter.max_separation", value="8"), + mimas.MimasISPyBParameter( + key="spotfinder.threshold.dispersion.kernel_size", value="6,6" + ), + mimas.MimasISPyBParameter( + key="spotfinder.threshold.dispersion.sigma_background", value="3" + ), + mimas.MimasISPyBParameter( + key="spotfinder.threshold.dispersion.sigma_strong", value="1" + ), +) + def xia2_dials_absorption_params( scenario: mimas.MimasScenario, @@ -298,6 +311,8 @@ def handle_rotation_end( xia2_dials_beamline_extra_params = ( *XIA2_DIALS_COPPER_RINGS_PARAMS, mimas.MimasISPyBParameter(key="failover", value="true"), + mimas.MimasISPyBParameter(key="remove_blanks", value="true"), + *XIA2_DIALS_VMXM_SPOTFINDING_PARAMS, ) triggervars_pref: Tuple[mimas.MimasISPyBTriggerVariable, ...] = () diff --git a/src/dlstbx/wrapper/xia2.py b/src/dlstbx/wrapper/xia2.py index 6f8bbfe35..4270579da 100644 --- a/src/dlstbx/wrapper/xia2.py +++ b/src/dlstbx/wrapper/xia2.py @@ -56,7 +56,11 @@ def construct_commandline( "unit_cell": "xia2.settings.unit_cell", } for param, value in params["ispyb_parameters"].items(): - command.append(translation.get(param, param) + "=" + value) + if "spotfinder" in param: + if "find_spots.phil_file=spots.phil" not in command: + command.append("find_spots.phil_file=spots.phil") + else: + command.append(translation.get(param, param) + "=" + value) return command @@ -195,11 +199,22 @@ def run_xia2(self, working_directory: Path, params: dict): f"Could not create run_xia2.sh script file in the working directory {working_directory}" ) return False - command = ["sh", f"{working_directory}/run_xia2.sh"] + run_command = ["sh", f"{working_directory}/run_xia2.sh"] + else: + run_command = command subprocess_directory = working_directory / params["program_name"] subprocess_directory.mkdir(parents=True, exist_ok=True) + # Write out spot finding parameters that are not directly accessible in xia2 to phil file + + if "find_spots.phil_file=spots.phil" in command: + with open(subprocess_directory / "spots.phil", "w") as phil: + for param, value in params["ispyb_parameters"].items(): + if "spotfinder" in param: + phil.write(f"{param}={value}\n") + self.log.info(f"Created spots.phil in {subprocess_directory}") + if "dials.integrate.phil_file" in params["xia2"]: dials_integrate_phil_file = subprocess_directory / params["xia2"].get( "dials.integrate.phil_file" @@ -219,7 +234,7 @@ def run_xia2(self, working_directory: Path, params: dict): try: start_time = time.perf_counter() result = subprocess.run( - command, + run_command, timeout=params.get("timeout"), cwd=subprocess_directory, ) From d808c41fa572a47354d75c5b6e277c3a383eb3c3 Mon Sep 17 00:00:00 2001 From: amyjaynethompson <52806925+amyjaynethompson@users.noreply.github.com> Date: Thu, 19 Feb 2026 16:04:36 +0000 Subject: [PATCH 2/3] tidy --- src/dlstbx/wrapper/xia2.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/dlstbx/wrapper/xia2.py b/src/dlstbx/wrapper/xia2.py index 4270579da..2d7158a52 100644 --- a/src/dlstbx/wrapper/xia2.py +++ b/src/dlstbx/wrapper/xia2.py @@ -56,7 +56,7 @@ def construct_commandline( "unit_cell": "xia2.settings.unit_cell", } for param, value in params["ispyb_parameters"].items(): - if "spotfinder" in param: + if param.startswith("spotfinder"): if "find_spots.phil_file=spots.phil" not in command: command.append("find_spots.phil_file=spots.phil") else: From b4be34dd0f7d4d50d243a7fe6dfa52987b5a515d Mon Sep 17 00:00:00 2001 From: amyjaynethompson <52806925+amyjaynethompson@users.noreply.github.com> Date: Mon, 23 Feb 2026 10:36:22 +0000 Subject: [PATCH 3/3] addressing comments --- src/dlstbx/wrapper/xia2.py | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/src/dlstbx/wrapper/xia2.py b/src/dlstbx/wrapper/xia2.py index 2d7158a52..8bda461ee 100644 --- a/src/dlstbx/wrapper/xia2.py +++ b/src/dlstbx/wrapper/xia2.py @@ -29,6 +29,7 @@ def construct_commandline( Takes job parameter dictionary, returns array.""" command = ["xia2"] + spotfinding_params = [] for param, values in params["xia2"].items(): if param == "images": @@ -57,12 +58,13 @@ def construct_commandline( } for param, value in params["ispyb_parameters"].items(): if param.startswith("spotfinder"): + spotfinding_params.append(f"{param}={value}\n") if "find_spots.phil_file=spots.phil" not in command: command.append("find_spots.phil_file=spots.phil") else: command.append(translation.get(param, param) + "=" + value) - return command + return command, spotfinding_params def send_results_to_ispyb( self, @@ -174,7 +176,7 @@ def run_xia2(self, working_directory: Path, params: dict): ) return False - command = self.construct_commandline( + command, spotfinding_params = self.construct_commandline( working_directory, params, "s3_urls" in self.recwrap.environment ) self.log.info("command: %s", " ".join(command)) @@ -199,20 +201,17 @@ def run_xia2(self, working_directory: Path, params: dict): f"Could not create run_xia2.sh script file in the working directory {working_directory}" ) return False - run_command = ["sh", f"{working_directory}/run_xia2.sh"] - else: - run_command = command + command = ["sh", f"{working_directory}/run_xia2.sh"] subprocess_directory = working_directory / params["program_name"] subprocess_directory.mkdir(parents=True, exist_ok=True) # Write out spot finding parameters that are not directly accessible in xia2 to phil file - if "find_spots.phil_file=spots.phil" in command: + if spotfinding_params: with open(subprocess_directory / "spots.phil", "w") as phil: - for param, value in params["ispyb_parameters"].items(): - if "spotfinder" in param: - phil.write(f"{param}={value}\n") + for phil_param in spotfinding_params: + phil.write(phil_param) self.log.info(f"Created spots.phil in {subprocess_directory}") if "dials.integrate.phil_file" in params["xia2"]: @@ -234,7 +233,7 @@ def run_xia2(self, working_directory: Path, params: dict): try: start_time = time.perf_counter() result = subprocess.run( - run_command, + command, timeout=params.get("timeout"), cwd=subprocess_directory, )