Skip to content

Commit

Permalink
update metadata
Browse files Browse the repository at this point in the history
improve metadata to comply with FOOPS recommendations
  • Loading branch information
jsimonclark committed Jun 23, 2024
1 parent 5aee817 commit f1075b9
Show file tree
Hide file tree
Showing 5 changed files with 306 additions and 198 deletions.
14 changes: 9 additions & 5 deletions .github/workflows/doc.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: "Sphinx: Render docs"
name: "docs"

on:
push:
Expand Down Expand Up @@ -89,9 +89,11 @@ jobs:
git fetch --tags
git tag | while read TAG; do
sudo mkdir -p "docs/_build/html/versions/$TAG"
sudo cp "electrochemistry.ttl" "docs/_build/html/versions/$TAG/"
python convert_ttl.py electrochemistry.ttl electrochemistry-foops.ttl
python convert_ttl.py electrochemicalquantities.ttl electrochemicalquantities-foops.ttl
sudo cp "electrochemistry-foops.ttl" "docs/_build/html/versions/$TAG/electrochemistry.ttl"
sudo cp "electrochemicalquantities-foops.ttl" "docs/_build/html/versions/$TAG/electrochemicalquantities.ttl"
sudo cp "electrochemistry-inferred.ttl" "docs/_build/html/versions/$TAG/"
sudo cp "electrochemicalquantities.ttl" "docs/_build/html/versions/$TAG/"
if [ -d "context" ]; then
echo "Context directory exists, copying context.json to $TAG"
Expand All @@ -106,8 +108,10 @@ jobs:
- name: Copy TTL files to HTML directory
run: |
sudo cp "electrochemistry.ttl" "docs/_build/html/electrochemistry.ttl"
sudo cp "electrochemicalquantities.ttl" "docs/_build/html/electrochemicalquantities.ttl"
python convert_ttl.py electrochemistry.ttl electrochemistry-foops.ttl
python convert_ttl.py electrochemicalquantities.ttl electrochemicalquantities-foops.ttl
sudo cp "electrochemistry-foops.ttl" "docs/_build/html/electrochemistry.ttl"
sudo cp "electrochemicalquantities-foops.ttl" "docs/_build/html/electrochemicalquantities.ttl"
sudo cp "electrochemistry-inferred.ttl" "docs/_build/html/electrochemistry-inferred.ttl"
- name: Upload artifacts
Expand Down
34 changes: 34 additions & 0 deletions docs/assets/img/fig/src/domain-electrochemistry-logo.drawio
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<mxfile host="65bd71144e">
<diagram id="NrZ29duDLyXxqPhjrZT9" name="Page-1">
<mxGraphModel dx="799" dy="469" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="850" pageHeight="1100" math="0" shadow="0">
<root>
<mxCell id="0"/>
<mxCell id="1" parent="0"/>
<mxCell id="2" value="&lt;font style=&quot;font-size: 104px;&quot;&gt;ECHO&lt;/font&gt;" style="text;strokeColor=none;fillColor=none;html=1;fontSize=24;fontStyle=1;verticalAlign=middle;align=center;" vertex="1" parent="1">
<mxGeometry x="335" y="40" width="350" height="120" as="geometry"/>
</mxCell>
<mxCell id="3" value="&lt;span style=&quot;font-weight: normal;&quot;&gt;Electrochemistry Domain Ontology&lt;/span&gt;" style="text;strokeColor=none;fillColor=none;html=1;fontSize=24;fontStyle=1;verticalAlign=middle;align=center;" vertex="1" parent="1">
<mxGeometry x="320" y="160" width="380" height="40" as="geometry"/>
</mxCell>
<mxCell id="12" value="" style="group" vertex="1" connectable="0" parent="1">
<mxGeometry x="140" y="40" width="181.1" height="161.88" as="geometry"/>
</mxCell>
<mxCell id="8" value="" style="ellipse;whiteSpace=wrap;html=1;fontSize=104;fillColor=none;rotation=30;shadow=1;strokeWidth=4;strokeColor=#028cae;" vertex="1" parent="12">
<mxGeometry x="9.616304589462196" y="36.42974499999999" width="161.86739082107562" height="81.84383" as="geometry"/>
</mxCell>
<mxCell id="10" value="" style="ellipse;whiteSpace=wrap;html=1;fontSize=104;fillColor=none;rotation=-210;shadow=1;strokeWidth=4;strokeColor=#028cae;" vertex="1" parent="12">
<mxGeometry x="9.616304589462196" y="36.42974499999999" width="161.86739082107562" height="81.84383" as="geometry"/>
</mxCell>
<mxCell id="11" value="" style="ellipse;whiteSpace=wrap;html=1;fontSize=104;fillColor=none;rotation=90;shadow=1;strokeWidth=4;strokeColor=#028cae;" vertex="1" parent="12">
<mxGeometry x="9.616304589462196" y="40.018084999999985" width="161.86739082107562" height="81.84383" as="geometry"/>
</mxCell>
<mxCell id="5" value="" style="ellipse;whiteSpace=wrap;html=1;aspect=fixed;fontSize=104;fillColor=#005CA2;strokeWidth=4;strokeColor=#e4c89e;" vertex="1" parent="12">
<mxGeometry x="50.0831522947311" y="36.42974499999999" width="80.93369541053781" height="80.93369541053781" as="geometry"/>
</mxCell>
<mxCell id="6" value="" style="verticalLabelPosition=bottom;verticalAlign=top;html=1;shape=mxgraph.basic.polygon;polyCoords=[[0.62,0.32],[0.57,0.43],[0.62,0.43],[0.46,0.65],[0.46,0.65],[0.51,0.48],[0.46,0.48],[0.51,0.32]];polyline=0;fontSize=104;fillColor=#E4C89E;" vertex="1" parent="12">
<mxGeometry x="7.59296220419875" y="3.3792449999999934" width="155.1229162035308" height="155.135" as="geometry"/>
</mxCell>
</root>
</mxGraphModel>
</diagram>
</mxfile>
1 change: 1 addition & 0 deletions docs/assets/img/fig/svg/domain-electrochemistry-logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
64 changes: 64 additions & 0 deletions docs/scripts/apply_foops_recommendations.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
from rdflib import Graph, Namespace, Literal
from rdflib.namespace import RDF, RDFS, SKOS
import sys

def add_foops_recommendations(input_file, output_file):
"""
Reads an ontology from a TTL file, adds extra relationships to comply with FOOPS recommendations,
and writes the updated ontology to a new TTL file.
Args:
input_file (str): Path to the input TTL file.
output_file (str): Path to the output TTL file where updated ontology will be saved.
"""
# Define the EMMO namespace
EMMO = Namespace("https://w3id.org/emmo#")

# Read the original TTL file content with UTF-8 encoding
with open(input_file, 'r', encoding='utf-8') as file:
ttl_content = file.read()

# Load the TTL content into an RDFLib graph
graph = Graph()
graph.parse(data=ttl_content, format='turtle')

# Prepare to collect new triples as a list
new_triples = []

# Duplicate skos:prefLabel triples as rdfs:label triples
for subj, pred, obj in graph.triples((None, SKOS.prefLabel, None)):
if isinstance(obj, Literal):
new_triples.append((subj, RDFS.label, obj))

# Duplicate EMMO-specific annotation triples as rdfs:comment triples
for subj, pred, obj in graph.triples((None, EMMO.EMMO_967080e5_2f42_4eb2_a3a9_c58143e835f9, None)):
if isinstance(obj, Literal):
new_triples.append((subj, RDFS.comment, obj))

# Add new triples to the graph
for triple in new_triples:
graph.add(triple)

# Serialize the graph to the output file with UTF-8 encoding
graph.serialize(destination=output_file, format='turtle')

def main():
"""
Main function to handle command-line arguments and invoke the FOOPS compliance update.
"""
# Check for command-line arguments
if len(sys.argv) != 3:
print("Usage: python convert_ttl.py <input_file> <output_file>")
sys.exit(1)

# Input and output file paths from command-line arguments
input_file = sys.argv[1]
output_file = sys.argv[2]

# Update the TTL file with FOOPS recommendations
add_foops_recommendations(input_file, output_file)

print(f"Updated TTL file saved as {output_file}")

if __name__ == "__main__":
main()
Loading

0 comments on commit f1075b9

Please sign in to comment.