|
| 1 | +import os |
| 2 | + |
| 3 | +from osw.auth import CredentialManager |
| 4 | +from osw.core import model |
| 5 | +from osw.express import OswExpress |
| 6 | +from osw.ontology import ImportConfig, OntologyImporter, ParserSettings |
| 7 | + |
| 8 | +# Use credentials from file. if none are found, the user will be prompted to enter them |
| 9 | +cm = CredentialManager( |
| 10 | + cred_filepath=os.path.join( |
| 11 | + os.path.dirname(os.path.abspath(__file__)), "accounts.pwd.yaml" |
| 12 | + ) |
| 13 | +) |
| 14 | +# Create the OSW object |
| 15 | +# Set a local password in you user settings when using SSO login (e.g. ORCID) |
| 16 | +osw_obj = OswExpress(domain="demo.open-semantic-lab.org", cred_mngr=cm) |
| 17 | +# Load the required schemas / data classes |
| 18 | +DEPENDENCIES = { |
| 19 | + # "OwlClass": "Category:OSW725a3cf5458f4daea86615fcbd0029f8", |
| 20 | + "OwlIndividual": "Category:OSW6b9ef2784a934b8ab96523366e23e906", |
| 21 | + "OwlOntology": "Category:OSW662db0a2ad0946148422245f84e82f64", |
| 22 | + "EmmoClass": "Category:OSW57beed5e1294434ba77bb6516e461456", |
| 23 | + "Item": "Category:Item", |
| 24 | + "ObjectProperty": "Category:ObjectProperty", |
| 25 | + "DataProperty": "Category:DataProperty", |
| 26 | + "AnnotationProperty": "Category:AnnotationProperty", |
| 27 | +} |
| 28 | +osw_obj.install_dependencies(DEPENDENCIES, mode="append") # , policy="if-missing") |
| 29 | + |
| 30 | +ontology_name = "MWO" |
| 31 | + |
| 32 | +# Define ontology metadata |
| 33 | +mwo = model.OwlOntology( |
| 34 | + name="MWO", |
| 35 | + label=[model.Label(text="MWO", lang="en")], |
| 36 | + iri="http://purls.helmholtz-metadaten.de/mwo", |
| 37 | + prefix="http://purls.helmholtz-metadaten.de/mwo/", |
| 38 | + prefix_name="mwo", |
| 39 | + see_also=["https://ise-fizkarlsruhe.github.io/mwo"], |
| 40 | +) |
| 41 | +pmdco = model.OwlOntology( |
| 42 | + name="PMDco", |
| 43 | + label=[model.Label(text="PMDco", lang="en")], |
| 44 | + iri="https://w3id.org/pmd/co", |
| 45 | + prefix="https://w3id.org/pmd/co/", |
| 46 | + prefix_name="pmdco", |
| 47 | + see_also=["https://w3id.org/pmd/co"], |
| 48 | +) |
| 49 | +nfdi = model.OwlOntology( |
| 50 | + name="NFDI", |
| 51 | + label=[model.Label(text="NFDI Ontology", lang="en")], |
| 52 | + iri="https://nfdi.fiz-karlsruhe.de/ontology", |
| 53 | + prefix="https://nfdi.fiz-karlsruhe.de/ontology/", |
| 54 | + prefix_name="nfdicore", |
| 55 | + see_also=["https://nfdi.fiz-karlsruhe.de/ontology"], |
| 56 | +) |
| 57 | +owl = model.OwlOntology( |
| 58 | + name="OWL", |
| 59 | + label=[model.Label(text="Web Ontology Language", lang="en")], |
| 60 | + iri="http://www.w3.org/2002/07/owl", |
| 61 | + prefix="http://www.w3.org/2002/07/owl#", |
| 62 | + prefix_name="owl", |
| 63 | + see_also=["http://www.w3.org/2002/07/owl"], |
| 64 | +) |
| 65 | +schema = model.OwlOntology( |
| 66 | + name="Schema.org", |
| 67 | + label=[model.Label(text="Schema.org", lang="en")], |
| 68 | + iri="http://schema.org/", |
| 69 | + prefix="http://schema.org/", |
| 70 | + prefix_name="schema", |
| 71 | + see_also=["http://schema.org/"], |
| 72 | +) |
| 73 | +skos = model.OwlOntology( |
| 74 | + name="SKOS", |
| 75 | + label=[model.Label(text="Simple Knowledge Organization System", lang="en")], |
| 76 | + iri="http://www.w3.org/2004/02/skos/core", |
| 77 | + prefix="http://www.w3.org/2004/02/skos/core#", |
| 78 | + prefix_name="skos", |
| 79 | + see_also=["http://www.w3.org/2004/02/skos/core"], |
| 80 | +) |
| 81 | +foaf = model.OwlOntology( |
| 82 | + name="FOAF", |
| 83 | + label=[model.Label(text="Friend of a Friend", lang="en")], |
| 84 | + iri="http://xmlns.com/foaf/0.1/", |
| 85 | + prefix="http://xmlns.com/foaf/0.1/", |
| 86 | + prefix_name="foaf", |
| 87 | + see_also=["http://xmlns.com/foaf/0.1/"], |
| 88 | +) |
| 89 | +dc = model.OwlOntology( |
| 90 | + name="DC", |
| 91 | + label=[model.Label(text="Dublin Core", lang="en")], |
| 92 | + iri="http://purl.org/dc/elements/1.1", |
| 93 | + prefix="http://purl.org/dc/elements/1.1/", |
| 94 | + prefix_name="dc", |
| 95 | + see_also=["http://purl.org/dc"], |
| 96 | +) |
| 97 | +bibo = model.OwlOntology( |
| 98 | + name="BIBO", |
| 99 | + label=[model.Label(text="The Bibliographic Ontology", lang="en")], |
| 100 | + iri="http://purl.org/ontology/bibo/", |
| 101 | + prefix="http://purl.org/ontology/bibo/", |
| 102 | + prefix_name="bibo", |
| 103 | + see_also=["http://purl.org/ontology/bibo/"], |
| 104 | +) |
| 105 | +vann = model.OwlOntology( |
| 106 | + name="VANN", |
| 107 | + label=[model.Label(text="Vocabulary Annotation", lang="en")], |
| 108 | + iri="http://purl.org/vocab/vann/", |
| 109 | + prefix="http://purl.org/vocab/vann/", |
| 110 | + prefix_name="vann", |
| 111 | + see_also=["http://purl.org/vocab/vann/"], |
| 112 | +) |
| 113 | +adms = model.OwlOntology( |
| 114 | + name="ADMS", |
| 115 | + label=[model.Label(text="ADMS Ontology", lang="en")], |
| 116 | + iri="http://www.w3.org/ns/adms", |
| 117 | + prefix="http://www.w3.org/ns/adms#", |
| 118 | + prefix_name="adms", |
| 119 | + see_also=["http://www.w3.org/ns/adms#"], |
| 120 | +) |
| 121 | +dcat = model.OwlOntology( |
| 122 | + name="DCAT", |
| 123 | + label=[model.Label(text="Data Catalog Vocabulary", lang="en")], |
| 124 | + iri="http://www.w3.org/ns/dcat", |
| 125 | + prefix="http://www.w3.org/ns/dcat#", |
| 126 | + prefix_name="dcat", |
| 127 | + see_also=["http://www.w3.org/ns/dcat#"], |
| 128 | +) |
| 129 | +dcterms = model.OwlOntology( |
| 130 | + name="DCTerms", |
| 131 | + label=[model.Label(text="Dublin Core Terms", lang="en")], |
| 132 | + iri="http://purl.org/dc/terms", |
| 133 | + prefix="http://purl.org/dc/terms/", |
| 134 | + prefix_name="dct", |
| 135 | + see_also=["http://purl.org/dc/terms"], |
| 136 | +) |
| 137 | +doap = model.OwlOntology( |
| 138 | + name="DOAP", |
| 139 | + label=[model.Label(text="Description of a Project", lang="en")], |
| 140 | + iri="http://usefulinc.com/ns/doap", |
| 141 | + prefix="http://usefulinc.com/ns/doap#", |
| 142 | + prefix_name="doap", |
| 143 | + see_also=["http://usefulinc.com/ns/doap"], |
| 144 | +) |
| 145 | +edam = model.OwlOntology( |
| 146 | + name="EDAM", |
| 147 | + label=[model.Label(text="EDAM Ontology", lang="en")], |
| 148 | + iri="http://edamontology.org", |
| 149 | + prefix="http://edamontology.org/", |
| 150 | + prefix_name="edam", |
| 151 | + see_also=["http://edamontology.org"], |
| 152 | +) |
| 153 | +edam_obo = model.OwlOntology( |
| 154 | + name="EDAM-OBO", |
| 155 | + label=[model.Label(text="EDAM Ontology (OBO)", lang="en")], |
| 156 | + iri="http://purl.obolibrary.org/obo/edam", |
| 157 | + prefix="http://purl.obolibrary.org/obo/edam#", |
| 158 | + prefix_name="edamobo", |
| 159 | + see_also=["http://edamontology.org"], |
| 160 | +) |
| 161 | +bfo = model.OwlOntology( |
| 162 | + name="BFO", |
| 163 | + label=[model.Label(text="Basic Formal Ontology", lang="en")], |
| 164 | + iri="http://purl.obolibrary.org/obo/", |
| 165 | + prefix="http://purl.obolibrary.org/obo/BFO_", |
| 166 | + prefix_name="bfo", |
| 167 | + see_also=["http://purl.obolibrary.org/obo/bfo"], |
| 168 | +) |
| 169 | +iao = model.OwlOntology( |
| 170 | + name="IAO", |
| 171 | + label=[model.Label(text="Information Artifact Ontology", lang="en")], |
| 172 | + iri="http://purl.obolibrary.org/obo/", |
| 173 | + prefix="http://purl.obolibrary.org/obo/IAO_", |
| 174 | + prefix_name="iao", |
| 175 | + see_also=["http://purl.obolibrary.org/obo/iao"], |
| 176 | +) |
| 177 | +omo = model.OwlOntology( |
| 178 | + name="OMO", |
| 179 | + label=[model.Label(text="Ontology for Media Objects", lang="en")], |
| 180 | + iri="http://purl.obolibrary.org/obo/", |
| 181 | + prefix="http://purl.obolibrary.org/obo/OMO_", |
| 182 | + prefix_name="omo", |
| 183 | + see_also=["http://purl.obolibrary.org/obo/omo"], |
| 184 | +) |
| 185 | +swo = model.OwlOntology( |
| 186 | + name="SWO", |
| 187 | + label=[model.Label(text="Software Ontology", lang="en")], |
| 188 | + iri="http://ebi.ac.uk/swo", |
| 189 | + prefix="http://ebi.ac.uk/swo/", |
| 190 | + prefix_name="swo", |
| 191 | + see_also=["http://ebi.ac.uk/swo/"], |
| 192 | +) |
| 193 | +obo_in_owl = model.OwlOntology( |
| 194 | + name="OBOInOWL", |
| 195 | + label=[model.Label(text="OBO In OWL", lang="en")], |
| 196 | + iri="http://www.geneontology.org/formats/oboInOwl", |
| 197 | + prefix="http://www.geneontology.org/formats/oboInOwl#", |
| 198 | + prefix_name="obo_in_owl", |
| 199 | + see_also=["http://www.geneontology.org/formats/oboInOwl"], |
| 200 | +) |
| 201 | +rdfs = model.OwlOntology( |
| 202 | + name="RDFS", |
| 203 | + label=[model.Label(text="RDF Schema", lang="en")], |
| 204 | + iri="http://www.w3.org/2000/01/rdf-schema", |
| 205 | + prefix="http://www.w3.org/2000/01/rdf-schema#", |
| 206 | + prefix_name="rdfs", |
| 207 | + see_also=["http://www.w3.org/2000/01/rdf-schema"], |
| 208 | +) |
| 209 | + |
| 210 | +import_config = ImportConfig( |
| 211 | + ontology_name=ontology_name, |
| 212 | + ontologies=[ |
| 213 | + mwo, |
| 214 | + pmdco, |
| 215 | + nfdi, |
| 216 | + owl, |
| 217 | + schema, |
| 218 | + skos, |
| 219 | + foaf, |
| 220 | + dc, |
| 221 | + bibo, |
| 222 | + vann, |
| 223 | + adms, |
| 224 | + dcat, |
| 225 | + dcterms, |
| 226 | + doap, |
| 227 | + edam, |
| 228 | + edam_obo, |
| 229 | + bfo, |
| 230 | + obo_in_owl, |
| 231 | + rdfs, |
| 232 | + iao, |
| 233 | + omo, |
| 234 | + swo, |
| 235 | + ], |
| 236 | + file="https://raw.githubusercontent.com/ISE-FIZKarlsruhe/mwo/refs/heads/main/mwo.ttl", |
| 237 | + base_class=model.OwlClass, |
| 238 | + base_class_title="Category:OSW725a3cf5458f4daea86615fcbd0029f8", # OwlClass |
| 239 | + dump_files=True, |
| 240 | + dump_path=os.path.dirname(os.path.abspath(__file__)), |
| 241 | + dry_run=False, |
| 242 | + change_id="84b563ec-4fd4-41da-8038-9cc4891fde85", |
| 243 | +) |
| 244 | +parser_settings = ParserSettings() |
| 245 | +parser_settings.ensure_array.append("elucidation") |
| 246 | +parser_settings.ensure_multilang.append("elucidation") |
| 247 | + |
| 248 | +# Import ontologies |
| 249 | +importer = OntologyImporter(osw=osw_obj, parser_settings=parser_settings) |
| 250 | +prefix_dict = importer.import_ontology(import_config) |
0 commit comments