Skip to content

Commit

Permalink
better handling of missing event maps
Browse files Browse the repository at this point in the history
  • Loading branch information
tdudgeon committed Nov 22, 2023
1 parent eb54454 commit cfb008f
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/xchemalign/aligner.py
Original file line number Diff line number Diff line change
Expand Up @@ -548,7 +548,7 @@ def _perform_alignments(self, meta):
self.logger.info('looking at', dtag)
# Skip if no output for this dataset
if dtag not in fs_model.alignments:
self.logger.warn('skipping {} as not in alignments'.format(dtag))
self.logger.warn('skipping {} as aligned structures not found'.format(dtag))
continue

new_meta[Constants.META_XTALS][dtag] = {}
Expand Down
41 changes: 28 additions & 13 deletions src/xchemalign/collator.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,8 @@ def __init__(self, config_file, logger=None):

self.target_name = utils.find_property(config, Constants.CONFIG_TARGET_NAME)

self.panddas_missing_ok = utils.find_property(config, Constants.META_PANDDAS_MISSING_OK, default=[])

self.version_number = None
self.version_dir = None
self.previous_version_dirs = []
Expand Down Expand Up @@ -623,14 +625,16 @@ def _copy_files(self, meta):
if best_event_map_paths:
for k, tup in best_event_map_paths.items():
path = tup[0]
digest = utils.gen_sha256(path)
ccp4_output = cryst_path / xtal_name / "{}_{}_{}_{}.ccp4".format(xtal_name, k[0], k[1], k[2])
# ccp4_output = cryst_path / xtal_name / "{}_{}_{}.ccp4".format(k[0], k[1], k[2])
event_maps_to_copy[k] = (path, ccp4_output, digest, k, tup[1], tup[2])
hist_data = hist_event_maps.get(k)
if hist_data:
if digest == hist_data.get(Constants.META_SHA256):
num_identical_historical_event_maps += 1
if path:
digest = utils.gen_sha256(path)
ccp4_output = (
cryst_path / xtal_name / "{}_{}_{}_{}.ccp4".format(xtal_name, k[0], k[1], k[2])
)
event_maps_to_copy[k] = (path, ccp4_output, digest, k, tup[1], tup[2])
hist_data = hist_event_maps.get(k)
if hist_data:
if digest == hist_data.get(Constants.META_SHA256):
num_identical_historical_event_maps += 1

else:
self.logger.error("PDB entry missing for {}".format(xtal_name))
Expand Down Expand Up @@ -919,9 +923,6 @@ def get_dataset_event_maps(
self, xtal_name: str, pdb_file: Path, event_tables: dict[Path, pd.DataFrame]
) -> dict[tuple[str, str, str], Path]:
# Get the relevant structure
# self.logger.info('Reading', xtal_name, pdb_file)
# self.logger.info('Using {} event tables'.format(len(event_tables)))

structure = gemmi.read_structure(str(pdb_file))

# Get the coordinates of ligands
Expand All @@ -930,11 +931,25 @@ def get_dataset_event_maps(
# Get the closest events within some reasonable radius
closest_event_maps = {}
for ligand_key, ligand_coord in ligand_coords.items():
# print('coord:', ligand_coord)
closest_event_map, data = self.get_closest_event_map(xtal_name, ligand_coord, event_tables)
if closest_event_map:
# print('closest:', closest_event_map)
closest_event_maps[ligand_key] = (closest_event_map, data[0], data[1])
else:
if xtal_name in self.panddas_missing_ok:
self.logger.warn(
"no PanDDA event map found for",
xtal_name,
"but this is OK as it's been added to the panddas_missing_ok",
"list in the config file",
)
else:
self.logger.error(
"no PanDDA event map found. If you want to allow this then add",
xtal_name,
"to the panddas_missing_ok list in the config file",
)

closest_event_maps[ligand_key] = (None, None, None)

return closest_event_maps

Expand Down
1 change: 1 addition & 0 deletions src/xchemalign/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ class Constants:
META_XTAL_CIF = "ligand_cif"
META_SMILES = "smiles"
META_BINDING_EVENT = "panddas_event_files"
META_PANDDAS_MISSING_OK = "panddas_missing_ok"
META_PROT_MODEL = "model"
META_PROT_CHAIN = "chain"
META_PROT_RES = "res"
Expand Down

0 comments on commit cfb008f

Please sign in to comment.