Skip to content

Commit

Permalink
switching to use the categories init parameter of kgxnode and a const…
Browse files Browse the repository at this point in the history
…ant instead of hardcoding node category
  • Loading branch information
EvanDietzMorris committed Aug 22, 2023
1 parent 81ac2ec commit 7ca750e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
4 changes: 3 additions & 1 deletion Common/node_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
GENE_FAMILY = 'biolink:GeneFamily'
GENOMIC_ENTITY = 'biolink:GenomicEntity'
FOOD = 'biolink:Food'
MACROMOLECULAR_COMPLEX = 'biolink:MacromolecularComplex'

# The root of all biolink_model entities
ROOT_ENTITY = NAMED_THING
Expand Down Expand Up @@ -55,7 +56,8 @@
GENETIC_CONDITION,
UNSPECIFIED,
GENE_FAMILY,
FOOD
FOOD,
MACROMOLECULAR_COMPLEX
]

# The following are used by edges:
Expand Down
10 changes: 8 additions & 2 deletions parsers/Reactome/src/loadReactome.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from Common.loader_interface import SourceDataLoader
from Common.kgxmodel import kgxnode, kgxedge
from Common.neo4j_tools import Neo4jTools
from Common.node_types import MACROMOLECULAR_COMPLEX, NAMED_THING
from Common.prefixes import REACTOME, NCBITAXON, GTOPDB, UNIPROTKB, CHEBI, KEGG_COMPOUND, KEGG_GLYCAN, PUBCHEM_COMPOUND, NCBIGENE, CLINVAR
from Common.utils import GetData

Expand Down Expand Up @@ -340,13 +341,18 @@ def process_node_from_neo4j(self, reference_entity_mapping, node_identity, node:

node_properties = {}
if any(x == 'Complex' for x in node_labels):
node_properties['category'] = ['biolink:MacromolecularComplex']
node_categories = [NAMED_THING, MACROMOLECULAR_COMPLEX]
else:
node_categories = [NAMED_THING]
if 'definition' in node.keys():
node_properties['definition'] = node['definition']
if 'url' in node.keys():
node_properties['url'] = node['url']
node_name = node['displayName'] if 'displayName' in node else ''
node_to_write = kgxnode(node_id, name=node_name, nodeprops=node_properties)
node_to_write = kgxnode(node_id,
name=node_name,
categories=node_categories,
nodeprops=node_properties)
self.output_file_writer.write_kgx_node(node_to_write)
return node_id

Expand Down

0 comments on commit 7ca750e

Please sign in to comment.