-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun_bratify.py
executable file
·66 lines (49 loc) · 2.36 KB
/
run_bratify.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
64
65
#!/usr/bin/python
# coding=<utf-8>
from bratify_owl import run_bratify
"""
Bratify is a program that produces Brat-formatted class hierarchy and labels from an OWL file.
Usage: edit the template below and run the program.
Copyright (C) 2017 Selja Seppälä
Email: [email protected]
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
"""
def name_of_ontology():
# Specify the paths to:
# - the input OWL file
# - the output file formatted for brat visual.conf
# - the output file formatted for brat annotation.conf
owl = "./path_to/owl_file.owl"
visualization_path = "./for_configuration_files/labels_for_visualization.txt"
annotation_path = "./for_configuration_files/hierarchy_for_annotation.txt"
# Specify the output format of the labels for Brat's system and for visualization.conf
# 1 = brat_syst_format | normal term format | ID
# 2 = ID | normal term format
output_style = "1"
# Specify the SPARQL query to get the labels and the PURLs for each class in the OWL file
query = """ SELECT DISTINCT ?child_label ?child_id ?parent_label ?parent_id
WHERE {
?child rdfs:subClassOf ?parent .
?child a owl:Class .
?parent a owl:Class .
?child rdfs:label ?child_label .
?parent rdfs:label ?parent_label .
?child oboInOwl:id ?child_id .
?parent oboInOwl:id ?parent_id .
FILTER ( ?parent != ?child )
}
#LIMIT 10
"""
# Run bratify.py for the specified ontology
run_bratify(owl, query, visualization_path, annotation_path, output_style)
if __name__ == '__main__':
name_of_ontology()