Skip to content

Commit

Permalink
SHACL testing (#13)
Browse files Browse the repository at this point in the history
* Basic setup for testing SHACL.
* Basic SHACL test.
* Explicitly typed every Node as obo:CDAO_0000140.
* Command line options to check for version number and help.
* Python script that invokes Java program for testing.
* Install Java 8 and use Maven in Travis for CI testing
* For now, need to compile uber-JAR locally, then upload it for testing. See #14.
  • Loading branch information
gaurav authored and hlapp committed Nov 22, 2016
1 parent f9d6148 commit 5349dc7
Show file tree
Hide file tree
Showing 15 changed files with 3,259 additions and 8 deletions.
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# Mac files
.DS_Store

# IDE files
.project

# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
Expand Down
22 changes: 14 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
# Our primary language is Python.
language: python
python:
- "2.7"
# command to install dependencies
#
# unfortunately needs to be custom because updating setuptools from within
# requirements.txt fails to be seen by the html5lib installation, and the
# version pre-installed on Travis is too low.

# We need Java 8 for SHACL testing.
addons:
apt:
packages:
- oracle-java8-set-default

# Install pip requirements.
install:
- "pip install -U setuptools"
- "pip install -r requirements.txt"
# command to run tests
- pip install --upgrade pip
- pip install -r requirements.txt
- pip install pytest

# Run the py.test suite.
script: py.test tests
17 changes: 17 additions & 0 deletions examples/trees/pg_2357.owl
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@

<owl:Thing rdf:about="&pg_2357;Node_1">
<rdf:type rdf:resource="&owl;NamedIndividual"/>
<rdf:type rdf:resource="&obo;CDAO_0000140" />
<obo:CDAO_0000149 rdf:resource="&pg_2357;Node_2"/>
<obo:CDAO_0000149 rdf:resource="&pg_2357;Alobevania_gattiae"/>
<obo:CDAO_0000149 rdf:resource="&pg_2357;Decevania_reticulata"/>
Expand All @@ -71,6 +72,7 @@

<owl:Thing rdf:about="&pg_2357;Node_2">
<rdf:type rdf:resource="&owl;NamedIndividual"/>
<rdf:type rdf:resource="&obo;CDAO_0000140" />
<obo:CDAO_0000149 rdf:resource="&pg_2357;Node_3"/>
<obo:CDAO_0000149 rdf:resource="&pg_2357;Rothevania_valdivianus"/>
<obo:CDAO_0000149 rdf:resource="&pg_2357;Hyptia_thoracica"/>
Expand All @@ -82,6 +84,7 @@

<owl:Thing rdf:about="&pg_2357;Node_3">
<rdf:type rdf:resource="&owl;NamedIndividual"/>
<rdf:type rdf:resource="&obo;CDAO_0000140" />
<obo:CDAO_0000149 rdf:resource="&pg_2357;Node_4"/>
<obo:CDAO_0000149 rdf:resource="&pg_2357;Node_7"/>
<phyloref:has_Sibling rdf:resource="&pg_2357;Rothevania_valdivianus"/>
Expand All @@ -92,6 +95,7 @@

<owl:Thing rdf:about="&pg_2357;Node_4">
<rdf:type rdf:resource="&owl;NamedIndividual"/>
<rdf:type rdf:resource="&obo;CDAO_0000140" />
<obo:CDAO_0000149 rdf:resource="&pg_2357;Node_5"/>
<obo:CDAO_0000149 rdf:resource="&pg_2357;Evaniscus_lansdownei"/>
<phyloref:has_Sibling rdf:resource="&pg_2357;Node_7"/>
Expand All @@ -101,6 +105,7 @@

<owl:Thing rdf:about="&pg_2357;Node_5">
<rdf:type rdf:resource="&owl;NamedIndividual"/>
<rdf:type rdf:resource="&obo;CDAO_0000140" />
<obo:CDAO_0000149 rdf:resource="&pg_2357;Node_6"/>
<obo:CDAO_0000149 rdf:resource="&pg_2357;Evaniscus_marginatus"/>
<phyloref:has_Sibling rdf:resource="&pg_2357;Evaniscus_lansdownei"/>
Expand All @@ -110,6 +115,7 @@

<owl:Thing rdf:about="&pg_2357;Node_6">
<rdf:type rdf:resource="&owl;NamedIndividual"/>
<rdf:type rdf:resource="&obo;CDAO_0000140" />
<obo:CDAO_0000149 rdf:resource="&pg_2357;Evaniscus_rufithorax"/>
<obo:CDAO_0000149 rdf:resource="&pg_2357;Evaniscus_sulcigenis"/>
<phyloref:has_Sibling rdf:resource="&pg_2357;Evaniscus_marginatus"/>
Expand All @@ -119,34 +125,39 @@

<owl:Thing rdf:about="&pg_2357;Evaniscus_rufithorax">
<rdf:type rdf:resource="&owl;NamedIndividual"/>
<rdf:type rdf:resource="&obo;CDAO_0000140" />
<phyloref:has_Sibling rdf:resource="&pg_2357;Evaniscus_sulcigenis"/>
</owl:Thing>

<!-- http://phyloinformatics.net/phylo/pg_2357#Evaniscus_sulcigenis -->

<owl:Thing rdf:about="&pg_2357;Evaniscus_sulcigenis">
<rdf:type rdf:resource="&owl;NamedIndividual"/>
<rdf:type rdf:resource="&obo;CDAO_0000140" />
<phyloref:has_Sibling rdf:resource="&pg_2357;Evaniscus_rufithorax"/>
</owl:Thing>

<!-- http://phyloinformatics.net/phylo/pg_2357#Evaniscus_marginatus -->

<owl:Thing rdf:about="&pg_2357;Evaniscus_marginatus">
<rdf:type rdf:resource="&owl;NamedIndividual"/>
<rdf:type rdf:resource="&obo;CDAO_0000140" />
<phyloref:has_Sibling rdf:resource="&pg_2357;Node_6"/>
</owl:Thing>

<!-- http://phyloinformatics.net/phylo/pg_2357#Evaniscus_lansdownei -->

<owl:Thing rdf:about="&pg_2357;Evaniscus_lansdownei">
<rdf:type rdf:resource="&owl;NamedIndividual"/>
<rdf:type rdf:resource="&obo;CDAO_0000140" />
<phyloref:has_Sibling rdf:resource="&pg_2357;Node_5"/>
</owl:Thing>

<!-- http://phyloinformatics.net/phylo/pg_2357#Node_7 -->

<owl:Thing rdf:about="&pg_2357;Node_7">
<rdf:type rdf:resource="&owl;NamedIndividual"/>
<rdf:type rdf:resource="&obo;CDAO_0000140" />
<obo:CDAO_0000149 rdf:resource="&pg_2357;Evaniscus_tibialis"/>
<obo:CDAO_0000149 rdf:resource="&pg_2357;Evaniscus_rafaeli"/>
<phyloref:has_Sibling rdf:resource="&pg_2357;Node_4"/>
Expand All @@ -156,20 +167,23 @@

<owl:Thing rdf:about="&pg_2357;Evaniscus_tibialis">
<rdf:type rdf:resource="&owl;NamedIndividual"/>
<rdf:type rdf:resource="&obo;CDAO_0000140" />
<phyloref:has_Sibling rdf:resource="&pg_2357;Evaniscus_rafaeli"/>
</owl:Thing>

<!-- http://phyloinformatics.net/phylo/pg_2357#Evaniscus_rafaeli -->

<owl:Thing rdf:about="&pg_2357;Evaniscus_rafaeli">
<rdf:type rdf:resource="&owl;NamedIndividual"/>
<rdf:type rdf:resource="&obo;CDAO_0000140" />
<phyloref:has_Sibling rdf:resource="&pg_2357;Evaniscus_tibialis"/>
</owl:Thing>

<!-- http://phyloinformatics.net/phylo/pg_2357#Rothevania_valdivianus -->

<owl:Thing rdf:about="&pg_2357;Rothevania_valdivianus">
<rdf:type rdf:resource="&owl;NamedIndividual"/>
<rdf:type rdf:resource="&obo;CDAO_0000140" />
<phyloref:has_Sibling rdf:resource="&pg_2357;Node_3"/>
<phyloref:has_Sibling rdf:resource="&pg_2357;Hyptia_thoracica"/>
</owl:Thing>
Expand All @@ -178,6 +192,7 @@

<owl:Thing rdf:about="&pg_2357;Hyptia_thoracica">
<rdf:type rdf:resource="&owl;NamedIndividual"/>
<rdf:type rdf:resource="&obo;CDAO_0000140" />
<phyloref:has_Sibling rdf:resource="&pg_2357;Node_3"/>
<phyloref:has_Sibling rdf:resource="&pg_2357;Rothevania_valdivianus"/>
</owl:Thing>
Expand All @@ -186,6 +201,7 @@

<owl:Thing rdf:about="&pg_2357;Alobevania_gattiae">
<rdf:type rdf:resource="&owl;NamedIndividual"/>
<rdf:type rdf:resource="&obo;CDAO_0000140" />
<phyloref:has_Sibling rdf:resource="&pg_2357;Node_2"/>
<phyloref:has_Sibling rdf:resource="&pg_2357;Decevania_reticulata"/>
</owl:Thing>
Expand All @@ -194,6 +210,7 @@

<owl:Thing rdf:about="&pg_2357;Decevania_reticulata">
<rdf:type rdf:resource="&owl;NamedIndividual"/>
<rdf:type rdf:resource="&obo;CDAO_0000140" />
<phyloref:has_Sibling rdf:resource="&pg_2357;Node_2"/>
<phyloref:has_Sibling rdf:resource="&pg_2357;Alobevania_gattiae"/>
</owl:Thing>
Expand Down
1 change: 1 addition & 0 deletions templates/individual.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

<owl:Thing rdf:about="&{{name}};{{term}}">
<rdf:type rdf:resource="&owl;NamedIndividual"/>
<rdf:type rdf:resource="&obo;CDAO_0000140" />
{{#children}}
<obo:CDAO_0000149 rdf:resource="&{{name}};{{child}}"/>
{{/children}}
Expand Down
37 changes: 37 additions & 0 deletions tests/ValidationShapes.ttl
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
@prefix ex: <http://phyloref.org/example/test_shacl.ttl#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix sh: <http://www.w3.org/ns/shacl#> .
@prefix obo: <http://purl.obolibrary.org/obo/> .
@prefix phyloref: <http://phyloinformatics.net/phyloref.owl#> .
@prefix dash: <http://datashapes.org/dash#> .
@prefix rdf: <http://www.w3.org/2002/07/owl#> .

#
# ex:Node
# A node in a phylogeny.
#

ex:Node a sh:Shape;
# Matches all nodes.
sh:targetClass obo:CDAO_0000140;

# Every node must either have:
sh:or (
[
# 1. A CDAO:hasChild relationship with another node.
sh:property [
sh:predicate obo:CDAO_0000149;
sh:class obo:CDAO_0000140;
sh:minCount 1;
];
]
[
# 2. A phyloref:has_Sibling relationship with another node.
sh:property [
sh:predicate phyloref:has_Sibling;
sh:class obo:CDAO_0000140;
sh:minCount 1;
];
]
);
.
Loading

0 comments on commit 5349dc7

Please sign in to comment.