-
Notifications
You must be signed in to change notification settings - Fork 0
/
Script-Build_OntologyExtension-Robot.sh
executable file
·605 lines (383 loc) · 13.1 KB
/
Script-Build_OntologyExtension-Robot.sh
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
#! /bin/bash
## META DATA
## =========
export title="RDFBones ontology extension template"
export shortname="template"
export version="0.1"
export ontology_iri="http://w3id.org/rdfbones/ext/template/latest/template.owl"
export version_iri="http://w3id.org/rdfbones/ext/template/v0-1/template.owl"
export creators="Felix Engel"
export contributors=("Stefan Schlager" "Lukas Bender")
export description="Extensions to the RDFBones core ontology are written to implement data structures representing osteological reseearch data in biological anthropology. The RDFBones ontology extension template provides a repository outline to help researchers embarking on the creation of an ontology extension. This output is dummy content proving that the template is operational and demonstrating how it is to be used. Authors of ontology extensions need to replace the dummy content with the information they intend to model in order to receive the desired outcome."
export comment="This is a dummy for an ontology extending the RDFBones core ontology. It is not intended for productivity but to demonstrate how the template for RDFBones ontology extensions works."
## VARIABLES
## =========
export cleanup=0
export update=0
export build=0
export full=0
export verbose=0
## USAGE FUNCTION
## ==============
function usage {
echo " "
echo "usage: $0 [-b][-c][-u]"
echo " "
echo " -b build owl file"
echo " -c cleanup temporary files"
echo " -u initialise/update submodules"
echo " -f merge extension with the core ontology and all dependencies and output as one owl file"
echo " -v verbose mode"
echo " -h -? print this help"
exit
}
while getopts "bcufvh?" opt; do
case "$opt" in
c)
cleanup=1
;;
u)
update=1
;;
b)
build=1
;;
f)
full=1
;;
v)
verbose=1
;;
?)
usage
;;
h)
usage
;;
esac
done
if [ -z "$1" ]; then
usage
fi
## SUBMODULES
## ==========
## Check if submodules are initialised
gitchk=$(git submodule foreach 'echo $sm_path `git rev-parse HEAD`')
if [ -z "$gitchk" ]; then
update=1
fi
## Initialise and update git submodules
if [ $update -eq 1 ]; then
if [ $verbose -eq 1 ]; then
echo "Initialising git submodules"
fi
git submodule init
if [ $verbose -eq 1 ]; then
echo "Updating git submodules"
fi
git submodule update
fi
## BUILD ONTOLOGY EXTENSION
## ========================
if [ $build -eq 1 ]; then
## DEPENDENCIES
## ------------
if [ $verbose -eq 1 ]; then
echo "Building dependencies"
fi
## Build core ontology
cd dependencies/RDFBones-O/robot/
./Script-Build_RDFBones-Robot.sh
cd ../../../
## Add additional build instructions as exemplified for the core ontology above
## ****************************************************************************
## Merge dependencies
if [ $verbose -eq 1 ]; then
echo "Merging dependencies"
fi
robot merge --input dependencies/RDFBones-O/robot/results/rdfbones.owl \
--output results/dependencies.owl
## Add additional dependencies files as input
## ******************************************
## TEMPLATES
## ---------
if [ $verbose -eq 1 ]; then
echo "Processing category labels template"
fi
## Create category labels
robot template --template template-category_labels.tsv \
--prefixes prefixes.json \
--input results/dependencies.owl \
--output results/template_CategoryLabels.owl
if [ $verbose -eq 1 ]; then
echo "Merging category labels"
fi
robot merge --input results/dependencies.owl \
--input results/template_CategoryLabels.owl \
--output results/merged.owl
## Create value specifications
if [ $verbose -eq 1 ]; then
echo "Processing value specifications template"
fi
robot template --template template-value_specifications.tsv \
--prefixes prefixes.json \
--input results/merged.owl \
--output results/template_ValueSpecifications.owl
if [ $verbose -eq 1 ]; then
echo "Merging value specifications"
fi
robot merge --input results/merged.owl \
--input results/template_ValueSpecifications.owl \
--output results/merged.owl
robot merge --input results/template_CategoryLabels.owl \
--input results/template_ValueSpecifications.owl \
--output results/extension.owl
## Create data items
if [ $verbose -eq 1 ]; then
echo "Processing data items template"
fi
robot template --template template-data_items.tsv \
--prefixes prefixes.json \
--input results/merged.owl \
--output results/template_DataItems.owl
if [ $verbose -eq 1 ]; then
echo "Merging data items"
fi
robot merge --input results/merged.owl \
--input results/template_DataItems.owl \
--output results/merged.owl
robot merge --input results/extension.owl \
--input results/template_DataItems.owl \
--output results/extension.owl
## Create data sets
if [ $verbose -eq 1 ]; then
echo "Processing data sets template"
fi
robot template --template template-data_sets.tsv \
--prefixes prefixes.json \
--input results/merged.owl \
--output results/template_DataSets.owl
if [ $verbose -eq 1 ]; then
echo "Merging data sets"
fi
robot merge --input results/merged.owl \
--input results/template_DataSets.owl \
--output results/merged.owl
robot merge --input results/extension.owl \
--input results/template_DataSets.owl \
--output results/extension.owl
## Create assays
if [ $verbose -eq 1 ]; then
echo "Processing assays template"
fi
robot template --template template-assays.tsv \
--prefixes prefixes.json \
--input results/merged.owl \
--output results/template_Assays.owl
if [ $verbose -eq 1 ]; then
echo "Merging assays"
fi
robot merge --input results/merged.owl \
--input results/template_Assays.owl \
--output results/merged.owl
robot merge --input results/extension.owl \
--input results/template_Assays.owl \
--output results/extension.owl
## Create data transformations
if [ $verbose -eq 1 ]; then
echo "Processing data transformations template"
fi
robot template --template template-data_transformations.tsv \
--prefixes prefixes.json \
--input results/merged.owl \
--output results/template_DataTransformations.owl
if [ $verbose -eq 1 ]; then
echo "Merging data transformations"
fi
robot merge --input results/merged.owl \
--input results/template_DataTransformations.owl \
--output results/merged.owl
robot merge --input results/extension.owl \
--input results/template_DataTransformations.owl \
--output results/extension.owl
## Create Conclusion Processes
if [ $verbose -eq 1 ]; then
echo "Processing conlusion processes template"
fi
robot template --template template-conclusion_processes.tsv \
--prefixes prefixes.json \
--input results/merged.owl \
--output results/template_ConclusionProcesses.owl
if [ $verbose -eq 1 ]; then
echo "Merging conclusion processes"
fi
robot merge --input results/merged.owl \
--input results/template_ConclusionProcesses.owl \
--output results/merged.owl
robot merge --input results/extension.owl \
--input results/template_ConclusionProcesses.owl \
--output results/extension.owl
## Create Study Design Execution Processes
if [ $verbose -eq 1 ]; then
echo "Processing study design execution processes template"
fi
robot template --template template-study_design_executions.tsv \
--prefixes prefixes.json \
--input results/merged.owl \
--output results/template_StudyDesignExecutions.owl
if [ $verbose -eq 1 ]; then
echo "Merging study design execution processes"
fi
robot merge --input results/merged.owl \
--input results/template_StudyDesignExecutions.owl \
--output results/merged.owl
robot merge --input results/extension.owl \
--input results/template_StudyDesignExecutions.owl \
--output results/extension.owl
## Create Protocols
if [ $verbose -eq 1 ]; then
echo "Processing protocols template"
fi
robot template --template template-protocols.tsv \
--prefixes prefixes.json \
--input results/merged.owl \
--output results/template_Protocols.owl
if [ $verbose -eq 1 ]; then
echo "Merging protocols"
fi
robot merge --input results/merged.owl \
--input results/template_Protocols.owl \
--output results/merged.owl
robot merge --input results/extension.owl \
--input results/template_Protocols.owl \
--output results/extension.owl
## Create Study Designs
if [ $verbose -eq 1 ]; then
echo "Processing study designs template"
fi
robot template --template template-study_designs.tsv \
--prefixes prefixes.json \
--input results/merged.owl \
--output results/template_StudyDesigns.owl
if [ $verbose -eq 1 ]; then
echo "Merging study designs"
fi
robot merge --input results/merged.owl \
--input results/template_StudyDesigns.owl \
--output results/merged.owl
robot merge --input results/extension.owl \
--input results/template_StudyDesigns.owl \
--output results/extension.owl
## Create Planning Processes
if [ $verbose -eq 1 ]; then
echo "Processing planning processes template"
fi
robot template --template template-planning.tsv \
--prefixes prefixes.json \
--input results/merged.owl \
--output results/template_Planning.owl
if [ $verbose -eq 1 ]; then
echo "Merging planning processes"
fi
robot merge --input results/merged.owl \
--input results/template_Planning.owl \
--output results/merged.owl
robot merge --input results/extension.owl \
--input results/template_Planning.owl \
--output results/extension.owl
## Create Investigation Processes
if [ $verbose -eq 1 ]; then
echo "Processing investigation processes template"
fi
robot template --template template-investigations.tsv \
--prefixes prefixes.json \
--input results/merged.owl \
--output results/template_Investigations.owl
if [ $verbose -eq 1 ]; then
echo "Merging investigation processes"
fi
robot merge --input results/merged.owl \
--input results/template_Investigations.owl \
--output results/merged.owl
robot merge --input results/extension.owl \
--input results/template_Investigations.owl \
--output results/extension.owl
## DEFINE OUTPUT FILE
## ------------------
cd results
if [ $full -eq 1 ]; then
output="merged.owl"
else
output="extension.owl"
fi
## CLEANUP TEMPORARY FILES
## -----------------------
if [ $cleanup -eq 1 ]; then
if [ $verbose -eq 1 ]; then
echo "Cleaning up temporary files"
fi
find . -not -regex ./"$output" -delete
fi
## CONSISTENCY TEST
## ----------------
if [ $verbose -eq 1 ]; then
echo "Testing consistency of output"
fi
robot reason --reasoner ELK \
--input "$output" \
-D debug.owl
## ANNOTATE OUTPUT
## ---------------
if [ $verbose -eq 1 ]; then
echo "Annotating output"
fi
robot annotate --input "$output" \
--remove-annotations \
--output "$output"
creatorsnumber=${#creators[*]}
for ((i = 0 ; i < $creatorsnumber ; i++)); do
robot annotate --input "$output" \
--annotation dc:creator "${creators[i]}" \
--output "$output"
done
contributorsnumber=${#contributors[*]}
for ((i = 0 ; i < $contributorsnumber ; i++)); do
robot annotate --input "$output" \
--annotation dc:contributor "${contributors[i]}" \
--output "$output"
done
robot annotate --input "$output" \
--ontology-iri "${ontology_iri}" \
--version-iri "${version_iri}" \
--annotation owl:versionInfo "${version}" \
--language-annotation rdfs:label "${title}" en \
--language-annotation rdfs:comment "${comment}" en \
--language-annotation dc:description "${description}" en \
--language-annotation dc:title "${title}" en \
--output $shortname.owl
## Change annotations to describe your extension and change file name in the final output statement.
## *************************************************************************************************
## CLEANUP TEMPORARY FILES
## -----------------------
if [ $cleanup -eq 1 ]; then
if [ $verbose -eq 1 ]; then
echo "Cleaning up temposrary files"
fi
rm "$output"
fi
cd ..
fi
## CLEANUP
## =======
## CLEANUP TEMPORARY FILES IN DEPENDENCIES
## ---------------------------------------
if [ $verbose -eq 1 ]; then
echo "Cleaning up temporary files in dependencies directories"
fi
## Remove temporary build files in RDFBones core ontology
FILE=dependencies/RDFBones-O/robot/results/
if [ -f "$FILE" ]; then
rm -r dependencies/RDFBones-O/robot/results/
fi
## Add cleanup commands for additional dependencies as exemplified above for the RDFBones core ontology.
## *****************************************************************************************************