Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 25 additions & 1 deletion src/dlstbx/wrapper/xia2_multiplex.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ def send_results_to_ispyb(
cluster_num=None,
attachments=[],
multiplex_filtering=False,
phil_path=None,
):
ispyb_command_list = []

Expand Down Expand Up @@ -96,6 +97,17 @@ def send_results_to_ispyb(
}
ispyb_command_list.append(integration)

# Step 3.5: Ammend paths in HTML for synchweb interactivity

if phil_path:
files_to_change = ["xia2.multiplex.html", "xia2.multiplex_clustering.html"]
for attachment in attachments:
if attachment["file_name"] in files_to_change:
html_path = (
pathlib.Path(attachment["file_path"]) / attachment["file_name"]
)
self.fix_paths_in_html_output(html_path, phil_path)

Comment on lines +100 to +110

@pblowey pblowey Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems to be a long-winded way of getting to a file path, which I think will always be results_directory / xia2-multiplex-working.phil

I think it would be better to just have some logic when you are constructing the attachments list in the first place to look out for the two html files of interest and fix the paths then using results_directory / xia2-multiplex-working.phil

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree it was a bit long-winded - have simplified significantly in the recent commit.

# Step 4: Upload attachments
if attachments:
for attachment in attachments:
Expand Down Expand Up @@ -186,6 +198,15 @@ def construct_commandline(self, params):

return command

def fix_paths_in_html_output(self, html_path, phil_path):
# Use this to make sure viewing the HTML in SynchWeb gives useful and helpful file paths for subset selection.
text = html_path.read_text(encoding="utf-8")
old = 'var PHIL_PATH_OVERRIDE = "";'
new = f"var PHIL_PATH_OVERRIDE = {json.dumps(str(phil_path))};"
if old in text:
# if old not in text, this is likely because it's a cluster and it's already been written
html_path.write_text(text.replace(old, new, 1), encoding="utf-8")

def run(self):
assert hasattr(self, "recwrap"), "No recipewrapper object found"

Expand Down Expand Up @@ -315,11 +336,11 @@ def is_final_result(final_file: pathlib.Path) -> bool:

allfiles = []
cluster_count = 0
phil_path = None

if success:
with multiplex_json.open("r") as fh:
d = json.load(fh)

for dataset_name, dataset in d["datasets"].items():
base_dir_logs = working_directory / "LogFiles"
base_dir_results = working_directory / "DataFiles"
Expand Down Expand Up @@ -429,6 +450,8 @@ def is_final_result(final_file: pathlib.Path) -> bool:
filetype = keep[file_pattern]
if filetype is None:
continue
if filename.name == "xia2-multiplex-working.phil":
phil_path = results_directory / filename.name

# Work out if in Processing, DataFiles or LogFiles (parent_dir)

Expand Down Expand Up @@ -568,6 +591,7 @@ def is_final_result(final_file: pathlib.Path) -> bool:
cluster_num=cluster_num,
attachments=attachments,
multiplex_filtering=filtering,
phil_path=phil_path,
)

self._success_counter.inc()
Expand Down
Loading