Skip to content

Instantly share code, notes, and snippets.

@johardi
Last active May 8, 2020 16:23
Show Gist options
  • Save johardi/caef750d7693263e6e428a0d4fc99618 to your computer and use it in GitHub Desktop.
Save johardi/caef750d7693263e6e428a0d4fc99618 to your computer and use it in GitHub Desktop.
Import CIDO ontology to Neo4j Workflow

Import CIDO ontology to Neo4j Workflow

STEP 0

Download the CIDO ontology from the BioPortal: https://bioportal.bioontology.org/ontologies/CIDO

STEP 1

In a terminal, after unpacking the owl2lpg-translation-cli package:

./run.sh translate -f csv /path/to/ontology/cido.owl > cido.csv

STEP 2

In Neo4j Browser:

Load the CSV files using the APOC library

CALL apoc.import.csv(
   [{fileName: 'file:/path/to/csv/project-node.csv', labels: []},
   {fileName: 'file:/path/to/csv/branch-node.csv', labels: []},
   {fileName: 'file:/path/to/csv/ontology-document-node.csv', labels: []},
   {fileName: 'file:/path/to/csv/entity-node.csv', labels: []},
   {fileName: 'file:/path/to/csv/iri-node.csv', labels: []},
   {fileName: 'file:/path/to/csv/literal-node.csv', labels: []},
   {fileName: 'file:/path/to/csv/anonymous-individual-node.csv', labels: []},
   {fileName: 'file:/path/to/csv/language-tag-node.csv', labels: []},
   {fileName: 'file:/path/to/csv/propertyless-node.csv', labels: []}],
   [{fileName: 'file:/path/to/csv/propertyless-edge.csv', type: ''}],
   {});

STEP 3

In Neo4j Browser:

a. Remove the residual __csv_id property created by the apoc.import.csv method

MATCH (n) WHERE EXISTS(n.__csv_id) REMOVE n.__csv_id

b. Remove the residual __csv_type property created by the apoc.import.csv method

MATCH ()-[r]->() WHERE EXISTS(r.__csv_type) REMOVE r.__csv_type

STEP 4

In Neo4j Browser:

a. Add the augmented edges for class expression parents (later it will be automatic)

MATCH (sub)<-[:SUB_CLASS_EXPRESSION]-(:SubClassOf)-[:SUPER_CLASS_EXPRESSION]->(super:ClassExpression)-[:CLASS_EXPRESSION]->(filler)
MATCH (super)-[:OBJECT_PROPERTY_EXPRESSION]->(property)
MERGE (sub)-[:RELATED_TO {iri:property.iri, type:'ObjectProperty'}]->(filler)

b. Add the augmented edges for annotation assertions (later it will be automatic)

MATCH (axiom:AnnotationAssertion)-[:ANNOTATION_PROPERTY]->(prop:AnnotationProperty)
MATCH (axiom)-[:ANNOTATION_SUBJECT]->(subject)
MATCH (axiom)-[:ANNOTATION_VALUE]->(literal)
MERGE (subject)-[:RELATED_TO {iri:prop.iri, type:'AnnotationProperty'}]->(literal)
MERGE (subject)-[:IS_SUBJECT_OF]->(axiom)

STEP 5

In Neo4j Browser:

a. Create an index on the Class.iri property

CREATE INDEX FOR (n:Class) ON (n.iri)

b. Create an index on the IRI.iri property

CREATE INDEX FOR (n:IRI) ON (n.iri)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment