use fastobo::ast as obo;
use horned_owl::model as owl;
use super::Context;
use super::IntoOwlCtx;
impl IntoOwlCtx for &obo::PrefixedIdent {
type Owl = owl::IRI;
fn into_owl(self, ctx: &mut Context) -> Self::Owl {
let iri = match ctx.idspaces.get(self.prefix()) {
Some(url) => format!("{}{}", url, self.local()),
None => format!(
"{}{}_{}",
crate::constants::uri::OBO,
self.prefix(),
self.local(),
),
};
ctx.build.iri(iri)
}
}
impl IntoOwlCtx for &obo::UnprefixedIdent {
type Owl = owl::IRI;
fn into_owl(self, ctx: &mut Context) -> Self::Owl {
ctx.build
.iri(format!("{}#{}", &ctx.ontology_iri, self.as_str()))
}
}
impl IntoOwlCtx for &obo::Url {
type Owl = owl::IRI;
fn into_owl(self, ctx: &mut Context) -> Self::Owl {
ctx.build.iri(self.as_str())
}
}
impl IntoOwlCtx for &obo::Ident {
type Owl = owl::IRI;
fn into_owl(self, ctx: &mut Context) -> Self::Owl {
match self {
obo::Ident::Url(url) => url.into_owl(ctx),
obo::Ident::Unprefixed(id) => id.into_owl(ctx),
obo::Ident::Prefixed(id) => id.into_owl(ctx),
}
}
}
impl IntoOwlCtx for &obo::ClassIdent {
type Owl = owl::IRI;
fn into_owl(self, ctx: &mut Context) -> Self::Owl {
self.as_ref().into_owl(ctx)
}
}
impl IntoOwlCtx for &obo::RelationIdent {
type Owl = owl::IRI;
fn into_owl(self, ctx: &mut Context) -> Self::Owl {
self.as_ref().into_owl(ctx)
}
}
impl IntoOwlCtx for &obo::SubsetIdent {
type Owl = owl::IRI;
fn into_owl(self, ctx: &mut Context) -> Self::Owl {
self.as_ref().into_owl(ctx)
}
}
impl IntoOwlCtx for &obo::SynonymTypeIdent {
type Owl = owl::IRI;
fn into_owl(self, ctx: &mut Context) -> Self::Owl {
self.as_ref().into_owl(ctx)
}
}