22
33import json
44import os
5+ import re
56import shutil
67import subprocess
78from pathlib import Path
89
10+ from cctbx .crystal import symmetry
11+
912import dlstbx .util .symlink
1013from dlstbx .util import ChainMapWithReplacement
1114from dlstbx .wrapper import Wrapper
@@ -111,7 +114,31 @@ def insertXOalignStrategies(self, xoalign_log):
111114 found_solutions = False
112115
113116 ispyb_command_list = []
117+
118+ space_group_pattern = re .compile (
119+ r"Space group symbol:\s*(\S+),\s*Number:\s*(\d+),\s*Point Group:\s*(\S+)"
120+ )
121+ unit_cell_pattern = re .compile (
122+ r"Real cell:\s*(-?[\d.]+)\s+(-?[\d.]+)\s+(-?[\d.]+)\s+(-?[\d.]+)\s+(-?[\d.]+)\s+(-?[\d.]+)"
123+ )
124+ found_space_group = False
125+ found_unit_cell = False
126+
114127 for line in xoalign_log .splitlines (True ):
128+ if match := space_group_pattern .search (line ):
129+ space_group_symbol = match .group (1 )
130+ found_space_group = True
131+
132+ if match := unit_cell_pattern .search (line ):
133+ unit_cell = [float (uc_param ) for uc_param in match .groups ()]
134+ found_unit_cell = True
135+
136+ if found_space_group and found_unit_cell :
137+ crystal_symmetry = symmetry (
138+ unit_cell = unit_cell ,
139+ space_group_symbol = space_group_symbol ,
140+ )
141+
115142 if "Independent Solutions" in line :
116143 found_solutions = True
117144 if "SmarGon" in line :
@@ -161,7 +188,20 @@ def insertXOalignStrategies(self, xoalign_log):
161188 }
162189 ispyb_command_list .append (d )
163190
164- # Step 2: Store screeningStrategy results, linked to the screeningOutputId
191+ # Step 2: Store screeningOutputLattice results, linked to the screeningOutputId
192+ # Keep the screeningOutputLatticeId
193+ d = {
194+ "ispyb_command" : "insert_screening_output_lattice" ,
195+ "screening_output_id" : f"$ispyb_screening_output_id_{ solution_id } " ,
196+ "store_result" : f"ispyb_screening_output_lattice_id_{ solution_id } " ,
197+ }
198+ uc_params = crystal_symmetry .unit_cell ().parameters ()
199+ for i , p in enumerate (("a" , "b" , "c" , "alpha" , "beta" , "gamma" )):
200+ d ["unitcell%s" % p ] = uc_params [i ]
201+ d ["spacegroup" ] = crystal_symmetry .space_group_info ().type ().lookup_symbol ()
202+ ispyb_command_list .append (d )
203+
204+ # Step 3: Store screeningStrategy results, linked to the screeningOutputId
165205 # Keep the screeningStrategyId
166206 d = {
167207 "program" : "XOalign" ,
@@ -171,7 +211,7 @@ def insertXOalignStrategies(self, xoalign_log):
171211 }
172212 ispyb_command_list .append (d )
173213
174- # Step 3 : Store screeningStrategyWedge results, linked to the screeningStrategyId
214+ # Step 4 : Store screeningStrategyWedge results, linked to the screeningStrategyId
175215 # Keep the screeningStrategyWedgeId
176216 d = {
177217 "wedgenumber" : 1 ,
0 commit comments