Skip to content

Commit 913e362

Browse files
committed
D2
1 parent a8285b5 commit 913e362

26 files changed

+905
-587
lines changed

.github/workflows/docs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
runs-on: ubuntu-latest
1717
steps:
1818
- name: Checkout main
19-
uses: actions/checkout@v3
19+
uses: actions/checkout@v4
2020

2121
- name: Deploy docs
2222
uses: mhausenblas/mkdocs-deploy-gh-pages@master

.github/workflows/qc.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@ jobs:
1919
ontology_qc:
2020
# The type of runner that the job will run on
2121
runs-on: ubuntu-latest
22-
container: obolibrary/odkfull:v1.5.4
22+
container: obolibrary/odkfull:v1.6
2323

2424
# Steps represent a sequence of tasks that will be executed as part of the job
2525
steps:
2626
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
27-
- uses: actions/checkout@v3
27+
- uses: actions/checkout@v4
2828

2929
- name: Run ontology QC checks
3030
env:

.gitignore

Lines changed: 69 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,77 @@
1+
# ODK-managed rules, do not modify
2+
# If you need to add your own ignore rules, you may do so below
3+
# the "End ODK-managed rules" marker at the end of this file.
4+
.DS_Store
5+
semantic.cache
6+
bin/
7+
8+
*.tmp
9+
*.tmp.obo
10+
*.tmp.owl
11+
*.tmp.json
12+
*-relation-graph.tsv.gz
13+
.template.db
14+
15+
.github/token.txt
16+
17+
/cto.owl
18+
/cto.obo
19+
/cto.json
20+
/cto.db
21+
/cto-base.*
22+
/cto-basic.*
23+
/cto-full.*
24+
/cto-simple.*
25+
/cto-simple-non-classified.*
26+
/mappings/
27+
/patterns/
28+
/reports/
29+
/subsets/
30+
31+
src/ontology/mirror
32+
src/ontology/mirror/*
33+
src/ontology/reports/*
34+
!src/ontology/reports/release-diff.md
35+
src/ontology/cto.owl
36+
src/ontology/cto.obo
37+
src/ontology/cto.json
38+
src/ontology/cto.db
39+
src/ontology/cto-base.*
40+
src/ontology/cto-basic.*
41+
src/ontology/cto-full.*
42+
src/ontology/cto-simple.*
43+
src/ontology/cto-simple-non-classified.*
44+
45+
src/ontology/seed.txt
46+
src/ontology/dosdp-tools.log
47+
src/ontology/ed_definitions_merged.owl
48+
src/ontology/ontologyterms.txt
49+
src/ontology/simple_seed.txt
50+
src/ontology/patterns
51+
src/ontology/merged-cto-edit.owl
52+
src/ontology/cto-edit.properties
53+
54+
src/ontology/target/
55+
src/ontology/tmp/*
56+
!src/ontology/tmp/.gitkeep
57+
!src/ontology/tmp/README.md
58+
59+
src/ontology/run.sh.conf
60+
src/ontology/run.sh.env
61+
62+
src/ontology/imports/*_terms_combined.txt
63+
64+
src/patterns/data/**/*.ofn
65+
src/patterns/data/**/*.txt
66+
src/patterns/pattern_owl_seed.txt
67+
src/patterns/all_pattern_terms.txt
68+
69+
# End of ODK-managed rules
170
widoco.jar
271
src/.DS_Store
372
/src/ontology/mirror
473
/src/ontology/reports
574
/src/ontology/tmp
6-
src/ontology/cto.owl
775
src/ontology/cto-full.owl
876
src/ontology/imports/.DS_Store
977
src/metadata/cto.md

Dockerfile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ RUN java -jar widoco-1.4.25-jar-with-dependencies_JDK-11.jar -ontFile /data/onto
88

99
FROM ghcr.io/epoz/shmarql:latest
1010

11+
# MkDocs D2 plugin
12+
RUN wget -qO- https://d2lang.com/install.sh | sh -s -- && d2 version
13+
RUN pip install --no-cache-dir mkdocs-d2-plugin
14+
1115
COPY docs /src/docs
1216
COPY mkdocs.yml a.yml
1317
RUN python -m shmarql docs_build -f a.yml
@@ -16,3 +20,4 @@ RUN mkdir /src/site/ontology
1620
COPY --from=widoco /public/doc /src/site/ontology
1721
RUN ls -l /src/site/ontology
1822
RUN cp /src/site/ontology/index-en.html /src/site/ontology/index.html
23+

docs/domain-examples.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,4 +85,10 @@ stateDiagram
8585
class C1
8686
state "xF" as keysig_xF
8787
88+
```
89+
90+
```d2
91+
92+
x -> x
93+
8894
```
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
## Constraint violation checks
2+
3+
We can define custom checks using [SPARQL](https://www.w3.org/TR/rdf-sparql-query/). SPARQL queries define bad modelling patterns (missing labels, misspelt URIs, and many more) in the ontology. If these queries return any results, then the build will fail. Custom checks are designed to be run as part of GitHub Actions Continuous Integration testing, but they can also run locally.
4+
5+
### Steps to add a constraint violation check:
6+
7+
1. Add the SPARQL query in `src/sparql`. The name of the file should end with `-violation.sparql`. Please give a name that helps to understand which violation the query wants to check.
8+
2. Add the name of the new file to odk configuration file `src/ontology/uberon-odk.yaml`:
9+
1. Include the name of the file (without the `-violation.sparql` part) to the list inside the key `custom_sparql_checks` that is inside `robot_report` key.
10+
1. If the `robot_report` or `custom_sparql_checks` keys are not available, please add this code block to the end of the file.
11+
12+
``` yaml
13+
robot_report:
14+
release_reports: False
15+
fail_on: ERROR
16+
use_labels: False
17+
custom_profile: True
18+
report_on:
19+
- edit
20+
custom_sparql_checks:
21+
- name-of-the-file-check
22+
```
23+
3. Update the repository so your new SPARQL check will be included in the QC.
24+
25+
```shell
26+
sh run.sh make update_repo
27+
```
28+

docs/odk-workflows/ManageDocumentation.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,5 +43,3 @@ The documentation is _not_ automatically updated from the Markdown, and needs to
4343
3. Just to double check, you can now navigate to your documentation pages (usually https://ISE-FIZKarlsruhe.github.io/nfdi4culture/).
4444
Just make sure you give GitHub 2-5 minutes to build the pages!
4545

46-
47-

docs/odk-workflows/RepositoryFileStructure.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,10 @@ These are the current imports in CTO
1919
| nfdicore | https://raw.githubusercontent.com/ISE-FIZKarlsruhe/nfdicore/main/nfdicore.ttl | mirror |
2020
| schema | https://raw.githubusercontent.com/schemaorg/schemaorg/refs/tags/v28.1-release/data/releases/28.1/schemaorg.owl | custom |
2121
| skos | http://www.w3.org/TR/skos-reference/skos.rdf | slme |
22-
2322
## Components
2423
Components, in contrast to imports, are considered full members of the ontology. This means that any axiom in a component is also included in the ontology base - which means it is considered _native_ to the ontology. While this sounds complicated, consider this: conceptually, no component should be part of more than one ontology. If that seems to be the case, we are most likely talking about an import. Components are often not needed for ontologies, but there are some use cases:
2524

2625
1. There is an automated process that generates and re-generates a part of the ontology
2726
2. A part of the ontology is managed in ROBOT templates
2827
3. The expressivity of the component is higher than the format of the edit file. For example, people still choose to manage their ontology in OBO format (they should not) missing out on a lot of owl features. They may choose to manage logic that is beyond OBO in a specific OWL component.
2928

30-

docs/odk-workflows/components.md

Lines changed: 27 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14,35 +14,46 @@ components:
1414
- filename: your-component-name.owl
1515
```
1616

17-
3) Add the component to your catalog file (src/ontology/catalog-v001.xml)
17+
3) Refresh your repo by running `sh run update_repo`. This will automatically (1) create a new file in `src/ontology/components/`, (2) update the `-edit` file so that it imports `https://nfdi4culture.de/ontology/cto/components/your-component-name.owl` (the IRI of your new component), and (3) update the XML catalog file (`src/ontology/catalog-v001.xml`) to redirect that IRI to the file in the `src/ontology/components` directory, so that the new component can be found by tools such as Protégé or ROBOT, when they load the `-edit` file.
18+
19+
If your component is to be generated by some automated process, add a goal in your custom Makefile (`src/ontology/cto.Makefile`) and make it perform any task needed to generate the component:
1820

1921
```
20-
<uri name="https://nfdi4culture.de/ontology/cto/components/your-component-name.owl" uri="components/your-component-name.owl"/>
22+
$(COMPONENTSDIR)/your-component-name.owl: $(SRC)
23+
<Insert here the code to produce the component>
2124
```
2225

23-
4) Add the component to the edit file (src/ontology/cto-edit.obo)
24-
for .obo formats:
26+
If the component is to be generated from a ROBOT template, the ODK can generate the appropriate code for you. For that, when adding the component fo the ODK configuration file (step 2 above), explicitly indicate that the component should be derived from template(s) and list the source templates:
2527

2628
```
27-
import: https://nfdi4culture.de/ontology/cto/components/your-component-name.owl
29+
components:
30+
products:
31+
- filename: your-component-name.owl
32+
use_template: true
33+
templates:
34+
- template1.tsv
35+
- template2.tsv
2836
```
2937

30-
for .owl formats:
38+
In this example, the component will be derived from the templates found in `src/templates/template1.tsv` and `src/templates/template2.tsv`. Initial empty templates will automatically be generated when the repository is refreshed (step 3).
39+
40+
Likewise, the ODK can generate the required code for the case where the component is to be derived from SSSOM mappings:
3141

3242
```
33-
Import(<https://nfdi4culture.de/ontology/cto/components/your-component-name.owl>)
43+
components:
44+
products:
45+
- filename: your-component-name.owl
46+
use_mappings: true
47+
mappings:
48+
- my-mappings.sssom.tsv
3449
```
3550

36-
5) Refresh your repo by running `sh run.sh make update_repo` - this should create a new file in src/ontology/components.
37-
6) In your custom makefile (src/ontology/cto.Makefile) add a goal for your custom make file. In this example, the goal is a ROBOT template.
51+
and for the case where the component is to be fetched from a remote resource:
3852

3953
```
40-
$(COMPONENTSDIR)/your-component-name.owl: $(SRC) ../templates/your-component-template.tsv
41-
$(ROBOT) template --template ../templates/your-component-template.tsv \
42-
annotate --ontology-iri $(ONTBASE)/$@ --output $(COMPONENTSDIR)/your-component-name.owl
54+
components:
55+
products:
56+
- filename: your-component-name.owl
57+
source: https://example.org/component-source.owl
4358
```
4459

45-
(If using a ROBOT template, do not forget to add your template tsv in src/templates/)
46-
47-
7) Make the file by running `sh run.sh make components/your-component-name.owl`
48-

mkdocs.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,6 @@ extra_javascript:
3535
# - optionalConfig.js
3636
- https://cdn.jsdelivr.net/npm/mermaid@11.12.0/dist/mermaid.min.js
3737
- extra-loader.js
38+
39+
plugins:
40+
- d2

0 commit comments

Comments
 (0)