forked from bio-ontology-research-group/deepgozero
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaxioms.py
executable file
·63 lines (46 loc) · 1.79 KB
/
axioms.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/usr/bin/env python
import click as ck
import numpy as np
import pandas as pd
import gzip
import logging
import torch as th
import jpype
import jpype.imports
import os
jars_dir = "jars/"
jars = f'{str.join(":", [jars_dir + name for name in os.listdir(jars_dir)])}'
if not jpype.isJVMStarted():
jpype.startJVM(
jpype.getDefaultJVMPath(), "-ea",
"-Djava.class.path=" + jars,
convertStrings=False)
# OWLAPI imports
from org.semanticweb.owlapi.model import OWLOntology
from org.semanticweb.owlapi.apibinding import OWLManager
from org.semanticweb.owlapi.reasoner import ConsoleProgressMonitor
from org.semanticweb.owlapi.reasoner import SimpleConfiguration
from org.semanticweb.owlapi.reasoner import InferenceType
from org.semanticweb.owlapi.util import InferredClassAssertionAxiomGenerator
from org.semanticweb.owlapi.util import InferredEquivalentClassAxiomGenerator
from org.semanticweb.owlapi.util import InferredSubClassAxiomGenerator
from org.semanticweb.elk.owlapi import ElkReasonerFactory;
from org.semanticweb.elk.owlapi import ElkReasonerConfiguration
from org.semanticweb.elk.reasoner.config import *
from org.semanticweb.owlapi.manchestersyntax.renderer import *
from org.semanticweb.owlapi.formats import *
from org.semanticweb.owlapi.model import OWLAxiom
from java.util import HashSet
from java.io import File
@ck.command()
def main():
ont_manager = OWLManager.createOWLOntologyManager()
data_factory = ont_manager.getOWLDataFactory()
ontology = ont_manager.loadOntologyFromOntologyDocument(
File("data/go-plus.owl"))
def to_go(uri):
return uri[1:-1].replace('http://purl.obolibrary.org/obo/GO_', 'GO:')
def to_rel(uri):
return uri[len('ObjectSomeValuesFrom(<http://purl.obolibrary.org/obo/'):-1]
if __name__ == '__main__':
main()