@@ -42,6 +42,7 @@ def run(self):
4242
4343 n_datasets = int (params .get ("n_datasets" ))
4444 if n_datasets > 1 : # array job case
45+ batch = True
4546 with open (model_dir / ".batch.json" , "r" ) as f :
4647 datasets = json .load (f )
4748 dtag = datasets [int (slurm_task_id ) - 1 ]
@@ -104,7 +105,7 @@ def run(self):
104105
105106 self .log .info (e .stdout )
106107 self .log .error (e .stderr )
107- self .send_attachments_to_ispyb (attachments , final_directory )
108+ self .send_attachments_to_ispyb (attachments , final_directory , batch )
108109 return False
109110
110111 restraints = compound_dir / f"{ CompoundCode } .restraints.cif"
@@ -145,7 +146,7 @@ def run(self):
145146 self .log .info (e .stdout )
146147 with open (pandda2_log , "w" ) as log_file :
147148 log_file .write (e .stdout )
148- self .send_attachments_to_ispyb (attachments , final_directory )
149+ self .send_attachments_to_ispyb (attachments , final_directory , batch )
149150 return False
150151
151152 with open (pandda2_log , "w" ) as log_file :
@@ -175,7 +176,7 @@ def run(self):
175176 self .log .info (
176177 (f"No events in { events_yaml } , can't continue with PanDDA2 Rhofit" )
177178 )
178- self .send_attachments_to_ispyb (attachments , final_directory )
179+ self .send_attachments_to_ispyb (attachments , final_directory , batch )
179180 return False
180181
181182 with open (events_yaml , "r" ) as file :
@@ -217,11 +218,12 @@ def run(self):
217218 )
218219
219220 cifs = list (ligand_dir .glob ("*.cif" ))
221+ cut = self .map_sigma (restricted_build_dmap , sigma = 1 )
220222
221223 rhofit_log = dataset_pdir / "rhofit.log"
222224 attachments .extend ([event_map , z_map , rhofit_log ])
223225 rhofit_command = f"module load buster; source { PANDDA_2_DIR } /venv/bin/activate; \
224- { PANDDA_2_DIR } /scripts/pandda_rhofit.sh -pdb { restricted_pdb_file } -map { restricted_build_dmap } -mtz { mtz_file } -cif { cifs [0 ]} -out { out_dir } -cut 2.0 > { rhofit_log } ;" # dmap_cut=2.0
226+ { PANDDA_2_DIR } /scripts/pandda_rhofit.sh -pdb { restricted_pdb_file } -map { restricted_build_dmap } -mtz { mtz_file } -cif { cifs [0 ]} -out { out_dir } -cut { cut } > { rhofit_log } ;" # dmap_cut=2.0
225227
226228 self .log .info (f"Running PanDDA Rhofit command: { rhofit_command } " )
227229
@@ -240,8 +242,8 @@ def run(self):
240242 self .log .error (f"Rhofit command: '{ rhofit_command } ' failed" )
241243 self .log .info (e .stdout )
242244 self .log .error (e .stderr )
243- self .send_attachments_to_ispyb (attachments , final_directory )
244- return False
245+ self .send_attachments_to_ispyb (attachments , final_directory , batch )
246+ return True
245247
246248 # -------------------------------------------------------
247249 # Ligand scoring
@@ -336,7 +338,7 @@ def run(self):
336338 # attachments.extend([json_results])
337339
338340 self .log .info (f"Attachments list: { attachments } " )
339- self .send_attachments_to_ispyb (attachments , final_directory )
341+ self .send_attachments_to_ispyb (attachments , final_directory , batch )
340342
341343 self .log .info (f"Auto PanDDA2 pipeline finished successfully for dtag { dtag } " )
342344 return True
@@ -357,6 +359,16 @@ def read_pandda_map(self, xmap_file):
357359 dmap = dmap_ccp4 .grid
358360 return dmap
359361
362+ def map_sigma (xmap , sigma ):
363+ ccp4 = gemmi .read_ccp4_map (str (xmap ))
364+ ccp4 .setup (0.0 )
365+ grid = ccp4 .grid
366+ grid_array = np .array (grid , copy = False )
367+ std = np .std (grid_array )
368+ non_zero_std = np .std (grid_array [(grid_array < - 0.05 ) | (grid_array > 0.05 )])
369+ new_sigma = sigma * (non_zero_std / std )
370+ return new_sigma
371+
360372 def expand_event_map (self , bdc , ground_state_file , xmap_file , coord , out_file ):
361373 """DEPRECATED. A method for recalculating event maps over the full cell."""
362374 ground_state_ccp4 = gemmi .read_ccp4_map (str (ground_state_file ), setup = False )
@@ -490,7 +502,9 @@ def get_contact_chain(self, protein_st, ligand_st):
490502
491503 return min (chain_counts , key = lambda _x : chain_counts [_x ])
492504
493- def send_attachments_to_ispyb (self , attachments , final_directory ):
505+ def send_attachments_to_ispyb (self , attachments , final_directory , batch ):
506+ if batch : # synchweb attachments not supported for array job processing
507+ return
494508 for f in attachments :
495509 if f .exists ():
496510 if f .suffix == ".html" :
0 commit comments