Skip to content

Commit 9d8a1f9

Browse files
authored
Merge pull request #721 from xchem/m2ms-1669-second-upload-fails
Improved logging on missing experiments
2 parents fd6c42b + e0a8656 commit 9d8a1f9

File tree

1 file changed

+53
-7
lines changed

1 file changed

+53
-7
lines changed

viewer/target_loader.py

+53-7
Original file line numberDiff line numberDiff line change
@@ -762,6 +762,7 @@ def _check_file_hash(
762762
if file_hash and file_hash != calculate_sha256(file_path):
763763
logfunc(key, f"Invalid hash for file {filename}")
764764
else:
765+
logger.debug("missing file: %s", file_path)
765766
logfunc(
766767
key,
767768
f"{key} referenced in {METADATA_FILE}: {obj_identifier} but not found in archive",
@@ -1505,11 +1506,14 @@ def process_site_observation(
15051506
"cmpd": compound,
15061507
"xtalform_site": xtalform_site,
15071508
"canon_site_conf": canon_site_conf,
1508-
"smiles": smiles,
1509+
# "smiles": smiles,
15091510
"seq_id": ligand,
15101511
"chain_id": chain,
15111512
}
15121513

1514+
# smiles removed from check fields aand removed to defaults as
1515+
# part of 1670
1516+
15131517
defaults = {
15141518
"bound_file": str(self._get_final_path(bound_file)),
15151519
"apo_solv_file": str(self._get_final_path(apo_solv_file)),
@@ -1524,6 +1528,7 @@ def process_site_observation(
15241528
"ligand_smiles": str(self._get_final_path(ligand_smiles)),
15251529
"ligand_sdf": str(self._get_final_path(ligand_sdf)),
15261530
"pdb_header_file": None,
1531+
"smiles": smiles,
15271532
}
15281533

15291534
index_data = {
@@ -2015,9 +2020,30 @@ def process_bundle(self):
20152020
f"{val.instance.canon_site.canon_site_num}"
20162021
+ f"{next(numerators[val.instance.canon_site.canon_site_num])}"
20172022
)
2018-
so_list = [
2019-
site_observation_objects[k].instance for k in val.index_data["members"]
2020-
]
2023+
2024+
so_list = []
2025+
for k in val.index_data["members"]:
2026+
try:
2027+
so_list.append(site_observation_objects[k].instance)
2028+
except KeyError as exc:
2029+
# this is something that started happening, people
2030+
# removing experiments. check if exists:
2031+
# the key looks something like A71EV2A-x4922/A/201/5
2032+
exp_code = k.split("/")[0]
2033+
if exp_code not in experiment_objects.keys():
2034+
# this is the root cause, that's the situation
2035+
# that's been happening
2036+
self.report.log(
2037+
logging.ERROR,
2038+
f"Experiment {exp_code} missing from {METADATA_FILE}",
2039+
)
2040+
else:
2041+
# this has not, handling it just in case
2042+
self.report.log(
2043+
logging.ERROR,
2044+
f"SiteObservation {k} missing from {METADATA_FILE}",
2045+
)
2046+
20212047
# tag = val.instance.name.split('+')[0]
20222048
tag = val.instance.name
20232049
try:
@@ -2132,9 +2158,29 @@ def process_bundle(self):
21322158
f"F{val.instance.xtalform.xtalform_num}"
21332159
+ f"{val.instance.xtalform_site_num}"
21342160
)
2135-
so_list = [
2136-
site_observation_objects[k].instance for k in val.index_data["residues"]
2137-
]
2161+
2162+
so_list = []
2163+
for k in val.index_data["residues"]:
2164+
try:
2165+
so_list.append(site_observation_objects[k].instance)
2166+
except KeyError as exc:
2167+
# this is something that started happening, people
2168+
# removing experiments. check if exists:
2169+
# the key looks something like A71EV2A-x4922/A/201/5
2170+
exp_code = k.split("/")[0]
2171+
if exp_code not in experiment_objects.keys():
2172+
# this is the root cause, that's the situation
2173+
# that's been happening
2174+
self.report.log(
2175+
logging.ERROR,
2176+
f"Experiment {exp_code} missing from {METADATA_FILE}",
2177+
)
2178+
else:
2179+
# this has not, handling it just in case
2180+
self.report.log(
2181+
logging.ERROR,
2182+
f"SiteObservation {k} missing from {METADATA_FILE}",
2183+
)
21382184
tag = val.versioned_key
21392185
try:
21402186
# remove protein name and 'x'

0 commit comments

Comments
 (0)