Skip to content

Commit

Permalink
adding qualified predicate and object aspect to regulates edges, mino…
Browse files Browse the repository at this point in the history
…r syntax cleanup
  • Loading branch information
EvanDietzMorris committed Feb 9, 2024
1 parent 1dd32df commit 28780d3
Showing 1 changed file with 20 additions and 14 deletions.
34 changes: 20 additions & 14 deletions parsers/Reactome/src/loadReactome.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
"output": "biolink:has_output",
"input": "biolink:has_input",
"hasEvent": "biolink:contains_process",
"normalPathway":"biolink:contains_process", #TODO Choose better biolink predicate for normalPathways/Reactions/Etc.
"normalReaction":"biolink:contains_process", #TODO Choose better biolink predicate for normalPathways/Reactions/Etc.
"normalPathway": "biolink:contains_process", #TODO Choose better biolink predicate for normalPathways/Reactions/Etc.
"normalReaction": "biolink:contains_process", #TODO Choose better biolink predicate for normalPathways/Reactions/Etc.
#"normalEntity":"biolink:contains_process", #TODO Choose better biolink predicate for normalPathways/Reactions/Etc.
"precedingEvent": "biolink:precedes",
"activeUnit": "biolink:actively_involves",
Expand All @@ -36,9 +36,9 @@
"cellType": "biolink:located_in",
"goBiologicalProcess": "biolink:subclass_of",
"disease": "biolink:disease_has_basis_in",
"regulator":"biolink:regulates",
"species":"biolink:in_taxon",
"includedLocation":"biolink:located_in"}
"regulator": "biolink:regulates",
"species": "biolink:in_taxon",
"includedLocation": "biolink:located_in"}


# TODO - use something like this instead of manipulating strings for individual cases
Expand Down Expand Up @@ -301,7 +301,6 @@ def write_neo4j_result_to_file(self, result: neo4j.Result, reference_entity_mapp
skipped_record_count = 0
for record in result:
record_data = record.data()

node_a_id = self.process_node_from_neo4j(reference_entity_mapping, record_data['a_id'], record_data['a'], record_data['a_labels'])
node_b_id = self.process_node_from_neo4j(reference_entity_mapping, record_data['b_id'], record_data['b'], record_data['b_labels'])
if node_a_id and node_b_id:
Expand All @@ -310,19 +309,19 @@ def write_neo4j_result_to_file(self, result: neo4j.Result, reference_entity_mapp
self.process_edge_from_neo4j(node_a_id,
record_data['r_type'],
node_b_id,
regulationType='positive',
regulation_type='positive',
complex_context=record_data.get('complex_context', None))
elif any("negative" in x.lower() for x in record_data['regulationType']):
self.process_edge_from_neo4j(node_a_id,
record_data['r_type'],
node_b_id,
regulationType='negative',
regulation_type='negative',
complex_context=record_data.get('complex_context', None))
else:
self.process_edge_from_neo4j(node_a_id,
record_data['r_type'],
node_b_id,
regulationType=None,
regulation_type=None,
complex_context=record_data.get('complex_context', None))
record_count += 1
else:
Expand Down Expand Up @@ -417,10 +416,15 @@ def process_node_from_neo4j(self, reference_entity_mapping, node_identity, node:
self.dbid_to_node_id_lookup[node['dbId']] = node_id
"""

def process_edge_from_neo4j(self, subject_id: str, relationship_type: str, object_id: str, regulationType=None, complex_context=None):
def process_edge_from_neo4j(self,
subject_id: str,
relationship_type: str,
object_id: str,
regulation_type=None,
complex_context=None):
predicate = PREDICATE_MAPPING.get(relationship_type, None)
if predicate:
if regulationType is None:
if not regulation_type:
output_edge = kgxedge(
subject_id=subject_id,
object_id=object_id,
Expand All @@ -429,14 +433,16 @@ def process_edge_from_neo4j(self, subject_id: str, relationship_type: str, objec
primary_knowledge_source=self.provenance_id
)
else:
if regulationType == 'positive':
if regulation_type == 'positive':
direction = 'upregulated'
elif regulationType == 'negative':
elif regulation_type == 'negative':
direction = 'downregulated'
else:
self.logger.warning(f'Unexpected regulation type encountered: {regulationType}')
self.logger.warning(f'Unexpected regulation type encountered: {regulation_type}')
return
edge_props = {
'qualified_predicate': 'causes',
'object_aspect': 'activity',
'object_direction_qualifier': direction,
}
if complex_context:
Expand Down

0 comments on commit 28780d3

Please sign in to comment.