Skip to content

Commit

Permalink
Update graph_relationships_loader.py
Browse files Browse the repository at this point in the history
  • Loading branch information
asmaa-a-abdelwahab authored Aug 6, 2024
1 parent 2ef57f4 commit cfb6a3e
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions chemgraphbuilder/graph_relationships_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,23 +92,26 @@ def __init__(self, uri, username, password):
"destination_label": "Compound",
"rel_type_column": None,
"relationship_type": "IS_SIMILAR_TO",
"is_directory": True
"is_directory": True,
"is_bidirectional": True
},
"Compound_Compound_CoOccurrence": {
"file_path": "Data/Relationships/Cpd_Cpd_CoOccurrence/*.csv",
"source_label": "Compound",
"destination_label": "Compound",
"rel_type_column": None,
"relationship_type": "CO_OCCURS_IN_LITERATURE",
"is_directory": True
"is_directory": True,
"is_bidirectional": True
},
"Compound_Gene_CoOccurrence": {
"file_path": "Data/Relationships/Cpd_Gene_CoOccurrence/*.csv",
"source_label": "Gene",
"destination_label": "Compound",
"rel_type_column": None,
"relationship_type": "CO_OCCURS_IN_LITERATURE",
"is_directory": True
"is_directory": True,
"is_bidirectional": True
}
}

Expand All @@ -133,6 +136,7 @@ def add_relationships(self, relationship_type):
destination_label = settings["destination_label"]
rel_type_column = settings.get("rel_type_column")
is_directory = settings.get("is_directory", False)
is_bidirectional = settings.get("is_bidirectional", False)

if is_directory:
self.add_graph_relationships.process_and_add_relationships_from_directory(file_path,
Expand All @@ -146,6 +150,11 @@ def add_relationships(self, relationship_type):
source_label,
destination_label,
rel_type_column)
if is_bidirectional:
self.add_graph_relationships.remove_self_relationships()
self.add_graph_relationships.make_relationships_bidirectional(settings["relationship_type"])
else:
self.add_graph_relationships.remove_self_relationships()

def main():
"""Main function to handle command-line arguments and run the GraphRelationshipsLoader."""
Expand Down

0 comments on commit cfb6a3e

Please sign in to comment.