forked from bio-ontology-research-group/SMUDGE
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathget_supperClasses.groovy
45 lines (40 loc) · 2.01 KB
/
get_supperClasses.groovy
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
@Grapes([
@Grab(group='org.semanticweb.elk', module='elk-owlapi', version='0.4.2'),
@Grab(group='net.sourceforge.owlapi', module='owlapi-api', version='4.1.0'),
@Grab(group='net.sourceforge.owlapi', module='owlapi-apibinding', version='4.1.0'),
@Grab(group='net.sourceforge.owlapi', module='owlapi-impl', version='4.1.0'),
@Grab(group='net.sourceforge.owlapi', module='owlapi-parsers', version='4.1.0'),
@GrabConfig(systemClassLoader=true)
])
import org.semanticweb.owlapi.model.parameters.*
import org.semanticweb.elk.owlapi.ElkReasonerFactory;
import org.semanticweb.elk.owlapi.ElkReasonerConfiguration
import org.semanticweb.elk.reasoner.config.*
import org.semanticweb.owlapi.apibinding.OWLManager;
import org.semanticweb.owlapi.reasoner.*
import org.semanticweb.owlapi.reasoner.structural.StructuralReasoner
import org.semanticweb.owlapi.vocab.OWLRDFVocabulary;
import org.semanticweb.owlapi.model.*;
import org.semanticweb.owlapi.io.*;
import org.semanticweb.owlapi.owllink.*;
import org.semanticweb.owlapi.util.*;
import org.semanticweb.owlapi.search.*;
import org.semanticweb.owlapi.manchestersyntax.renderer.*;
import org.semanticweb.owlapi.reasoner.structural.*
OWLOntologyManager manager = OWLManager.createOWLOntologyManager()
def ont = manager.loadOntologyFromOntologyDocument(new File(args[0]))
OWLDataFactory fac = manager.getOWLDataFactory()
ConsoleProgressMonitor progressMonitor = new ConsoleProgressMonitor()
OWLReasonerConfiguration config = new SimpleConfiguration(progressMonitor)
ElkReasonerFactory f1 = new ElkReasonerFactory()
OWLReasoner reasoner = f1.createReasoner(ont,config)
new File("../../../Documents/smudge_data/phenomNet_super_classes.txt").withWriter { writer ->
for (OWLClass c: ont.getClassesInSignature(false)){
NodeSet superclasses = reasoner.getSuperClasses(c, false);
writer.write c.getIRI().getShortForm() + " "
for (Node<OWLClass> superc: superclasses){
writer.write superc.getRepresentativeElement().getIRI().getShortForm() + " "
}
writer.writeLine ""
}
}