microbiomedata / nmdc-ontology

Creative Commons Zero v1.0 Universal
0 stars 0 forks source link

Use robot mirroring to make iterative builds of this ontology faster? #50

Open turbomam opened 6 months ago

turbomam commented 6 months ago

https://robot.obolibrary.org/mirror

robot mirror --input test.owl \
  --directory results/my-cache \
  --output results/my-catalog.xml
usage: robot mirror --input <file> --directory <directory> --output <file>
    --add-prefix <arg>      add prefix 'foo: http://bar' to the output
    --add-prefixes <arg>    add JSON-LD prefixes to the output
    --catalog <arg>         use catalog from provided file
 -d,--directory <arg>       target directory
 -h,--help                  print usage information
 -i,--input <arg>           mirror ontology from a file
 -I,--input-iri <arg>       mirror ontology from an IRI
    --noprefixes            do not use default prefixes
 -o,--output <arg>          output file for catalog (default
                            catalog-v001.xml)
 -p,--prefix <arg>          add a prefix 'foo: http://bar'
 -P,--prefixes <arg>        use prefixes from JSON-LD file
    --strict                use strict parsing when loading an ontology
 -V,--version               print version information
 -v,--verbose               increased logging
 -vv,--very-verbose         high logging
 -vvv,--very-very-verbose   maximum logging, including stack traces
 -x,--xml-entities          use entity substitution with ontology XML
                            output

This will generate a directory results/my-cache/purl.obolibrary.org/obo/ro/ (based on the ontology IRI) with the imported ontologies as files. The file my-catalog.xml is a generated XML catalog mapping the source URIs to local files.

<catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog" prefer="public">
<!--  generated mapping  -->
<uri name="http://purl.obolibrary.org/obo/ro/core.owl" uri="purl.obolibrary.org/obo/ro/core.owl"/>
<!--  generated mapping  -->
<uri name="http://purl.obolibrary.org/obo/ro/annotations.owl" uri="purl.obolibrary.org/obo/ro/annotations.owl"/>
<!--  generated mapping  -->
<uri name="http://purl.obolibrary.org/obo/ro/bfo-classes-minimal.owl" uri="purl.obolibrary.org/obo/ro/bfo-classes-minimal.owl"/>
</catalog>
turbomam commented 6 months ago

Here is the catalog we are currently using: src/ontology/catalog-v001.xml

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<catalog prefer="public" xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog">
    <uri id="Imports Wizard Entry" name="http://purl.obolibrary.org/obo/nmdco/releases/2021-08-17/imports/ro_import.owl" uri="imports/ro_import.owl"/>
    <uri id="Imports Wizard Entry" name="http://purl.obolibrary.org/obo/nmdco/releases/2021-08-17/imports/po_import.owl" uri="imports/po_import.owl"/>
    <group id="imports" prefer="public" xml:base="">
        <uri name="http://purl.obolibrary.org/obo/nmdco/imports/ro_import.owl" uri="imports/ro_import.owl"/>
        <uri name="http://purl.obolibrary.org/obo/nmdco/imports/po_import.owl" uri="imports/po_import.owl"/>
        <uri name="http://purl.obolibrary.org/obo/nmdco/imports/envo_import.owl" uri="imports/envo_import.owl"/>
    </group>
</catalog>
turbomam commented 6 months ago

src/ontology/nmdco-edit.owl (saved in functional syntax)

Prefix(:=<http://purl.obolibrary.org/obo/nmdco.owl#>)
Prefix(dce:=<http://purl.org/dc/elements/1.1/>)
Prefix(owl:=<http://www.w3.org/2002/07/owl#>)
Prefix(rdf:=<http://www.w3.org/1999/02/22-rdf-syntax-ns#>)
Prefix(xml:=<http://www.w3.org/XML/1998/namespace>)
Prefix(xsd:=<http://www.w3.org/2001/XMLSchema#>)
Prefix(rdfs:=<http://www.w3.org/2000/01/rdf-schema#>)
Prefix(dcterms:=<http://purl.org/dc/terms/>)

Ontology(<http://purl.obolibrary.org/obo/nmdco.owl>
Import(<http://purl.obolibrary.org/obo/nmdco/imports/envo_import.owl>)
Import(<http://purl.obolibrary.org/obo/nmdco/imports/po_import.owl>)
Import(<http://purl.obolibrary.org/obo/nmdco/imports/ro_import.owl>)
Annotation(dce:description "The NMDC Ontology (NMDCO) is used  by the National Micrbiome Data Collaborative (NMDC, https://microbiomedata.org) to annotate multi-omic microbiome metadata. It merges a number of ontologies relevant to the NMDC (such as the plant and environment ontologies) into a single ontology.

It is maintained using Github at https://github.com/microbiomedata/nmdc-ontology.

Please use this GitHub repository's Issue tracker to request new terms/classes or report errors or specific concerns related to the ontology.")
Annotation(dce:title "NMDC Ontology")
Annotation(dcterms:creator "Bill Duncan (https://orcid.org/0000-0001-9625-1899)")
Annotation(dcterms:license <https://creativecommons.org/publicdomain/zero/1.0/>)

Declaration(Class(<http://purl.obolibrary.org/obo/NMDCO_00000000>))

############################
#   Classes
############################

# Class: <http://purl.obolibrary.org/obo/NMDCO_00000000> (root node)

AnnotationAssertion(rdfs:label <http://purl.obolibrary.org/obo/NMDCO_00000000> "root node"@en)

)
turbomam commented 6 months ago

very crude example

robot mirror \
    --directory mirror \
    --input src/ontology/nmdco-edit.owl \
    --output mirror-catalog.xml
turbomam commented 6 months ago

Can catalogs be merged?

mirror-catalog.xml

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<catalog prefer="public" xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog">

  <!-- generated mapping -->
  <uri name="http://purl.obolibrary.org/obo/nmdco/imports/po_import.owl" uri="purl.obolibrary.org/obo/nmdco/imports/po_import.owl"/>

  <!-- generated mapping -->
  <uri name="http://purl.obolibrary.org/obo/nmdco/imports/envo_import.owl" uri="purl.obolibrary.org/obo/nmdco/imports/envo_import.owl"/>

  <!-- generated mapping -->
  <uri name="http://purl.obolibrary.org/obo/nmdco/imports/ro_import.owl" uri="purl.obolibrary.org/obo/nmdco/imports/ro_import.owl"/>

  <!-- generated mapping -->
  <uri name="http://purl.obolibrary.org/obo/nmdco.owl" uri="purl.obolibrary.org/obo/nmdco.owl"/>
</catalog>
turbomam commented 6 months ago
tree mirror
mirror
└── purl.obolibrary.org
    └── obo
        ├── nmdco
        │   └── imports
        │       ├── envo_import.owl
        │       ├── po_import.owl
        │       └── ro_import.owl
        └── nmdco.owl
turbomam commented 6 months ago

That was fast. Maybe it's the parsing that takes a while on each iteration of the build