Triple

class Triple(*, subject: Reference, predicate: Reference, object: Reference)[source]

Bases: BaseModel

A Pydantic model for a subject-predicate-object triple.

Triples can be constructed either from strings representing CURIEs or pre-parsed Reference objects representing CURIEs.

from curies import Triple, Reference

# construction with string representations of CURIEs
triple = Triple(
    subject="mesh:C000089",
    predicate="skos:exactMatch",
    object="CHEBI:28646",
)

# construction with object representations of CURIEs
triple = Triple(
    subject=Reference(prefix="mesh", identifier="C000089"),
    predicate=Reference(prefix="skos", identifier="exactMatch"),
    object=Reference(prefix="CHEBI", identifier="28646"),
)

Note

It’s up to you to validate your CURIEs are semantically sound, e.g., against the bioregistry.

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

Attributes Summary

model_config

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

Methods Summary

as_str_triple()

Get a three-tuple of strings representing this triple.

as_uri_triple(converter)

Get a three-tuple of strings representing the expanded URIs.

from_curies(subject_curie, predicate_curie, ...)

Construct a triple from three CURIE strings.

from_uris(subject, predicate, object, *, ...)

Construct a triple from three URI strings.

Attributes Documentation

model_config = {'frozen': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

Methods Documentation

as_str_triple() StrTriple[source]

Get a three-tuple of strings representing this triple.

as_uri_triple(converter: Converter) tuple[str, str, str][source]

Get a three-tuple of strings representing the expanded URIs.

classmethod from_curies(subject_curie: str, predicate_curie: str, object_curie: str, *, reference_cls: type[Reference] = <class 'curies.api.Reference'>) Self[source]

Construct a triple from three CURIE strings.

classmethod from_uris(subject: str, predicate: str, object: str, *, converter: Converter, reference_cls: type[Reference] = <class 'curies.api.Reference'>) Self[source]

Construct a triple from three URI strings.