Skip to content

Commit

Permalink
Merge pull request #8 from INCATools/anitacaron/issue7
Browse files Browse the repository at this point in the history
Add relationships from config to graph
  • Loading branch information
Anita Caron authored Apr 17, 2024
2 parents adc9402 + 6bae6b3 commit 62a9d91
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src/relation_validator/utils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,19 +163,23 @@ def get_ontologies_version():

def get_obograph(
rel_terms: Dict[str, List[Tuple[str, str]]],
labels: Dict[str, str]
labels: Dict[str, str],
properties: Dict[str, str]
) -> Graph:
"""
Transform graph into OBOGgraph
"""
edges = []
nodes = {}
properties_ = {v: k for k, v in properties.items()}

for rel, terms in rel_terms.items():
for sub, obj in terms:
edges.append(Edge(sub=sub, pred=rel, obj=obj))
nodes[sub] = Node(id=sub, lbl=labels[sub])
nodes[obj] = Node(id=obj, lbl=labels[obj])
if "not_matched" not in rel:
nodes[rel] = Node(id=rel, lbl=properties_[rel])

return Graph(id="valid", nodes=list(nodes.values()), edges=edges)

Expand Down
2 changes: 1 addition & 1 deletion src/relation_validator/validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def validate(args):
report.to_csv(output_filename, sep=sep, index=False)

labels = get_labels(data)
graph = get_obograph(rel_terms, labels)
graph = get_obograph(rel_terms, labels, config["relationships"])
save_obograph(graph, f"{temp_filename}.png")
return True

Expand Down

0 comments on commit 62a9d91

Please sign in to comment.