Skip to content

Commit

Permalink
Added all available metadata present in Monarch KG to edge properties.
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Korn committed Sep 19, 2024
1 parent 5e9151b commit 224d0b5
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions parsers/monarchkg/src/loadMonarchKG.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@ def parse_data(self) -> dict:
skipped_ignore_knowledge_source = 0
skipped_undesired_predicate = 0
full_tar_path = os.path.join(self.data_path, self.monarch_graph_archive)
protected_edge_labels = [SUBJECT_ID, OBJECT_ID, PREDICATE,PRIMARY_KNOWLEDGE_SOURCE,
AGGREGATOR_KNOWLEDGE_SOURCES, KNOWLEDGE_LEVEL, AGENT_TYPE,
PUBLICATIONS, "biolink:primary_knowledge_source", "biolink:aggregator_knowledge_source"]

with tarfile.open(full_tar_path, 'r') as tar_files:
with tar_files.extractfile(self.monarch_edge_file_archive_path) as edges_file:
for line in edges_file:
Expand Down Expand Up @@ -125,13 +129,14 @@ def parse_data(self) -> dict:
KNOWLEDGE_LEVEL: monarch_edge[KNOWLEDGE_LEVEL] if KNOWLEDGE_LEVEL in monarch_edge else NOT_PROVIDED,
AGENT_TYPE: monarch_edge[AGENT_TYPE] if AGENT_TYPE in monarch_edge else NOT_PROVIDED
}

if monarch_edge[PUBLICATIONS]:
edge_properties[PUBLICATIONS] = monarch_edge[PUBLICATIONS]

for edge_attribute in monarch_edge:
if '_qualifier' in edge_attribute and monarch_edge[edge_attribute]:
if edge_attribute not in protected_edge_labels and monarch_edge[edge_attribute]:
edge_properties[edge_attribute] = monarch_edge[edge_attribute]
elif edge_attribute == QUALIFIED_PREDICATE and monarch_edge[QUALIFIED_PREDICATE]:
edge_properties[QUALIFIED_PREDICATE] = monarch_edge[QUALIFIED_PREDICATE]

output_edge = kgxedge(
subject_id=subject_id,
predicate=predicate,
Expand Down

0 comments on commit 224d0b5

Please sign in to comment.