Skip to content

Commit a7e56bd

Browse files
committed
Use labxchem filepaths for synchweb attachments
1 parent e00fd10 commit a7e56bd

2 files changed

Lines changed: 17 additions & 20 deletions

File tree

src/dlstbx/wrapper/pandda_xchem.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ def run(self):
106106

107107
self.log.info(e.stdout)
108108
self.log.error(e.stderr)
109-
self.send_attachments_to_ispyb(attachments, final_directory, batch)
109+
self.send_attachments_to_ispyb(attachments, batch)
110110
return False
111111

112112
restraints = compound_dir / f"{CompoundCode}.restraints.cif"
@@ -147,7 +147,7 @@ def run(self):
147147
self.log.info(e.stdout)
148148
with open(pandda2_log, "w") as log_file:
149149
log_file.write(e.stdout)
150-
self.send_attachments_to_ispyb(attachments, final_directory, batch)
150+
self.send_attachments_to_ispyb(attachments, batch)
151151
return False
152152

153153
with open(pandda2_log, "w") as log_file:
@@ -177,7 +177,7 @@ def run(self):
177177
self.log.info(
178178
(f"No events in {events_yaml}, can't continue with PanDDA2 Rhofit")
179179
)
180-
self.send_attachments_to_ispyb(attachments, final_directory, batch)
180+
self.send_attachments_to_ispyb(attachments, batch)
181181
return False
182182

183183
with open(events_yaml, "r") as file:
@@ -243,7 +243,7 @@ def run(self):
243243
self.log.error(f"Rhofit command: '{rhofit_command}' failed")
244244
self.log.info(e.stdout)
245245
self.log.error(e.stderr)
246-
self.send_attachments_to_ispyb(attachments, final_directory, batch)
246+
self.send_attachments_to_ispyb(attachments, batch)
247247
return True
248248

249249
# -------------------------------------------------------
@@ -339,7 +339,7 @@ def run(self):
339339
# attachments.extend([json_results])
340340

341341
self.log.info(f"Attachments list: {attachments}")
342-
self.send_attachments_to_ispyb(attachments, final_directory, batch)
342+
self.send_attachments_to_ispyb(attachments, batch)
343343

344344
self.log.info(f"Auto PanDDA2 pipeline finished successfully for dtag {dtag}")
345345
return True
@@ -501,7 +501,7 @@ def get_contact_chain(self, protein_st, ligand_st):
501501

502502
return min(chain_counts, key=lambda _x: chain_counts[_x])
503503

504-
def send_attachments_to_ispyb(self, attachments, final_directory, batch):
504+
def send_attachments_to_ispyb(self, attachments, batch):
505505
if batch: # synchweb attachments not supported for array job processing
506506
return
507507
for f in attachments:
@@ -524,9 +524,8 @@ def send_attachments_to_ispyb(self, attachments, final_directory, batch):
524524
else:
525525
continue
526526
try:
527-
shutil.copy(f, final_directory)
528527
result_dict = {
529-
"file_path": str(final_directory),
528+
"file_path": str(f.parents[0]),
530529
"file_name": f.name,
531530
"file_type": file_type,
532531
"importance_rank": importance_rank,

src/dlstbx/wrapper/pipedream_xchem.py

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import json
44
import os
5-
import shutil
65
import sqlite3
76
import subprocess
87
from pathlib import Path
@@ -95,7 +94,7 @@ def run(self):
9594
)
9695
self.log.info(e.stdout)
9796
self.log.error(e.stderr)
98-
self.send_attachments_to_ispyb(attachments, final_directory)
97+
self.send_attachments_to_ispyb(attachments)
9998
return False
10099

101100
restraints = compound_dir / f"{CompoundCode}.restraints.cif"
@@ -152,7 +151,7 @@ def run(self):
152151
stderr.write(e.stderr)
153152

154153
attachments.extend([out_dir / "stderr.out"])
155-
self.send_attachments_to_ispyb(attachments, final_directory)
154+
self.send_attachments_to_ispyb(attachments)
156155
return False
157156

158157
self.log.info(f"Pipedream finished successfully for dtag {dtag}")
@@ -194,7 +193,7 @@ def run(self):
194193
)
195194
except Exception as e:
196195
self.log.info(f"Can't continue with pipedream postprocessing: {e}")
197-
self.send_attachments_to_ispyb(attachments, final_directory)
196+
self.send_attachments_to_ispyb(attachments)
198197
return True
199198

200199
# Post-processing: Generate maps and run edstats
@@ -206,7 +205,7 @@ def run(self):
206205
os.system(f"gemmi sf2map --sample 5 {str(refine_mtz)} {map_fofc} 2>&1")
207206
except Exception as e:
208207
self.log.debug(f"Cannot continue with pipedream postprocessing: {e}")
209-
self.send_attachments_to_ispyb(attachments, final_directory)
208+
self.send_attachments_to_ispyb(attachments)
210209
return True
211210

212211
try:
@@ -229,15 +228,15 @@ def run(self):
229228
self.log.debug(
230229
"Can't continue with pipedream postprocessing: resolution range None"
231230
)
232-
self.send_attachments_to_ispyb(attachments, final_directory)
231+
self.send_attachments_to_ispyb(attachments)
233232
return True
234233

235234
# Run edstats if both maps exist and resolution range is found
236235
if not map_2fofc.exists() or not map_fofc.exists():
237236
self.log.debug(
238237
"Can't continue with pipedream postprocessing: maps not found"
239238
)
240-
self.send_attachments_to_ispyb(attachments, final_directory)
239+
self.send_attachments_to_ispyb(attachments)
241240
return True
242241

243242
edstats_out = postrefine_dir / "edstats.out"
@@ -258,13 +257,13 @@ def run(self):
258257
self.log.error(f"Edstats command: '{edstats_command}' failed")
259258
self.log.info(e.stdout)
260259
self.log.error(e.stderr)
261-
self.send_attachments_to_ispyb(attachments, final_directory)
260+
self.send_attachments_to_ispyb(attachments)
262261
return True
263262

264263
self.log.info(f"Pipedream postprocessing finished successfully for dtag {dtag}")
265264

266265
attachments.extend([edstats_out])
267-
self.send_attachments_to_ispyb(attachments, final_directory)
266+
self.send_attachments_to_ispyb(attachments)
268267
return True
269268

270269
def process_pdb_file(self, dimple_pdb: Path):
@@ -355,7 +354,7 @@ def save_dataset_metadata(
355354
with open(json_file, "w", encoding="utf-8") as f:
356355
json.dump(data, f, indent=2)
357356

358-
def send_attachments_to_ispyb(self, attachments, final_directory):
357+
def send_attachments_to_ispyb(self, attachments):
359358
for f in attachments:
360359
if f.exists():
361360
if f.suffix == ".html":
@@ -382,9 +381,8 @@ def send_attachments_to_ispyb(self, attachments, final_directory):
382381
else:
383382
continue
384383
try:
385-
shutil.copy(f, final_directory)
386384
result_dict = {
387-
"file_path": str(final_directory),
385+
"file_path": str(f.parents[0]),
388386
"file_name": f.name,
389387
"file_type": file_type,
390388
"importance_rank": importance_rank,

0 commit comments

Comments
 (0)