"docs/vscode:/vscode.git/clone" did not exist on "412ec84317e269bfffac0bc228582462d1293fed"
Commit 106286c0 authored by Lucas Bickmann's avatar Lucas Bickmann
Browse files

Fix for obsolete-file, which references old pdb-ids which have been replaced several times

parent 2ef7893a
...@@ -130,6 +130,22 @@ def _is_after_cutoff( ...@@ -130,6 +130,22 @@ def _is_after_cutoff(
return False return False
def _replace_obsolete_references(obsolete_mapping) -> Mapping[str, str]:
"""Generates a new obsolete by tracing all cross-references and store the latest leaf to all referencing nodes"""
obsolete_new = {}
obsolete_keys = obsolete_mapping.keys()
def _new_target(k):
v = obsolete_mapping[k]
if v in obsolete_keys:
return _new_target(v)
return v
for k in obsolete_keys:
obsolete_new[k] = _new_target(k)
return obsolete_new
def _parse_obsolete(obsolete_file_path: str) -> Mapping[str, str]: def _parse_obsolete(obsolete_file_path: str) -> Mapping[str, str]:
"""Parses the data file from PDB that lists which PDB ids are obsolete.""" """Parses the data file from PDB that lists which PDB ids are obsolete."""
with open(obsolete_file_path) as f: with open(obsolete_file_path) as f:
...@@ -143,6 +159,7 @@ def _parse_obsolete(obsolete_file_path: str) -> Mapping[str, str]: ...@@ -143,6 +159,7 @@ def _parse_obsolete(obsolete_file_path: str) -> Mapping[str, str]:
from_id = line[20:24].lower() from_id = line[20:24].lower()
to_id = line[29:33].lower() to_id = line[29:33].lower()
result[from_id] = to_id result[from_id] = to_id
_replace_obsolete_references(result)
return result return result
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment