diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index a9506cd..f8c9ff6 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -77,7 +77,7 @@ jobs: # install your root project, if required #---------------------------------------------- - name: Install library - run: poetry install --no-interaction --extras gilda + run: poetry install --no-interaction #---------------------------------------------- # run test suite @@ -85,22 +85,3 @@ jobs: - name: Run tests run: poetry run python -m unittest discover - #---------------------------------------------- - # coverage report - #---------------------------------------------- - - name: Generate coverage results - run: | - poetry run coverage run -m unittest discover - poetry run coverage xml - poetry run coverage report -m - - #---------------------------------------------- - # upload coverage results - #---------------------------------------------- - - name: Upload coverage report - uses: codecov/codecov-action@v1.0.5 - with: - name: codecov-results-${{ matrix.python-version }} - token: ${{ secrets.CODECOV_TOKEN }} - file: ./coverage.xml - fail_ci_if_error: true diff --git a/Makefile b/Makefile index d00fa27..d5aefcb 100644 --- a/Makefile +++ b/Makefile @@ -13,11 +13,17 @@ PREFIX_DIR = $(BUILDER_DIR)/prefixes ALL_OBO_ONTS := $(shell cat reports/obo.tsv) SELECTED_ONTS = obi mondo go envo ro hp mp zfa wbphenotype ecto upheno uberon_cm doid chebi pr wbphenotype fbbt dron +# EXTRA_ONTOLOGIES is defined in ontologies.Makefile +ALL_ONTS = $(ALL_OBO_ONTS) $(EXTRA_ONTOLOGIES) + +STAGED_ONTOLOGIES = $(patsubst %,stage/%.db.gz,$(ALL_ONTS)) + TEST_ONTOLOGIES = go-nucleus robot-example + all: build_all stage_all -build_all: $(patsubst %,all-%,$(ALL_OBO_ONTS)) -stage_all: $(patsubst %,stage/%.db.gz,$(ALL_OBO_ONTS)) +build_all: $(patsubst %,all-%,$(ALL_ONTS)) +stage_all: $(STAGED_ONTOLOGIES) selected: $(patsubst %,all-%,$(SELECTED_ONTS)) @@ -25,6 +31,14 @@ all-%: db/%.db sqlite3 $< "SELECT COUNT(*) FROM statements" stage/%.db.gz: db/%.db gzip -c $< > $@.tmp && mv $@.tmp $@ +.PRECIOUS: stage/%.db.gz + +list-onts: + echo $(ALL_ONTS) +list-extra: + echo $(EXTRA_ONTOLOGIES) +list-staged: + ls -alt $(STAGED_ONTOLOGIES) # INSTALL include install.Makefile @@ -97,10 +111,6 @@ db/obo-ontologies.owl: reports/obo.tsv: db/obo-ontologies.db sqlite3 $< "SELECT subject FROM ontology_status_statement WHERE value = 'active'" | perl -npe 's@^obo:@@' > $@ -# to test -list-onts: - echo $(ALL_OBO_ONTS) - @@ -119,21 +129,6 @@ reports/%.problems.tsv: db/%.db target/%.views STAMP: touch $@ -# download OWL, ensuring converted to RDF/XML -db/%.owl: STAMP - robot merge -I http://purl.obolibrary.org/obo/$*.owl -o $@ -.PRECIOUS: db/%.owl - -db/foodon.owl: STAMP - robot merge -I $(OBO)/foodon.owl relax reduce -c true -o $@ - -db/go.owl: STAMP - curl -L -s http://purl.obolibrary.org/obo/go/extensions/go-plus.owl > $@ - -db/monarch.owl: - robot merge -I http://purl.obolibrary.org/obo/upheno/monarch.owl -o $@ - - db/reactome-Homo-sapiens.owl: download/reactome-biopax.zip db/biopax.owl unzip -p $< Homo_sapiens.owl > $@.tmp &&\ robot merge -i $@.tmp -i db/biopax.owl -o $@ diff --git a/install.Makefile b/install.Makefile index e06a17e..d3bb04d 100644 --- a/install.Makefile +++ b/install.Makefile @@ -17,7 +17,7 @@ bin/rdftab: curl -L -o $@ $(RDFTAB_URL) chmod +x $@ -RG_VERSION=2.2.0 +RG_VERSION=2.3.0 bin/relation-graph: curl -L -s https://github.com/balhoff/relation-graph/releases/download/v$(RG_VERSION)/relation-graph-cli-$(RG_VERSION).tgz | tar -zxv && mv relation-graph-cli-$(RG_VERSION) relation-graph && (cd bin && ln -s ../relation-graph/bin/relation-graph) diff --git a/ontologies.Makefile b/ontologies.Makefile index 07b793f..ce1f9cd 100644 --- a/ontologies.Makefile +++ b/ontologies.Makefile @@ -1,58 +1,319 @@ -db/msio.owl: STAMP - curl -L -s https://raw.githubusercontent.com/MSI-Metabolomics-Standards-Initiative/MSIO/master/releases/latest_release/MSIO-merged-reasoned.owl > $@.tmp && mv $@.tmp $@ +download/chiro.owl: STAMP + curl -L -s http://purl.obolibrary.org/obo/chiro.owl > $@.tmp + sha256sum -b $@.tmp > $@.sha256 + mv $@.tmp $@ -db/phenio.owl: STAMP - curl -L -s https://github.com/monarch-initiative/phenio/releases/latest/download/phenio.owl > $@.tmp && mv $@.tmp $@ +.PRECIOUS: download/chiro.owl -db/bero.owl: STAMP - curl -L -s https://github.com/berkeleybop/bero/releases/download/2022-05-26/bero.owl > $@.tmp && mv $@.tmp $@ +db/chiro.owl: download/chiro.owl + robot relax -i $< merge -o $@ -db/aio.owl: STAMP - curl -L -s https://raw.githubusercontent.com/berkeleybop/artificial-intelligence-ontology/main/aio.owl > $@.tmp && mv $@.tmp $@ -db/reacto.owl: STAMP - curl -L -s http://purl.obolibrary.org/obo/go/extensions/reacto.owl > $@.tmp && mv $@.tmp $@ +download/ncit.owl: STAMP + curl -L -s http://purl.obolibrary.org/obo/ncit.owl > $@.tmp + sha256sum -b $@.tmp > $@.sha256 + mv $@.tmp $@ -db/go-lego.owl: STAMP - curl -L -s http://purl.obolibrary.org/obo/go/extensions/go-lego.owl > $@.tmp && mv $@.tmp $@ +.PRECIOUS: download/ncit.owl -db/bao.owl: STAMP - robot merge -I http://www.bioassayontology.org/bao/bao_complete.owl -o $@ +db/ncit.owl: download/ncit.owl + robot relax -i $< merge -o $@ -db/biolink.owl: STAMP - robot merge -I https://w3id.org/biolink/biolink-model.owl.ttl -o $@ -db/biopax.owl: STAMP - curl -L -s http://www.biopax.org/release/biopax-level3.owl > $@.tmp && mv $@.tmp $@ +download/foodon.owl: STAMP + curl -L -s http://purl.obolibrary.org/obo/foodon.owl > $@.tmp + sha256sum -b $@.tmp > $@.sha256 + mv $@.tmp $@ -db/enanomapper.owl: STAMP - robot merge -I http://enanomapper.github.io/ontologies/enanomapper.owl -o $@ +.PRECIOUS: download/foodon.owl -db/mlo.owl: STAMP - robot merge -I https://raw.githubusercontent.com/berkeleybop/artificial-intelligence-ontology/main/external/ml-ontology-202010021305.owl -o $@ +db/foodon.owl: download/foodon.owl + robot merge -i $< relax reduce -c true -o $@ -db/ito.owl: STAMP - curl -L -s https://github.com/OpenBioLink/ITO/raw/master/ITO.owl.zip > $@.tmp && unzip -p $@.tmp ITO.owl > $@.tmp2 && mv $@.tmp2 $@ && rm $@.tmp -db/efo.owl: STAMP - robot merge -I http://www.ebi.ac.uk/efo/efo.owl -o $@ +download/chebiplus.owl: STAMP + curl -L -s http://purl.obolibrary.org/obo/chebi.owl > $@.tmp + sha256sum -b $@.tmp > $@.sha256 + mv $@.tmp $@ -db/edam.owl: STAMP - curl -L -s http://edamontology.org/EDAM.owl > $@.tmp && mv $@.tmp $@ +.PRECIOUS: download/chebiplus.owl -db/sweetAll.owl: STAMP - robot merge -I http://sweetontology.net/sweetAll -o $@ +db/chebiplus.owl: download/chebiplus.owl + robot merge -i $< -I http://purl.obolibrary.org/obo/chiro.owl relax -o $@ -db/lov.owl: STAMP - robot merge -I https://lov.linkeddata.es/lov.n3.gz -o $@ -db/schema-dot-org.owl: STAMP - curl -L -s https://schema.org/version/latest/schemaorg-current-https.rdf > $@.tmp && mv $@.tmp $@ +download/msio.owl: STAMP + curl -L -s https://raw.githubusercontent.com/MSI-Metabolomics-Standards-Initiative/MSIO/master/releases/latest_release/MSIO-merged-reasoned.owl > $@.tmp + sha256sum -b $@.tmp > $@.sha256 + mv $@.tmp $@ -db/cosmo.owl: STAMP - robot merge -I https://micra.com/COSMO/COSMO.owl -o $@ +.PRECIOUS: download/msio.owl -db/co_324.owl: STAMP - curl -L -s https://cropontology.org/ontology/CO_324/rdf > $@.tmp && mv $@.tmp $@ +db/msio.owl: download/msio.owl + cp $< $@ -EXTRA_ONTOLOGIES = msio phenio bero aio reacto go-lego bao biolink biopax enanomapper mlo ito efo edam sweetAll lov schema-dot-org cosmo co_324 + +download/phenio.owl: STAMP + curl -L -s https://github.com/monarch-initiative/phenio/releases/latest/download/phenio.owl > $@.tmp + sha256sum -b $@.tmp > $@.sha256 + mv $@.tmp $@ + +.PRECIOUS: download/phenio.owl + +db/phenio.owl: download/phenio.owl + cp $< $@ + + +download/comploinc.owl: STAMP + curl -L -s https://github.com/loinc/comp-loinc/releases/download/v2022-11-05/merged_reasoned_loinc.owl > $@.tmp + sha256sum -b $@.tmp > $@.sha256 + mv $@.tmp $@ + +.PRECIOUS: download/comploinc.owl + +db/comploinc.owl: download/comploinc.owl + robot relax -i $< merge -o $@ + + +download/bero.owl: STAMP + curl -L -s https://github.com/berkeleybop/bero/releases/download/2022-05-26/bero.owl > $@.tmp + sha256sum -b $@.tmp > $@.sha256 + mv $@.tmp $@ + +.PRECIOUS: download/bero.owl + +db/bero.owl: download/bero.owl + cp $< $@ + + +download/aio.owl: STAMP + curl -L -s https://raw.githubusercontent.com/berkeleybop/artificial-intelligence-ontology/main/aio.owl > $@.tmp + sha256sum -b $@.tmp > $@.sha256 + mv $@.tmp $@ + +.PRECIOUS: download/aio.owl + +db/aio.owl: download/aio.owl + cp $< $@ + + +download/reacto.owl: STAMP + curl -L -s http://purl.obolibrary.org/obo/go/extensions/reacto.owl > $@.tmp + sha256sum -b $@.tmp > $@.sha256 + mv $@.tmp $@ + +.PRECIOUS: download/reacto.owl + +db/reacto.owl: download/reacto.owl + cp $< $@ + + +download/go.owl: STAMP + curl -L -s http://purl.obolibrary.org/obo/go/extensions/go-plus.owl > $@.tmp + sha256sum -b $@.tmp > $@.sha256 + mv $@.tmp $@ + +.PRECIOUS: download/go.owl + +db/go.owl: download/go.owl + cp $< $@ + + +download/go-lego.owl: STAMP + curl -L -s http://purl.obolibrary.org/obo/go/extensions/go-lego.owl > $@.tmp + sha256sum -b $@.tmp > $@.sha256 + mv $@.tmp $@ + +.PRECIOUS: download/go-lego.owl + +db/go-lego.owl: download/go-lego.owl + cp $< $@ + + +download/bao.owl: STAMP + curl -L -s http://www.bioassayontology.org/bao/bao_complete.owl > $@.tmp + sha256sum -b $@.tmp > $@.sha256 + mv $@.tmp $@ + +.PRECIOUS: download/bao.owl + +db/bao.owl: download/bao.owl + robot merge -i $< -o $@ + + +download/orcid.owl: STAMP + curl -L -s https://raw.githubusercontent.com/cthoyt/wikidata-orcid-ontology/main/orcid.owl > $@.tmp + sha256sum -b $@.tmp > $@.sha256 + mv $@.tmp $@ + +.PRECIOUS: download/orcid.owl + +db/orcid.owl: download/orcid.owl + cp $< $@ + + +download/cpont.owl: STAMP + curl -L -s https://w3id.org/cpont/cpont.owl > $@.tmp + sha256sum -b $@.tmp > $@.sha256 + mv $@.tmp $@ + +.PRECIOUS: download/cpont.owl + +db/cpont.owl: download/cpont.owl + cp $< $@ + + +download/biolink.owl: STAMP + curl -L -s https://w3id.org/biolink/biolink-model.owl.ttl > $@.tmp + sha256sum -b $@.tmp > $@.sha256 + mv $@.tmp $@ + +.PRECIOUS: download/biolink.owl + +db/biolink.owl: download/biolink.owl + robot merge -i $< -o $@ + + +download/biopax.owl: STAMP + curl -L -s http://www.biopax.org/release/biopax-level3.owl > $@.tmp + sha256sum -b $@.tmp > $@.sha256 + mv $@.tmp $@ + +.PRECIOUS: download/biopax.owl + +db/biopax.owl: download/biopax.owl + cp $< $@ + + +download/enanomapper.owl: STAMP + curl -L -s http://enanomapper.github.io/ontologies/enanomapper.owl > $@.tmp + sha256sum -b $@.tmp > $@.sha256 + mv $@.tmp $@ + +.PRECIOUS: download/enanomapper.owl + +db/enanomapper.owl: download/enanomapper.owl + robot merge -i $< -o $@ + + +download/mlo.owl: STAMP + curl -L -s https://raw.githubusercontent.com/berkeleybop/artificial-intelligence-ontology/main/external/ml-ontology-202010021305.owl > $@.tmp + sha256sum -b $@.tmp > $@.sha256 + mv $@.tmp $@ + +.PRECIOUS: download/mlo.owl + +db/mlo.owl: download/mlo.owl + robot merge -i $< -o $@ + + +download/ito.owl: STAMP + curl -L -s https://github.com/OpenBioLink/ITO/raw/master/ITO.owl.zip > $@.zip.tmp && unzip -p $@.zip.tmp ITO.owl > $@.tmp && rm $@.zip.tmp + sha256sum -b $@.tmp > $@.sha256 + mv $@.tmp $@ + +.PRECIOUS: download/ito.owl + +db/ito.owl: download/ito.owl + cp $< $@ + + +download/reactome-Homo-sapiens.owl: STAMP + curl -L -s https://reactome.org/download/current/biopax.zip > $@.zip.tmp && unzip -p $@.zip.tmp Homo_sapiens.owl > $@.tmp && rm $@.zip.tmp + sha256sum -b $@.tmp > $@.sha256 + mv $@.tmp $@ + +.PRECIOUS: download/reactome-Homo-sapiens.owl + +db/reactome-Homo-sapiens.owl: download/reactome-Homo-sapiens.owl + cp $< $@ + + +download/efo.owl: STAMP + curl -L -s http://www.ebi.ac.uk/efo/efo.owl > $@.tmp + sha256sum -b $@.tmp > $@.sha256 + mv $@.tmp $@ + +.PRECIOUS: download/efo.owl + +db/efo.owl: download/efo.owl + robot merge -i $< -o $@ + + +download/edam.owl: STAMP + curl -L -s http://edamontology.org/EDAM.owl > $@.tmp + sha256sum -b $@.tmp > $@.sha256 + mv $@.tmp $@ + +.PRECIOUS: download/edam.owl + +db/edam.owl: download/edam.owl + cp $< $@ + + +download/sweetAll.owl: STAMP + curl -L -s http://sweetontology.net/sweetAll > $@.tmp + sha256sum -b $@.tmp > $@.sha256 + mv $@.tmp $@ + +.PRECIOUS: download/sweetAll.owl + +db/sweetAll.owl: download/sweetAll.owl + robot merge -i $< -o $@ + + +download/lov.owl: STAMP + curl -L -s https://lov.linkeddata.es/lov.n3.gz > $@.tmp + sha256sum -b $@.tmp > $@.sha256 + mv $@.tmp $@ + +.PRECIOUS: download/lov.owl + +db/lov.owl: download/lov.owl + robot merge -i $< -o $@ + + +download/schema-dot-org.owl: STAMP + curl -L -s https://schema.org/version/latest/schemaorg-current-https.rdf > $@.tmp + sha256sum -b $@.tmp > $@.sha256 + mv $@.tmp $@ + +.PRECIOUS: download/schema-dot-org.owl + +db/schema-dot-org.owl: download/schema-dot-org.owl + cp $< $@ + + +download/cosmo.owl: STAMP + curl -L -s https://micra.com/COSMO/COSMO.owl > $@.tmp + sha256sum -b $@.tmp > $@.sha256 + mv $@.tmp $@ + +.PRECIOUS: download/cosmo.owl + +db/cosmo.owl: download/cosmo.owl + robot merge -i $< -o $@ + + +download/co_324.owl: STAMP + curl -L -s https://cropontology.org/ontology/CO_324/rdf > $@.tmp + sha256sum -b $@.tmp > $@.sha256 + mv $@.tmp $@ + +.PRECIOUS: download/co_324.owl + +db/co_324.owl: download/co_324.owl + cp $< $@ + + +download/%.owl: STAMP + curl -L -s http://purl.obolibrary.org/obo/$*.owl > $@.tmp + sha256sum -b $@.tmp > $@.sha256 + mv $@.tmp $@ + +.PRECIOUS: download/%.owl + +db/%.owl: download/%.owl + robot merge -i $< -o $@ + +EXTRA_ONTOLOGIES = chiro ncit foodon chebiplus msio phenio comploinc bero aio reacto go go-lego bao orcid cpont biolink biopax enanomapper mlo ito reactome-Homo-sapiens efo edam sweetAll lov schema-dot-org cosmo co_324 diff --git a/src/__init__.py b/src/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/src/semsql/builder/build.Makefile b/src/semsql/builder/build.Makefile index 14a18ff..0d5078f 100644 --- a/src/semsql/builder/build.Makefile +++ b/src/semsql/builder/build.Makefile @@ -5,7 +5,7 @@ # Directory containing this Makefile # https://stackoverflow.com/questions/18136918/how-to-get-current-relative-directory-of-your-makefile THIS_DIR := $(dir $(abspath $(firstword $(MAKEFILE_LIST)))) -PREFIX_DIR = $(THIS_DIR)/prefixes +PREFIX_DIR = $(THIS_DIR)prefixes # Template sqlite database TEMPLATE = .template.db @@ -68,21 +68,18 @@ $(TEMPLATE): $(THIS_DIR)/sql_schema/semsql.sql build_prefixes # will be simplified in future. See: # - https://github.com/balhoff/relation-graph/issues/123 # - https://github.com/balhoff/relation-graph/issues/25 -%-$(RGSUFFIX).tsv: %-min.owl %-properties.txt +%-$(RGSUFFIX).tsv: %-min.owl %-properties.txt $(PREFIX_DIR)/prefixes.yaml $(RG) --disable-owl-nothing true \ --ontology-file $<\ $(RG_PROPERTIES) \ - --output-file $@.ttl.tmp \ + --output-file $@.tmp \ --equivalence-as-subclass true \ + --mode TSV \ + --prefixes $(PREFIX_DIR)/prefixes.yaml \ --output-individuals true \ --output-subclasses true \ --reflexive-subclasses true && \ - riot --out RDFXML --syntax turtle $@.ttl.tmp > $@.owl.tmp && \ - sqlite3 $@.db.tmp -cmd ".mode csv" ".import $(THIS_DIR)/prefixes/prefixes.csv prefix" && \ - rdftab $@.db.tmp < $@.owl.tmp && \ - sqlite3 $@.db.tmp -cmd '.separator "\t"' -cmd '.header on' "SELECT subject,predicate,object FROM statements " > $@.tmp && \ - mv $@.tmp $@ && \ - rm $@.*.tmp + mv $@.tmp $@ .PRECIOUS: %-$(RGSUFFIX).tsv %-properties.txt: @@ -92,7 +89,7 @@ $(TEMPLATE): $(THIS_DIR)/sql_schema/semsql.sql build_prefixes # Prefixes # --- -build_prefixes: $(PREFIX_DIR)/prefixes.csv +build_prefixes: $(PREFIX_DIR)/prefixes.csv $(PREFIX_DIR)/prefixes.yaml $(PREFIX_DIR)/obo_prefixes.owl: robot convert -I http://purl.obolibrary.org/meta/obo_prefixes.ttl -o $@ @@ -106,3 +103,7 @@ $(PREFIX_DIR)/obo_prefixes.csv: $(PREFIX_DIR)/obo_prefixes.db $(PREFIX_DIR)/prefixes.csv: $(PREFIX_DIR)/prefixes_curated.csv $(PREFIX_DIR)/prefixes_local.csv $(PREFIX_DIR)/obo_prefixes.csv cat $^ > $@ +# see https://github.com/INCATools/relation-graph/issues/168 +$(PREFIX_DIR)/prefixes.yaml: $(PREFIX_DIR)/prefixes.csv + grep -v ^prefix, $< | grep -v ^obo, | perl -npe 's@,(.*)@: "$$1"@' > $@.tmp && mv $@.tmp $@ + diff --git a/src/semsql/builder/builder.py b/src/semsql/builder/builder.py index a1c4309..02d5ca8 100644 --- a/src/semsql/builder/builder.py +++ b/src/semsql/builder/builder.py @@ -12,6 +12,9 @@ from sqlalchemy.orm import sessionmaker from semsql.builder.registry import registry_schema +from semsql.builder.registry.registry_schema import (Makefile, MakefileRule, + Ontology) +from semsql.utils.makefile_utils import makefile_to_string this_path = Path(__file__).parent @@ -20,6 +23,7 @@ class DockerConfig: """ Configuration for running ODK Docker image """ + odk_version: str = None # not used yet memory: str = None @@ -72,7 +76,7 @@ def db_from_owl(input: str) -> str: make(db) return db else: - raise ValueError(f"Path must be an OWL file") + raise ValueError("Path must be an OWL file") def download_obo_sqlite(ontology: str, destination: str): @@ -104,10 +108,10 @@ def connect(owl_file: str): """ db = db_from_owl(owl_file) engine = create_engine(f"sqlite:///{db}") - Session = sessionmaker(bind=engine) - session = Session() + session = sessionmaker(bind=engine)() return session + def compile_registry(registry_path: str, local_prefix_file: TextIO = None) -> str: """ Generate makefile content from registry @@ -118,24 +122,52 @@ def compile_registry(registry_path: str, local_prefix_file: TextIO = None) -> st """ registry: registry_schema.Registry registry = yaml_loader.load(registry_path, target_class=registry_schema.Registry) - mkfile = "" + makefile = Makefile() onts = [] + generic = Ontology("%", has_imports=True, suppress=True) if local_prefix_file: local_prefix_file.write("prefix,base\n") - for ont in registry.ontologies.values(): + for ont in list(registry.ontologies.values()) + [generic]: + # download target + if ont == generic: + command = "curl -L -s http://purl.obolibrary.org/obo/$*.owl > $@.tmp" + elif ont.zip_extract_file: + command = ( + f"curl -L -s {ont.url} > $@.zip.tmp && " + "unzip -p $@.zip.tmp {ont.zip_extract_file} " + "> $@.tmp && rm $@.zip.tmp" + ) + else: + command = f"curl -L -s {ont.url} > $@.tmp" + download_rule = MakefileRule( + target=f"download/{ont.id}.owl", + dependencies=["STAMP"], + commands=[ + command, + "sha256sum -b $@.tmp > $@.sha256", + "mv $@.tmp $@", + ], + precious=True, + ) + makefile.rules.append(download_rule) + # main build target target = f"db/{ont.id}.owl" - dependencies = ["STAMP"] - if ont.zip_extract_file: - command = f"curl -L -s {ont.url} > $@.tmp && unzip -p $@.tmp {ont.zip_extract_file} > $@.tmp2 && mv $@.tmp2 $@ && rm $@.tmp" - elif ont.has_imports or (ont.format and ont.format != 'rdfxml'): - command = f"robot merge -I {ont.url} -o $@" + dependencies = [f"download/{ont.id}.owl"] + if ont.has_imports or (ont.format and ont.format != "rdfxml"): + command = "robot merge -i $< -o $@" + elif ont.build_command: + command = ont.build_command.format(ont=ont) else: - command = f"curl -L -s {ont.url} > $@.tmp && mv $@.tmp $@" - dependencies_str = " ".join(dependencies) - mkfile += f"{target}: {dependencies_str}\n\t{command}\n\n" - onts.append(ont.id) + command = "cp $< $@" + rule = MakefileRule( + target=target, dependencies=dependencies, commands=[command] + ) + makefile.rules.append(rule) + if not ont.suppress: + onts.append(ont.id) if local_prefix_file: for pn in ont.prefixmap.values(): local_prefix_file.write(f"{pn.prefix},{pn.prefix_value}\n") + mkfile = makefile_to_string(makefile) mkfile += f"EXTRA_ONTOLOGIES = {' '.join(onts)}" return mkfile diff --git a/src/semsql/builder/cli.py b/src/semsql/builder/cli.py index 51a7467..ccab05e 100644 --- a/src/semsql/builder/cli.py +++ b/src/semsql/builder/cli.py @@ -3,10 +3,10 @@ import click from linkml_runtime import SchemaView from linkml_runtime.utils.formatutils import underscore -from semsql.linkml import path_to_schema from sqlalchemy import text import semsql.builder.builder as builder +from semsql.linkml import path_to_schema from semsql.sqlutils.viewgen import get_viewdef @@ -51,10 +51,12 @@ def make(path, docker): @main.command() -@click.option("--local-prefixes", - "-P", - type=click.File(mode="w"), - help="path to local prefixes file (will be overridden)") +@click.option( + "--local-prefixes", + "-P", + type=click.File(mode="w"), + help="path to local prefixes file (will be overridden)", +) @click.argument("registry") def generate_makefile(registry, local_prefixes): """ @@ -125,9 +127,7 @@ def view2table(views, schema, index: bool): if index: for sn in sv.class_slots(cn): colname = underscore(sn) - print( - f"CREATE INDEX {tn}_{colname} ON {tn}({colname});" - ) + print(f"CREATE INDEX {tn}_{colname} ON {tn}({colname});") else: logging.error(f"No view for {cn}") diff --git a/src/semsql/builder/prefixes/prefixes.csv b/src/semsql/builder/prefixes/prefixes.csv index 896e0a0..5a58706 100644 --- a/src/semsql/builder/prefixes/prefixes.csv +++ b/src/semsql/builder/prefixes/prefixes.csv @@ -49,9 +49,12 @@ wikidata,http://www.wikidata.org/entity/ schema,https://schema.org/ ICD10CM,http://purl.bioontology.org/ontology/ICD10CM/ ICD10WHO,https://icd.who.int/browse10/2019/en#/ +snomedct,http://snomed.info/id/ prefix,base MSIO,http://purl.obolibrary.org/obo/MSIO_ nmrCV,http://nmrML.org/nmrCV#NMR: +loinc,https://loinc.org/ +orcid,https://orcid.org/ evs.ncit,http://ncicb.nci.nih.gov/xml/owl/EVS/Thesaurus.owl# old.fix,http://purl.org/obo/owl/FIX# mlo,http://www.a2rd.net.br/mlo# diff --git a/src/semsql/builder/prefixes/prefixes_curated.csv b/src/semsql/builder/prefixes/prefixes_curated.csv index e82b3d2..dff10e6 100644 --- a/src/semsql/builder/prefixes/prefixes_curated.csv +++ b/src/semsql/builder/prefixes/prefixes_curated.csv @@ -49,3 +49,4 @@ wikidata,http://www.wikidata.org/entity/ schema,https://schema.org/ ICD10CM,http://purl.bioontology.org/ontology/ICD10CM/ ICD10WHO,https://icd.who.int/browse10/2019/en#/ +snomedct,http://snomed.info/id/ diff --git a/src/semsql/builder/prefixes/prefixes_local.csv b/src/semsql/builder/prefixes/prefixes_local.csv index 1d210c6..c506c6a 100644 --- a/src/semsql/builder/prefixes/prefixes_local.csv +++ b/src/semsql/builder/prefixes/prefixes_local.csv @@ -1,6 +1,8 @@ prefix,base MSIO,http://purl.obolibrary.org/obo/MSIO_ nmrCV,http://nmrML.org/nmrCV#NMR: +loinc,https://loinc.org/ +orcid,https://orcid.org/ evs.ncit,http://ncicb.nci.nih.gov/xml/owl/EVS/Thesaurus.owl# old.fix,http://purl.org/obo/owl/FIX# mlo,http://www.a2rd.net.br/mlo# diff --git a/src/semsql/builder/registry/__init__.py b/src/semsql/builder/registry/__init__.py new file mode 100644 index 0000000..c9bade5 --- /dev/null +++ b/src/semsql/builder/registry/__init__.py @@ -0,0 +1,12 @@ +from pathlib import Path + +this_path = Path(__file__).parent + + +def path_to_ontology_registry() -> Path: + """ + Returns path to the registry file + + :return: + """ + return this_path / "ontologies.yaml" diff --git a/src/semsql/builder/registry/ontologies.yaml b/src/semsql/builder/registry/ontologies.yaml index 93745a9..c7224a3 100644 --- a/src/semsql/builder/registry/ontologies.yaml +++ b/src/semsql/builder/registry/ontologies.yaml @@ -2,6 +2,18 @@ id: semantic-sql-registry description: Registry overlap for Semantic-SQL designed to supplement OBO vocabularies license: CC0 ontologies: + chiro: + url: http://purl.obolibrary.org/obo/chiro.owl + build_command: "robot relax -i $< merge -o $@" + ncit: + url: http://purl.obolibrary.org/obo/ncit.owl + build_command: "robot relax -i $< merge -o $@" + foodon: + url: http://purl.obolibrary.org/obo/foodon.owl + build_command: "robot merge -i $< relax reduce -c true -o $@" + chebiplus: + url: http://purl.obolibrary.org/obo/chebi.owl + build_command: "robot merge -i $< -I http://purl.obolibrary.org/obo/chiro.owl relax -o $@" msio: url: https://raw.githubusercontent.com/MSI-Metabolomics-Standards-Initiative/MSIO/master/releases/latest_release/MSIO-merged-reasoned.owl prefixmap: @@ -17,17 +29,30 @@ ontologies: - UPHENO:0000001 - UPHENO:0000003 - RO:0002202 + comploinc: + url: https://github.com/loinc/comp-loinc/releases/download/v2022-11-05/merged_reasoned_loinc.owl + build_command: "robot relax -i $< merge -o $@" + prefixmap: + loinc: https://loinc.org/ bero: url: https://github.com/berkeleybop/bero/releases/download/2022-05-26/bero.owl aio: url: https://raw.githubusercontent.com/berkeleybop/artificial-intelligence-ontology/main/aio.owl reacto: url: http://purl.obolibrary.org/obo/go/extensions/reacto.owl + go: + url: http://purl.obolibrary.org/obo/go/extensions/go-plus.owl go-lego: url: http://purl.obolibrary.org/obo/go/extensions/go-lego.owl bao: url: http://www.bioassayontology.org/bao/bao_complete.owl has_imports: true + orcid: + url: https://raw.githubusercontent.com/cthoyt/wikidata-orcid-ontology/main/orcid.owl + prefixmap: + orcid: https://orcid.org/ + cpont: + url: https://w3id.org/cpont/cpont.owl biolink: url: https://w3id.org/biolink/biolink-model.owl.ttl jsonld_context: https://biolink.github.io/biolink-model/context.jsonld @@ -49,6 +74,9 @@ ontologies: ito: url: https://github.com/OpenBioLink/ITO/raw/master/ITO.owl.zip zip_extract_file: ITO.owl + reactome-Homo-sapiens: + url: https://reactome.org/download/current/biopax.zip + zip_extract_file: Homo_sapiens.owl efo: url: http://www.ebi.ac.uk/efo/efo.owl has_imports: true diff --git a/src/semsql/builder/registry/registry_schema.py b/src/semsql/builder/registry/registry_schema.py index 5067436..27cd3a6 100644 --- a/src/semsql/builder/registry/registry_schema.py +++ b/src/semsql/builder/registry/registry_schema.py @@ -1,5 +1,5 @@ # Auto generated from registry_schema.yaml by pythongen.py version: 0.9.0 -# Generation date: 2022-10-18T18:20:11 +# Generation date: 2022-11-13T13:16:23 # Schema: ontology_registry # # id: https://w3id.org/semsql/registry @@ -7,23 +7,25 @@ # license: https://creativecommons.org/publicdomain/zero/1.0/ import dataclasses -import sys -import re -from jsonasobj2 import JsonObj, as_dict -from typing import Optional, List, Union, Dict, ClassVar, Any from dataclasses import dataclass -from linkml_runtime.linkml_model.meta import EnumDefinition, PermissibleValue, PvFormulaOptions +from typing import Any, ClassVar, Dict, List, Optional, Union -from linkml_runtime.utils.slot import Slot -from linkml_runtime.utils.metamodelcore import empty_list, empty_dict, bnode -from linkml_runtime.utils.yamlutils import YAMLRoot, extended_str, extended_float, extended_int -from linkml_runtime.utils.dataclass_extensions_376 import dataclasses_init_fn_with_kwargs -from linkml_runtime.utils.formatutils import camelcase, underscore, sfx +from jsonasobj2 import JsonObj, as_dict +from linkml_runtime.linkml_model.meta import (EnumDefinition, PermissibleValue, + PvFormulaOptions) +from linkml_runtime.linkml_model.types import (Boolean, Integer, String, + Uriorcurie) +from linkml_runtime.utils.curienamespace import CurieNamespace +from linkml_runtime.utils.dataclass_extensions_376 import \ + dataclasses_init_fn_with_kwargs from linkml_runtime.utils.enumerations import EnumDefinitionImpl +from linkml_runtime.utils.formatutils import camelcase, sfx, underscore +from linkml_runtime.utils.metamodelcore import (Bool, URIorCURIE, bnode, + empty_dict, empty_list) +from linkml_runtime.utils.slot import Slot +from linkml_runtime.utils.yamlutils import (YAMLRoot, extended_float, + extended_int, extended_str) from rdflib import Namespace, URIRef -from linkml_runtime.utils.curienamespace import CurieNamespace -from linkml_runtime.linkml_model.types import Boolean, Integer, String, Uriorcurie -from linkml_runtime.utils.metamodelcore import Bool, URIorCURIE metamodel_version = "1.7.0" version = None @@ -32,9 +34,9 @@ dataclasses._init_fn = dataclasses_init_fn_with_kwargs # Namespaces -LINKML = CurieNamespace('linkml', 'https://w3id.org/linkml/') -SEMSQL_REGISTRY = CurieNamespace('semsql_registry', 'https://w3id.org/semsql/registry') -XSD = CurieNamespace('xsd', 'http://www.w3.org/2001/XMLSchema#') +LINKML = CurieNamespace("linkml", "https://w3id.org/linkml/") +SEMSQL_REGISTRY = CurieNamespace("semsql_registry", "https://w3id.org/semsql/registry") +XSD = CurieNamespace("xsd", "http://www.w3.org/2001/XMLSchema#") DEFAULT_ = SEMSQL_REGISTRY @@ -85,15 +87,23 @@ class Ontology(YAMLRoot): id: Union[str, OntologyId] = None description: Optional[str] = None url: Optional[Union[str, Identifier]] = None + sha256: Optional[str] = None + local_path: Optional[str] = None has_imports: Optional[int] = None jsonld_context: Optional[Union[str, HttpsIdentifier]] = None - prefixmap: Optional[Union[Dict[Union[str, PrefixMapPrefix], Union[dict, "PrefixMap"]], List[Union[dict, "PrefixMap"]]]] = empty_dict() + prefixmap: Optional[ + Union[ + Dict[Union[str, PrefixMapPrefix], Union[dict, "PrefixMap"]], + List[Union[dict, "PrefixMap"]], + ] + ] = empty_dict() named_prefixmaps: Optional[Union[str, List[str]]] = empty_list() format: Optional[str] = None compression: Optional[Union[str, "CompressionEnum"]] = None suppress: Optional[Union[bool, Bool]] = None relation_graph_settings: Optional[Union[dict, "RelationGraphConfiguration"]] = None zip_extract_file: Optional[str] = None + build_command: Optional[str] = None def __post_init__(self, *_: List[str], **kwargs: Dict[str, Any]): if self._is_empty(self.id): @@ -107,33 +117,58 @@ def __post_init__(self, *_: List[str], **kwargs: Dict[str, Any]): if self.url is not None and not isinstance(self.url, Identifier): self.url = Identifier(self.url) + if self.sha256 is not None and not isinstance(self.sha256, str): + self.sha256 = str(self.sha256) + + if self.local_path is not None and not isinstance(self.local_path, str): + self.local_path = str(self.local_path) + if self.has_imports is not None and not isinstance(self.has_imports, int): self.has_imports = int(self.has_imports) - if self.jsonld_context is not None and not isinstance(self.jsonld_context, HttpsIdentifier): + if self.jsonld_context is not None and not isinstance( + self.jsonld_context, HttpsIdentifier + ): self.jsonld_context = HttpsIdentifier(self.jsonld_context) - self._normalize_inlined_as_dict(slot_name="prefixmap", slot_type=PrefixMap, key_name="prefix", keyed=True) + self._normalize_inlined_as_dict( + slot_name="prefixmap", slot_type=PrefixMap, key_name="prefix", keyed=True + ) if not isinstance(self.named_prefixmaps, list): - self.named_prefixmaps = [self.named_prefixmaps] if self.named_prefixmaps is not None else [] - self.named_prefixmaps = [v if isinstance(v, str) else str(v) for v in self.named_prefixmaps] + self.named_prefixmaps = ( + [self.named_prefixmaps] if self.named_prefixmaps is not None else [] + ) + self.named_prefixmaps = [ + v if isinstance(v, str) else str(v) for v in self.named_prefixmaps + ] if self.format is not None and not isinstance(self.format, str): self.format = str(self.format) - if self.compression is not None and not isinstance(self.compression, CompressionEnum): + if self.compression is not None and not isinstance( + self.compression, CompressionEnum + ): self.compression = CompressionEnum(self.compression) if self.suppress is not None and not isinstance(self.suppress, Bool): self.suppress = Bool(self.suppress) - if self.relation_graph_settings is not None and not isinstance(self.relation_graph_settings, RelationGraphConfiguration): - self.relation_graph_settings = RelationGraphConfiguration(**as_dict(self.relation_graph_settings)) + if self.relation_graph_settings is not None and not isinstance( + self.relation_graph_settings, RelationGraphConfiguration + ): + self.relation_graph_settings = RelationGraphConfiguration( + **as_dict(self.relation_graph_settings) + ) - if self.zip_extract_file is not None and not isinstance(self.zip_extract_file, str): + if self.zip_extract_file is not None and not isinstance( + self.zip_extract_file, str + ): self.zip_extract_file = str(self.zip_extract_file) + if self.build_command is not None and not isinstance(self.build_command, str): + self.build_command = str(self.build_command) + super().__post_init__(**kwargs) @@ -155,7 +190,9 @@ def __post_init__(self, *_: List[str], **kwargs: Dict[str, Any]): if not isinstance(self.prefix, PrefixMapPrefix): self.prefix = PrefixMapPrefix(self.prefix) - if self.prefix_value is not None and not isinstance(self.prefix_value, HttpIdentifier): + if self.prefix_value is not None and not isinstance( + self.prefix_value, HttpIdentifier + ): self.prefix_value = HttpIdentifier(self.prefix_value) super().__post_init__(**kwargs) @@ -173,7 +210,12 @@ class Registry(YAMLRoot): id: Union[str, RegistryId] = None description: Optional[str] = None license: Optional[str] = None - ontologies: Optional[Union[Dict[Union[str, OntologyId], Union[dict, Ontology]], List[Union[dict, Ontology]]]] = empty_dict() + ontologies: Optional[ + Union[ + Dict[Union[str, OntologyId], Union[dict, Ontology]], + List[Union[dict, Ontology]], + ] + ] = empty_dict() def __post_init__(self, *_: List[str], **kwargs: Dict[str, Any]): if self._is_empty(self.id): @@ -187,7 +229,9 @@ def __post_init__(self, *_: List[str], **kwargs: Dict[str, Any]): if self.license is not None and not isinstance(self.license, str): self.license = str(self.license) - self._normalize_inlined_as_dict(slot_name="ontologies", slot_type=Ontology, key_name="id", keyed=True) + self._normalize_inlined_as_dict( + slot_name="ontologies", slot_type=Ontology, key_name="id", keyed=True + ) super().__post_init__(**kwargs) @@ -201,86 +245,349 @@ class RelationGraphConfiguration(YAMLRoot): class_name: ClassVar[str] = "RelationGraphConfiguration" class_model_uri: ClassVar[URIRef] = SEMSQL_REGISTRY.RelationGraphConfiguration - properties: Optional[Union[Union[str, URIorCURIE], List[Union[str, URIorCURIE]]]] = empty_list() + properties: Optional[ + Union[Union[str, URIorCURIE], List[Union[str, URIorCURIE]]] + ] = empty_list() def __post_init__(self, *_: List[str], **kwargs: Dict[str, Any]): if not isinstance(self.properties, list): self.properties = [self.properties] if self.properties is not None else [] - self.properties = [v if isinstance(v, URIorCURIE) else URIorCURIE(v) for v in self.properties] + self.properties = [ + v if isinstance(v, URIorCURIE) else URIorCURIE(v) for v in self.properties + ] super().__post_init__(**kwargs) -# Enumerations -class FormatEnum(EnumDefinitionImpl): +@dataclass +class MakefileRule(YAMLRoot): + _inherited_slots: ClassVar[List[str]] = [] - n3 = PermissibleValue(text="n3", - description="n3") + class_class_uri: ClassVar[URIRef] = SEMSQL_REGISTRY.MakefileRule + class_class_curie: ClassVar[str] = "semsql_registry:MakefileRule" + class_name: ClassVar[str] = "MakefileRule" + class_model_uri: ClassVar[URIRef] = SEMSQL_REGISTRY.MakefileRule - _defn = EnumDefinition( - name="FormatEnum", - ) + target: Optional[str] = None + dependencies: Optional[Union[str, List[str]]] = empty_list() + commands: Optional[Union[str, List[str]]] = empty_list() + comments: Optional[Union[str, List[str]]] = empty_list() + precious: Optional[Union[bool, Bool]] = None -class CompressionEnum(EnumDefinitionImpl): + def __post_init__(self, *_: List[str], **kwargs: Dict[str, Any]): + if self.target is not None and not isinstance(self.target, str): + self.target = str(self.target) - gzip = PermissibleValue(text="gzip", - description="gzip") + if not isinstance(self.dependencies, list): + self.dependencies = ( + [self.dependencies] if self.dependencies is not None else [] + ) + self.dependencies = [ + v if isinstance(v, str) else str(v) for v in self.dependencies + ] - _defn = EnumDefinition( - name="CompressionEnum", - ) + if not isinstance(self.commands, list): + self.commands = [self.commands] if self.commands is not None else [] + self.commands = [v if isinstance(v, str) else str(v) for v in self.commands] -# Slots -class slots: - pass + if not isinstance(self.comments, list): + self.comments = [self.comments] if self.comments is not None else [] + self.comments = [v if isinstance(v, str) else str(v) for v in self.comments] -slots.id = Slot(uri=SEMSQL_REGISTRY.id, name="id", curie=SEMSQL_REGISTRY.curie('id'), - model_uri=SEMSQL_REGISTRY.id, domain=None, range=URIRef) + if self.precious is not None and not isinstance(self.precious, Bool): + self.precious = Bool(self.precious) -slots.description = Slot(uri=SEMSQL_REGISTRY.description, name="description", curie=SEMSQL_REGISTRY.curie('description'), - model_uri=SEMSQL_REGISTRY.description, domain=None, range=Optional[str]) + super().__post_init__(**kwargs) -slots.url = Slot(uri=SEMSQL_REGISTRY.url, name="url", curie=SEMSQL_REGISTRY.curie('url'), - model_uri=SEMSQL_REGISTRY.url, domain=None, range=Optional[Union[str, Identifier]]) -slots.relation_graph_settings = Slot(uri=SEMSQL_REGISTRY.relation_graph_settings, name="relation_graph_settings", curie=SEMSQL_REGISTRY.curie('relation_graph_settings'), - model_uri=SEMSQL_REGISTRY.relation_graph_settings, domain=None, range=Optional[Union[dict, RelationGraphConfiguration]]) +@dataclass +class Makefile(YAMLRoot): + _inherited_slots: ClassVar[List[str]] = [] -slots.has_imports = Slot(uri=SEMSQL_REGISTRY.has_imports, name="has_imports", curie=SEMSQL_REGISTRY.curie('has_imports'), - model_uri=SEMSQL_REGISTRY.has_imports, domain=None, range=Optional[int]) + class_class_uri: ClassVar[URIRef] = SEMSQL_REGISTRY.Makefile + class_class_curie: ClassVar[str] = "semsql_registry:Makefile" + class_name: ClassVar[str] = "Makefile" + class_model_uri: ClassVar[URIRef] = SEMSQL_REGISTRY.Makefile -slots.jsonld_context = Slot(uri=SEMSQL_REGISTRY.jsonld_context, name="jsonld_context", curie=SEMSQL_REGISTRY.curie('jsonld_context'), - model_uri=SEMSQL_REGISTRY.jsonld_context, domain=None, range=Optional[Union[str, HttpsIdentifier]]) + rules: Optional[ + Union[Union[dict, MakefileRule], List[Union[dict, MakefileRule]]] + ] = empty_list() -slots.prefixmap = Slot(uri=SEMSQL_REGISTRY.prefixmap, name="prefixmap", curie=SEMSQL_REGISTRY.curie('prefixmap'), - model_uri=SEMSQL_REGISTRY.prefixmap, domain=None, range=Optional[Union[Dict[Union[str, PrefixMapPrefix], Union[dict, PrefixMap]], List[Union[dict, PrefixMap]]]]) + def __post_init__(self, *_: List[str], **kwargs: Dict[str, Any]): + if not isinstance(self.rules, list): + self.rules = [self.rules] if self.rules is not None else [] + self.rules = [ + v if isinstance(v, MakefileRule) else MakefileRule(**as_dict(v)) + for v in self.rules + ] + + super().__post_init__(**kwargs) + + +# Enumerations +class FormatEnum(EnumDefinitionImpl): -slots.zip_extract_file = Slot(uri=SEMSQL_REGISTRY.zip_extract_file, name="zip_extract_file", curie=SEMSQL_REGISTRY.curie('zip_extract_file'), - model_uri=SEMSQL_REGISTRY.zip_extract_file, domain=None, range=Optional[str]) + n3 = PermissibleValue(text="n3", description="n3") -slots.named_prefixmaps = Slot(uri=SEMSQL_REGISTRY.named_prefixmaps, name="named_prefixmaps", curie=SEMSQL_REGISTRY.curie('named_prefixmaps'), - model_uri=SEMSQL_REGISTRY.named_prefixmaps, domain=None, range=Optional[Union[str, List[str]]]) + _defn = EnumDefinition( + name="FormatEnum", + ) -slots.format = Slot(uri=SEMSQL_REGISTRY.format, name="format", curie=SEMSQL_REGISTRY.curie('format'), - model_uri=SEMSQL_REGISTRY.format, domain=None, range=Optional[str]) -slots.compression = Slot(uri=SEMSQL_REGISTRY.compression, name="compression", curie=SEMSQL_REGISTRY.curie('compression'), - model_uri=SEMSQL_REGISTRY.compression, domain=None, range=Optional[Union[str, "CompressionEnum"]]) +class CompressionEnum(EnumDefinitionImpl): -slots.prefix = Slot(uri=SEMSQL_REGISTRY.prefix, name="prefix", curie=SEMSQL_REGISTRY.curie('prefix'), - model_uri=SEMSQL_REGISTRY.prefix, domain=None, range=URIRef) + gzip = PermissibleValue(text="gzip", description="gzip") -slots.prefix_value = Slot(uri=SEMSQL_REGISTRY.prefix_value, name="prefix_value", curie=SEMSQL_REGISTRY.curie('prefix_value'), - model_uri=SEMSQL_REGISTRY.prefix_value, domain=None, range=Optional[Union[str, HttpIdentifier]]) + _defn = EnumDefinition( + name="CompressionEnum", + ) -slots.license = Slot(uri=SEMSQL_REGISTRY.license, name="license", curie=SEMSQL_REGISTRY.curie('license'), - model_uri=SEMSQL_REGISTRY.license, domain=None, range=Optional[str]) -slots.ontologies = Slot(uri=SEMSQL_REGISTRY.ontologies, name="ontologies", curie=SEMSQL_REGISTRY.curie('ontologies'), - model_uri=SEMSQL_REGISTRY.ontologies, domain=None, range=Optional[Union[Dict[Union[str, OntologyId], Union[dict, Ontology]], List[Union[dict, Ontology]]]]) +# Slots +class slots: + pass -slots.suppress = Slot(uri=SEMSQL_REGISTRY.suppress, name="suppress", curie=SEMSQL_REGISTRY.curie('suppress'), - model_uri=SEMSQL_REGISTRY.suppress, domain=None, range=Optional[Union[bool, Bool]]) -slots.relationGraphConfiguration__properties = Slot(uri=SEMSQL_REGISTRY.properties, name="relationGraphConfiguration__properties", curie=SEMSQL_REGISTRY.curie('properties'), - model_uri=SEMSQL_REGISTRY.relationGraphConfiguration__properties, domain=None, range=Optional[Union[Union[str, URIorCURIE], List[Union[str, URIorCURIE]]]]) +slots.id = Slot( + uri=SEMSQL_REGISTRY.id, + name="id", + curie=SEMSQL_REGISTRY.curie("id"), + model_uri=SEMSQL_REGISTRY.id, + domain=None, + range=URIRef, +) + +slots.description = Slot( + uri=SEMSQL_REGISTRY.description, + name="description", + curie=SEMSQL_REGISTRY.curie("description"), + model_uri=SEMSQL_REGISTRY.description, + domain=None, + range=Optional[str], +) + +slots.url = Slot( + uri=SEMSQL_REGISTRY.url, + name="url", + curie=SEMSQL_REGISTRY.curie("url"), + model_uri=SEMSQL_REGISTRY.url, + domain=None, + range=Optional[Union[str, Identifier]], +) + +slots.relation_graph_settings = Slot( + uri=SEMSQL_REGISTRY.relation_graph_settings, + name="relation_graph_settings", + curie=SEMSQL_REGISTRY.curie("relation_graph_settings"), + model_uri=SEMSQL_REGISTRY.relation_graph_settings, + domain=None, + range=Optional[Union[dict, RelationGraphConfiguration]], +) + +slots.has_imports = Slot( + uri=SEMSQL_REGISTRY.has_imports, + name="has_imports", + curie=SEMSQL_REGISTRY.curie("has_imports"), + model_uri=SEMSQL_REGISTRY.has_imports, + domain=None, + range=Optional[int], +) + +slots.jsonld_context = Slot( + uri=SEMSQL_REGISTRY.jsonld_context, + name="jsonld_context", + curie=SEMSQL_REGISTRY.curie("jsonld_context"), + model_uri=SEMSQL_REGISTRY.jsonld_context, + domain=None, + range=Optional[Union[str, HttpsIdentifier]], +) + +slots.prefixmap = Slot( + uri=SEMSQL_REGISTRY.prefixmap, + name="prefixmap", + curie=SEMSQL_REGISTRY.curie("prefixmap"), + model_uri=SEMSQL_REGISTRY.prefixmap, + domain=None, + range=Optional[ + Union[ + Dict[Union[str, PrefixMapPrefix], Union[dict, PrefixMap]], + List[Union[dict, PrefixMap]], + ] + ], +) + +slots.zip_extract_file = Slot( + uri=SEMSQL_REGISTRY.zip_extract_file, + name="zip_extract_file", + curie=SEMSQL_REGISTRY.curie("zip_extract_file"), + model_uri=SEMSQL_REGISTRY.zip_extract_file, + domain=None, + range=Optional[str], +) + +slots.named_prefixmaps = Slot( + uri=SEMSQL_REGISTRY.named_prefixmaps, + name="named_prefixmaps", + curie=SEMSQL_REGISTRY.curie("named_prefixmaps"), + model_uri=SEMSQL_REGISTRY.named_prefixmaps, + domain=None, + range=Optional[Union[str, List[str]]], +) + +slots.format = Slot( + uri=SEMSQL_REGISTRY.format, + name="format", + curie=SEMSQL_REGISTRY.curie("format"), + model_uri=SEMSQL_REGISTRY.format, + domain=None, + range=Optional[str], +) + +slots.build_command = Slot( + uri=SEMSQL_REGISTRY.build_command, + name="build_command", + curie=SEMSQL_REGISTRY.curie("build_command"), + model_uri=SEMSQL_REGISTRY.build_command, + domain=None, + range=Optional[str], +) + +slots.sha256 = Slot( + uri=SEMSQL_REGISTRY.sha256, + name="sha256", + curie=SEMSQL_REGISTRY.curie("sha256"), + model_uri=SEMSQL_REGISTRY.sha256, + domain=None, + range=Optional[str], +) + +slots.local_path = Slot( + uri=SEMSQL_REGISTRY.local_path, + name="local_path", + curie=SEMSQL_REGISTRY.curie("local_path"), + model_uri=SEMSQL_REGISTRY.local_path, + domain=None, + range=Optional[str], +) + +slots.compression = Slot( + uri=SEMSQL_REGISTRY.compression, + name="compression", + curie=SEMSQL_REGISTRY.curie("compression"), + model_uri=SEMSQL_REGISTRY.compression, + domain=None, + range=Optional[Union[str, "CompressionEnum"]], +) + +slots.prefix = Slot( + uri=SEMSQL_REGISTRY.prefix, + name="prefix", + curie=SEMSQL_REGISTRY.curie("prefix"), + model_uri=SEMSQL_REGISTRY.prefix, + domain=None, + range=URIRef, +) + +slots.prefix_value = Slot( + uri=SEMSQL_REGISTRY.prefix_value, + name="prefix_value", + curie=SEMSQL_REGISTRY.curie("prefix_value"), + model_uri=SEMSQL_REGISTRY.prefix_value, + domain=None, + range=Optional[Union[str, HttpIdentifier]], +) + +slots.license = Slot( + uri=SEMSQL_REGISTRY.license, + name="license", + curie=SEMSQL_REGISTRY.curie("license"), + model_uri=SEMSQL_REGISTRY.license, + domain=None, + range=Optional[str], +) + +slots.ontologies = Slot( + uri=SEMSQL_REGISTRY.ontologies, + name="ontologies", + curie=SEMSQL_REGISTRY.curie("ontologies"), + model_uri=SEMSQL_REGISTRY.ontologies, + domain=None, + range=Optional[ + Union[ + Dict[Union[str, OntologyId], Union[dict, Ontology]], + List[Union[dict, Ontology]], + ] + ], +) + +slots.suppress = Slot( + uri=SEMSQL_REGISTRY.suppress, + name="suppress", + curie=SEMSQL_REGISTRY.curie("suppress"), + model_uri=SEMSQL_REGISTRY.suppress, + domain=None, + range=Optional[Union[bool, Bool]], +) + +slots.relationGraphConfiguration__properties = Slot( + uri=SEMSQL_REGISTRY.properties, + name="relationGraphConfiguration__properties", + curie=SEMSQL_REGISTRY.curie("properties"), + model_uri=SEMSQL_REGISTRY.relationGraphConfiguration__properties, + domain=None, + range=Optional[Union[Union[str, URIorCURIE], List[Union[str, URIorCURIE]]]], +) + +slots.makefileRule__target = Slot( + uri=SEMSQL_REGISTRY.target, + name="makefileRule__target", + curie=SEMSQL_REGISTRY.curie("target"), + model_uri=SEMSQL_REGISTRY.makefileRule__target, + domain=None, + range=Optional[str], +) + +slots.makefileRule__dependencies = Slot( + uri=SEMSQL_REGISTRY.dependencies, + name="makefileRule__dependencies", + curie=SEMSQL_REGISTRY.curie("dependencies"), + model_uri=SEMSQL_REGISTRY.makefileRule__dependencies, + domain=None, + range=Optional[Union[str, List[str]]], +) + +slots.makefileRule__commands = Slot( + uri=SEMSQL_REGISTRY.commands, + name="makefileRule__commands", + curie=SEMSQL_REGISTRY.curie("commands"), + model_uri=SEMSQL_REGISTRY.makefileRule__commands, + domain=None, + range=Optional[Union[str, List[str]]], +) + +slots.makefileRule__comments = Slot( + uri=SEMSQL_REGISTRY.comments, + name="makefileRule__comments", + curie=SEMSQL_REGISTRY.curie("comments"), + model_uri=SEMSQL_REGISTRY.makefileRule__comments, + domain=None, + range=Optional[Union[str, List[str]]], +) + +slots.makefileRule__precious = Slot( + uri=SEMSQL_REGISTRY.precious, + name="makefileRule__precious", + curie=SEMSQL_REGISTRY.curie("precious"), + model_uri=SEMSQL_REGISTRY.makefileRule__precious, + domain=None, + range=Optional[Union[bool, Bool]], +) + +slots.makefile__rules = Slot( + uri=SEMSQL_REGISTRY.rules, + name="makefile__rules", + curie=SEMSQL_REGISTRY.curie("rules"), + model_uri=SEMSQL_REGISTRY.makefile__rules, + domain=None, + range=Optional[Union[Union[dict, MakefileRule], List[Union[dict, MakefileRule]]]], +) diff --git a/src/semsql/builder/registry/registry_schema.yaml b/src/semsql/builder/registry/registry_schema.yaml index 317a7d4..07cf978 100644 --- a/src/semsql/builder/registry/registry_schema.yaml +++ b/src/semsql/builder/registry/registry_schema.yaml @@ -64,6 +64,9 @@ slots: examples: - value: n3 #range: format_enum + build_command: + sha256: + local_path: compression: examples: - value: gzip @@ -99,6 +102,8 @@ classes: - description - url - id + - sha256 + - local_path - has_imports - jsonld_context - prefixmap @@ -108,6 +113,7 @@ classes: - suppress - relation_graph_settings - zip_extract_file + - build_command PrefixMap: slots: - prefix @@ -124,3 +130,20 @@ classes: properties: range: uriorcurie multivalued: true + MakefileRule: + attributes: + target: + dependencies: + multivalued: true + commands: + multivalued: true + comments: + multivalued: true + precious: + range: boolean + Makefile: + attributes: + rules: + range: MakefileRule + inlined: true + multivalued: true diff --git a/src/semsql/builder/sql_schema/omo.sql b/src/semsql/builder/sql_schema/omo.sql index df3b8b2..43a1206 100644 --- a/src/semsql/builder/sql_schema/omo.sql +++ b/src/semsql/builder/sql_schema/omo.sql @@ -1,115 +1,134 @@ -- # Class: "has_text_definition_statement" Description: "" --- * Slot: stanza Description: --- * Slot: subject Description: --- * Slot: predicate Description: +-- * Slot: stanza Description: the term which this statement is about +-- * Slot: subject Description: The subject of the statement +-- * Slot: predicate Description: The predicate of the statement -- * Slot: object Description: Note the range of this slot is always a node. If the triple represents a literal, instead value will be populated -- * Slot: value Description: Note the range of this slot is always a string. Only used the triple represents a literal assertion --- * Slot: datatype Description: --- * Slot: language Description: +-- * Slot: datatype Description: the rdf datatype of the value, for example, xsd:string +-- * Slot: language Description: the human language in which the value is encoded, e.g. en -- # Class: "has_oio_synonym_statement" Description: "" --- * Slot: stanza Description: --- * Slot: subject Description: --- * Slot: predicate Description: +-- * Slot: stanza Description: the term which this statement is about +-- * Slot: subject Description: The subject of the statement +-- * Slot: predicate Description: The predicate of the statement -- * Slot: object Description: Note the range of this slot is always a node. If the triple represents a literal, instead value will be populated -- * Slot: value Description: Note the range of this slot is always a string. Only used the triple represents a literal assertion --- * Slot: datatype Description: --- * Slot: language Description: +-- * Slot: datatype Description: the rdf datatype of the value, for example, xsd:string +-- * Slot: language Description: the human language in which the value is encoded, e.g. en -- # Class: "has_exact_synonym_statement" Description: "" --- * Slot: stanza Description: --- * Slot: subject Description: --- * Slot: predicate Description: +-- * Slot: stanza Description: the term which this statement is about +-- * Slot: subject Description: The subject of the statement +-- * Slot: predicate Description: The predicate of the statement -- * Slot: object Description: Note the range of this slot is always a node. If the triple represents a literal, instead value will be populated -- * Slot: value Description: Note the range of this slot is always a string. Only used the triple represents a literal assertion --- * Slot: datatype Description: --- * Slot: language Description: +-- * Slot: datatype Description: the rdf datatype of the value, for example, xsd:string +-- * Slot: language Description: the human language in which the value is encoded, e.g. en -- # Class: "has_broad_synonym_statement" Description: "" --- * Slot: stanza Description: --- * Slot: subject Description: --- * Slot: predicate Description: +-- * Slot: stanza Description: the term which this statement is about +-- * Slot: subject Description: The subject of the statement +-- * Slot: predicate Description: The predicate of the statement -- * Slot: object Description: Note the range of this slot is always a node. If the triple represents a literal, instead value will be populated -- * Slot: value Description: Note the range of this slot is always a string. Only used the triple represents a literal assertion --- * Slot: datatype Description: --- * Slot: language Description: +-- * Slot: datatype Description: the rdf datatype of the value, for example, xsd:string +-- * Slot: language Description: the human language in which the value is encoded, e.g. en -- # Class: "has_narrow_synonym_statement" Description: "" --- * Slot: stanza Description: --- * Slot: subject Description: --- * Slot: predicate Description: +-- * Slot: stanza Description: the term which this statement is about +-- * Slot: subject Description: The subject of the statement +-- * Slot: predicate Description: The predicate of the statement -- * Slot: object Description: Note the range of this slot is always a node. If the triple represents a literal, instead value will be populated -- * Slot: value Description: Note the range of this slot is always a string. Only used the triple represents a literal assertion --- * Slot: datatype Description: --- * Slot: language Description: +-- * Slot: datatype Description: the rdf datatype of the value, for example, xsd:string +-- * Slot: language Description: the human language in which the value is encoded, e.g. en -- # Class: "has_related_synonym_statement" Description: "" --- * Slot: stanza Description: --- * Slot: subject Description: --- * Slot: predicate Description: +-- * Slot: stanza Description: the term which this statement is about +-- * Slot: subject Description: The subject of the statement +-- * Slot: predicate Description: The predicate of the statement -- * Slot: object Description: Note the range of this slot is always a node. If the triple represents a literal, instead value will be populated -- * Slot: value Description: Note the range of this slot is always a string. Only used the triple represents a literal assertion --- * Slot: datatype Description: --- * Slot: language Description: +-- * Slot: datatype Description: the rdf datatype of the value, for example, xsd:string +-- * Slot: language Description: the human language in which the value is encoded, e.g. en -- # Class: "has_synonym_statement" Description: "" --- * Slot: stanza Description: --- * Slot: subject Description: --- * Slot: predicate Description: +-- * Slot: stanza Description: the term which this statement is about +-- * Slot: subject Description: The subject of the statement +-- * Slot: predicate Description: The predicate of the statement -- * Slot: object Description: Note the range of this slot is always a node. If the triple represents a literal, instead value will be populated -- * Slot: value Description: Note the range of this slot is always a string. Only used the triple represents a literal assertion --- * Slot: datatype Description: --- * Slot: language Description: +-- * Slot: datatype Description: the rdf datatype of the value, for example, xsd:string +-- * Slot: language Description: the human language in which the value is encoded, e.g. en -- # Class: "has_exact_match_statement" Description: "" --- * Slot: stanza Description: --- * Slot: subject Description: --- * Slot: predicate Description: +-- * Slot: stanza Description: the term which this statement is about +-- * Slot: subject Description: The subject of the statement +-- * Slot: predicate Description: The predicate of the statement -- * Slot: object Description: Note the range of this slot is always a node. If the triple represents a literal, instead value will be populated -- * Slot: value Description: Note the range of this slot is always a string. Only used the triple represents a literal assertion --- * Slot: datatype Description: --- * Slot: language Description: +-- * Slot: datatype Description: the rdf datatype of the value, for example, xsd:string +-- * Slot: language Description: the human language in which the value is encoded, e.g. en -- # Class: "has_broad_match_statement" Description: "" --- * Slot: stanza Description: --- * Slot: subject Description: --- * Slot: predicate Description: +-- * Slot: stanza Description: the term which this statement is about +-- * Slot: subject Description: The subject of the statement +-- * Slot: predicate Description: The predicate of the statement -- * Slot: object Description: Note the range of this slot is always a node. If the triple represents a literal, instead value will be populated -- * Slot: value Description: Note the range of this slot is always a string. Only used the triple represents a literal assertion --- * Slot: datatype Description: --- * Slot: language Description: +-- * Slot: datatype Description: the rdf datatype of the value, for example, xsd:string +-- * Slot: language Description: the human language in which the value is encoded, e.g. en -- # Class: "has_narrow_match_statement" Description: "" --- * Slot: stanza Description: --- * Slot: subject Description: --- * Slot: predicate Description: +-- * Slot: stanza Description: the term which this statement is about +-- * Slot: subject Description: The subject of the statement +-- * Slot: predicate Description: The predicate of the statement -- * Slot: object Description: Note the range of this slot is always a node. If the triple represents a literal, instead value will be populated -- * Slot: value Description: Note the range of this slot is always a string. Only used the triple represents a literal assertion --- * Slot: datatype Description: --- * Slot: language Description: +-- * Slot: datatype Description: the rdf datatype of the value, for example, xsd:string +-- * Slot: language Description: the human language in which the value is encoded, e.g. en -- # Class: "has_related_match_statement" Description: "" --- * Slot: stanza Description: --- * Slot: subject Description: --- * Slot: predicate Description: +-- * Slot: stanza Description: the term which this statement is about +-- * Slot: subject Description: The subject of the statement +-- * Slot: predicate Description: The predicate of the statement -- * Slot: object Description: Note the range of this slot is always a node. If the triple represents a literal, instead value will be populated -- * Slot: value Description: Note the range of this slot is always a string. Only used the triple represents a literal assertion --- * Slot: datatype Description: --- * Slot: language Description: +-- * Slot: datatype Description: the rdf datatype of the value, for example, xsd:string +-- * Slot: language Description: the human language in which the value is encoded, e.g. en -- # Class: "has_match_statement" Description: "" --- * Slot: stanza Description: --- * Slot: subject Description: --- * Slot: predicate Description: +-- * Slot: stanza Description: the term which this statement is about +-- * Slot: subject Description: The subject of the statement +-- * Slot: predicate Description: The predicate of the statement -- * Slot: object Description: Note the range of this slot is always a node. If the triple represents a literal, instead value will be populated -- * Slot: value Description: Note the range of this slot is always a string. Only used the triple represents a literal assertion --- * Slot: datatype Description: --- * Slot: language Description: +-- * Slot: datatype Description: the rdf datatype of the value, for example, xsd:string +-- * Slot: language Description: the human language in which the value is encoded, e.g. en -- # Class: "has_dbxref_statement" Description: "" --- * Slot: stanza Description: --- * Slot: subject Description: --- * Slot: predicate Description: +-- * Slot: stanza Description: the term which this statement is about +-- * Slot: subject Description: The subject of the statement +-- * Slot: predicate Description: The predicate of the statement -- * Slot: object Description: Note the range of this slot is always a node. If the triple represents a literal, instead value will be populated -- * Slot: value Description: Note the range of this slot is always a string. Only used the triple represents a literal assertion --- * Slot: datatype Description: --- * Slot: language Description: +-- * Slot: datatype Description: the rdf datatype of the value, for example, xsd:string +-- * Slot: language Description: the human language in which the value is encoded, e.g. en -- # Class: "has_mapping_statement" Description: "" --- * Slot: stanza Description: --- * Slot: subject Description: --- * Slot: predicate Description: +-- * Slot: stanza Description: the term which this statement is about +-- * Slot: subject Description: The subject of the statement +-- * Slot: predicate Description: The predicate of the statement -- * Slot: object Description: Note the range of this slot is always a node. If the triple represents a literal, instead value will be populated -- * Slot: value Description: Note the range of this slot is always a string. Only used the triple represents a literal assertion --- * Slot: datatype Description: --- * Slot: language Description: +-- * Slot: datatype Description: the rdf datatype of the value, for example, xsd:string +-- * Slot: language Description: the human language in which the value is encoded, e.g. en +-- # Class: "contributor" Description: "" +-- * Slot: stanza Description: the term which this statement is about +-- * Slot: subject Description: The subject of the statement +-- * Slot: predicate Description: The predicate of the statement +-- * Slot: object Description: Note the range of this slot is always a node. If the triple represents a literal, instead value will be populated +-- * Slot: value Description: Note the range of this slot is always a string. Only used the triple represents a literal assertion +-- * Slot: datatype Description: the rdf datatype of the value, for example, xsd:string +-- * Slot: language Description: the human language in which the value is encoded, e.g. en +-- # Class: "creator" Description: "" +-- * Slot: stanza Description: the term which this statement is about +-- * Slot: subject Description: The subject of the statement +-- * Slot: predicate Description: The predicate of the statement +-- * Slot: object Description: Note the range of this slot is always a node. If the triple represents a literal, instead value will be populated +-- * Slot: value Description: Note the range of this slot is always a string. Only used the triple represents a literal assertion +-- * Slot: datatype Description: the rdf datatype of the value, for example, xsd:string +-- * Slot: language Description: the human language in which the value is encoded, e.g. en +-- # Class: "orcid" Description: "" +-- * Slot: label Description: A label for an element +-- * Slot: id Description: An identifier for an element. Note blank node ids are not unique across databases -- # Class: "axiom_dbxref_annotation" Description: "" -- * Slot: annotation_subject Description: -- * Slot: annotation_predicate Description: @@ -118,18 +137,13 @@ -- * Slot: annotation_language Description: -- * Slot: annotation_datatype Description: -- * Slot: id Description: An identifier for an element. Note blank node ids are not unique across databases --- * Slot: axiom_predicate Description: --- * Slot: axiom_object Description: --- * Slot: axiom_value Description: --- * Slot: axiom_language Description: --- * Slot: axiom_datatype Description: --- * Slot: stanza Description: --- * Slot: subject Description: --- * Slot: predicate Description: +-- * Slot: stanza Description: the term which this statement is about +-- * Slot: subject Description: The subject of the statement +-- * Slot: predicate Description: The predicate of the statement -- * Slot: object Description: Note the range of this slot is always a node. If the triple represents a literal, instead value will be populated -- * Slot: value Description: Note the range of this slot is always a string. Only used the triple represents a literal assertion --- * Slot: datatype Description: --- * Slot: language Description: +-- * Slot: datatype Description: the rdf datatype of the value, for example, xsd:string +-- * Slot: language Description: the human language in which the value is encoded, e.g. en -- # Class: "ontology_node" Description: "A node representing an ontology" -- * Slot: id Description: An identifier for an element. Note blank node ids are not unique across databases -- # Class: "object_property_node" Description: "A node representing an OWL object property" @@ -149,71 +163,71 @@ -- # Class: "deprecated_node" Description: "" -- * Slot: id Description: An identifier for an element. Note blank node ids are not unique across databases -- # Class: "owl_imports_statement" Description: "" --- * Slot: stanza Description: --- * Slot: subject Description: --- * Slot: predicate Description: +-- * Slot: stanza Description: the term which this statement is about +-- * Slot: subject Description: The subject of the statement +-- * Slot: predicate Description: The predicate of the statement -- * Slot: object Description: Note the range of this slot is always a node. If the triple represents a literal, instead value will be populated -- * Slot: value Description: Note the range of this slot is always a string. Only used the triple represents a literal assertion --- * Slot: datatype Description: --- * Slot: language Description: +-- * Slot: datatype Description: the rdf datatype of the value, for example, xsd:string +-- * Slot: language Description: the human language in which the value is encoded, e.g. en -- # Class: "owl_inverse_of_statement" Description: "" --- * Slot: stanza Description: --- * Slot: subject Description: --- * Slot: predicate Description: +-- * Slot: stanza Description: the term which this statement is about +-- * Slot: subject Description: The subject of the statement +-- * Slot: predicate Description: The predicate of the statement -- * Slot: object Description: Note the range of this slot is always a node. If the triple represents a literal, instead value will be populated -- * Slot: value Description: Note the range of this slot is always a string. Only used the triple represents a literal assertion --- * Slot: datatype Description: --- * Slot: language Description: +-- * Slot: datatype Description: the rdf datatype of the value, for example, xsd:string +-- * Slot: language Description: the human language in which the value is encoded, e.g. en -- # Class: "owl_complement_of_statement" Description: "" --- * Slot: stanza Description: --- * Slot: subject Description: --- * Slot: predicate Description: +-- * Slot: stanza Description: the term which this statement is about +-- * Slot: subject Description: The subject of the statement +-- * Slot: predicate Description: The predicate of the statement -- * Slot: object Description: Note the range of this slot is always a node. If the triple represents a literal, instead value will be populated -- * Slot: value Description: Note the range of this slot is always a string. Only used the triple represents a literal assertion --- * Slot: datatype Description: --- * Slot: language Description: +-- * Slot: datatype Description: the rdf datatype of the value, for example, xsd:string +-- * Slot: language Description: the human language in which the value is encoded, e.g. en -- # Class: "owl_equivalent_class_statement" Description: "A statement that connects two class_nodes where both classes are equivalent" --- * Slot: stanza Description: +-- * Slot: stanza Description: the term which this statement is about -- * Slot: subject Description: One of the two classes that are equivalent. No significance to subject vs object --- * Slot: predicate Description: +-- * Slot: predicate Description: The predicate of the statement -- * Slot: object Description: One of the two classes that are equivalent. No significance to subject vs object -- * Slot: value Description: Note the range of this slot is always a string. Only used the triple represents a literal assertion --- * Slot: datatype Description: --- * Slot: language Description: +-- * Slot: datatype Description: the rdf datatype of the value, for example, xsd:string +-- * Slot: language Description: the human language in which the value is encoded, e.g. en -- # Class: "owl_same_as_statement" Description: "A statement that connects two individual nodes where both individual are equivalent" --- * Slot: stanza Description: +-- * Slot: stanza Description: the term which this statement is about -- * Slot: subject Description: One of the two classes that are equivalent. No significance to subject vs object --- * Slot: predicate Description: +-- * Slot: predicate Description: The predicate of the statement -- * Slot: object Description: One of the two classes that are equivalent. No significance to subject vs object -- * Slot: value Description: Note the range of this slot is always a string. Only used the triple represents a literal assertion --- * Slot: datatype Description: --- * Slot: language Description: +-- * Slot: datatype Description: the rdf datatype of the value, for example, xsd:string +-- * Slot: language Description: the human language in which the value is encoded, e.g. en -- # Class: "owl_disjoint_class_statement" Description: "" --- * Slot: stanza Description: +-- * Slot: stanza Description: the term which this statement is about -- * Slot: subject Description: One of the two classes that are disjoint. No significance to subject vs object --- * Slot: predicate Description: +-- * Slot: predicate Description: The predicate of the statement -- * Slot: object Description: One of the two classes that are disjoint. No significance to subject vs object -- * Slot: value Description: Note the range of this slot is always a string. Only used the triple represents a literal assertion --- * Slot: datatype Description: --- * Slot: language Description: +-- * Slot: datatype Description: the rdf datatype of the value, for example, xsd:string +-- * Slot: language Description: the human language in which the value is encoded, e.g. en -- # Class: "owl_reified_axiom" Description: "An OWL axiom that has been reified - i.e. it includes an [id](id) field that uniquely identifies that axiom and which can be the subject of additional statements" -- * Slot: id Description: An identifier for an element. Note blank node ids are not unique across databases --- * Slot: stanza Description: --- * Slot: subject Description: --- * Slot: predicate Description: +-- * Slot: stanza Description: the term which this statement is about +-- * Slot: subject Description: The subject of the statement +-- * Slot: predicate Description: The predicate of the statement -- * Slot: object Description: Note the range of this slot is always a node. If the triple represents a literal, instead value will be populated -- * Slot: value Description: Note the range of this slot is always a string. Only used the triple represents a literal assertion --- * Slot: datatype Description: --- * Slot: language Description: +-- * Slot: datatype Description: the rdf datatype of the value, for example, xsd:string +-- * Slot: language Description: the human language in which the value is encoded, e.g. en -- # Class: "owl_axiom" Description: "" -- * Slot: id Description: An identifier for an element. Note blank node ids are not unique across databases --- * Slot: stanza Description: --- * Slot: subject Description: --- * Slot: predicate Description: +-- * Slot: stanza Description: the term which this statement is about +-- * Slot: subject Description: The subject of the statement +-- * Slot: predicate Description: The predicate of the statement -- * Slot: object Description: Note the range of this slot is always a node. If the triple represents a literal, instead value will be populated -- * Slot: value Description: Note the range of this slot is always a string. Only used the triple represents a literal assertion --- * Slot: datatype Description: --- * Slot: language Description: +-- * Slot: datatype Description: the rdf datatype of the value, for example, xsd:string +-- * Slot: language Description: the human language in which the value is encoded, e.g. en -- # Class: "owl_axiom_annotation" Description: "" -- * Slot: annotation_subject Description: -- * Slot: annotation_predicate Description: @@ -222,18 +236,13 @@ -- * Slot: annotation_language Description: -- * Slot: annotation_datatype Description: -- * Slot: id Description: An identifier for an element. Note blank node ids are not unique across databases --- * Slot: axiom_predicate Description: --- * Slot: axiom_object Description: --- * Slot: axiom_value Description: --- * Slot: axiom_language Description: --- * Slot: axiom_datatype Description: --- * Slot: stanza Description: --- * Slot: subject Description: --- * Slot: predicate Description: +-- * Slot: stanza Description: the term which this statement is about +-- * Slot: subject Description: The subject of the statement +-- * Slot: predicate Description: The predicate of the statement -- * Slot: object Description: Note the range of this slot is always a node. If the triple represents a literal, instead value will be populated -- * Slot: value Description: Note the range of this slot is always a string. Only used the triple represents a literal assertion --- * Slot: datatype Description: --- * Slot: language Description: +-- * Slot: datatype Description: the rdf datatype of the value, for example, xsd:string +-- * Slot: language Description: the human language in which the value is encoded, e.g. en -- # Class: "anonymous_expression" Description: "An OWL expression, such as a class expression. Expressions are "anonymous" as they are a composition of named elements rather than a named element themselves" -- * Slot: id Description: An identifier for an element. Note blank node ids are not unique across databases -- # Class: "anonymous_class_expression" Description: "An OWL anonymous class expression, such as for example `SomeValuesFrom(partOf Hand)`" @@ -263,8 +272,8 @@ -- * Slot: filler Description: This is Null for a self-restriction -- * Slot: id Description: An identifier for an element. Note blank node ids are not unique across databases -- # Class: "owl_complex_axiom" Description: "An axiom that is composed of two or more statements" --- * Slot: subject Description: --- * Slot: predicate Description: +-- * Slot: subject Description: The subject of the statement +-- * Slot: predicate Description: The predicate of the statement -- * Slot: object Description: Note the range of this slot is always a node. If the triple represents a literal, instead value will be populated -- # Class: "owl_subclass_of_some_values_from" Description: "Composition of subClassOf and SomeValuesFrom" -- * Slot: subject Description: the class C in the axiom C subClassOf P some D @@ -273,130 +282,130 @@ -- # Class: "owl_equivalent_to_intersection_member" Description: "Composition of `OwlEquivalentClass`, `OwlIntersectionOf`, and `RdfListMember`; `C = X1 and ... and Xn`" -- * Slot: subject Description: the defined class -- * Slot: object Description: a class expression that forms the defining expression --- * Slot: predicate Description: +-- * Slot: predicate Description: The predicate of the statement -- # Class: "prefix" Description: "Maps CURIEs to URIs" -- * Slot: prefix Description: A standardized prefix such as 'GO' or 'rdf' or 'FlyBase' -- * Slot: base Description: The base URI a prefix will expand to -- # Class: "statements" Description: "Represents an RDF triple" --- * Slot: stanza Description: --- * Slot: subject Description: --- * Slot: predicate Description: +-- * Slot: stanza Description: the term which this statement is about +-- * Slot: subject Description: The subject of the statement +-- * Slot: predicate Description: The predicate of the statement -- * Slot: object Description: Note the range of this slot is always a node. If the triple represents a literal, instead value will be populated -- * Slot: value Description: Note the range of this slot is always a string. Only used the triple represents a literal assertion --- * Slot: datatype Description: --- * Slot: language Description: +-- * Slot: datatype Description: the rdf datatype of the value, for example, xsd:string +-- * Slot: language Description: the human language in which the value is encoded, e.g. en -- # Class: "node_to_node_statement" Description: "A statement where object is non-null and value is not populated" --- * Slot: stanza Description: --- * Slot: subject Description: --- * Slot: predicate Description: +-- * Slot: stanza Description: the term which this statement is about +-- * Slot: subject Description: The subject of the statement +-- * Slot: predicate Description: The predicate of the statement -- * Slot: object Description: Note the range of this slot is always a node. If the triple represents a literal, instead value will be populated -- * Slot: value Description: Note the range of this slot is always a string. Only used the triple represents a literal assertion --- * Slot: datatype Description: --- * Slot: language Description: +-- * Slot: datatype Description: the rdf datatype of the value, for example, xsd:string +-- * Slot: language Description: the human language in which the value is encoded, e.g. en -- # Class: "node_to_value_statement" Description: "A statement where value is non-null and object is not populated" --- * Slot: stanza Description: --- * Slot: subject Description: --- * Slot: predicate Description: +-- * Slot: stanza Description: the term which this statement is about +-- * Slot: subject Description: The subject of the statement +-- * Slot: predicate Description: The predicate of the statement -- * Slot: object Description: Note the range of this slot is always a node. If the triple represents a literal, instead value will be populated -- * Slot: value Description: Note the range of this slot is always a string. Only used the triple represents a literal assertion --- * Slot: datatype Description: --- * Slot: language Description: +-- * Slot: datatype Description: the rdf datatype of the value, for example, xsd:string +-- * Slot: language Description: the human language in which the value is encoded, e.g. en -- # Class: "rdf_type_statement" Description: "A statement that indicates the asserted type of the subject entity" --- * Slot: stanza Description: --- * Slot: subject Description: --- * Slot: predicate Description: +-- * Slot: stanza Description: the term which this statement is about +-- * Slot: subject Description: The subject of the statement +-- * Slot: predicate Description: The predicate of the statement -- * Slot: object Description: The entity type -- * Slot: value Description: Note the range of this slot is always a string. Only used the triple represents a literal assertion --- * Slot: datatype Description: --- * Slot: language Description: +-- * Slot: datatype Description: the rdf datatype of the value, for example, xsd:string +-- * Slot: language Description: the human language in which the value is encoded, e.g. en -- # Class: "rdfs_subclass_of_statement" Description: "" --- * Slot: stanza Description: +-- * Slot: stanza Description: the term which this statement is about -- * Slot: subject Description: The subclass element of the triple --- * Slot: predicate Description: +-- * Slot: predicate Description: The predicate of the statement -- * Slot: object Description: The superclass element of the triple -- * Slot: value Description: Note the range of this slot is always a string. Only used the triple represents a literal assertion --- * Slot: datatype Description: --- * Slot: language Description: +-- * Slot: datatype Description: the rdf datatype of the value, for example, xsd:string +-- * Slot: language Description: the human language in which the value is encoded, e.g. en -- # Class: "rdfs_subclass_of_named_statement" Description: "" --- * Slot: stanza Description: --- * Slot: subject Description: --- * Slot: predicate Description: +-- * Slot: stanza Description: the term which this statement is about +-- * Slot: subject Description: The subject of the statement +-- * Slot: predicate Description: The predicate of the statement -- * Slot: object Description: Note the range of this slot is always a node. If the triple represents a literal, instead value will be populated -- * Slot: value Description: Note the range of this slot is always a string. Only used the triple represents a literal assertion --- * Slot: datatype Description: --- * Slot: language Description: +-- * Slot: datatype Description: the rdf datatype of the value, for example, xsd:string +-- * Slot: language Description: the human language in which the value is encoded, e.g. en -- # Class: "rdfs_subproperty_of_statement" Description: "" --- * Slot: stanza Description: +-- * Slot: stanza Description: the term which this statement is about -- * Slot: subject Description: The subproperty element of the triple --- * Slot: predicate Description: +-- * Slot: predicate Description: The predicate of the statement -- * Slot: object Description: The superproperty element of the triple -- * Slot: value Description: Note the range of this slot is always a string. Only used the triple represents a literal assertion --- * Slot: datatype Description: --- * Slot: language Description: +-- * Slot: datatype Description: the rdf datatype of the value, for example, xsd:string +-- * Slot: language Description: the human language in which the value is encoded, e.g. en -- # Class: "rdfs_label_statement" Description: "" --- * Slot: stanza Description: --- * Slot: subject Description: --- * Slot: predicate Description: +-- * Slot: stanza Description: the term which this statement is about +-- * Slot: subject Description: The subject of the statement +-- * Slot: predicate Description: The predicate of the statement -- * Slot: object Description: Note the range of this slot is always a node. If the triple represents a literal, instead value will be populated -- * Slot: value Description: The label value --- * Slot: datatype Description: --- * Slot: language Description: +-- * Slot: datatype Description: the rdf datatype of the value, for example, xsd:string +-- * Slot: language Description: the human language in which the value is encoded, e.g. en -- # Class: "rdfs_domain_statement" Description: "" --- * Slot: stanza Description: --- * Slot: subject Description: --- * Slot: predicate Description: +-- * Slot: stanza Description: the term which this statement is about +-- * Slot: subject Description: The subject of the statement +-- * Slot: predicate Description: The predicate of the statement -- * Slot: object Description: Note the range of this slot is always a node. If the triple represents a literal, instead value will be populated -- * Slot: value Description: Note the range of this slot is always a string. Only used the triple represents a literal assertion --- * Slot: datatype Description: --- * Slot: language Description: +-- * Slot: datatype Description: the rdf datatype of the value, for example, xsd:string +-- * Slot: language Description: the human language in which the value is encoded, e.g. en -- # Class: "rdfs_range_statement" Description: "" --- * Slot: stanza Description: --- * Slot: subject Description: --- * Slot: predicate Description: +-- * Slot: stanza Description: the term which this statement is about +-- * Slot: subject Description: The subject of the statement +-- * Slot: predicate Description: The predicate of the statement -- * Slot: object Description: Note the range of this slot is always a node. If the triple represents a literal, instead value will be populated -- * Slot: value Description: Note the range of this slot is always a string. Only used the triple represents a literal assertion --- * Slot: datatype Description: --- * Slot: language Description: +-- * Slot: datatype Description: the rdf datatype of the value, for example, xsd:string +-- * Slot: language Description: the human language in which the value is encoded, e.g. en -- # Class: "rdf_list_statement" Description: "A statement that is used to represent aspects of RDF lists" --- * Slot: stanza Description: +-- * Slot: stanza Description: the term which this statement is about -- * Slot: subject Description: The rdf:List to which the statement applies --- * Slot: predicate Description: +-- * Slot: predicate Description: The predicate of the statement -- * Slot: object Description: Note the range of this slot is always a node. If the triple represents a literal, instead value will be populated -- * Slot: value Description: Note the range of this slot is always a string. Only used the triple represents a literal assertion --- * Slot: datatype Description: --- * Slot: language Description: +-- * Slot: datatype Description: the rdf datatype of the value, for example, xsd:string +-- * Slot: language Description: the human language in which the value is encoded, e.g. en -- # Class: "rdf_first_statement" Description: "A statement that connects a list to its first element. This is a low-level triple, it is unlikely you need to use this directly. It is used to define rdf_list_member_statement, which is more useful" --- * Slot: stanza Description: --- * Slot: subject Description: --- * Slot: predicate Description: +-- * Slot: stanza Description: the term which this statement is about +-- * Slot: subject Description: The subject of the statement +-- * Slot: predicate Description: The predicate of the statement -- * Slot: object Description: Note the range of this slot is always a node. If the triple represents a literal, instead value will be populated -- * Slot: value Description: Note the range of this slot is always a string. Only used the triple represents a literal assertion --- * Slot: datatype Description: --- * Slot: language Description: +-- * Slot: datatype Description: the rdf datatype of the value, for example, xsd:string +-- * Slot: language Description: the human language in which the value is encoded, e.g. en -- # Class: "rdf_rest_statement" Description: "A statement that connects a list to its remaining elements. This is a low-level triple, it is unlikely you need to use this directly. It is used to define rdf_list_member_statement, which is more useful" --- * Slot: stanza Description: --- * Slot: subject Description: --- * Slot: predicate Description: +-- * Slot: stanza Description: the term which this statement is about +-- * Slot: subject Description: The subject of the statement +-- * Slot: predicate Description: The predicate of the statement -- * Slot: object Description: Note the range of this slot is always a node. If the triple represents a literal, instead value will be populated -- * Slot: value Description: Note the range of this slot is always a string. Only used the triple represents a literal assertion --- * Slot: datatype Description: --- * Slot: language Description: +-- * Slot: datatype Description: the rdf datatype of the value, for example, xsd:string +-- * Slot: language Description: the human language in which the value is encoded, e.g. en -- # Class: "rdf_rest_transitive_statement" Description: "" --- * Slot: stanza Description: --- * Slot: subject Description: --- * Slot: predicate Description: +-- * Slot: stanza Description: the term which this statement is about +-- * Slot: subject Description: The subject of the statement +-- * Slot: predicate Description: The predicate of the statement -- * Slot: object Description: Note the range of this slot is always a node. If the triple represents a literal, instead value will be populated -- * Slot: value Description: Note the range of this slot is always a string. Only used the triple represents a literal assertion --- * Slot: datatype Description: --- * Slot: language Description: +-- * Slot: datatype Description: the rdf datatype of the value, for example, xsd:string +-- * Slot: language Description: the human language in which the value is encoded, e.g. en -- # Class: "rdf_list_member_statement" Description: "" --- * Slot: stanza Description: --- * Slot: subject Description: --- * Slot: predicate Description: +-- * Slot: stanza Description: the term which this statement is about +-- * Slot: subject Description: The subject of the statement +-- * Slot: predicate Description: The predicate of the statement -- * Slot: object Description: Note the range of this slot is always a node. If the triple represents a literal, instead value will be populated -- * Slot: value Description: Note the range of this slot is always a string. Only used the triple represents a literal assertion --- * Slot: datatype Description: --- * Slot: language Description: +-- * Slot: datatype Description: the rdf datatype of the value, for example, xsd:string +-- * Slot: language Description: the human language in which the value is encoded, e.g. en -- # Class: "node" Description: "The basic unit of representation in an RDF or OWL graph" -- * Slot: id Description: An identifier for an element. Note blank node ids are not unique across databases -- # Class: "blank_node" Description: "A node with an ID that is not preserved between databases" @@ -555,6 +564,29 @@ CREATE TABLE has_mapping_statement ( datatype TEXT, language TEXT ); +CREATE TABLE contributor ( + stanza TEXT, + subject TEXT, + predicate TEXT, + object TEXT NOT NULL, + value TEXT, + datatype TEXT, + language TEXT +); +CREATE TABLE creator ( + stanza TEXT, + subject TEXT, + predicate TEXT, + object TEXT NOT NULL, + value TEXT, + datatype TEXT, + language TEXT +); +CREATE TABLE orcid ( + label TEXT, + id TEXT, + PRIMARY KEY (id) +); CREATE TABLE axiom_dbxref_annotation ( annotation_subject TEXT, annotation_predicate TEXT, @@ -563,11 +595,6 @@ CREATE TABLE axiom_dbxref_annotation ( annotation_language TEXT, annotation_datatype TEXT, id TEXT, - axiom_predicate TEXT, - axiom_object TEXT, - axiom_value TEXT, - axiom_language TEXT, - axiom_datatype TEXT, stanza TEXT, subject TEXT, predicate TEXT, @@ -697,11 +724,6 @@ CREATE TABLE owl_axiom_annotation ( annotation_language TEXT, annotation_datatype TEXT, id TEXT, - axiom_predicate TEXT, - axiom_object TEXT, - axiom_value TEXT, - axiom_language TEXT, - axiom_datatype TEXT, stanza TEXT, subject TEXT, predicate TEXT, @@ -955,8 +977,6 @@ CREATE TABLE count_of_subclasses ( element TEXT, count_value INTEGER ); --- ** REWRITE TABLES AS VIEWS ** --- SCHEMA: https://w3id.org/semsql/omo DROP TABLE has_text_definition_statement; CREATE VIEW has_text_definition_statement AS SELECT * FROM statements WHERE predicate='IAO:0000115'; @@ -997,96 +1017,22 @@ CREATE VIEW has_dbxref_statement AS SELECT * FROM statements WHERE predicate='oi DROP TABLE has_mapping_statement; CREATE VIEW has_mapping_statement AS SELECT * FROM has_match_statement UNION SELECT * FROM has_dbxref_statement; -DROP TABLE axiom_dbxref_annotation; -CREATE VIEW axiom_dbxref_annotation AS SELECT * FROM owl_axiom_annotation WHERE annotation_predicate = 'oio:hasDbXref'; - -DROP TABLE node_to_node_statement; -CREATE VIEW node_to_node_statement AS SELECT * FROM statements WHERE object IS NOT NULL; - -DROP TABLE node_to_value_statement; -CREATE VIEW node_to_value_statement AS SELECT * FROM statements WHERE value IS NOT NULL; - -DROP TABLE rdf_type_statement; -CREATE VIEW rdf_type_statement AS SELECT * FROM statements WHERE predicate='rdf:type'; - -DROP TABLE rdfs_subclass_of_statement; -CREATE VIEW rdfs_subclass_of_statement AS SELECT * FROM statements WHERE predicate='rdfs:subClassOf'; - -DROP TABLE rdfs_subclass_of_named_statement; -CREATE VIEW rdfs_subclass_of_named_statement AS SELECT * FROM rdfs_subclass_of_statement WHERE object NOT LIKE '_:%'; - -DROP TABLE rdfs_subproperty_of_statement; -CREATE VIEW rdfs_subproperty_of_statement AS SELECT * FROM statements WHERE predicate='rdfs:subPropertyOf'; - -DROP TABLE rdfs_label_statement; -CREATE VIEW rdfs_label_statement AS SELECT * FROM statements WHERE predicate='rdfs:label'; - -DROP TABLE rdfs_domain_statement; -CREATE VIEW rdfs_domain_statement AS SELECT * FROM statements WHERE predicate='rdfs:domain'; - -DROP TABLE rdfs_range_statement; -CREATE VIEW rdfs_range_statement AS SELECT * FROM statements WHERE predicate='rdfs:range'; - -DROP TABLE rdf_first_statement; -CREATE VIEW rdf_first_statement AS SELECT * FROM statements WHERE predicate='rdf:first'; - -DROP TABLE rdf_rest_statement; -CREATE VIEW rdf_rest_statement AS SELECT * FROM statements WHERE predicate='rdf:rest'; - -DROP TABLE rdf_rest_transitive_statement; -CREATE VIEW rdf_rest_transitive_statement AS WITH RECURSIVE rdf_rest_transitive_statement - ( - subject, object - ) - AS - (SELECT subject, object - FROM rdf_rest_statement - UNION ALL - SELECT - rest.subject, rest_t.object - FROM rdf_rest_statement AS rest - JOIN rdf_rest_transitive_statement AS rest_t - ON rest.object = rest_t.subject - ) - SELECT * FROM rdf_rest_transitive_statement; - -DROP TABLE rdf_list_member_statement; -CREATE VIEW rdf_list_member_statement AS SELECT - rest_t.subject, - f.object - FROM rdf_rest_transitive_statement AS rest_t JOIN rdf_first_statement AS f ON (rest_t.object = f.subject) - UNION - SELECT subject,object FROM rdf_first_statement; - -DROP TABLE node; -CREATE VIEW node AS SELECT distinct(subject) AS id FROM statements UNION SELECT distinct(object) AS id FROM statements WHERE datatype IS NOT NULL; - -DROP TABLE blank_node; -CREATE VIEW blank_node AS SELECT * FROM node WHERE id LIKE '_:%'; - -DROP TABLE rdf_list_node; -CREATE VIEW rdf_list_node AS SELECT distinct subject AS id from rdf_type_statement WHERE object = 'rdf:List'; - -DROP TABLE iri_node; -CREATE VIEW iri_node AS SELECT * FROM node WHERE id NOT LIKE '_:%'; - -DROP TABLE class_node; -CREATE VIEW class_node AS SELECT distinct subject AS id from rdf_type_statement WHERE object = 'owl:Class'; - -DROP TABLE property_node; -CREATE VIEW property_node AS SELECT distinct subject AS id from rdf_type_statement WHERE object = 'owl:Property'; - -DROP TABLE named_individual_node; -CREATE VIEW named_individual_node AS SELECT distinct subject AS id from rdf_type_statement WHERE object = 'owl:NamedIndividual'; +DROP TABLE contributor; +CREATE VIEW contributor AS SELECT * FROM statements WHERE predicate='dcterms:contributor'; -DROP TABLE count_of_predicates; -CREATE VIEW count_of_predicates AS SELECT predicate AS element, count(*) AS count_value FROM statements GROUP BY predicate ORDER BY count_value DESC; +DROP TABLE creator; +CREATE VIEW creator AS SELECT * FROM statements WHERE predicate='dcterms:creator'; -DROP TABLE count_of_instantiated_classes; -CREATE VIEW count_of_instantiated_classes AS SELECT object AS element, count(*) AS count_value FROM rdf_type_statement GROUP BY element ORDER BY count_value DESC; +DROP TABLE orcid; +CREATE VIEW orcid AS SELECT + subject AS id, + value AS label + FROM + rdfs_label_statement + WHERE subject like 'orcid:%'; -DROP TABLE count_of_subclasses; -CREATE VIEW count_of_subclasses AS SELECT sc.object AS element, count(distinct sc.subject) AS count_value FROM rdfs_subclass_of_statement AS sc GROUP BY sc.object ORDER BY count_value DESC; +DROP TABLE axiom_dbxref_annotation; +CREATE VIEW axiom_dbxref_annotation AS SELECT * FROM owl_axiom_annotation WHERE annotation_predicate = 'oio:hasDbXref'; DROP TABLE ontology_node; CREATE VIEW ontology_node AS SELECT DISTINCT subject AS id FROM rdf_type_statement WHERE object='owl:Ontology'; @@ -1131,7 +1077,7 @@ DROP TABLE owl_same_as_statement; CREATE VIEW owl_same_as_statement AS SELECT * FROM statements WHERE predicate='owl:sameAs'; DROP TABLE owl_disjoint_class_statement; -CREATE VIEW owl_disjoint_class_statement AS SELECT * FROM statements WHERE predicate='owl:disjointClass'; +CREATE VIEW owl_disjoint_class_statement AS SELECT * FROM statements WHERE predicate='owl:disjointWith'; DROP TABLE owl_reified_axiom; CREATE VIEW owl_reified_axiom AS SELECT axs.subject AS id, axs.stanza AS stanza, axs.object AS subject, axp.object AS predicate, axo.object AS object, axo.value AS value, axo.datatype AS datatype, axo.language AS language FROM statements AS axs, statements AS axp, statements AS axo WHERE axs.predicate = 'owl:annotatedSource' AND axp.predicate = 'owl:annotatedProperty' AND axo.predicate = 'owl:annotatedTarget' AND axs.subject = axp.subject AND axs.subject = axo.subject; @@ -1239,3 +1185,91 @@ CREATE VIEW owl_equivalent_to_intersection_member AS SELECT e.stanza, rdf_list_member_statement AS m ON (i.object=m.subject) WHERE i.predicate = 'owl:intersectionOf'; + +DROP TABLE node_to_node_statement; +CREATE VIEW node_to_node_statement AS SELECT * FROM statements WHERE object IS NOT NULL; + +DROP TABLE node_to_value_statement; +CREATE VIEW node_to_value_statement AS SELECT * FROM statements WHERE value IS NOT NULL; + +DROP TABLE rdf_type_statement; +CREATE VIEW rdf_type_statement AS SELECT * FROM statements WHERE predicate='rdf:type'; + +DROP TABLE rdfs_subclass_of_statement; +CREATE VIEW rdfs_subclass_of_statement AS SELECT * FROM statements WHERE predicate='rdfs:subClassOf'; + +DROP TABLE rdfs_subclass_of_named_statement; +CREATE VIEW rdfs_subclass_of_named_statement AS SELECT * FROM rdfs_subclass_of_statement WHERE object NOT LIKE '_:%'; + +DROP TABLE rdfs_subproperty_of_statement; +CREATE VIEW rdfs_subproperty_of_statement AS SELECT * FROM statements WHERE predicate='rdfs:subPropertyOf'; + +DROP TABLE rdfs_label_statement; +CREATE VIEW rdfs_label_statement AS SELECT * FROM statements WHERE predicate='rdfs:label'; + +DROP TABLE rdfs_domain_statement; +CREATE VIEW rdfs_domain_statement AS SELECT * FROM statements WHERE predicate='rdfs:domain'; + +DROP TABLE rdfs_range_statement; +CREATE VIEW rdfs_range_statement AS SELECT * FROM statements WHERE predicate='rdfs:range'; + +DROP TABLE rdf_first_statement; +CREATE VIEW rdf_first_statement AS SELECT * FROM statements WHERE predicate='rdf:first'; + +DROP TABLE rdf_rest_statement; +CREATE VIEW rdf_rest_statement AS SELECT * FROM statements WHERE predicate='rdf:rest'; + +DROP TABLE rdf_rest_transitive_statement; +CREATE VIEW rdf_rest_transitive_statement AS WITH RECURSIVE rdf_rest_transitive_statement + ( + subject, object + ) + AS + (SELECT subject, object + FROM rdf_rest_statement + UNION ALL + SELECT + rest.subject, rest_t.object + FROM rdf_rest_statement AS rest + JOIN rdf_rest_transitive_statement AS rest_t + ON rest.object = rest_t.subject + ) + SELECT * FROM rdf_rest_transitive_statement; + +DROP TABLE rdf_list_member_statement; +CREATE VIEW rdf_list_member_statement AS SELECT + rest_t.subject, + f.object + FROM rdf_rest_transitive_statement AS rest_t JOIN rdf_first_statement AS f ON (rest_t.object = f.subject) + UNION + SELECT subject,object FROM rdf_first_statement; + +DROP TABLE node; +CREATE VIEW node AS SELECT distinct(subject) AS id FROM statements UNION SELECT distinct(object) AS id FROM statements WHERE datatype IS NOT NULL; + +DROP TABLE blank_node; +CREATE VIEW blank_node AS SELECT * FROM node WHERE id LIKE '_:%'; + +DROP TABLE rdf_list_node; +CREATE VIEW rdf_list_node AS SELECT distinct subject AS id from rdf_type_statement WHERE object = 'rdf:List'; + +DROP TABLE iri_node; +CREATE VIEW iri_node AS SELECT * FROM node WHERE id NOT LIKE '_:%'; + +DROP TABLE class_node; +CREATE VIEW class_node AS SELECT distinct subject AS id from rdf_type_statement WHERE object = 'owl:Class'; + +DROP TABLE property_node; +CREATE VIEW property_node AS SELECT distinct subject AS id from rdf_type_statement WHERE object = 'owl:Property'; + +DROP TABLE named_individual_node; +CREATE VIEW named_individual_node AS SELECT distinct subject AS id from rdf_type_statement WHERE object = 'owl:NamedIndividual'; + +DROP TABLE count_of_predicates; +CREATE VIEW count_of_predicates AS SELECT predicate AS element, count(*) AS count_value FROM statements GROUP BY predicate ORDER BY count_value DESC; + +DROP TABLE count_of_instantiated_classes; +CREATE VIEW count_of_instantiated_classes AS SELECT object AS element, count(*) AS count_value FROM rdf_type_statement GROUP BY element ORDER BY count_value DESC; + +DROP TABLE count_of_subclasses; +CREATE VIEW count_of_subclasses AS SELECT sc.object AS element, count(distinct sc.subject) AS count_value FROM rdfs_subclass_of_statement AS sc GROUP BY sc.object ORDER BY count_value DESC; diff --git a/src/semsql/builder/sql_schema/owl.sql b/src/semsql/builder/sql_schema/owl.sql index f4da11e..d24d5a3 100644 --- a/src/semsql/builder/sql_schema/owl.sql +++ b/src/semsql/builder/sql_schema/owl.sql @@ -17,71 +17,71 @@ -- # Class: "deprecated_node" Description: "" -- * Slot: id Description: An identifier for an element. Note blank node ids are not unique across databases -- # Class: "owl_imports_statement" Description: "" --- * Slot: stanza Description: --- * Slot: subject Description: --- * Slot: predicate Description: +-- * Slot: stanza Description: the term which this statement is about +-- * Slot: subject Description: The subject of the statement +-- * Slot: predicate Description: The predicate of the statement -- * Slot: object Description: Note the range of this slot is always a node. If the triple represents a literal, instead value will be populated -- * Slot: value Description: Note the range of this slot is always a string. Only used the triple represents a literal assertion --- * Slot: datatype Description: --- * Slot: language Description: +-- * Slot: datatype Description: the rdf datatype of the value, for example, xsd:string +-- * Slot: language Description: the human language in which the value is encoded, e.g. en -- # Class: "owl_inverse_of_statement" Description: "" --- * Slot: stanza Description: --- * Slot: subject Description: --- * Slot: predicate Description: +-- * Slot: stanza Description: the term which this statement is about +-- * Slot: subject Description: The subject of the statement +-- * Slot: predicate Description: The predicate of the statement -- * Slot: object Description: Note the range of this slot is always a node. If the triple represents a literal, instead value will be populated -- * Slot: value Description: Note the range of this slot is always a string. Only used the triple represents a literal assertion --- * Slot: datatype Description: --- * Slot: language Description: +-- * Slot: datatype Description: the rdf datatype of the value, for example, xsd:string +-- * Slot: language Description: the human language in which the value is encoded, e.g. en -- # Class: "owl_complement_of_statement" Description: "" --- * Slot: stanza Description: --- * Slot: subject Description: --- * Slot: predicate Description: +-- * Slot: stanza Description: the term which this statement is about +-- * Slot: subject Description: The subject of the statement +-- * Slot: predicate Description: The predicate of the statement -- * Slot: object Description: Note the range of this slot is always a node. If the triple represents a literal, instead value will be populated -- * Slot: value Description: Note the range of this slot is always a string. Only used the triple represents a literal assertion --- * Slot: datatype Description: --- * Slot: language Description: +-- * Slot: datatype Description: the rdf datatype of the value, for example, xsd:string +-- * Slot: language Description: the human language in which the value is encoded, e.g. en -- # Class: "owl_equivalent_class_statement" Description: "A statement that connects two class_nodes where both classes are equivalent" --- * Slot: stanza Description: +-- * Slot: stanza Description: the term which this statement is about -- * Slot: subject Description: One of the two classes that are equivalent. No significance to subject vs object --- * Slot: predicate Description: +-- * Slot: predicate Description: The predicate of the statement -- * Slot: object Description: One of the two classes that are equivalent. No significance to subject vs object -- * Slot: value Description: Note the range of this slot is always a string. Only used the triple represents a literal assertion --- * Slot: datatype Description: --- * Slot: language Description: +-- * Slot: datatype Description: the rdf datatype of the value, for example, xsd:string +-- * Slot: language Description: the human language in which the value is encoded, e.g. en -- # Class: "owl_same_as_statement" Description: "A statement that connects two individual nodes where both individual are equivalent" --- * Slot: stanza Description: +-- * Slot: stanza Description: the term which this statement is about -- * Slot: subject Description: One of the two classes that are equivalent. No significance to subject vs object --- * Slot: predicate Description: +-- * Slot: predicate Description: The predicate of the statement -- * Slot: object Description: One of the two classes that are equivalent. No significance to subject vs object -- * Slot: value Description: Note the range of this slot is always a string. Only used the triple represents a literal assertion --- * Slot: datatype Description: --- * Slot: language Description: +-- * Slot: datatype Description: the rdf datatype of the value, for example, xsd:string +-- * Slot: language Description: the human language in which the value is encoded, e.g. en -- # Class: "owl_disjoint_class_statement" Description: "" --- * Slot: stanza Description: +-- * Slot: stanza Description: the term which this statement is about -- * Slot: subject Description: One of the two classes that are disjoint. No significance to subject vs object --- * Slot: predicate Description: +-- * Slot: predicate Description: The predicate of the statement -- * Slot: object Description: One of the two classes that are disjoint. No significance to subject vs object -- * Slot: value Description: Note the range of this slot is always a string. Only used the triple represents a literal assertion --- * Slot: datatype Description: --- * Slot: language Description: +-- * Slot: datatype Description: the rdf datatype of the value, for example, xsd:string +-- * Slot: language Description: the human language in which the value is encoded, e.g. en -- # Class: "owl_reified_axiom" Description: "An OWL axiom that has been reified - i.e. it includes an [id](id) field that uniquely identifies that axiom and which can be the subject of additional statements" -- * Slot: id Description: An identifier for an element. Note blank node ids are not unique across databases --- * Slot: stanza Description: --- * Slot: subject Description: --- * Slot: predicate Description: +-- * Slot: stanza Description: the term which this statement is about +-- * Slot: subject Description: The subject of the statement +-- * Slot: predicate Description: The predicate of the statement -- * Slot: object Description: Note the range of this slot is always a node. If the triple represents a literal, instead value will be populated -- * Slot: value Description: Note the range of this slot is always a string. Only used the triple represents a literal assertion --- * Slot: datatype Description: --- * Slot: language Description: +-- * Slot: datatype Description: the rdf datatype of the value, for example, xsd:string +-- * Slot: language Description: the human language in which the value is encoded, e.g. en -- # Class: "owl_axiom" Description: "" -- * Slot: id Description: An identifier for an element. Note blank node ids are not unique across databases --- * Slot: stanza Description: --- * Slot: subject Description: --- * Slot: predicate Description: +-- * Slot: stanza Description: the term which this statement is about +-- * Slot: subject Description: The subject of the statement +-- * Slot: predicate Description: The predicate of the statement -- * Slot: object Description: Note the range of this slot is always a node. If the triple represents a literal, instead value will be populated -- * Slot: value Description: Note the range of this slot is always a string. Only used the triple represents a literal assertion --- * Slot: datatype Description: --- * Slot: language Description: +-- * Slot: datatype Description: the rdf datatype of the value, for example, xsd:string +-- * Slot: language Description: the human language in which the value is encoded, e.g. en -- # Class: "owl_axiom_annotation" Description: "" -- * Slot: annotation_subject Description: -- * Slot: annotation_predicate Description: @@ -90,13 +90,13 @@ -- * Slot: annotation_language Description: -- * Slot: annotation_datatype Description: -- * Slot: id Description: An identifier for an element. Note blank node ids are not unique across databases --- * Slot: stanza Description: --- * Slot: subject Description: --- * Slot: predicate Description: +-- * Slot: stanza Description: the term which this statement is about +-- * Slot: subject Description: The subject of the statement +-- * Slot: predicate Description: The predicate of the statement -- * Slot: object Description: Note the range of this slot is always a node. If the triple represents a literal, instead value will be populated -- * Slot: value Description: Note the range of this slot is always a string. Only used the triple represents a literal assertion --- * Slot: datatype Description: --- * Slot: language Description: +-- * Slot: datatype Description: the rdf datatype of the value, for example, xsd:string +-- * Slot: language Description: the human language in which the value is encoded, e.g. en -- # Class: "anonymous_expression" Description: "An OWL expression, such as a class expression. Expressions are "anonymous" as they are a composition of named elements rather than a named element themselves" -- * Slot: id Description: An identifier for an element. Note blank node ids are not unique across databases -- # Class: "anonymous_class_expression" Description: "An OWL anonymous class expression, such as for example `SomeValuesFrom(partOf Hand)`" @@ -126,8 +126,8 @@ -- * Slot: filler Description: This is Null for a self-restriction -- * Slot: id Description: An identifier for an element. Note blank node ids are not unique across databases -- # Class: "owl_complex_axiom" Description: "An axiom that is composed of two or more statements" --- * Slot: subject Description: --- * Slot: predicate Description: +-- * Slot: subject Description: The subject of the statement +-- * Slot: predicate Description: The predicate of the statement -- * Slot: object Description: Note the range of this slot is always a node. If the triple represents a literal, instead value will be populated -- # Class: "owl_subclass_of_some_values_from" Description: "Composition of subClassOf and SomeValuesFrom" -- * Slot: subject Description: the class C in the axiom C subClassOf P some D @@ -136,130 +136,130 @@ -- # Class: "owl_equivalent_to_intersection_member" Description: "Composition of `OwlEquivalentClass`, `OwlIntersectionOf`, and `RdfListMember`; `C = X1 and ... and Xn`" -- * Slot: subject Description: the defined class -- * Slot: object Description: a class expression that forms the defining expression --- * Slot: predicate Description: +-- * Slot: predicate Description: The predicate of the statement -- # Class: "prefix" Description: "Maps CURIEs to URIs" -- * Slot: prefix Description: A standardized prefix such as 'GO' or 'rdf' or 'FlyBase' -- * Slot: base Description: The base URI a prefix will expand to -- # Class: "statements" Description: "Represents an RDF triple" --- * Slot: stanza Description: --- * Slot: subject Description: --- * Slot: predicate Description: +-- * Slot: stanza Description: the term which this statement is about +-- * Slot: subject Description: The subject of the statement +-- * Slot: predicate Description: The predicate of the statement -- * Slot: object Description: Note the range of this slot is always a node. If the triple represents a literal, instead value will be populated -- * Slot: value Description: Note the range of this slot is always a string. Only used the triple represents a literal assertion --- * Slot: datatype Description: --- * Slot: language Description: +-- * Slot: datatype Description: the rdf datatype of the value, for example, xsd:string +-- * Slot: language Description: the human language in which the value is encoded, e.g. en -- # Class: "node_to_node_statement" Description: "A statement where object is non-null and value is not populated" --- * Slot: stanza Description: --- * Slot: subject Description: --- * Slot: predicate Description: +-- * Slot: stanza Description: the term which this statement is about +-- * Slot: subject Description: The subject of the statement +-- * Slot: predicate Description: The predicate of the statement -- * Slot: object Description: Note the range of this slot is always a node. If the triple represents a literal, instead value will be populated -- * Slot: value Description: Note the range of this slot is always a string. Only used the triple represents a literal assertion --- * Slot: datatype Description: --- * Slot: language Description: +-- * Slot: datatype Description: the rdf datatype of the value, for example, xsd:string +-- * Slot: language Description: the human language in which the value is encoded, e.g. en -- # Class: "node_to_value_statement" Description: "A statement where value is non-null and object is not populated" --- * Slot: stanza Description: --- * Slot: subject Description: --- * Slot: predicate Description: +-- * Slot: stanza Description: the term which this statement is about +-- * Slot: subject Description: The subject of the statement +-- * Slot: predicate Description: The predicate of the statement -- * Slot: object Description: Note the range of this slot is always a node. If the triple represents a literal, instead value will be populated -- * Slot: value Description: Note the range of this slot is always a string. Only used the triple represents a literal assertion --- * Slot: datatype Description: --- * Slot: language Description: +-- * Slot: datatype Description: the rdf datatype of the value, for example, xsd:string +-- * Slot: language Description: the human language in which the value is encoded, e.g. en -- # Class: "rdf_type_statement" Description: "A statement that indicates the asserted type of the subject entity" --- * Slot: stanza Description: --- * Slot: subject Description: --- * Slot: predicate Description: +-- * Slot: stanza Description: the term which this statement is about +-- * Slot: subject Description: The subject of the statement +-- * Slot: predicate Description: The predicate of the statement -- * Slot: object Description: The entity type -- * Slot: value Description: Note the range of this slot is always a string. Only used the triple represents a literal assertion --- * Slot: datatype Description: --- * Slot: language Description: +-- * Slot: datatype Description: the rdf datatype of the value, for example, xsd:string +-- * Slot: language Description: the human language in which the value is encoded, e.g. en -- # Class: "rdfs_subclass_of_statement" Description: "" --- * Slot: stanza Description: +-- * Slot: stanza Description: the term which this statement is about -- * Slot: subject Description: The subclass element of the triple --- * Slot: predicate Description: +-- * Slot: predicate Description: The predicate of the statement -- * Slot: object Description: The superclass element of the triple -- * Slot: value Description: Note the range of this slot is always a string. Only used the triple represents a literal assertion --- * Slot: datatype Description: --- * Slot: language Description: +-- * Slot: datatype Description: the rdf datatype of the value, for example, xsd:string +-- * Slot: language Description: the human language in which the value is encoded, e.g. en -- # Class: "rdfs_subclass_of_named_statement" Description: "" --- * Slot: stanza Description: --- * Slot: subject Description: --- * Slot: predicate Description: +-- * Slot: stanza Description: the term which this statement is about +-- * Slot: subject Description: The subject of the statement +-- * Slot: predicate Description: The predicate of the statement -- * Slot: object Description: Note the range of this slot is always a node. If the triple represents a literal, instead value will be populated -- * Slot: value Description: Note the range of this slot is always a string. Only used the triple represents a literal assertion --- * Slot: datatype Description: --- * Slot: language Description: +-- * Slot: datatype Description: the rdf datatype of the value, for example, xsd:string +-- * Slot: language Description: the human language in which the value is encoded, e.g. en -- # Class: "rdfs_subproperty_of_statement" Description: "" --- * Slot: stanza Description: +-- * Slot: stanza Description: the term which this statement is about -- * Slot: subject Description: The subproperty element of the triple --- * Slot: predicate Description: +-- * Slot: predicate Description: The predicate of the statement -- * Slot: object Description: The superproperty element of the triple -- * Slot: value Description: Note the range of this slot is always a string. Only used the triple represents a literal assertion --- * Slot: datatype Description: --- * Slot: language Description: +-- * Slot: datatype Description: the rdf datatype of the value, for example, xsd:string +-- * Slot: language Description: the human language in which the value is encoded, e.g. en -- # Class: "rdfs_label_statement" Description: "" --- * Slot: stanza Description: --- * Slot: subject Description: --- * Slot: predicate Description: +-- * Slot: stanza Description: the term which this statement is about +-- * Slot: subject Description: The subject of the statement +-- * Slot: predicate Description: The predicate of the statement -- * Slot: object Description: Note the range of this slot is always a node. If the triple represents a literal, instead value will be populated -- * Slot: value Description: The label value --- * Slot: datatype Description: --- * Slot: language Description: +-- * Slot: datatype Description: the rdf datatype of the value, for example, xsd:string +-- * Slot: language Description: the human language in which the value is encoded, e.g. en -- # Class: "rdfs_domain_statement" Description: "" --- * Slot: stanza Description: --- * Slot: subject Description: --- * Slot: predicate Description: +-- * Slot: stanza Description: the term which this statement is about +-- * Slot: subject Description: The subject of the statement +-- * Slot: predicate Description: The predicate of the statement -- * Slot: object Description: Note the range of this slot is always a node. If the triple represents a literal, instead value will be populated -- * Slot: value Description: Note the range of this slot is always a string. Only used the triple represents a literal assertion --- * Slot: datatype Description: --- * Slot: language Description: +-- * Slot: datatype Description: the rdf datatype of the value, for example, xsd:string +-- * Slot: language Description: the human language in which the value is encoded, e.g. en -- # Class: "rdfs_range_statement" Description: "" --- * Slot: stanza Description: --- * Slot: subject Description: --- * Slot: predicate Description: +-- * Slot: stanza Description: the term which this statement is about +-- * Slot: subject Description: The subject of the statement +-- * Slot: predicate Description: The predicate of the statement -- * Slot: object Description: Note the range of this slot is always a node. If the triple represents a literal, instead value will be populated -- * Slot: value Description: Note the range of this slot is always a string. Only used the triple represents a literal assertion --- * Slot: datatype Description: --- * Slot: language Description: +-- * Slot: datatype Description: the rdf datatype of the value, for example, xsd:string +-- * Slot: language Description: the human language in which the value is encoded, e.g. en -- # Class: "rdf_list_statement" Description: "A statement that is used to represent aspects of RDF lists" --- * Slot: stanza Description: +-- * Slot: stanza Description: the term which this statement is about -- * Slot: subject Description: The rdf:List to which the statement applies --- * Slot: predicate Description: +-- * Slot: predicate Description: The predicate of the statement -- * Slot: object Description: Note the range of this slot is always a node. If the triple represents a literal, instead value will be populated -- * Slot: value Description: Note the range of this slot is always a string. Only used the triple represents a literal assertion --- * Slot: datatype Description: --- * Slot: language Description: +-- * Slot: datatype Description: the rdf datatype of the value, for example, xsd:string +-- * Slot: language Description: the human language in which the value is encoded, e.g. en -- # Class: "rdf_first_statement" Description: "A statement that connects a list to its first element. This is a low-level triple, it is unlikely you need to use this directly. It is used to define rdf_list_member_statement, which is more useful" --- * Slot: stanza Description: --- * Slot: subject Description: --- * Slot: predicate Description: +-- * Slot: stanza Description: the term which this statement is about +-- * Slot: subject Description: The subject of the statement +-- * Slot: predicate Description: The predicate of the statement -- * Slot: object Description: Note the range of this slot is always a node. If the triple represents a literal, instead value will be populated -- * Slot: value Description: Note the range of this slot is always a string. Only used the triple represents a literal assertion --- * Slot: datatype Description: --- * Slot: language Description: +-- * Slot: datatype Description: the rdf datatype of the value, for example, xsd:string +-- * Slot: language Description: the human language in which the value is encoded, e.g. en -- # Class: "rdf_rest_statement" Description: "A statement that connects a list to its remaining elements. This is a low-level triple, it is unlikely you need to use this directly. It is used to define rdf_list_member_statement, which is more useful" --- * Slot: stanza Description: --- * Slot: subject Description: --- * Slot: predicate Description: +-- * Slot: stanza Description: the term which this statement is about +-- * Slot: subject Description: The subject of the statement +-- * Slot: predicate Description: The predicate of the statement -- * Slot: object Description: Note the range of this slot is always a node. If the triple represents a literal, instead value will be populated -- * Slot: value Description: Note the range of this slot is always a string. Only used the triple represents a literal assertion --- * Slot: datatype Description: --- * Slot: language Description: +-- * Slot: datatype Description: the rdf datatype of the value, for example, xsd:string +-- * Slot: language Description: the human language in which the value is encoded, e.g. en -- # Class: "rdf_rest_transitive_statement" Description: "" --- * Slot: stanza Description: --- * Slot: subject Description: --- * Slot: predicate Description: +-- * Slot: stanza Description: the term which this statement is about +-- * Slot: subject Description: The subject of the statement +-- * Slot: predicate Description: The predicate of the statement -- * Slot: object Description: Note the range of this slot is always a node. If the triple represents a literal, instead value will be populated -- * Slot: value Description: Note the range of this slot is always a string. Only used the triple represents a literal assertion --- * Slot: datatype Description: --- * Slot: language Description: +-- * Slot: datatype Description: the rdf datatype of the value, for example, xsd:string +-- * Slot: language Description: the human language in which the value is encoded, e.g. en -- # Class: "rdf_list_member_statement" Description: "" --- * Slot: stanza Description: --- * Slot: subject Description: --- * Slot: predicate Description: +-- * Slot: stanza Description: the term which this statement is about +-- * Slot: subject Description: The subject of the statement +-- * Slot: predicate Description: The predicate of the statement -- * Slot: object Description: Note the range of this slot is always a node. If the triple represents a literal, instead value will be populated -- * Slot: value Description: Note the range of this slot is always a string. Only used the triple represents a literal assertion --- * Slot: datatype Description: --- * Slot: language Description: +-- * Slot: datatype Description: the rdf datatype of the value, for example, xsd:string +-- * Slot: language Description: the human language in which the value is encoded, e.g. en -- # Class: "node" Description: "The basic unit of representation in an RDF or OWL graph" -- * Slot: id Description: An identifier for an element. Note blank node ids are not unique across databases -- # Class: "blank_node" Description: "A node with an ID that is not preserved between databases" @@ -709,7 +709,7 @@ DROP TABLE owl_same_as_statement; CREATE VIEW owl_same_as_statement AS SELECT * FROM statements WHERE predicate='owl:sameAs'; DROP TABLE owl_disjoint_class_statement; -CREATE VIEW owl_disjoint_class_statement AS SELECT * FROM statements WHERE predicate='owl:disjointClass'; +CREATE VIEW owl_disjoint_class_statement AS SELECT * FROM statements WHERE predicate='owl:disjointWith'; DROP TABLE owl_reified_axiom; CREATE VIEW owl_reified_axiom AS SELECT axs.subject AS id, axs.stanza AS stanza, axs.object AS subject, axp.object AS predicate, axo.object AS object, axo.value AS value, axo.datatype AS datatype, axo.language AS language FROM statements AS axs, statements AS axp, statements AS axo WHERE axs.predicate = 'owl:annotatedSource' AND axp.predicate = 'owl:annotatedProperty' AND axo.predicate = 'owl:annotatedTarget' AND axs.subject = axp.subject AND axs.subject = axo.subject; diff --git a/src/semsql/builder/sql_schema/rdf.sql b/src/semsql/builder/sql_schema/rdf.sql index ffbf6a8..19af11f 100644 --- a/src/semsql/builder/sql_schema/rdf.sql +++ b/src/semsql/builder/sql_schema/rdf.sql @@ -2,125 +2,125 @@ -- * Slot: prefix Description: A standardized prefix such as 'GO' or 'rdf' or 'FlyBase' -- * Slot: base Description: The base URI a prefix will expand to -- # Class: "statements" Description: "Represents an RDF triple" --- * Slot: stanza Description: --- * Slot: subject Description: --- * Slot: predicate Description: +-- * Slot: stanza Description: the term which this statement is about +-- * Slot: subject Description: The subject of the statement +-- * Slot: predicate Description: The predicate of the statement -- * Slot: object Description: Note the range of this slot is always a node. If the triple represents a literal, instead value will be populated -- * Slot: value Description: Note the range of this slot is always a string. Only used the triple represents a literal assertion --- * Slot: datatype Description: --- * Slot: language Description: +-- * Slot: datatype Description: the rdf datatype of the value, for example, xsd:string +-- * Slot: language Description: the human language in which the value is encoded, e.g. en -- # Class: "node_to_node_statement" Description: "A statement where object is non-null and value is not populated" --- * Slot: stanza Description: --- * Slot: subject Description: --- * Slot: predicate Description: +-- * Slot: stanza Description: the term which this statement is about +-- * Slot: subject Description: The subject of the statement +-- * Slot: predicate Description: The predicate of the statement -- * Slot: object Description: Note the range of this slot is always a node. If the triple represents a literal, instead value will be populated -- * Slot: value Description: Note the range of this slot is always a string. Only used the triple represents a literal assertion --- * Slot: datatype Description: --- * Slot: language Description: +-- * Slot: datatype Description: the rdf datatype of the value, for example, xsd:string +-- * Slot: language Description: the human language in which the value is encoded, e.g. en -- # Class: "node_to_value_statement" Description: "A statement where value is non-null and object is not populated" --- * Slot: stanza Description: --- * Slot: subject Description: --- * Slot: predicate Description: +-- * Slot: stanza Description: the term which this statement is about +-- * Slot: subject Description: The subject of the statement +-- * Slot: predicate Description: The predicate of the statement -- * Slot: object Description: Note the range of this slot is always a node. If the triple represents a literal, instead value will be populated -- * Slot: value Description: Note the range of this slot is always a string. Only used the triple represents a literal assertion --- * Slot: datatype Description: --- * Slot: language Description: +-- * Slot: datatype Description: the rdf datatype of the value, for example, xsd:string +-- * Slot: language Description: the human language in which the value is encoded, e.g. en -- # Class: "rdf_type_statement" Description: "A statement that indicates the asserted type of the subject entity" --- * Slot: stanza Description: --- * Slot: subject Description: --- * Slot: predicate Description: +-- * Slot: stanza Description: the term which this statement is about +-- * Slot: subject Description: The subject of the statement +-- * Slot: predicate Description: The predicate of the statement -- * Slot: object Description: The entity type -- * Slot: value Description: Note the range of this slot is always a string. Only used the triple represents a literal assertion --- * Slot: datatype Description: --- * Slot: language Description: +-- * Slot: datatype Description: the rdf datatype of the value, for example, xsd:string +-- * Slot: language Description: the human language in which the value is encoded, e.g. en -- # Class: "rdfs_subclass_of_statement" Description: "" --- * Slot: stanza Description: +-- * Slot: stanza Description: the term which this statement is about -- * Slot: subject Description: The subclass element of the triple --- * Slot: predicate Description: +-- * Slot: predicate Description: The predicate of the statement -- * Slot: object Description: The superclass element of the triple -- * Slot: value Description: Note the range of this slot is always a string. Only used the triple represents a literal assertion --- * Slot: datatype Description: --- * Slot: language Description: +-- * Slot: datatype Description: the rdf datatype of the value, for example, xsd:string +-- * Slot: language Description: the human language in which the value is encoded, e.g. en -- # Class: "rdfs_subclass_of_named_statement" Description: "" --- * Slot: stanza Description: --- * Slot: subject Description: --- * Slot: predicate Description: +-- * Slot: stanza Description: the term which this statement is about +-- * Slot: subject Description: The subject of the statement +-- * Slot: predicate Description: The predicate of the statement -- * Slot: object Description: Note the range of this slot is always a node. If the triple represents a literal, instead value will be populated -- * Slot: value Description: Note the range of this slot is always a string. Only used the triple represents a literal assertion --- * Slot: datatype Description: --- * Slot: language Description: +-- * Slot: datatype Description: the rdf datatype of the value, for example, xsd:string +-- * Slot: language Description: the human language in which the value is encoded, e.g. en -- # Class: "rdfs_subproperty_of_statement" Description: "" --- * Slot: stanza Description: +-- * Slot: stanza Description: the term which this statement is about -- * Slot: subject Description: The subproperty element of the triple --- * Slot: predicate Description: +-- * Slot: predicate Description: The predicate of the statement -- * Slot: object Description: The superproperty element of the triple -- * Slot: value Description: Note the range of this slot is always a string. Only used the triple represents a literal assertion --- * Slot: datatype Description: --- * Slot: language Description: +-- * Slot: datatype Description: the rdf datatype of the value, for example, xsd:string +-- * Slot: language Description: the human language in which the value is encoded, e.g. en -- # Class: "rdfs_label_statement" Description: "" --- * Slot: stanza Description: --- * Slot: subject Description: --- * Slot: predicate Description: +-- * Slot: stanza Description: the term which this statement is about +-- * Slot: subject Description: The subject of the statement +-- * Slot: predicate Description: The predicate of the statement -- * Slot: object Description: Note the range of this slot is always a node. If the triple represents a literal, instead value will be populated -- * Slot: value Description: The label value --- * Slot: datatype Description: --- * Slot: language Description: +-- * Slot: datatype Description: the rdf datatype of the value, for example, xsd:string +-- * Slot: language Description: the human language in which the value is encoded, e.g. en -- # Class: "rdfs_domain_statement" Description: "" --- * Slot: stanza Description: --- * Slot: subject Description: --- * Slot: predicate Description: +-- * Slot: stanza Description: the term which this statement is about +-- * Slot: subject Description: The subject of the statement +-- * Slot: predicate Description: The predicate of the statement -- * Slot: object Description: Note the range of this slot is always a node. If the triple represents a literal, instead value will be populated -- * Slot: value Description: Note the range of this slot is always a string. Only used the triple represents a literal assertion --- * Slot: datatype Description: --- * Slot: language Description: +-- * Slot: datatype Description: the rdf datatype of the value, for example, xsd:string +-- * Slot: language Description: the human language in which the value is encoded, e.g. en -- # Class: "rdfs_range_statement" Description: "" --- * Slot: stanza Description: --- * Slot: subject Description: --- * Slot: predicate Description: +-- * Slot: stanza Description: the term which this statement is about +-- * Slot: subject Description: The subject of the statement +-- * Slot: predicate Description: The predicate of the statement -- * Slot: object Description: Note the range of this slot is always a node. If the triple represents a literal, instead value will be populated -- * Slot: value Description: Note the range of this slot is always a string. Only used the triple represents a literal assertion --- * Slot: datatype Description: --- * Slot: language Description: +-- * Slot: datatype Description: the rdf datatype of the value, for example, xsd:string +-- * Slot: language Description: the human language in which the value is encoded, e.g. en -- # Class: "rdf_list_statement" Description: "A statement that is used to represent aspects of RDF lists" --- * Slot: stanza Description: +-- * Slot: stanza Description: the term which this statement is about -- * Slot: subject Description: The rdf:List to which the statement applies --- * Slot: predicate Description: +-- * Slot: predicate Description: The predicate of the statement -- * Slot: object Description: Note the range of this slot is always a node. If the triple represents a literal, instead value will be populated -- * Slot: value Description: Note the range of this slot is always a string. Only used the triple represents a literal assertion --- * Slot: datatype Description: --- * Slot: language Description: +-- * Slot: datatype Description: the rdf datatype of the value, for example, xsd:string +-- * Slot: language Description: the human language in which the value is encoded, e.g. en -- # Class: "rdf_first_statement" Description: "A statement that connects a list to its first element. This is a low-level triple, it is unlikely you need to use this directly. It is used to define rdf_list_member_statement, which is more useful" --- * Slot: stanza Description: --- * Slot: subject Description: --- * Slot: predicate Description: +-- * Slot: stanza Description: the term which this statement is about +-- * Slot: subject Description: The subject of the statement +-- * Slot: predicate Description: The predicate of the statement -- * Slot: object Description: Note the range of this slot is always a node. If the triple represents a literal, instead value will be populated -- * Slot: value Description: Note the range of this slot is always a string. Only used the triple represents a literal assertion --- * Slot: datatype Description: --- * Slot: language Description: +-- * Slot: datatype Description: the rdf datatype of the value, for example, xsd:string +-- * Slot: language Description: the human language in which the value is encoded, e.g. en -- # Class: "rdf_rest_statement" Description: "A statement that connects a list to its remaining elements. This is a low-level triple, it is unlikely you need to use this directly. It is used to define rdf_list_member_statement, which is more useful" --- * Slot: stanza Description: --- * Slot: subject Description: --- * Slot: predicate Description: +-- * Slot: stanza Description: the term which this statement is about +-- * Slot: subject Description: The subject of the statement +-- * Slot: predicate Description: The predicate of the statement -- * Slot: object Description: Note the range of this slot is always a node. If the triple represents a literal, instead value will be populated -- * Slot: value Description: Note the range of this slot is always a string. Only used the triple represents a literal assertion --- * Slot: datatype Description: --- * Slot: language Description: +-- * Slot: datatype Description: the rdf datatype of the value, for example, xsd:string +-- * Slot: language Description: the human language in which the value is encoded, e.g. en -- # Class: "rdf_rest_transitive_statement" Description: "" --- * Slot: stanza Description: --- * Slot: subject Description: --- * Slot: predicate Description: +-- * Slot: stanza Description: the term which this statement is about +-- * Slot: subject Description: The subject of the statement +-- * Slot: predicate Description: The predicate of the statement -- * Slot: object Description: Note the range of this slot is always a node. If the triple represents a literal, instead value will be populated -- * Slot: value Description: Note the range of this slot is always a string. Only used the triple represents a literal assertion --- * Slot: datatype Description: --- * Slot: language Description: +-- * Slot: datatype Description: the rdf datatype of the value, for example, xsd:string +-- * Slot: language Description: the human language in which the value is encoded, e.g. en -- # Class: "rdf_list_member_statement" Description: "" --- * Slot: stanza Description: --- * Slot: subject Description: --- * Slot: predicate Description: +-- * Slot: stanza Description: the term which this statement is about +-- * Slot: subject Description: The subject of the statement +-- * Slot: predicate Description: The predicate of the statement -- * Slot: object Description: Note the range of this slot is always a node. If the triple represents a literal, instead value will be populated -- * Slot: value Description: Note the range of this slot is always a string. Only used the triple represents a literal assertion --- * Slot: datatype Description: --- * Slot: language Description: +-- * Slot: datatype Description: the rdf datatype of the value, for example, xsd:string +-- * Slot: language Description: the human language in which the value is encoded, e.g. en -- # Class: "node" Description: "The basic unit of representation in an RDF or OWL graph" -- * Slot: id Description: An identifier for an element. Note blank node ids are not unique across databases -- # Class: "blank_node" Description: "A node with an ID that is not preserved between databases" @@ -336,8 +336,6 @@ CREATE TABLE count_of_subclasses ( element TEXT, count_value INTEGER ); --- ** REWRITE TABLES AS VIEWS ** --- SCHEMA: https://w3id.org/semsql/rdf DROP TABLE node_to_node_statement; CREATE VIEW node_to_node_statement AS SELECT * FROM statements WHERE object IS NOT NULL; diff --git a/src/semsql/builder/sql_schema/relation_graph.sql b/src/semsql/builder/sql_schema/relation_graph.sql index 1327f6a..7ed4bda 100644 --- a/src/semsql/builder/sql_schema/relation_graph.sql +++ b/src/semsql/builder/sql_schema/relation_graph.sql @@ -1,10 +1,10 @@ -- # Class: "relation_graph_construct" Description: "A construct used as part of a Relation Graph" --- * Slot: subject Description: --- * Slot: predicate Description: +-- * Slot: subject Description: The subject of the statement +-- * Slot: predicate Description: The predicate of the statement -- * Slot: object Description: Note the range of this slot is always a node. If the triple represents a literal, instead value will be populated -- # Class: "edge" Description: "A relation graph edge that connects two entities by a predicate. Note an edge is distinct from a statement, in that an axiom such as A SubClassOf R some B is represented as multiple statements, but is a single relation graph edge" --- * Slot: subject Description: --- * Slot: predicate Description: +-- * Slot: subject Description: The subject of the statement +-- * Slot: predicate Description: The predicate of the statement -- * Slot: object Description: Note the range of this slot is always a node. If the triple represents a literal, instead value will be populated -- # Class: "subgraph_query" Description: "A subgraph query encompasses as subgraph edge and a seed/anchor object and seed/anchor predicate" -- * Slot: subject Description: subject of the subgraph edge @@ -13,58 +13,58 @@ -- * Slot: anchor_object Description: The entity that is used to seed the graph. The seed entity will bear some relationship to each subgraph edge; E.g. with an ancestor subgraph query, all edges will have a subject that descends from the ancestor -- * Slot: anchor_predicate Description: The predicate that is used to determine if an edge should be included based on relationship to the anchor_object. -- # Class: "subgraph_edge_by_ancestor" Description: "An edge within a subgraph anchored around a set of ancestor terms" --- * Slot: subject Description: --- * Slot: predicate Description: +-- * Slot: subject Description: The subject of the statement +-- * Slot: predicate Description: The predicate of the statement -- * Slot: object Description: Note the range of this slot is always a node. If the triple represents a literal, instead value will be populated -- * Slot: anchor_object Description: The ancestor term -- * Slot: anchor_predicate Description: The entailed predicate that holds between each edge subject and the ancestor -- # Class: "subgraph_edge_by_descendant" Description: "An edge within a subgraph anchored around a set of descendant terms" --- * Slot: subject Description: --- * Slot: predicate Description: +-- * Slot: subject Description: The subject of the statement +-- * Slot: predicate Description: The predicate of the statement -- * Slot: object Description: Note the range of this slot is always a node. If the triple represents a literal, instead value will be populated -- * Slot: anchor_object Description: The descendant term -- * Slot: anchor_predicate Description: The entailed predicate that holds between the descendant and each edge subject -- # Class: "subgraph_edge_by_ancestor_or_descendant" Description: "" --- * Slot: subject Description: --- * Slot: predicate Description: +-- * Slot: subject Description: The subject of the statement +-- * Slot: predicate Description: The predicate of the statement -- * Slot: object Description: Note the range of this slot is always a node. If the triple represents a literal, instead value will be populated -- * Slot: anchor_object Description: -- * Slot: anchor_predicate Description: -- # Class: "subgraph_edge_by_parent" Description: "An edge within a subgraph anchored around a set of parent terms" --- * Slot: subject Description: --- * Slot: predicate Description: +-- * Slot: subject Description: The subject of the statement +-- * Slot: predicate Description: The predicate of the statement -- * Slot: object Description: Note the range of this slot is always a node. If the triple represents a literal, instead value will be populated -- * Slot: anchor_object Description: The parent term -- * Slot: anchor_predicate Description: The entailed predicate that holds between each edge subject and the parent -- # Class: "subgraph_edge_by_child" Description: "An edge within a subgraph anchored around a set of child terms" --- * Slot: subject Description: --- * Slot: predicate Description: +-- * Slot: subject Description: The subject of the statement +-- * Slot: predicate Description: The predicate of the statement -- * Slot: object Description: Note the range of this slot is always a node. If the triple represents a literal, instead value will be populated -- * Slot: anchor_object Description: The child term -- * Slot: anchor_predicate Description: The entailed predicate that holds between the child and each edge subject -- # Class: "subgraph_edge_by_self" Description: "A special null form of a subgraph query where there is no expansion" --- * Slot: subject Description: --- * Slot: predicate Description: +-- * Slot: subject Description: The subject of the statement +-- * Slot: predicate Description: The predicate of the statement -- * Slot: object Description: Note the range of this slot is always a node. If the triple represents a literal, instead value will be populated -- * Slot: anchor_object Description: -- * Slot: anchor_predicate Description: -- # Class: "entailed_edge" Description: "A relation graph edge that is inferred" --- * Slot: subject Description: --- * Slot: predicate Description: +-- * Slot: subject Description: The subject of the statement +-- * Slot: predicate Description: The predicate of the statement -- * Slot: object Description: Note the range of this slot is always a node. If the triple represents a literal, instead value will be populated -- # Class: "entailed_edge_cycle" Description: "An edge that composes with another edge to make a cycle" --- * Slot: subject Description: --- * Slot: predicate Description: +-- * Slot: subject Description: The subject of the statement +-- * Slot: predicate Description: The predicate of the statement -- * Slot: object Description: Note the range of this slot is always a node. If the triple represents a literal, instead value will be populated -- * Slot: secondary_predicate Description: -- # Class: "entailed_edge_same_predicate_cycle" Description: "An entailed_edge_cycle over a single predicate" --- * Slot: subject Description: --- * Slot: predicate Description: +-- * Slot: subject Description: The subject of the statement +-- * Slot: predicate Description: The predicate of the statement -- * Slot: object Description: Note the range of this slot is always a node. If the triple represents a literal, instead value will be populated -- * Slot: secondary_predicate Description: -- # Class: "transitive_edge" Description: "A relation graph edge that is formed from a chain of one or more edges" --- * Slot: subject Description: --- * Slot: predicate Description: +-- * Slot: subject Description: The subject of the statement +-- * Slot: predicate Description: The predicate of the statement -- * Slot: object Description: Note the range of this slot is always a node. If the triple represents a literal, instead value will be populated -- # Class: "ontology_node" Description: "A node representing an ontology" -- * Slot: id Description: An identifier for an element. Note blank node ids are not unique across databases @@ -85,71 +85,71 @@ -- # Class: "deprecated_node" Description: "" -- * Slot: id Description: An identifier for an element. Note blank node ids are not unique across databases -- # Class: "owl_imports_statement" Description: "" --- * Slot: stanza Description: --- * Slot: subject Description: --- * Slot: predicate Description: +-- * Slot: stanza Description: the term which this statement is about +-- * Slot: subject Description: The subject of the statement +-- * Slot: predicate Description: The predicate of the statement -- * Slot: object Description: Note the range of this slot is always a node. If the triple represents a literal, instead value will be populated -- * Slot: value Description: Note the range of this slot is always a string. Only used the triple represents a literal assertion --- * Slot: datatype Description: --- * Slot: language Description: +-- * Slot: datatype Description: the rdf datatype of the value, for example, xsd:string +-- * Slot: language Description: the human language in which the value is encoded, e.g. en -- # Class: "owl_inverse_of_statement" Description: "" --- * Slot: stanza Description: --- * Slot: subject Description: --- * Slot: predicate Description: +-- * Slot: stanza Description: the term which this statement is about +-- * Slot: subject Description: The subject of the statement +-- * Slot: predicate Description: The predicate of the statement -- * Slot: object Description: Note the range of this slot is always a node. If the triple represents a literal, instead value will be populated -- * Slot: value Description: Note the range of this slot is always a string. Only used the triple represents a literal assertion --- * Slot: datatype Description: --- * Slot: language Description: +-- * Slot: datatype Description: the rdf datatype of the value, for example, xsd:string +-- * Slot: language Description: the human language in which the value is encoded, e.g. en -- # Class: "owl_complement_of_statement" Description: "" --- * Slot: stanza Description: --- * Slot: subject Description: --- * Slot: predicate Description: +-- * Slot: stanza Description: the term which this statement is about +-- * Slot: subject Description: The subject of the statement +-- * Slot: predicate Description: The predicate of the statement -- * Slot: object Description: Note the range of this slot is always a node. If the triple represents a literal, instead value will be populated -- * Slot: value Description: Note the range of this slot is always a string. Only used the triple represents a literal assertion --- * Slot: datatype Description: --- * Slot: language Description: +-- * Slot: datatype Description: the rdf datatype of the value, for example, xsd:string +-- * Slot: language Description: the human language in which the value is encoded, e.g. en -- # Class: "owl_equivalent_class_statement" Description: "A statement that connects two class_nodes where both classes are equivalent" --- * Slot: stanza Description: +-- * Slot: stanza Description: the term which this statement is about -- * Slot: subject Description: One of the two classes that are equivalent. No significance to subject vs object --- * Slot: predicate Description: +-- * Slot: predicate Description: The predicate of the statement -- * Slot: object Description: One of the two classes that are equivalent. No significance to subject vs object -- * Slot: value Description: Note the range of this slot is always a string. Only used the triple represents a literal assertion --- * Slot: datatype Description: --- * Slot: language Description: +-- * Slot: datatype Description: the rdf datatype of the value, for example, xsd:string +-- * Slot: language Description: the human language in which the value is encoded, e.g. en -- # Class: "owl_same_as_statement" Description: "A statement that connects two individual nodes where both individual are equivalent" --- * Slot: stanza Description: +-- * Slot: stanza Description: the term which this statement is about -- * Slot: subject Description: One of the two classes that are equivalent. No significance to subject vs object --- * Slot: predicate Description: +-- * Slot: predicate Description: The predicate of the statement -- * Slot: object Description: One of the two classes that are equivalent. No significance to subject vs object -- * Slot: value Description: Note the range of this slot is always a string. Only used the triple represents a literal assertion --- * Slot: datatype Description: --- * Slot: language Description: +-- * Slot: datatype Description: the rdf datatype of the value, for example, xsd:string +-- * Slot: language Description: the human language in which the value is encoded, e.g. en -- # Class: "owl_disjoint_class_statement" Description: "" --- * Slot: stanza Description: +-- * Slot: stanza Description: the term which this statement is about -- * Slot: subject Description: One of the two classes that are disjoint. No significance to subject vs object --- * Slot: predicate Description: +-- * Slot: predicate Description: The predicate of the statement -- * Slot: object Description: One of the two classes that are disjoint. No significance to subject vs object -- * Slot: value Description: Note the range of this slot is always a string. Only used the triple represents a literal assertion --- * Slot: datatype Description: --- * Slot: language Description: +-- * Slot: datatype Description: the rdf datatype of the value, for example, xsd:string +-- * Slot: language Description: the human language in which the value is encoded, e.g. en -- # Class: "owl_reified_axiom" Description: "An OWL axiom that has been reified - i.e. it includes an [id](id) field that uniquely identifies that axiom and which can be the subject of additional statements" -- * Slot: id Description: An identifier for an element. Note blank node ids are not unique across databases --- * Slot: stanza Description: --- * Slot: subject Description: --- * Slot: predicate Description: +-- * Slot: stanza Description: the term which this statement is about +-- * Slot: subject Description: The subject of the statement +-- * Slot: predicate Description: The predicate of the statement -- * Slot: object Description: Note the range of this slot is always a node. If the triple represents a literal, instead value will be populated -- * Slot: value Description: Note the range of this slot is always a string. Only used the triple represents a literal assertion --- * Slot: datatype Description: --- * Slot: language Description: +-- * Slot: datatype Description: the rdf datatype of the value, for example, xsd:string +-- * Slot: language Description: the human language in which the value is encoded, e.g. en -- # Class: "owl_axiom" Description: "" -- * Slot: id Description: An identifier for an element. Note blank node ids are not unique across databases --- * Slot: stanza Description: --- * Slot: subject Description: --- * Slot: predicate Description: +-- * Slot: stanza Description: the term which this statement is about +-- * Slot: subject Description: The subject of the statement +-- * Slot: predicate Description: The predicate of the statement -- * Slot: object Description: Note the range of this slot is always a node. If the triple represents a literal, instead value will be populated -- * Slot: value Description: Note the range of this slot is always a string. Only used the triple represents a literal assertion --- * Slot: datatype Description: --- * Slot: language Description: +-- * Slot: datatype Description: the rdf datatype of the value, for example, xsd:string +-- * Slot: language Description: the human language in which the value is encoded, e.g. en -- # Class: "owl_axiom_annotation" Description: "" -- * Slot: annotation_subject Description: -- * Slot: annotation_predicate Description: @@ -158,18 +158,13 @@ -- * Slot: annotation_language Description: -- * Slot: annotation_datatype Description: -- * Slot: id Description: An identifier for an element. Note blank node ids are not unique across databases --- * Slot: axiom_predicate Description: --- * Slot: axiom_object Description: --- * Slot: axiom_value Description: --- * Slot: axiom_language Description: --- * Slot: axiom_datatype Description: --- * Slot: stanza Description: --- * Slot: subject Description: --- * Slot: predicate Description: +-- * Slot: stanza Description: the term which this statement is about +-- * Slot: subject Description: The subject of the statement +-- * Slot: predicate Description: The predicate of the statement -- * Slot: object Description: Note the range of this slot is always a node. If the triple represents a literal, instead value will be populated -- * Slot: value Description: Note the range of this slot is always a string. Only used the triple represents a literal assertion --- * Slot: datatype Description: --- * Slot: language Description: +-- * Slot: datatype Description: the rdf datatype of the value, for example, xsd:string +-- * Slot: language Description: the human language in which the value is encoded, e.g. en -- # Class: "anonymous_expression" Description: "An OWL expression, such as a class expression. Expressions are "anonymous" as they are a composition of named elements rather than a named element themselves" -- * Slot: id Description: An identifier for an element. Note blank node ids are not unique across databases -- # Class: "anonymous_class_expression" Description: "An OWL anonymous class expression, such as for example `SomeValuesFrom(partOf Hand)`" @@ -199,8 +194,8 @@ -- * Slot: filler Description: This is Null for a self-restriction -- * Slot: id Description: An identifier for an element. Note blank node ids are not unique across databases -- # Class: "owl_complex_axiom" Description: "An axiom that is composed of two or more statements" --- * Slot: subject Description: --- * Slot: predicate Description: +-- * Slot: subject Description: The subject of the statement +-- * Slot: predicate Description: The predicate of the statement -- * Slot: object Description: Note the range of this slot is always a node. If the triple represents a literal, instead value will be populated -- # Class: "owl_subclass_of_some_values_from" Description: "Composition of subClassOf and SomeValuesFrom" -- * Slot: subject Description: the class C in the axiom C subClassOf P some D @@ -209,130 +204,130 @@ -- # Class: "owl_equivalent_to_intersection_member" Description: "Composition of `OwlEquivalentClass`, `OwlIntersectionOf`, and `RdfListMember`; `C = X1 and ... and Xn`" -- * Slot: subject Description: the defined class -- * Slot: object Description: a class expression that forms the defining expression --- * Slot: predicate Description: +-- * Slot: predicate Description: The predicate of the statement -- # Class: "prefix" Description: "Maps CURIEs to URIs" -- * Slot: prefix Description: A standardized prefix such as 'GO' or 'rdf' or 'FlyBase' -- * Slot: base Description: The base URI a prefix will expand to -- # Class: "statements" Description: "Represents an RDF triple" --- * Slot: stanza Description: --- * Slot: subject Description: --- * Slot: predicate Description: +-- * Slot: stanza Description: the term which this statement is about +-- * Slot: subject Description: The subject of the statement +-- * Slot: predicate Description: The predicate of the statement -- * Slot: object Description: Note the range of this slot is always a node. If the triple represents a literal, instead value will be populated -- * Slot: value Description: Note the range of this slot is always a string. Only used the triple represents a literal assertion --- * Slot: datatype Description: --- * Slot: language Description: +-- * Slot: datatype Description: the rdf datatype of the value, for example, xsd:string +-- * Slot: language Description: the human language in which the value is encoded, e.g. en -- # Class: "node_to_node_statement" Description: "A statement where object is non-null and value is not populated" --- * Slot: stanza Description: --- * Slot: subject Description: --- * Slot: predicate Description: +-- * Slot: stanza Description: the term which this statement is about +-- * Slot: subject Description: The subject of the statement +-- * Slot: predicate Description: The predicate of the statement -- * Slot: object Description: Note the range of this slot is always a node. If the triple represents a literal, instead value will be populated -- * Slot: value Description: Note the range of this slot is always a string. Only used the triple represents a literal assertion --- * Slot: datatype Description: --- * Slot: language Description: +-- * Slot: datatype Description: the rdf datatype of the value, for example, xsd:string +-- * Slot: language Description: the human language in which the value is encoded, e.g. en -- # Class: "node_to_value_statement" Description: "A statement where value is non-null and object is not populated" --- * Slot: stanza Description: --- * Slot: subject Description: --- * Slot: predicate Description: +-- * Slot: stanza Description: the term which this statement is about +-- * Slot: subject Description: The subject of the statement +-- * Slot: predicate Description: The predicate of the statement -- * Slot: object Description: Note the range of this slot is always a node. If the triple represents a literal, instead value will be populated -- * Slot: value Description: Note the range of this slot is always a string. Only used the triple represents a literal assertion --- * Slot: datatype Description: --- * Slot: language Description: +-- * Slot: datatype Description: the rdf datatype of the value, for example, xsd:string +-- * Slot: language Description: the human language in which the value is encoded, e.g. en -- # Class: "rdf_type_statement" Description: "A statement that indicates the asserted type of the subject entity" --- * Slot: stanza Description: --- * Slot: subject Description: --- * Slot: predicate Description: +-- * Slot: stanza Description: the term which this statement is about +-- * Slot: subject Description: The subject of the statement +-- * Slot: predicate Description: The predicate of the statement -- * Slot: object Description: The entity type -- * Slot: value Description: Note the range of this slot is always a string. Only used the triple represents a literal assertion --- * Slot: datatype Description: --- * Slot: language Description: +-- * Slot: datatype Description: the rdf datatype of the value, for example, xsd:string +-- * Slot: language Description: the human language in which the value is encoded, e.g. en -- # Class: "rdfs_subclass_of_statement" Description: "" --- * Slot: stanza Description: +-- * Slot: stanza Description: the term which this statement is about -- * Slot: subject Description: The subclass element of the triple --- * Slot: predicate Description: +-- * Slot: predicate Description: The predicate of the statement -- * Slot: object Description: The superclass element of the triple -- * Slot: value Description: Note the range of this slot is always a string. Only used the triple represents a literal assertion --- * Slot: datatype Description: --- * Slot: language Description: +-- * Slot: datatype Description: the rdf datatype of the value, for example, xsd:string +-- * Slot: language Description: the human language in which the value is encoded, e.g. en -- # Class: "rdfs_subclass_of_named_statement" Description: "" --- * Slot: stanza Description: --- * Slot: subject Description: --- * Slot: predicate Description: +-- * Slot: stanza Description: the term which this statement is about +-- * Slot: subject Description: The subject of the statement +-- * Slot: predicate Description: The predicate of the statement -- * Slot: object Description: Note the range of this slot is always a node. If the triple represents a literal, instead value will be populated -- * Slot: value Description: Note the range of this slot is always a string. Only used the triple represents a literal assertion --- * Slot: datatype Description: --- * Slot: language Description: +-- * Slot: datatype Description: the rdf datatype of the value, for example, xsd:string +-- * Slot: language Description: the human language in which the value is encoded, e.g. en -- # Class: "rdfs_subproperty_of_statement" Description: "" --- * Slot: stanza Description: +-- * Slot: stanza Description: the term which this statement is about -- * Slot: subject Description: The subproperty element of the triple --- * Slot: predicate Description: +-- * Slot: predicate Description: The predicate of the statement -- * Slot: object Description: The superproperty element of the triple -- * Slot: value Description: Note the range of this slot is always a string. Only used the triple represents a literal assertion --- * Slot: datatype Description: --- * Slot: language Description: +-- * Slot: datatype Description: the rdf datatype of the value, for example, xsd:string +-- * Slot: language Description: the human language in which the value is encoded, e.g. en -- # Class: "rdfs_label_statement" Description: "" --- * Slot: stanza Description: --- * Slot: subject Description: --- * Slot: predicate Description: +-- * Slot: stanza Description: the term which this statement is about +-- * Slot: subject Description: The subject of the statement +-- * Slot: predicate Description: The predicate of the statement -- * Slot: object Description: Note the range of this slot is always a node. If the triple represents a literal, instead value will be populated -- * Slot: value Description: The label value --- * Slot: datatype Description: --- * Slot: language Description: +-- * Slot: datatype Description: the rdf datatype of the value, for example, xsd:string +-- * Slot: language Description: the human language in which the value is encoded, e.g. en -- # Class: "rdfs_domain_statement" Description: "" --- * Slot: stanza Description: --- * Slot: subject Description: --- * Slot: predicate Description: +-- * Slot: stanza Description: the term which this statement is about +-- * Slot: subject Description: The subject of the statement +-- * Slot: predicate Description: The predicate of the statement -- * Slot: object Description: Note the range of this slot is always a node. If the triple represents a literal, instead value will be populated -- * Slot: value Description: Note the range of this slot is always a string. Only used the triple represents a literal assertion --- * Slot: datatype Description: --- * Slot: language Description: +-- * Slot: datatype Description: the rdf datatype of the value, for example, xsd:string +-- * Slot: language Description: the human language in which the value is encoded, e.g. en -- # Class: "rdfs_range_statement" Description: "" --- * Slot: stanza Description: --- * Slot: subject Description: --- * Slot: predicate Description: +-- * Slot: stanza Description: the term which this statement is about +-- * Slot: subject Description: The subject of the statement +-- * Slot: predicate Description: The predicate of the statement -- * Slot: object Description: Note the range of this slot is always a node. If the triple represents a literal, instead value will be populated -- * Slot: value Description: Note the range of this slot is always a string. Only used the triple represents a literal assertion --- * Slot: datatype Description: --- * Slot: language Description: +-- * Slot: datatype Description: the rdf datatype of the value, for example, xsd:string +-- * Slot: language Description: the human language in which the value is encoded, e.g. en -- # Class: "rdf_list_statement" Description: "A statement that is used to represent aspects of RDF lists" --- * Slot: stanza Description: +-- * Slot: stanza Description: the term which this statement is about -- * Slot: subject Description: The rdf:List to which the statement applies --- * Slot: predicate Description: +-- * Slot: predicate Description: The predicate of the statement -- * Slot: object Description: Note the range of this slot is always a node. If the triple represents a literal, instead value will be populated -- * Slot: value Description: Note the range of this slot is always a string. Only used the triple represents a literal assertion --- * Slot: datatype Description: --- * Slot: language Description: +-- * Slot: datatype Description: the rdf datatype of the value, for example, xsd:string +-- * Slot: language Description: the human language in which the value is encoded, e.g. en -- # Class: "rdf_first_statement" Description: "A statement that connects a list to its first element. This is a low-level triple, it is unlikely you need to use this directly. It is used to define rdf_list_member_statement, which is more useful" --- * Slot: stanza Description: --- * Slot: subject Description: --- * Slot: predicate Description: +-- * Slot: stanza Description: the term which this statement is about +-- * Slot: subject Description: The subject of the statement +-- * Slot: predicate Description: The predicate of the statement -- * Slot: object Description: Note the range of this slot is always a node. If the triple represents a literal, instead value will be populated -- * Slot: value Description: Note the range of this slot is always a string. Only used the triple represents a literal assertion --- * Slot: datatype Description: --- * Slot: language Description: +-- * Slot: datatype Description: the rdf datatype of the value, for example, xsd:string +-- * Slot: language Description: the human language in which the value is encoded, e.g. en -- # Class: "rdf_rest_statement" Description: "A statement that connects a list to its remaining elements. This is a low-level triple, it is unlikely you need to use this directly. It is used to define rdf_list_member_statement, which is more useful" --- * Slot: stanza Description: --- * Slot: subject Description: --- * Slot: predicate Description: +-- * Slot: stanza Description: the term which this statement is about +-- * Slot: subject Description: The subject of the statement +-- * Slot: predicate Description: The predicate of the statement -- * Slot: object Description: Note the range of this slot is always a node. If the triple represents a literal, instead value will be populated -- * Slot: value Description: Note the range of this slot is always a string. Only used the triple represents a literal assertion --- * Slot: datatype Description: --- * Slot: language Description: +-- * Slot: datatype Description: the rdf datatype of the value, for example, xsd:string +-- * Slot: language Description: the human language in which the value is encoded, e.g. en -- # Class: "rdf_rest_transitive_statement" Description: "" --- * Slot: stanza Description: --- * Slot: subject Description: --- * Slot: predicate Description: +-- * Slot: stanza Description: the term which this statement is about +-- * Slot: subject Description: The subject of the statement +-- * Slot: predicate Description: The predicate of the statement -- * Slot: object Description: Note the range of this slot is always a node. If the triple represents a literal, instead value will be populated -- * Slot: value Description: Note the range of this slot is always a string. Only used the triple represents a literal assertion --- * Slot: datatype Description: --- * Slot: language Description: +-- * Slot: datatype Description: the rdf datatype of the value, for example, xsd:string +-- * Slot: language Description: the human language in which the value is encoded, e.g. en -- # Class: "rdf_list_member_statement" Description: "" --- * Slot: stanza Description: --- * Slot: subject Description: --- * Slot: predicate Description: +-- * Slot: stanza Description: the term which this statement is about +-- * Slot: subject Description: The subject of the statement +-- * Slot: predicate Description: The predicate of the statement -- * Slot: object Description: Note the range of this slot is always a node. If the triple represents a literal, instead value will be populated -- * Slot: value Description: Note the range of this slot is always a string. Only used the triple represents a literal assertion --- * Slot: datatype Description: --- * Slot: language Description: +-- * Slot: datatype Description: the rdf datatype of the value, for example, xsd:string +-- * Slot: language Description: the human language in which the value is encoded, e.g. en -- # Class: "node" Description: "The basic unit of representation in an RDF or OWL graph" -- * Slot: id Description: An identifier for an element. Note blank node ids are not unique across databases -- # Class: "blank_node" Description: "A node with an ID that is not preserved between databases" @@ -566,11 +561,6 @@ CREATE TABLE owl_axiom_annotation ( annotation_language TEXT, annotation_datatype TEXT, id TEXT, - axiom_predicate TEXT, - axiom_object TEXT, - axiom_value TEXT, - axiom_language TEXT, - axiom_datatype TEXT, stanza TEXT, subject TEXT, predicate TEXT, @@ -824,12 +814,16 @@ CREATE TABLE count_of_subclasses ( element TEXT, count_value INTEGER ); --- ** REWRITE TABLES AS VIEWS ** --- SCHEMA: https://w3id.org/semsql/relation_graph DROP TABLE edge; -CREATE VIEW edge AS SELECT subject, predicate, object FROM owl_subclass_of_some_values_from UNION - SELECT subject, predicate, object FROM rdfs_subclass_of_named_statement; +CREATE VIEW edge AS SELECT subject, predicate, object + FROM owl_subclass_of_some_values_from + UNION + SELECT subject, predicate, object + FROM rdfs_subclass_of_named_statement + UNION + SELECT subject, predicate, object + FROM rdf_type_statement WHERE object IN (SELECT id FROM class_node); DROP TABLE subgraph_edge_by_ancestor; CREATE VIEW subgraph_edge_by_ancestor AS SELECT @@ -895,94 +889,6 @@ CREATE VIEW transitive_edge AS WITH RECURSIVE transitive_edge ) SELECT * FROM transitive_edge; -DROP TABLE node_to_node_statement; -CREATE VIEW node_to_node_statement AS SELECT * FROM statements WHERE object IS NOT NULL; - -DROP TABLE node_to_value_statement; -CREATE VIEW node_to_value_statement AS SELECT * FROM statements WHERE value IS NOT NULL; - -DROP TABLE rdf_type_statement; -CREATE VIEW rdf_type_statement AS SELECT * FROM statements WHERE predicate='rdf:type'; - -DROP TABLE rdfs_subclass_of_statement; -CREATE VIEW rdfs_subclass_of_statement AS SELECT * FROM statements WHERE predicate='rdfs:subClassOf'; - -DROP TABLE rdfs_subclass_of_named_statement; -CREATE VIEW rdfs_subclass_of_named_statement AS SELECT * FROM rdfs_subclass_of_statement WHERE object NOT LIKE '_:%'; - -DROP TABLE rdfs_subproperty_of_statement; -CREATE VIEW rdfs_subproperty_of_statement AS SELECT * FROM statements WHERE predicate='rdfs:subPropertyOf'; - -DROP TABLE rdfs_label_statement; -CREATE VIEW rdfs_label_statement AS SELECT * FROM statements WHERE predicate='rdfs:label'; - -DROP TABLE rdfs_domain_statement; -CREATE VIEW rdfs_domain_statement AS SELECT * FROM statements WHERE predicate='rdfs:domain'; - -DROP TABLE rdfs_range_statement; -CREATE VIEW rdfs_range_statement AS SELECT * FROM statements WHERE predicate='rdfs:range'; - -DROP TABLE rdf_first_statement; -CREATE VIEW rdf_first_statement AS SELECT * FROM statements WHERE predicate='rdf:first'; - -DROP TABLE rdf_rest_statement; -CREATE VIEW rdf_rest_statement AS SELECT * FROM statements WHERE predicate='rdf:rest'; - -DROP TABLE rdf_rest_transitive_statement; -CREATE VIEW rdf_rest_transitive_statement AS WITH RECURSIVE rdf_rest_transitive_statement - ( - subject, object - ) - AS - (SELECT subject, object - FROM rdf_rest_statement - UNION ALL - SELECT - rest.subject, rest_t.object - FROM rdf_rest_statement AS rest - JOIN rdf_rest_transitive_statement AS rest_t - ON rest.object = rest_t.subject - ) - SELECT * FROM rdf_rest_transitive_statement; - -DROP TABLE rdf_list_member_statement; -CREATE VIEW rdf_list_member_statement AS SELECT - rest_t.subject, - f.object - FROM rdf_rest_transitive_statement AS rest_t JOIN rdf_first_statement AS f ON (rest_t.object = f.subject) - UNION - SELECT subject,object FROM rdf_first_statement; - -DROP TABLE node; -CREATE VIEW node AS SELECT distinct(subject) AS id FROM statements UNION SELECT distinct(object) AS id FROM statements WHERE datatype IS NOT NULL; - -DROP TABLE blank_node; -CREATE VIEW blank_node AS SELECT * FROM node WHERE id LIKE '_:%'; - -DROP TABLE rdf_list_node; -CREATE VIEW rdf_list_node AS SELECT distinct subject AS id from rdf_type_statement WHERE object = 'rdf:List'; - -DROP TABLE iri_node; -CREATE VIEW iri_node AS SELECT * FROM node WHERE id NOT LIKE '_:%'; - -DROP TABLE class_node; -CREATE VIEW class_node AS SELECT distinct subject AS id from rdf_type_statement WHERE object = 'owl:Class'; - -DROP TABLE property_node; -CREATE VIEW property_node AS SELECT distinct subject AS id from rdf_type_statement WHERE object = 'owl:Property'; - -DROP TABLE named_individual_node; -CREATE VIEW named_individual_node AS SELECT distinct subject AS id from rdf_type_statement WHERE object = 'owl:NamedIndividual'; - -DROP TABLE count_of_predicates; -CREATE VIEW count_of_predicates AS SELECT predicate AS element, count(*) AS count_value FROM statements GROUP BY predicate ORDER BY count_value DESC; - -DROP TABLE count_of_instantiated_classes; -CREATE VIEW count_of_instantiated_classes AS SELECT object AS element, count(*) AS count_value FROM rdf_type_statement GROUP BY element ORDER BY count_value DESC; - -DROP TABLE count_of_subclasses; -CREATE VIEW count_of_subclasses AS SELECT sc.object AS element, count(distinct sc.subject) AS count_value FROM rdfs_subclass_of_statement AS sc GROUP BY sc.object ORDER BY count_value DESC; - DROP TABLE ontology_node; CREATE VIEW ontology_node AS SELECT DISTINCT subject AS id FROM rdf_type_statement WHERE object='owl:Ontology'; @@ -1026,7 +932,7 @@ DROP TABLE owl_same_as_statement; CREATE VIEW owl_same_as_statement AS SELECT * FROM statements WHERE predicate='owl:sameAs'; DROP TABLE owl_disjoint_class_statement; -CREATE VIEW owl_disjoint_class_statement AS SELECT * FROM statements WHERE predicate='owl:disjointClass'; +CREATE VIEW owl_disjoint_class_statement AS SELECT * FROM statements WHERE predicate='owl:disjointWith'; DROP TABLE owl_reified_axiom; CREATE VIEW owl_reified_axiom AS SELECT axs.subject AS id, axs.stanza AS stanza, axs.object AS subject, axp.object AS predicate, axo.object AS object, axo.value AS value, axo.datatype AS datatype, axo.language AS language FROM statements AS axs, statements AS axp, statements AS axo WHERE axs.predicate = 'owl:annotatedSource' AND axp.predicate = 'owl:annotatedProperty' AND axo.predicate = 'owl:annotatedTarget' AND axs.subject = axp.subject AND axs.subject = axo.subject; @@ -1134,3 +1040,91 @@ CREATE VIEW owl_equivalent_to_intersection_member AS SELECT e.stanza, rdf_list_member_statement AS m ON (i.object=m.subject) WHERE i.predicate = 'owl:intersectionOf'; + +DROP TABLE node_to_node_statement; +CREATE VIEW node_to_node_statement AS SELECT * FROM statements WHERE object IS NOT NULL; + +DROP TABLE node_to_value_statement; +CREATE VIEW node_to_value_statement AS SELECT * FROM statements WHERE value IS NOT NULL; + +DROP TABLE rdf_type_statement; +CREATE VIEW rdf_type_statement AS SELECT * FROM statements WHERE predicate='rdf:type'; + +DROP TABLE rdfs_subclass_of_statement; +CREATE VIEW rdfs_subclass_of_statement AS SELECT * FROM statements WHERE predicate='rdfs:subClassOf'; + +DROP TABLE rdfs_subclass_of_named_statement; +CREATE VIEW rdfs_subclass_of_named_statement AS SELECT * FROM rdfs_subclass_of_statement WHERE object NOT LIKE '_:%'; + +DROP TABLE rdfs_subproperty_of_statement; +CREATE VIEW rdfs_subproperty_of_statement AS SELECT * FROM statements WHERE predicate='rdfs:subPropertyOf'; + +DROP TABLE rdfs_label_statement; +CREATE VIEW rdfs_label_statement AS SELECT * FROM statements WHERE predicate='rdfs:label'; + +DROP TABLE rdfs_domain_statement; +CREATE VIEW rdfs_domain_statement AS SELECT * FROM statements WHERE predicate='rdfs:domain'; + +DROP TABLE rdfs_range_statement; +CREATE VIEW rdfs_range_statement AS SELECT * FROM statements WHERE predicate='rdfs:range'; + +DROP TABLE rdf_first_statement; +CREATE VIEW rdf_first_statement AS SELECT * FROM statements WHERE predicate='rdf:first'; + +DROP TABLE rdf_rest_statement; +CREATE VIEW rdf_rest_statement AS SELECT * FROM statements WHERE predicate='rdf:rest'; + +DROP TABLE rdf_rest_transitive_statement; +CREATE VIEW rdf_rest_transitive_statement AS WITH RECURSIVE rdf_rest_transitive_statement + ( + subject, object + ) + AS + (SELECT subject, object + FROM rdf_rest_statement + UNION ALL + SELECT + rest.subject, rest_t.object + FROM rdf_rest_statement AS rest + JOIN rdf_rest_transitive_statement AS rest_t + ON rest.object = rest_t.subject + ) + SELECT * FROM rdf_rest_transitive_statement; + +DROP TABLE rdf_list_member_statement; +CREATE VIEW rdf_list_member_statement AS SELECT + rest_t.subject, + f.object + FROM rdf_rest_transitive_statement AS rest_t JOIN rdf_first_statement AS f ON (rest_t.object = f.subject) + UNION + SELECT subject,object FROM rdf_first_statement; + +DROP TABLE node; +CREATE VIEW node AS SELECT distinct(subject) AS id FROM statements UNION SELECT distinct(object) AS id FROM statements WHERE datatype IS NOT NULL; + +DROP TABLE blank_node; +CREATE VIEW blank_node AS SELECT * FROM node WHERE id LIKE '_:%'; + +DROP TABLE rdf_list_node; +CREATE VIEW rdf_list_node AS SELECT distinct subject AS id from rdf_type_statement WHERE object = 'rdf:List'; + +DROP TABLE iri_node; +CREATE VIEW iri_node AS SELECT * FROM node WHERE id NOT LIKE '_:%'; + +DROP TABLE class_node; +CREATE VIEW class_node AS SELECT distinct subject AS id from rdf_type_statement WHERE object = 'owl:Class'; + +DROP TABLE property_node; +CREATE VIEW property_node AS SELECT distinct subject AS id from rdf_type_statement WHERE object = 'owl:Property'; + +DROP TABLE named_individual_node; +CREATE VIEW named_individual_node AS SELECT distinct subject AS id from rdf_type_statement WHERE object = 'owl:NamedIndividual'; + +DROP TABLE count_of_predicates; +CREATE VIEW count_of_predicates AS SELECT predicate AS element, count(*) AS count_value FROM statements GROUP BY predicate ORDER BY count_value DESC; + +DROP TABLE count_of_instantiated_classes; +CREATE VIEW count_of_instantiated_classes AS SELECT object AS element, count(*) AS count_value FROM rdf_type_statement GROUP BY element ORDER BY count_value DESC; + +DROP TABLE count_of_subclasses; +CREATE VIEW count_of_subclasses AS SELECT sc.object AS element, count(distinct sc.subject) AS count_value FROM rdfs_subclass_of_statement AS sc GROUP BY sc.object ORDER BY count_value DESC; diff --git a/src/semsql/builder/sql_schema/semsql.sql b/src/semsql/builder/sql_schema/semsql.sql index b7584e7..cb1d788 100644 --- a/src/semsql/builder/sql_schema/semsql.sql +++ b/src/semsql/builder/sql_schema/semsql.sql @@ -1,123 +1,142 @@ -- # Class: "term_association" Description: "A minimal datamodel for relating a subject entity to an object term" -- * Slot: id Description: An identifier for an element. Note blank node ids are not unique across databases --- * Slot: subject Description: --- * Slot: predicate Description: +-- * Slot: subject Description: The subject of the statement +-- * Slot: predicate Description: The predicate of the statement -- * Slot: object Description: Note the range of this slot is always a node. If the triple represents a literal, instead value will be populated -- * Slot: evidence_type Description: -- * Slot: publication Description: -- * Slot: source Description: -- # Class: "has_text_definition_statement" Description: "" --- * Slot: stanza Description: --- * Slot: subject Description: --- * Slot: predicate Description: +-- * Slot: stanza Description: the term which this statement is about +-- * Slot: subject Description: The subject of the statement +-- * Slot: predicate Description: The predicate of the statement -- * Slot: object Description: Note the range of this slot is always a node. If the triple represents a literal, instead value will be populated -- * Slot: value Description: Note the range of this slot is always a string. Only used the triple represents a literal assertion --- * Slot: datatype Description: --- * Slot: language Description: +-- * Slot: datatype Description: the rdf datatype of the value, for example, xsd:string +-- * Slot: language Description: the human language in which the value is encoded, e.g. en -- # Class: "has_oio_synonym_statement" Description: "" --- * Slot: stanza Description: --- * Slot: subject Description: --- * Slot: predicate Description: +-- * Slot: stanza Description: the term which this statement is about +-- * Slot: subject Description: The subject of the statement +-- * Slot: predicate Description: The predicate of the statement -- * Slot: object Description: Note the range of this slot is always a node. If the triple represents a literal, instead value will be populated -- * Slot: value Description: Note the range of this slot is always a string. Only used the triple represents a literal assertion --- * Slot: datatype Description: --- * Slot: language Description: +-- * Slot: datatype Description: the rdf datatype of the value, for example, xsd:string +-- * Slot: language Description: the human language in which the value is encoded, e.g. en -- # Class: "has_exact_synonym_statement" Description: "" --- * Slot: stanza Description: --- * Slot: subject Description: --- * Slot: predicate Description: +-- * Slot: stanza Description: the term which this statement is about +-- * Slot: subject Description: The subject of the statement +-- * Slot: predicate Description: The predicate of the statement -- * Slot: object Description: Note the range of this slot is always a node. If the triple represents a literal, instead value will be populated -- * Slot: value Description: Note the range of this slot is always a string. Only used the triple represents a literal assertion --- * Slot: datatype Description: --- * Slot: language Description: +-- * Slot: datatype Description: the rdf datatype of the value, for example, xsd:string +-- * Slot: language Description: the human language in which the value is encoded, e.g. en -- # Class: "has_broad_synonym_statement" Description: "" --- * Slot: stanza Description: --- * Slot: subject Description: --- * Slot: predicate Description: +-- * Slot: stanza Description: the term which this statement is about +-- * Slot: subject Description: The subject of the statement +-- * Slot: predicate Description: The predicate of the statement -- * Slot: object Description: Note the range of this slot is always a node. If the triple represents a literal, instead value will be populated -- * Slot: value Description: Note the range of this slot is always a string. Only used the triple represents a literal assertion --- * Slot: datatype Description: --- * Slot: language Description: +-- * Slot: datatype Description: the rdf datatype of the value, for example, xsd:string +-- * Slot: language Description: the human language in which the value is encoded, e.g. en -- # Class: "has_narrow_synonym_statement" Description: "" --- * Slot: stanza Description: --- * Slot: subject Description: --- * Slot: predicate Description: +-- * Slot: stanza Description: the term which this statement is about +-- * Slot: subject Description: The subject of the statement +-- * Slot: predicate Description: The predicate of the statement -- * Slot: object Description: Note the range of this slot is always a node. If the triple represents a literal, instead value will be populated -- * Slot: value Description: Note the range of this slot is always a string. Only used the triple represents a literal assertion --- * Slot: datatype Description: --- * Slot: language Description: +-- * Slot: datatype Description: the rdf datatype of the value, for example, xsd:string +-- * Slot: language Description: the human language in which the value is encoded, e.g. en -- # Class: "has_related_synonym_statement" Description: "" --- * Slot: stanza Description: --- * Slot: subject Description: --- * Slot: predicate Description: +-- * Slot: stanza Description: the term which this statement is about +-- * Slot: subject Description: The subject of the statement +-- * Slot: predicate Description: The predicate of the statement -- * Slot: object Description: Note the range of this slot is always a node. If the triple represents a literal, instead value will be populated -- * Slot: value Description: Note the range of this slot is always a string. Only used the triple represents a literal assertion --- * Slot: datatype Description: --- * Slot: language Description: +-- * Slot: datatype Description: the rdf datatype of the value, for example, xsd:string +-- * Slot: language Description: the human language in which the value is encoded, e.g. en -- # Class: "has_synonym_statement" Description: "" --- * Slot: stanza Description: --- * Slot: subject Description: --- * Slot: predicate Description: +-- * Slot: stanza Description: the term which this statement is about +-- * Slot: subject Description: The subject of the statement +-- * Slot: predicate Description: The predicate of the statement -- * Slot: object Description: Note the range of this slot is always a node. If the triple represents a literal, instead value will be populated -- * Slot: value Description: Note the range of this slot is always a string. Only used the triple represents a literal assertion --- * Slot: datatype Description: --- * Slot: language Description: +-- * Slot: datatype Description: the rdf datatype of the value, for example, xsd:string +-- * Slot: language Description: the human language in which the value is encoded, e.g. en -- # Class: "has_exact_match_statement" Description: "" --- * Slot: stanza Description: --- * Slot: subject Description: --- * Slot: predicate Description: +-- * Slot: stanza Description: the term which this statement is about +-- * Slot: subject Description: The subject of the statement +-- * Slot: predicate Description: The predicate of the statement -- * Slot: object Description: Note the range of this slot is always a node. If the triple represents a literal, instead value will be populated -- * Slot: value Description: Note the range of this slot is always a string. Only used the triple represents a literal assertion --- * Slot: datatype Description: --- * Slot: language Description: +-- * Slot: datatype Description: the rdf datatype of the value, for example, xsd:string +-- * Slot: language Description: the human language in which the value is encoded, e.g. en -- # Class: "has_broad_match_statement" Description: "" --- * Slot: stanza Description: --- * Slot: subject Description: --- * Slot: predicate Description: +-- * Slot: stanza Description: the term which this statement is about +-- * Slot: subject Description: The subject of the statement +-- * Slot: predicate Description: The predicate of the statement -- * Slot: object Description: Note the range of this slot is always a node. If the triple represents a literal, instead value will be populated -- * Slot: value Description: Note the range of this slot is always a string. Only used the triple represents a literal assertion --- * Slot: datatype Description: --- * Slot: language Description: +-- * Slot: datatype Description: the rdf datatype of the value, for example, xsd:string +-- * Slot: language Description: the human language in which the value is encoded, e.g. en -- # Class: "has_narrow_match_statement" Description: "" --- * Slot: stanza Description: --- * Slot: subject Description: --- * Slot: predicate Description: +-- * Slot: stanza Description: the term which this statement is about +-- * Slot: subject Description: The subject of the statement +-- * Slot: predicate Description: The predicate of the statement -- * Slot: object Description: Note the range of this slot is always a node. If the triple represents a literal, instead value will be populated -- * Slot: value Description: Note the range of this slot is always a string. Only used the triple represents a literal assertion --- * Slot: datatype Description: --- * Slot: language Description: +-- * Slot: datatype Description: the rdf datatype of the value, for example, xsd:string +-- * Slot: language Description: the human language in which the value is encoded, e.g. en -- # Class: "has_related_match_statement" Description: "" --- * Slot: stanza Description: --- * Slot: subject Description: --- * Slot: predicate Description: +-- * Slot: stanza Description: the term which this statement is about +-- * Slot: subject Description: The subject of the statement +-- * Slot: predicate Description: The predicate of the statement -- * Slot: object Description: Note the range of this slot is always a node. If the triple represents a literal, instead value will be populated -- * Slot: value Description: Note the range of this slot is always a string. Only used the triple represents a literal assertion --- * Slot: datatype Description: --- * Slot: language Description: +-- * Slot: datatype Description: the rdf datatype of the value, for example, xsd:string +-- * Slot: language Description: the human language in which the value is encoded, e.g. en -- # Class: "has_match_statement" Description: "" --- * Slot: stanza Description: --- * Slot: subject Description: --- * Slot: predicate Description: +-- * Slot: stanza Description: the term which this statement is about +-- * Slot: subject Description: The subject of the statement +-- * Slot: predicate Description: The predicate of the statement -- * Slot: object Description: Note the range of this slot is always a node. If the triple represents a literal, instead value will be populated -- * Slot: value Description: Note the range of this slot is always a string. Only used the triple represents a literal assertion --- * Slot: datatype Description: --- * Slot: language Description: +-- * Slot: datatype Description: the rdf datatype of the value, for example, xsd:string +-- * Slot: language Description: the human language in which the value is encoded, e.g. en -- # Class: "has_dbxref_statement" Description: "" --- * Slot: stanza Description: --- * Slot: subject Description: --- * Slot: predicate Description: +-- * Slot: stanza Description: the term which this statement is about +-- * Slot: subject Description: The subject of the statement +-- * Slot: predicate Description: The predicate of the statement -- * Slot: object Description: Note the range of this slot is always a node. If the triple represents a literal, instead value will be populated -- * Slot: value Description: Note the range of this slot is always a string. Only used the triple represents a literal assertion --- * Slot: datatype Description: --- * Slot: language Description: +-- * Slot: datatype Description: the rdf datatype of the value, for example, xsd:string +-- * Slot: language Description: the human language in which the value is encoded, e.g. en -- # Class: "has_mapping_statement" Description: "" --- * Slot: stanza Description: --- * Slot: subject Description: --- * Slot: predicate Description: +-- * Slot: stanza Description: the term which this statement is about +-- * Slot: subject Description: The subject of the statement +-- * Slot: predicate Description: The predicate of the statement -- * Slot: object Description: Note the range of this slot is always a node. If the triple represents a literal, instead value will be populated -- * Slot: value Description: Note the range of this slot is always a string. Only used the triple represents a literal assertion --- * Slot: datatype Description: --- * Slot: language Description: +-- * Slot: datatype Description: the rdf datatype of the value, for example, xsd:string +-- * Slot: language Description: the human language in which the value is encoded, e.g. en +-- # Class: "contributor" Description: "" +-- * Slot: stanza Description: the term which this statement is about +-- * Slot: subject Description: The subject of the statement +-- * Slot: predicate Description: The predicate of the statement +-- * Slot: object Description: Note the range of this slot is always a node. If the triple represents a literal, instead value will be populated +-- * Slot: value Description: Note the range of this slot is always a string. Only used the triple represents a literal assertion +-- * Slot: datatype Description: the rdf datatype of the value, for example, xsd:string +-- * Slot: language Description: the human language in which the value is encoded, e.g. en +-- # Class: "creator" Description: "" +-- * Slot: stanza Description: the term which this statement is about +-- * Slot: subject Description: The subject of the statement +-- * Slot: predicate Description: The predicate of the statement +-- * Slot: object Description: Note the range of this slot is always a node. If the triple represents a literal, instead value will be populated +-- * Slot: value Description: Note the range of this slot is always a string. Only used the triple represents a literal assertion +-- * Slot: datatype Description: the rdf datatype of the value, for example, xsd:string +-- * Slot: language Description: the human language in which the value is encoded, e.g. en +-- # Class: "orcid" Description: "" +-- * Slot: label Description: A label for an element +-- * Slot: id Description: An identifier for an element. Note blank node ids are not unique across databases -- # Class: "axiom_dbxref_annotation" Description: "" -- * Slot: annotation_subject Description: -- * Slot: annotation_predicate Description: @@ -126,18 +145,13 @@ -- * Slot: annotation_language Description: -- * Slot: annotation_datatype Description: -- * Slot: id Description: An identifier for an element. Note blank node ids are not unique across databases --- * Slot: axiom_predicate Description: --- * Slot: axiom_object Description: --- * Slot: axiom_value Description: --- * Slot: axiom_language Description: --- * Slot: axiom_datatype Description: --- * Slot: stanza Description: --- * Slot: subject Description: --- * Slot: predicate Description: +-- * Slot: stanza Description: the term which this statement is about +-- * Slot: subject Description: The subject of the statement +-- * Slot: predicate Description: The predicate of the statement -- * Slot: object Description: Note the range of this slot is always a node. If the triple represents a literal, instead value will be populated -- * Slot: value Description: Note the range of this slot is always a string. Only used the triple represents a literal assertion --- * Slot: datatype Description: --- * Slot: language Description: +-- * Slot: datatype Description: the rdf datatype of the value, for example, xsd:string +-- * Slot: language Description: the human language in which the value is encoded, e.g. en -- # Class: "ontology_node" Description: "A node representing an ontology" -- * Slot: id Description: An identifier for an element. Note blank node ids are not unique across databases -- # Class: "object_property_node" Description: "A node representing an OWL object property" @@ -157,71 +171,71 @@ -- # Class: "deprecated_node" Description: "" -- * Slot: id Description: An identifier for an element. Note blank node ids are not unique across databases -- # Class: "owl_imports_statement" Description: "" --- * Slot: stanza Description: --- * Slot: subject Description: --- * Slot: predicate Description: +-- * Slot: stanza Description: the term which this statement is about +-- * Slot: subject Description: The subject of the statement +-- * Slot: predicate Description: The predicate of the statement -- * Slot: object Description: Note the range of this slot is always a node. If the triple represents a literal, instead value will be populated -- * Slot: value Description: Note the range of this slot is always a string. Only used the triple represents a literal assertion --- * Slot: datatype Description: --- * Slot: language Description: +-- * Slot: datatype Description: the rdf datatype of the value, for example, xsd:string +-- * Slot: language Description: the human language in which the value is encoded, e.g. en -- # Class: "owl_inverse_of_statement" Description: "" --- * Slot: stanza Description: --- * Slot: subject Description: --- * Slot: predicate Description: +-- * Slot: stanza Description: the term which this statement is about +-- * Slot: subject Description: The subject of the statement +-- * Slot: predicate Description: The predicate of the statement -- * Slot: object Description: Note the range of this slot is always a node. If the triple represents a literal, instead value will be populated -- * Slot: value Description: Note the range of this slot is always a string. Only used the triple represents a literal assertion --- * Slot: datatype Description: --- * Slot: language Description: +-- * Slot: datatype Description: the rdf datatype of the value, for example, xsd:string +-- * Slot: language Description: the human language in which the value is encoded, e.g. en -- # Class: "owl_complement_of_statement" Description: "" --- * Slot: stanza Description: --- * Slot: subject Description: --- * Slot: predicate Description: +-- * Slot: stanza Description: the term which this statement is about +-- * Slot: subject Description: The subject of the statement +-- * Slot: predicate Description: The predicate of the statement -- * Slot: object Description: Note the range of this slot is always a node. If the triple represents a literal, instead value will be populated -- * Slot: value Description: Note the range of this slot is always a string. Only used the triple represents a literal assertion --- * Slot: datatype Description: --- * Slot: language Description: +-- * Slot: datatype Description: the rdf datatype of the value, for example, xsd:string +-- * Slot: language Description: the human language in which the value is encoded, e.g. en -- # Class: "owl_equivalent_class_statement" Description: "A statement that connects two class_nodes where both classes are equivalent" --- * Slot: stanza Description: +-- * Slot: stanza Description: the term which this statement is about -- * Slot: subject Description: One of the two classes that are equivalent. No significance to subject vs object --- * Slot: predicate Description: +-- * Slot: predicate Description: The predicate of the statement -- * Slot: object Description: One of the two classes that are equivalent. No significance to subject vs object -- * Slot: value Description: Note the range of this slot is always a string. Only used the triple represents a literal assertion --- * Slot: datatype Description: --- * Slot: language Description: +-- * Slot: datatype Description: the rdf datatype of the value, for example, xsd:string +-- * Slot: language Description: the human language in which the value is encoded, e.g. en -- # Class: "owl_same_as_statement" Description: "A statement that connects two individual nodes where both individual are equivalent" --- * Slot: stanza Description: +-- * Slot: stanza Description: the term which this statement is about -- * Slot: subject Description: One of the two classes that are equivalent. No significance to subject vs object --- * Slot: predicate Description: +-- * Slot: predicate Description: The predicate of the statement -- * Slot: object Description: One of the two classes that are equivalent. No significance to subject vs object -- * Slot: value Description: Note the range of this slot is always a string. Only used the triple represents a literal assertion --- * Slot: datatype Description: --- * Slot: language Description: +-- * Slot: datatype Description: the rdf datatype of the value, for example, xsd:string +-- * Slot: language Description: the human language in which the value is encoded, e.g. en -- # Class: "owl_disjoint_class_statement" Description: "" --- * Slot: stanza Description: +-- * Slot: stanza Description: the term which this statement is about -- * Slot: subject Description: One of the two classes that are disjoint. No significance to subject vs object --- * Slot: predicate Description: +-- * Slot: predicate Description: The predicate of the statement -- * Slot: object Description: One of the two classes that are disjoint. No significance to subject vs object -- * Slot: value Description: Note the range of this slot is always a string. Only used the triple represents a literal assertion --- * Slot: datatype Description: --- * Slot: language Description: +-- * Slot: datatype Description: the rdf datatype of the value, for example, xsd:string +-- * Slot: language Description: the human language in which the value is encoded, e.g. en -- # Class: "owl_reified_axiom" Description: "An OWL axiom that has been reified - i.e. it includes an [id](id) field that uniquely identifies that axiom and which can be the subject of additional statements" -- * Slot: id Description: An identifier for an element. Note blank node ids are not unique across databases --- * Slot: stanza Description: --- * Slot: subject Description: --- * Slot: predicate Description: +-- * Slot: stanza Description: the term which this statement is about +-- * Slot: subject Description: The subject of the statement +-- * Slot: predicate Description: The predicate of the statement -- * Slot: object Description: Note the range of this slot is always a node. If the triple represents a literal, instead value will be populated -- * Slot: value Description: Note the range of this slot is always a string. Only used the triple represents a literal assertion --- * Slot: datatype Description: --- * Slot: language Description: +-- * Slot: datatype Description: the rdf datatype of the value, for example, xsd:string +-- * Slot: language Description: the human language in which the value is encoded, e.g. en -- # Class: "owl_axiom" Description: "" -- * Slot: id Description: An identifier for an element. Note blank node ids are not unique across databases --- * Slot: stanza Description: --- * Slot: subject Description: --- * Slot: predicate Description: +-- * Slot: stanza Description: the term which this statement is about +-- * Slot: subject Description: The subject of the statement +-- * Slot: predicate Description: The predicate of the statement -- * Slot: object Description: Note the range of this slot is always a node. If the triple represents a literal, instead value will be populated -- * Slot: value Description: Note the range of this slot is always a string. Only used the triple represents a literal assertion --- * Slot: datatype Description: --- * Slot: language Description: +-- * Slot: datatype Description: the rdf datatype of the value, for example, xsd:string +-- * Slot: language Description: the human language in which the value is encoded, e.g. en -- # Class: "owl_axiom_annotation" Description: "" -- * Slot: annotation_subject Description: -- * Slot: annotation_predicate Description: @@ -230,18 +244,13 @@ -- * Slot: annotation_language Description: -- * Slot: annotation_datatype Description: -- * Slot: id Description: An identifier for an element. Note blank node ids are not unique across databases --- * Slot: axiom_predicate Description: --- * Slot: axiom_object Description: --- * Slot: axiom_value Description: --- * Slot: axiom_language Description: --- * Slot: axiom_datatype Description: --- * Slot: stanza Description: --- * Slot: subject Description: --- * Slot: predicate Description: +-- * Slot: stanza Description: the term which this statement is about +-- * Slot: subject Description: The subject of the statement +-- * Slot: predicate Description: The predicate of the statement -- * Slot: object Description: Note the range of this slot is always a node. If the triple represents a literal, instead value will be populated -- * Slot: value Description: Note the range of this slot is always a string. Only used the triple represents a literal assertion --- * Slot: datatype Description: --- * Slot: language Description: +-- * Slot: datatype Description: the rdf datatype of the value, for example, xsd:string +-- * Slot: language Description: the human language in which the value is encoded, e.g. en -- # Class: "anonymous_expression" Description: "An OWL expression, such as a class expression. Expressions are "anonymous" as they are a composition of named elements rather than a named element themselves" -- * Slot: id Description: An identifier for an element. Note blank node ids are not unique across databases -- # Class: "anonymous_class_expression" Description: "An OWL anonymous class expression, such as for example `SomeValuesFrom(partOf Hand)`" @@ -271,8 +280,8 @@ -- * Slot: filler Description: This is Null for a self-restriction -- * Slot: id Description: An identifier for an element. Note blank node ids are not unique across databases -- # Class: "owl_complex_axiom" Description: "An axiom that is composed of two or more statements" --- * Slot: subject Description: --- * Slot: predicate Description: +-- * Slot: subject Description: The subject of the statement +-- * Slot: predicate Description: The predicate of the statement -- * Slot: object Description: Note the range of this slot is always a node. If the triple represents a literal, instead value will be populated -- # Class: "owl_subclass_of_some_values_from" Description: "Composition of subClassOf and SomeValuesFrom" -- * Slot: subject Description: the class C in the axiom C subClassOf P some D @@ -281,130 +290,130 @@ -- # Class: "owl_equivalent_to_intersection_member" Description: "Composition of `OwlEquivalentClass`, `OwlIntersectionOf`, and `RdfListMember`; `C = X1 and ... and Xn`" -- * Slot: subject Description: the defined class -- * Slot: object Description: a class expression that forms the defining expression --- * Slot: predicate Description: +-- * Slot: predicate Description: The predicate of the statement -- # Class: "prefix" Description: "Maps CURIEs to URIs" -- * Slot: prefix Description: A standardized prefix such as 'GO' or 'rdf' or 'FlyBase' -- * Slot: base Description: The base URI a prefix will expand to -- # Class: "statements" Description: "Represents an RDF triple" --- * Slot: stanza Description: --- * Slot: subject Description: --- * Slot: predicate Description: +-- * Slot: stanza Description: the term which this statement is about +-- * Slot: subject Description: The subject of the statement +-- * Slot: predicate Description: The predicate of the statement -- * Slot: object Description: Note the range of this slot is always a node. If the triple represents a literal, instead value will be populated -- * Slot: value Description: Note the range of this slot is always a string. Only used the triple represents a literal assertion --- * Slot: datatype Description: --- * Slot: language Description: +-- * Slot: datatype Description: the rdf datatype of the value, for example, xsd:string +-- * Slot: language Description: the human language in which the value is encoded, e.g. en -- # Class: "node_to_node_statement" Description: "A statement where object is non-null and value is not populated" --- * Slot: stanza Description: --- * Slot: subject Description: --- * Slot: predicate Description: +-- * Slot: stanza Description: the term which this statement is about +-- * Slot: subject Description: The subject of the statement +-- * Slot: predicate Description: The predicate of the statement -- * Slot: object Description: Note the range of this slot is always a node. If the triple represents a literal, instead value will be populated -- * Slot: value Description: Note the range of this slot is always a string. Only used the triple represents a literal assertion --- * Slot: datatype Description: --- * Slot: language Description: +-- * Slot: datatype Description: the rdf datatype of the value, for example, xsd:string +-- * Slot: language Description: the human language in which the value is encoded, e.g. en -- # Class: "node_to_value_statement" Description: "A statement where value is non-null and object is not populated" --- * Slot: stanza Description: --- * Slot: subject Description: --- * Slot: predicate Description: +-- * Slot: stanza Description: the term which this statement is about +-- * Slot: subject Description: The subject of the statement +-- * Slot: predicate Description: The predicate of the statement -- * Slot: object Description: Note the range of this slot is always a node. If the triple represents a literal, instead value will be populated -- * Slot: value Description: Note the range of this slot is always a string. Only used the triple represents a literal assertion --- * Slot: datatype Description: --- * Slot: language Description: +-- * Slot: datatype Description: the rdf datatype of the value, for example, xsd:string +-- * Slot: language Description: the human language in which the value is encoded, e.g. en -- # Class: "rdf_type_statement" Description: "A statement that indicates the asserted type of the subject entity" --- * Slot: stanza Description: --- * Slot: subject Description: --- * Slot: predicate Description: +-- * Slot: stanza Description: the term which this statement is about +-- * Slot: subject Description: The subject of the statement +-- * Slot: predicate Description: The predicate of the statement -- * Slot: object Description: The entity type -- * Slot: value Description: Note the range of this slot is always a string. Only used the triple represents a literal assertion --- * Slot: datatype Description: --- * Slot: language Description: +-- * Slot: datatype Description: the rdf datatype of the value, for example, xsd:string +-- * Slot: language Description: the human language in which the value is encoded, e.g. en -- # Class: "rdfs_subclass_of_statement" Description: "" --- * Slot: stanza Description: +-- * Slot: stanza Description: the term which this statement is about -- * Slot: subject Description: The subclass element of the triple --- * Slot: predicate Description: +-- * Slot: predicate Description: The predicate of the statement -- * Slot: object Description: The superclass element of the triple -- * Slot: value Description: Note the range of this slot is always a string. Only used the triple represents a literal assertion --- * Slot: datatype Description: --- * Slot: language Description: +-- * Slot: datatype Description: the rdf datatype of the value, for example, xsd:string +-- * Slot: language Description: the human language in which the value is encoded, e.g. en -- # Class: "rdfs_subclass_of_named_statement" Description: "" --- * Slot: stanza Description: --- * Slot: subject Description: --- * Slot: predicate Description: +-- * Slot: stanza Description: the term which this statement is about +-- * Slot: subject Description: The subject of the statement +-- * Slot: predicate Description: The predicate of the statement -- * Slot: object Description: Note the range of this slot is always a node. If the triple represents a literal, instead value will be populated -- * Slot: value Description: Note the range of this slot is always a string. Only used the triple represents a literal assertion --- * Slot: datatype Description: --- * Slot: language Description: +-- * Slot: datatype Description: the rdf datatype of the value, for example, xsd:string +-- * Slot: language Description: the human language in which the value is encoded, e.g. en -- # Class: "rdfs_subproperty_of_statement" Description: "" --- * Slot: stanza Description: +-- * Slot: stanza Description: the term which this statement is about -- * Slot: subject Description: The subproperty element of the triple --- * Slot: predicate Description: +-- * Slot: predicate Description: The predicate of the statement -- * Slot: object Description: The superproperty element of the triple -- * Slot: value Description: Note the range of this slot is always a string. Only used the triple represents a literal assertion --- * Slot: datatype Description: --- * Slot: language Description: +-- * Slot: datatype Description: the rdf datatype of the value, for example, xsd:string +-- * Slot: language Description: the human language in which the value is encoded, e.g. en -- # Class: "rdfs_label_statement" Description: "" --- * Slot: stanza Description: --- * Slot: subject Description: --- * Slot: predicate Description: +-- * Slot: stanza Description: the term which this statement is about +-- * Slot: subject Description: The subject of the statement +-- * Slot: predicate Description: The predicate of the statement -- * Slot: object Description: Note the range of this slot is always a node. If the triple represents a literal, instead value will be populated -- * Slot: value Description: The label value --- * Slot: datatype Description: --- * Slot: language Description: +-- * Slot: datatype Description: the rdf datatype of the value, for example, xsd:string +-- * Slot: language Description: the human language in which the value is encoded, e.g. en -- # Class: "rdfs_domain_statement" Description: "" --- * Slot: stanza Description: --- * Slot: subject Description: --- * Slot: predicate Description: +-- * Slot: stanza Description: the term which this statement is about +-- * Slot: subject Description: The subject of the statement +-- * Slot: predicate Description: The predicate of the statement -- * Slot: object Description: Note the range of this slot is always a node. If the triple represents a literal, instead value will be populated -- * Slot: value Description: Note the range of this slot is always a string. Only used the triple represents a literal assertion --- * Slot: datatype Description: --- * Slot: language Description: +-- * Slot: datatype Description: the rdf datatype of the value, for example, xsd:string +-- * Slot: language Description: the human language in which the value is encoded, e.g. en -- # Class: "rdfs_range_statement" Description: "" --- * Slot: stanza Description: --- * Slot: subject Description: --- * Slot: predicate Description: +-- * Slot: stanza Description: the term which this statement is about +-- * Slot: subject Description: The subject of the statement +-- * Slot: predicate Description: The predicate of the statement -- * Slot: object Description: Note the range of this slot is always a node. If the triple represents a literal, instead value will be populated -- * Slot: value Description: Note the range of this slot is always a string. Only used the triple represents a literal assertion --- * Slot: datatype Description: --- * Slot: language Description: +-- * Slot: datatype Description: the rdf datatype of the value, for example, xsd:string +-- * Slot: language Description: the human language in which the value is encoded, e.g. en -- # Class: "rdf_list_statement" Description: "A statement that is used to represent aspects of RDF lists" --- * Slot: stanza Description: +-- * Slot: stanza Description: the term which this statement is about -- * Slot: subject Description: The rdf:List to which the statement applies --- * Slot: predicate Description: +-- * Slot: predicate Description: The predicate of the statement -- * Slot: object Description: Note the range of this slot is always a node. If the triple represents a literal, instead value will be populated -- * Slot: value Description: Note the range of this slot is always a string. Only used the triple represents a literal assertion --- * Slot: datatype Description: --- * Slot: language Description: +-- * Slot: datatype Description: the rdf datatype of the value, for example, xsd:string +-- * Slot: language Description: the human language in which the value is encoded, e.g. en -- # Class: "rdf_first_statement" Description: "A statement that connects a list to its first element. This is a low-level triple, it is unlikely you need to use this directly. It is used to define rdf_list_member_statement, which is more useful" --- * Slot: stanza Description: --- * Slot: subject Description: --- * Slot: predicate Description: +-- * Slot: stanza Description: the term which this statement is about +-- * Slot: subject Description: The subject of the statement +-- * Slot: predicate Description: The predicate of the statement -- * Slot: object Description: Note the range of this slot is always a node. If the triple represents a literal, instead value will be populated -- * Slot: value Description: Note the range of this slot is always a string. Only used the triple represents a literal assertion --- * Slot: datatype Description: --- * Slot: language Description: +-- * Slot: datatype Description: the rdf datatype of the value, for example, xsd:string +-- * Slot: language Description: the human language in which the value is encoded, e.g. en -- # Class: "rdf_rest_statement" Description: "A statement that connects a list to its remaining elements. This is a low-level triple, it is unlikely you need to use this directly. It is used to define rdf_list_member_statement, which is more useful" --- * Slot: stanza Description: --- * Slot: subject Description: --- * Slot: predicate Description: +-- * Slot: stanza Description: the term which this statement is about +-- * Slot: subject Description: The subject of the statement +-- * Slot: predicate Description: The predicate of the statement -- * Slot: object Description: Note the range of this slot is always a node. If the triple represents a literal, instead value will be populated -- * Slot: value Description: Note the range of this slot is always a string. Only used the triple represents a literal assertion --- * Slot: datatype Description: --- * Slot: language Description: +-- * Slot: datatype Description: the rdf datatype of the value, for example, xsd:string +-- * Slot: language Description: the human language in which the value is encoded, e.g. en -- # Class: "rdf_rest_transitive_statement" Description: "" --- * Slot: stanza Description: --- * Slot: subject Description: --- * Slot: predicate Description: +-- * Slot: stanza Description: the term which this statement is about +-- * Slot: subject Description: The subject of the statement +-- * Slot: predicate Description: The predicate of the statement -- * Slot: object Description: Note the range of this slot is always a node. If the triple represents a literal, instead value will be populated -- * Slot: value Description: Note the range of this slot is always a string. Only used the triple represents a literal assertion --- * Slot: datatype Description: --- * Slot: language Description: +-- * Slot: datatype Description: the rdf datatype of the value, for example, xsd:string +-- * Slot: language Description: the human language in which the value is encoded, e.g. en -- # Class: "rdf_list_member_statement" Description: "" --- * Slot: stanza Description: --- * Slot: subject Description: --- * Slot: predicate Description: +-- * Slot: stanza Description: the term which this statement is about +-- * Slot: subject Description: The subject of the statement +-- * Slot: predicate Description: The predicate of the statement -- * Slot: object Description: Note the range of this slot is always a node. If the triple represents a literal, instead value will be populated -- * Slot: value Description: Note the range of this slot is always a string. Only used the triple represents a literal assertion --- * Slot: datatype Description: --- * Slot: language Description: +-- * Slot: datatype Description: the rdf datatype of the value, for example, xsd:string +-- * Slot: language Description: the human language in which the value is encoded, e.g. en -- # Class: "node" Description: "The basic unit of representation in an RDF or OWL graph" -- * Slot: id Description: An identifier for an element. Note blank node ids are not unique across databases -- # Class: "blank_node" Description: "A node with an ID that is not preserved between databases" @@ -437,12 +446,12 @@ -- # Class: "individual_trait" Description: "" -- # Class: "is_report" Description: "Used to describe classes/views that have a reporting function" -- # Class: "relation_graph_construct" Description: "A construct used as part of a Relation Graph" --- * Slot: subject Description: --- * Slot: predicate Description: +-- * Slot: subject Description: The subject of the statement +-- * Slot: predicate Description: The predicate of the statement -- * Slot: object Description: Note the range of this slot is always a node. If the triple represents a literal, instead value will be populated -- # Class: "edge" Description: "A relation graph edge that connects two entities by a predicate. Note an edge is distinct from a statement, in that an axiom such as A SubClassOf R some B is represented as multiple statements, but is a single relation graph edge" --- * Slot: subject Description: --- * Slot: predicate Description: +-- * Slot: subject Description: The subject of the statement +-- * Slot: predicate Description: The predicate of the statement -- * Slot: object Description: Note the range of this slot is always a node. If the triple represents a literal, instead value will be populated -- # Class: "subgraph_query" Description: "A subgraph query encompasses as subgraph edge and a seed/anchor object and seed/anchor predicate" -- * Slot: subject Description: subject of the subgraph edge @@ -451,67 +460,67 @@ -- * Slot: anchor_object Description: The entity that is used to seed the graph. The seed entity will bear some relationship to each subgraph edge; E.g. with an ancestor subgraph query, all edges will have a subject that descends from the ancestor -- * Slot: anchor_predicate Description: The predicate that is used to determine if an edge should be included based on relationship to the anchor_object. -- # Class: "subgraph_edge_by_ancestor" Description: "An edge within a subgraph anchored around a set of ancestor terms" --- * Slot: subject Description: --- * Slot: predicate Description: +-- * Slot: subject Description: The subject of the statement +-- * Slot: predicate Description: The predicate of the statement -- * Slot: object Description: Note the range of this slot is always a node. If the triple represents a literal, instead value will be populated -- * Slot: anchor_object Description: The ancestor term -- * Slot: anchor_predicate Description: The entailed predicate that holds between each edge subject and the ancestor -- # Class: "subgraph_edge_by_descendant" Description: "An edge within a subgraph anchored around a set of descendant terms" --- * Slot: subject Description: --- * Slot: predicate Description: +-- * Slot: subject Description: The subject of the statement +-- * Slot: predicate Description: The predicate of the statement -- * Slot: object Description: Note the range of this slot is always a node. If the triple represents a literal, instead value will be populated -- * Slot: anchor_object Description: The descendant term -- * Slot: anchor_predicate Description: The entailed predicate that holds between the descendant and each edge subject -- # Class: "subgraph_edge_by_ancestor_or_descendant" Description: "" --- * Slot: subject Description: --- * Slot: predicate Description: +-- * Slot: subject Description: The subject of the statement +-- * Slot: predicate Description: The predicate of the statement -- * Slot: object Description: Note the range of this slot is always a node. If the triple represents a literal, instead value will be populated -- * Slot: anchor_object Description: -- * Slot: anchor_predicate Description: -- # Class: "subgraph_edge_by_parent" Description: "An edge within a subgraph anchored around a set of parent terms" --- * Slot: subject Description: --- * Slot: predicate Description: +-- * Slot: subject Description: The subject of the statement +-- * Slot: predicate Description: The predicate of the statement -- * Slot: object Description: Note the range of this slot is always a node. If the triple represents a literal, instead value will be populated -- * Slot: anchor_object Description: The parent term -- * Slot: anchor_predicate Description: The entailed predicate that holds between each edge subject and the parent -- # Class: "subgraph_edge_by_child" Description: "An edge within a subgraph anchored around a set of child terms" --- * Slot: subject Description: --- * Slot: predicate Description: +-- * Slot: subject Description: The subject of the statement +-- * Slot: predicate Description: The predicate of the statement -- * Slot: object Description: Note the range of this slot is always a node. If the triple represents a literal, instead value will be populated -- * Slot: anchor_object Description: The child term -- * Slot: anchor_predicate Description: The entailed predicate that holds between the child and each edge subject -- # Class: "subgraph_edge_by_self" Description: "A special null form of a subgraph query where there is no expansion" --- * Slot: subject Description: --- * Slot: predicate Description: +-- * Slot: subject Description: The subject of the statement +-- * Slot: predicate Description: The predicate of the statement -- * Slot: object Description: Note the range of this slot is always a node. If the triple represents a literal, instead value will be populated -- * Slot: anchor_object Description: -- * Slot: anchor_predicate Description: -- # Class: "entailed_edge" Description: "A relation graph edge that is inferred" --- * Slot: subject Description: --- * Slot: predicate Description: +-- * Slot: subject Description: The subject of the statement +-- * Slot: predicate Description: The predicate of the statement -- * Slot: object Description: Note the range of this slot is always a node. If the triple represents a literal, instead value will be populated -- # Class: "entailed_edge_cycle" Description: "An edge that composes with another edge to make a cycle" --- * Slot: subject Description: --- * Slot: predicate Description: +-- * Slot: subject Description: The subject of the statement +-- * Slot: predicate Description: The predicate of the statement -- * Slot: object Description: Note the range of this slot is always a node. If the triple represents a literal, instead value will be populated -- * Slot: secondary_predicate Description: -- # Class: "entailed_edge_same_predicate_cycle" Description: "An entailed_edge_cycle over a single predicate" --- * Slot: subject Description: --- * Slot: predicate Description: +-- * Slot: subject Description: The subject of the statement +-- * Slot: predicate Description: The predicate of the statement -- * Slot: object Description: Note the range of this slot is always a node. If the triple represents a literal, instead value will be populated -- * Slot: secondary_predicate Description: -- # Class: "transitive_edge" Description: "A relation graph edge that is formed from a chain of one or more edges" --- * Slot: subject Description: --- * Slot: predicate Description: +-- * Slot: subject Description: The subject of the statement +-- * Slot: predicate Description: The predicate of the statement -- * Slot: object Description: Note the range of this slot is always a node. If the triple represents a literal, instead value will be populated -- # Class: "ontology_status_statement" Description: "" --- * Slot: stanza Description: --- * Slot: subject Description: --- * Slot: predicate Description: +-- * Slot: stanza Description: the term which this statement is about +-- * Slot: subject Description: The subject of the statement +-- * Slot: predicate Description: The predicate of the statement -- * Slot: object Description: Note the range of this slot is always a node. If the triple represents a literal, instead value will be populated -- * Slot: value Description: Note the range of this slot is always a string. Only used the triple represents a literal assertion --- * Slot: datatype Description: --- * Slot: language Description: +-- * Slot: datatype Description: the rdf datatype of the value, for example, xsd:string +-- * Slot: language Description: the human language in which the value is encoded, e.g. en -- # Class: "repair_action" Description: "Represents an action that needs to be taken to repair a problem" -- * Slot: subject Description: The thing that is problematic -- * Slot: description Description: @@ -520,26 +529,26 @@ -- * Slot: predicate Description: The property of the thing that is problematic -- * Slot: value Description: Note the range of this slot is always a string. Only used the triple represents a literal assertion -- # Class: "lexical_problem" Description: "a problem with the textual value of an annotation property" --- * Slot: subject Description: --- * Slot: predicate Description: +-- * Slot: subject Description: The subject of the statement +-- * Slot: predicate Description: The predicate of the statement -- * Slot: value Description: Note the range of this slot is always a string. Only used the triple represents a literal assertion -- # Class: "trailing_whitespace_problem" Description: "" --- * Slot: subject Description: --- * Slot: predicate Description: +-- * Slot: subject Description: The subject of the statement +-- * Slot: predicate Description: The predicate of the statement -- * Slot: value Description: Note the range of this slot is always a string. Only used the triple represents a literal assertion -- # Class: "property_used_with_datatype_values_and_objects" Description: "A problem in which the same property is used two two different ways, one in which the range is a literal value, the other where it is an object." --- * Slot: subject Description: --- * Slot: predicate Description: +-- * Slot: subject Description: The subject of the statement +-- * Slot: predicate Description: The predicate of the statement -- * Slot: value Description: Note the range of this slot is always a string. Only used the triple represents a literal assertion -- # Class: "node_with_two_labels_problem" Description: "" -- * Slot: label1 Description: -- * Slot: label2 Description: --- * Slot: subject Description: --- * Slot: predicate Description: +-- * Slot: subject Description: The subject of the statement +-- * Slot: predicate Description: The predicate of the statement -- * Slot: value Description: Note the range of this slot is always a string. Only used the triple represents a literal assertion -- # Class: "all_problems" Description: "" --- * Slot: subject Description: --- * Slot: predicate Description: +-- * Slot: subject Description: The subject of the statement +-- * Slot: predicate Description: The predicate of the statement -- * Slot: value Description: Note the range of this slot is always a string. Only used the triple represents a literal assertion CREATE TABLE term_association ( @@ -678,6 +687,29 @@ CREATE TABLE has_mapping_statement ( datatype TEXT, language TEXT ); +CREATE TABLE contributor ( + stanza TEXT, + subject TEXT, + predicate TEXT, + object TEXT NOT NULL, + value TEXT, + datatype TEXT, + language TEXT +); +CREATE TABLE creator ( + stanza TEXT, + subject TEXT, + predicate TEXT, + object TEXT NOT NULL, + value TEXT, + datatype TEXT, + language TEXT +); +CREATE TABLE orcid ( + label TEXT, + id TEXT, + PRIMARY KEY (id) +); CREATE TABLE axiom_dbxref_annotation ( annotation_subject TEXT, annotation_predicate TEXT, @@ -686,11 +718,6 @@ CREATE TABLE axiom_dbxref_annotation ( annotation_language TEXT, annotation_datatype TEXT, id TEXT, - axiom_predicate TEXT, - axiom_object TEXT, - axiom_value TEXT, - axiom_language TEXT, - axiom_datatype TEXT, stanza TEXT, subject TEXT, predicate TEXT, @@ -820,11 +847,6 @@ CREATE TABLE owl_axiom_annotation ( annotation_language TEXT, annotation_datatype TEXT, id TEXT, - axiom_predicate TEXT, - axiom_object TEXT, - axiom_value TEXT, - axiom_language TEXT, - axiom_datatype TEXT, stanza TEXT, subject TEXT, predicate TEXT, @@ -1244,6 +1266,20 @@ CREATE VIEW has_dbxref_statement AS SELECT * FROM statements WHERE predicate='oi DROP TABLE has_mapping_statement; CREATE VIEW has_mapping_statement AS SELECT * FROM has_match_statement UNION SELECT * FROM has_dbxref_statement; +DROP TABLE contributor; +CREATE VIEW contributor AS SELECT * FROM statements WHERE predicate='dcterms:contributor'; + +DROP TABLE creator; +CREATE VIEW creator AS SELECT * FROM statements WHERE predicate='dcterms:creator'; + +DROP TABLE orcid; +CREATE VIEW orcid AS SELECT + subject AS id, + value AS label + FROM + rdfs_label_statement + WHERE subject like 'orcid:%'; + DROP TABLE axiom_dbxref_annotation; CREATE VIEW axiom_dbxref_annotation AS SELECT * FROM owl_axiom_annotation WHERE annotation_predicate = 'oio:hasDbXref'; @@ -1290,7 +1326,7 @@ DROP TABLE owl_same_as_statement; CREATE VIEW owl_same_as_statement AS SELECT * FROM statements WHERE predicate='owl:sameAs'; DROP TABLE owl_disjoint_class_statement; -CREATE VIEW owl_disjoint_class_statement AS SELECT * FROM statements WHERE predicate='owl:disjointClass'; +CREATE VIEW owl_disjoint_class_statement AS SELECT * FROM statements WHERE predicate='owl:disjointWith'; DROP TABLE owl_reified_axiom; CREATE VIEW owl_reified_axiom AS SELECT axs.subject AS id, axs.stanza AS stanza, axs.object AS subject, axp.object AS predicate, axo.object AS object, axo.value AS value, axo.datatype AS datatype, axo.language AS language FROM statements AS axs, statements AS axp, statements AS axo WHERE axs.predicate = 'owl:annotatedSource' AND axp.predicate = 'owl:annotatedProperty' AND axo.predicate = 'owl:annotatedTarget' AND axs.subject = axp.subject AND axs.subject = axo.subject; @@ -1488,8 +1524,14 @@ DROP TABLE count_of_subclasses; CREATE VIEW count_of_subclasses AS SELECT sc.object AS element, count(distinct sc.subject) AS count_value FROM rdfs_subclass_of_statement AS sc GROUP BY sc.object ORDER BY count_value DESC; DROP TABLE edge; -CREATE VIEW edge AS SELECT subject, predicate, object FROM owl_subclass_of_some_values_from UNION - SELECT subject, predicate, object FROM rdfs_subclass_of_named_statement; +CREATE VIEW edge AS SELECT subject, predicate, object + FROM owl_subclass_of_some_values_from + UNION + SELECT subject, predicate, object + FROM rdfs_subclass_of_named_statement + UNION + SELECT subject, predicate, object + FROM rdf_type_statement WHERE object IN (SELECT id FROM class_node); DROP TABLE subgraph_edge_by_ancestor; CREATE VIEW subgraph_edge_by_ancestor AS SELECT diff --git a/src/semsql/linkml/__init__.py b/src/semsql/linkml/__init__.py index 5beeffc..1b56169 100644 --- a/src/semsql/linkml/__init__.py +++ b/src/semsql/linkml/__init__.py @@ -2,6 +2,7 @@ this_path = Path(__file__).parent + def path_to_schema(schema_name: str = "semsql") -> Path: """ Returns path to the name of a schema @@ -9,4 +10,4 @@ def path_to_schema(schema_name: str = "semsql") -> Path: :param schema_name: defaults to global schema (semsql) :return: """ - return this_path / f"{schema_name}.yaml" \ No newline at end of file + return this_path / f"{schema_name}.yaml" diff --git a/src/semsql/linkml/omo.yaml b/src/semsql/linkml/omo.yaml index 473e8be..c66a0f8 100644 --- a/src/semsql/linkml/omo.yaml +++ b/src/semsql/linkml/omo.yaml @@ -94,6 +94,34 @@ classes: union_of: - has_match_statement - has_dbxref_statement + contributor: + is_a: node_to_node_statement + classification_rules: + is_a: statements + slot_conditions: + predicate: + equals_string: "dcterms:contributor" + creator: + is_a: node_to_node_statement + classification_rules: + is_a: statements + slot_conditions: + predicate: + equals_string: "dcterms:creator" + orcid: + is_a: node + slots: + - label + comments: + - |- + sqlview>> + SELECT + subject AS id, + value AS label + FROM + rdfs_label_statement + WHERE subject like 'orcid:%' + axiom_dbxref_annotation: comments: - sqlview>> SELECT * FROM owl_axiom_annotation WHERE annotation_predicate = 'oio:hasDbXref' @@ -101,4 +129,4 @@ classes: slots: evidence_type: publication: - source: \ No newline at end of file + source: diff --git a/src/semsql/linkml/owl.yaml b/src/semsql/linkml/owl.yaml index 6819901..3511804 100644 --- a/src/semsql/linkml/owl.yaml +++ b/src/semsql/linkml/owl.yaml @@ -136,7 +136,7 @@ classes: range: named_individual_node owl_disjoint_class_statement: comments: - - sqlview>> SELECT * FROM statements WHERE predicate='owl:disjointClass' + - sqlview>> SELECT * FROM statements WHERE predicate='owl:disjointWith' is_a: node_to_node_statement slot_usage: subject: diff --git a/src/semsql/linkml/rdf.yaml b/src/semsql/linkml/rdf.yaml index adec803..2a964b8 100644 --- a/src/semsql/linkml/rdf.yaml +++ b/src/semsql/linkml/rdf.yaml @@ -36,6 +36,13 @@ slots: across databases identifier: true range: node id type + label: + description: A label for an element + range: string + see_also: + - semsql:rdfs_label_statements + comments: + - intended for use as a node property. Labels can also be retrieved as rdfs_label_statement objects subject: aliases: - about diff --git a/src/semsql/loader.py b/src/semsql/loader.py index 7f7918d..253cf2d 100644 --- a/src/semsql/loader.py +++ b/src/semsql/loader.py @@ -30,8 +30,8 @@ def create_and_load(inputs: List[str], create: bool, url: str) -> None: engine = create_engine(url) with engine.connect() as con: load_ddl(con, "prefixes/prefix.sql") - #load_rdftab(con, "sql/rdftab.sql") - #load_rdftab(con, "sql_schema/semsql.sql") + # load_rdftab(con, "sql/rdftab.sql") + # load_rdftab(con, "sql_schema/semsql.sql") for input in inputs: subprocess.run(["./bin/rdftab", db, input]) diff --git a/src/semsql/ontlib/__init__.py b/src/semsql/ontlib/__init__.py index 866c477..b96e2db 100644 --- a/src/semsql/ontlib/__init__.py +++ b/src/semsql/ontlib/__init__.py @@ -1 +1,3 @@ from semsql.ontlib.subgraph import extract_subgraph + +__all__ = ["extract_subgraph"] diff --git a/src/semsql/ontlib/common_queries.py b/src/semsql/ontlib/common_queries.py index 728d838..ba93da0 100644 --- a/src/semsql/ontlib/common_queries.py +++ b/src/semsql/ontlib/common_queries.py @@ -1,8 +1,7 @@ import logging from typing import Dict, List, Optional -from semsql.sqla.semsql import (HasTextDefinitionStatement, - Prefix, +from semsql.sqla.semsql import (HasTextDefinitionStatement, Prefix, RdfsLabelStatement) PREFIX_MAP = Dict[str, str] diff --git a/src/semsql/ontlib/subgraph.py b/src/semsql/ontlib/subgraph.py index f7e78f7..a8aa7fc 100644 --- a/src/semsql/ontlib/subgraph.py +++ b/src/semsql/ontlib/subgraph.py @@ -164,7 +164,7 @@ def to_obo_format(g: OboGraphDict) -> None: for n in g["nodes"]: id = n["id"] print() - print(f"[Term]") + print("[Term]") print(f"id: {id}") print(f'name: {n["lbl"]}') if "meta" in n: @@ -189,7 +189,7 @@ def to_obo_format(g: OboGraphDict) -> None: print(f"relationship: {p} {o}{cmt}") -def to_markdown(g: OboGraphDict, prefixes: PREFIX_MAP = {}, definitions=True) -> None: +def to_markdown(g: OboGraphDict, prefixes: PREFIX_MAP = None, definitions=True) -> None: """ Serialization to markdown @@ -197,6 +197,8 @@ def to_markdown(g: OboGraphDict, prefixes: PREFIX_MAP = {}, definitions=True) -> :param g: :return: """ + if prefixes is None: + prefixes = {} eix = graph_to_subject_index(g) nix = {n["id"]: n for n in g["nodes"]} for n in g["nodes"]: @@ -225,7 +227,7 @@ def to_markdown(g: OboGraphDict, prefixes: PREFIX_MAP = {}, definitions=True) -> print(f" * {plink} {olink} {cmt}") -def _id_to_markdown_link(id: str, prefixes={}): +def _id_to_markdown_link(id: str, prefixes=None): pfx, localid = id.split(":") if pfx in prefixes: url = f"{prefixes[pfx]}{localid}" @@ -238,7 +240,7 @@ def render_edges( session, edges: List[Row], to_format: str = "text", - seeds: List[CURIE] = [], + seeds: List[CURIE] = None, stylemap: str = None, configure: str = None, ): @@ -251,6 +253,8 @@ def render_edges( :param stylemap: used for graphviz rendering :return: """ + if seeds is None: + seeds = [] prefixes = get_prefixes(session) if to_format == "obojson": g = edges_to_obograph(session, edges, definitions=True) @@ -265,15 +269,15 @@ def render_edges( g1 = edges_to_obograph(session, edges) g = {"graphs": [g1]} logger.debug(f"graph = {g}") - EXEC = "og2dot.js" - if shutil.which(EXEC) is None: - logger.error(f"No {EXEC}") + exec = "og2dot.js" + if shutil.which(exec) is None: + logger.error(f"No {exec}") print("You need to install a node package to be able to visualize results") print("") print("npm install -g obographviz") print("Then set your path to include og2dot") raise Exception( - f"Cannot find {EXEC} on path. Install from https://github.com/cmungall/obographviz" + f"Cannot find {exec} on path. Install from https://github.com/cmungall/obographviz" ) with tempfile.NamedTemporaryFile(dir="/tmp", mode="w") as tmpfile: style = {} @@ -414,8 +418,7 @@ def cli( """ logging.basicConfig(level=LOGLEVEL[verbose]) engine = create_engine(f"sqlite:///{db}") - Session = sessionmaker(bind=engine) - session = Session() + session = sessionmaker(bind=engine)() logger.info(f"QUERY: {terms}") ids = term_search(session, terms, TERM_QUERY_VIEWS[match_criteria]) logger.debug(f"SEED CURIES: {ids}") diff --git a/src/semsql/sqlutils/view2table.py b/src/semsql/sqlutils/view2table.py index 546f751..5eb6ab8 100644 --- a/src/semsql/sqlutils/view2table.py +++ b/src/semsql/sqlutils/view2table.py @@ -36,9 +36,7 @@ def cli(inputs, name: str, index: bool): if index: for sn in sv.class_slots(cn): colname = underscore(sn) - print( - f"CREATE INDEX {tn}_{colname} ON {tn}({colname});" - ) + print(f"CREATE INDEX {tn}_{colname} ON {tn}({colname});") if __name__ == "__main__": diff --git a/src/semsql/utils/makefile_utils.py b/src/semsql/utils/makefile_utils.py new file mode 100644 index 0000000..fd32351 --- /dev/null +++ b/src/semsql/utils/makefile_utils.py @@ -0,0 +1,26 @@ +from semsql.builder.registry.registry_schema import Makefile, MakefileRule + + +def makerule_to_string(makerule: MakefileRule) -> str: + """ + Convert a MakeRule to a string + + :param makerule: + :return: + """ + dependencies_str = " ".join(makerule.dependencies) + commands_str = "".join([f"\t{c}\n" for c in makerule.commands]) + as_str = f"{makerule.target}: {dependencies_str}\n{commands_str}" + if makerule.precious: + as_str = f"{as_str}\n.PRECIOUS: {makerule.target}" + return f"{as_str}\n" + + +def makefile_to_string(makefile: Makefile) -> str: + """ + Convert a Makefile to a string + + :param makefile: + :return: + """ + return "\n".join([makerule_to_string(m) for m in makefile.rules]) diff --git a/tests/test_builder/test_builder.py b/tests/test_builder/test_builder.py new file mode 100644 index 0000000..ec0950a --- /dev/null +++ b/tests/test_builder/test_builder.py @@ -0,0 +1,22 @@ +import os +import unittest + +from semsql.builder import builder +from semsql.builder.registry import path_to_ontology_registry + +cwd = os.path.abspath(os.path.dirname(__file__)) +DB_DIR = os.path.join(cwd, "../inputs") +OUTPUT_DIR = os.path.join(cwd, "../outputs") +SRC_OWL = os.path.join(DB_DIR, "go-nucleus.owl") +SRC_DB = os.path.join(DB_DIR, "go-nucleus.db") +TEST_OWL = os.path.join(OUTPUT_DIR, "go-nucleus-in.owl") +TEST_DB = os.path.join(OUTPUT_DIR, "go-nucleus-in.db") + + +class TestBuilder(unittest.TestCase): + def setUp(self) -> None: + self.registry = str(path_to_ontology_registry()) + + def test_builder(self): + mkfile = builder.compile_registry(self.registry) + print(mkfile) diff --git a/tests/test_builder/test_cli.py b/tests/test_builder/test_cli.py index b28fce5..0007167 100644 --- a/tests/test_builder/test_cli.py +++ b/tests/test_builder/test_cli.py @@ -1,4 +1,3 @@ -import logging import os import unittest from shutil import copyfile @@ -24,7 +23,7 @@ def setUp(self) -> None: def test_main_help(self): result = self.runner.invoke(main, ["--help"]) out = result.stdout - err = result.stderr + result.stderr self.assertIn("query", out) self.assertIn("make", out) self.assertIn("download", out) @@ -32,20 +31,22 @@ def test_main_help(self): self.assertEqual(0, self.runner.invoke(main, ["download", "--help"]).exit_code) self.assertEqual(0, self.runner.invoke(main, ["make", "--help"]).exit_code) self.assertEqual(0, self.runner.invoke(main, ["query", "--help"]).exit_code) - self.assertEqual(0, self.runner.invoke(main, ["view2table", "--help"]).exit_code) + self.assertEqual( + 0, self.runner.invoke(main, ["view2table", "--help"]).exit_code + ) def test_view2table(self): result = self.runner.invoke(main, ["view2table", TEST_DB]) - out = result.stdout - err = result.stderr + result.stdout + result.stderr self.assertEqual(0, result.exit_code) @unittest.skip("Requires Docker or installing dependencies") def test_make_db(self): copyfile(SRC_OWL, TEST_OWL) result = self.runner.invoke(main, ["make", TEST_DB]) - out = result.stdout - err = result.stderr + result.stdout + result.stderr self.assertEqual(0, result.exit_code) @unittest.skip("Requires Docker or installing dependencies") @@ -54,6 +55,6 @@ def test_query(self): main, ["query", "-i", SRC_OWL, "SELECT * FROM rdfs_label_statement"] ) out = result.stdout - err = result.stderr + result.stderr self.assertIn("nucleus", out) self.assertEqual(0, result.exit_code) diff --git a/tests/test_ontlib/test_common_queries.py b/tests/test_ontlib/test_common_queries.py index 74d587a..0dfe3cf 100644 --- a/tests/test_ontlib/test_common_queries.py +++ b/tests/test_ontlib/test_common_queries.py @@ -20,8 +20,7 @@ class CommonQueriesTestCase(unittest.TestCase): def setUp(self): path = os.path.join(DB_DIR, "go-nucleus.db") engine = create_engine(f"sqlite:///{path}") - Session = sessionmaker(bind=engine) - self.session = Session() + self.session = sessionmaker(bind=engine)() def test_common_queries(self): diff --git a/tests/test_ontlib/test_subgraph.py b/tests/test_ontlib/test_subgraph.py index c1fa1ba..2caac06 100644 --- a/tests/test_ontlib/test_subgraph.py +++ b/tests/test_ontlib/test_subgraph.py @@ -23,13 +23,12 @@ class SubgraphTestCase(unittest.TestCase): def test_subgraph(self): path = os.path.join(DB_DIR, "go-nucleus.db") engine = create_engine(f"sqlite:///{path}") - Session = sessionmaker(bind=engine) - session = Session() + session = sessionmaker(bind=engine)() edges = extract_subgraph( session, terms=["CL:0000000"], view=SubgraphEdgeByAncestor ) lines = [] - print(f'graph for descendants of "cell"') + print('graph for descendants of "cell"') for e in edges: line = f"{e.subject} {e.predicate} {e.object}" print(line) @@ -37,7 +36,7 @@ def test_subgraph(self): assert "GO:0031967 BFO:0000050 GO:0043229" in lines assert "GO:0031975 rdfs:subClassOf GO:0110165" in lines - print(f'graph for ancestors of "nuclear membrane"') + print('graph for ancestors of "nuclear membrane"') edges = extract_subgraph( session, terms=["GO:0031965"], view=SubgraphEdgeByDescendant ) diff --git a/tests/test_orm/test_basic_sqla.py b/tests/test_orm/test_basic_sqla.py index 67f1063..10c038b 100644 --- a/tests/test_orm/test_basic_sqla.py +++ b/tests/test_orm/test_basic_sqla.py @@ -17,8 +17,7 @@ class SQLAlchemyTestCase(unittest.TestCase): def setUp(self) -> None: path = os.path.join(DB_DIR, "go-nucleus.db") engine = create_engine(f"sqlite:///{path}") - SessionClass = sessionmaker(bind=engine) - self.session = SessionClass() + self.session = sessionmaker(bind=engine)() def test_basic_sqla(self): """ @@ -87,8 +86,9 @@ def add_label(q, join_slot): q = add_label(q, RdfsSubclassOfStatement.subject) q = add_label(q, OwlSomeValuesFrom.filler) null = "NONE" - for ax, ex, sl, fl in q.all(): - line = f'{ax.subject} "{sl.value if sl else null}" subClassOf {ex.on_property} SOME {ex.filler} "{fl.value if fl else null}"' + for ax, _ex, sl, _fl in q.all(): + line = f'{ax.subject} "{sl.value if sl else null}"' + ' subClassOf {ex.on_property} SOME {ex.filler} "{fl.value if fl else null}"' logging.info(line) # print(line) lines.append(line) diff --git a/tests/test_orm/test_crud.py b/tests/test_orm/test_crud.py index 1048693..940075b 100644 --- a/tests/test_orm/test_crud.py +++ b/tests/test_orm/test_crud.py @@ -23,8 +23,7 @@ def test_crud(self): """ copyfile(SRC_DB, TEST_DB) engine = create_engine(f"sqlite:///{TEST_DB}") - Session = sessionmaker(bind=engine) - session = Session() + session = sessionmaker(bind=engine)() q = ( session.query(Statements) .filter(Statements.predicate == "rdfs:label") diff --git a/tests/test_orm/test_problems.py b/tests/test_orm/test_problems.py index 2c4d37c..6b25bc5 100644 --- a/tests/test_orm/test_problems.py +++ b/tests/test_orm/test_problems.py @@ -18,8 +18,7 @@ def test_problems(self): """ path = os.path.join(DB_DIR, "go-nucleus.db") engine = create_engine(f"sqlite:///{path}") - Session = sessionmaker(bind=engine) - session = Session() + session = sessionmaker(bind=engine)() print("OWL query:") q = session.query(AllProblems) n = 0 diff --git a/tox.ini b/tox.ini new file mode 100644 index 0000000..2030809 --- /dev/null +++ b/tox.ini @@ -0,0 +1,68 @@ +# Tox (http://tox.testrun.org/) is a tool for running tests +# in multiple virtualenvs. This configuration file will run the +# test suite on all supported python versions. To use it, "pip install tox" +# and then run "tox" from this directory. + +[tox] +isolated_build = true +envlist = + lint + flake8 + +[testenv:lint] +deps = + black + isort +skip_install = true +commands = + black . + isort . +description = Run linters. + +[testenv:flake8] +skip_install = true +deps = + flake8<5.0.0 + flake8-bandit + flake8-black + flake8-bugbear + flake8-colors + flake8-isort + pep8-naming +commands = + flake8 src/ tests/ +description = Run the flake8 tool with several plugins (bandit, docstrings, import order, pep8 naming). + +######################### +# Flake8 Configuration # +# (.flake8) # +######################### +[flake8] +ignore = + BLK100 # can't get black and isort to agree + E203 + W503 + C901 # needs code change so ignoring for now. + E731 # needs code change so ignoring for now. + S101 # asserts are fine + S106 # flags false positives with test_table_filler + N801 # mixed case is bad but there's a lot of auto-generated code + N815 # same ^ + S404 # Consider possible security implications associated with the subprocess module. + S108 # Probable insecure usage of temp file/directory. + S307 # Use of possibly insecure function - consider using safer ast.literal_eval. + S603 # subprocess call - check for execution of untrusted input. + S607 # Starting a process with a partial executable path ["open" in both cases] + S608 # Possible SQL injection vector through string-based query construction. + B024 # StreamingWriter is an abstract base class, but it has no abstract methods. + # Remember to use @abstractmethod, @abstractclassmethod and/or @abstractproperty decorators. +max-line-length = 120 +max-complexity = 13 +import-order-style = pycharm +application-import-names = + oaklib + tests +exclude = + datamodels ## datamodels are auto-generated + registry_schema.py ## auto-generated + sqla