diff --git a/biosimulators_utils/omex_meta/data_model.py b/biosimulators_utils/omex_meta/data_model.py index f8ba0575..ee5a5837 100644 --- a/biosimulators_utils/omex_meta/data_model.py +++ b/biosimulators_utils/omex_meta/data_model.py @@ -19,6 +19,7 @@ 'BIOSIMULATIONS_PREDICATE_TYPES', 'BIOSIMULATIONS_THUMBNAIL_FORMATS', 'BIOSIMULATIONS_NAMESPACE_PREFIX_MAP', + 'BIOSIMULATIONS_NAMESPACE_ALIASES', 'BIOSIMULATIONS_THUMBNAIL_FORMATS', ] @@ -352,6 +353,11 @@ class OmexMetadataSchema(str, enum.Enum): 'http://xmlns.com/foaf/0.1/': 'foaf', } +BIOSIMULATIONS_NAMESPACE_ALIASES = { + 'http://purl.org/dc/elements/1.1/': 'http://dublincore.org/specifications/dublin-core/dcmi-terms/', + 'http://sempublishing.sourceforge.net/scoro/': 'http://purl.org/spar/scoro/', +} + BIOSIMULATIONS_THUMBNAIL_FORMATS = [ 'GIF', 'JPEG', diff --git a/biosimulators_utils/omex_meta/io.py b/biosimulators_utils/omex_meta/io.py index 7c7fa238..198552d8 100644 --- a/biosimulators_utils/omex_meta/io.py +++ b/biosimulators_utils/omex_meta/io.py @@ -11,7 +11,8 @@ from .data_model import (Triple, OmexMetadataOutputFormat, OmexMetadataSchema, BIOSIMULATIONS_ROOT_URI_PATTERN, BIOSIMULATIONS_PREDICATE_TYPES, - BIOSIMULATIONS_NAMESPACE_PREFIX_MAP) + BIOSIMULATIONS_NAMESPACE_PREFIX_MAP, + BIOSIMULATIONS_NAMESPACE_ALIASES) from .utils import get_local_combine_archive_content_uri, get_global_combine_archive_content_uri from .validation import validate_biosimulations_metadata from lxml import etree @@ -570,6 +571,24 @@ def parse_triples_to_schema(cls, triples, combine_archive_uri): errors = [] warnings = [] + for triple in triples: + subject = str(triple.subject) + predicate = str(triple.predicate) + object = str(triple.object) + + for ns, alias in BIOSIMULATIONS_NAMESPACE_ALIASES.items(): + if isinstance(triple.subject, rdflib.term.URIRef) and subject.startswith(ns): + subject = alias + subject[len(ns):] + triple.subject = rdflib.term.URIRef(subject) + + if isinstance(triple.predicate, rdflib.term.URIRef) and predicate.startswith(ns): + predicate = alias + predicate[len(ns):] + triple.predicate = rdflib.term.URIRef(predicate) + + if isinstance(triple.object, rdflib.term.URIRef) and object.startswith(ns): + object = alias + object[len(ns):] + triple.object = rdflib.term.URIRef(object) + objects = {} for triple in triples: for node, is_subject in [(triple.subject, True), (triple.object, False)]: