132_pretend_chebi_hierarchy_is_consistent_over_acid_base_relations
- ChEBI
- Metabolite
The ChEBI hierarchy is not consistent between conjugate base/acid relationships this query pretends that these can be transfered as is. In the example specifically for lipids
Use at
PREFIX rdfs:<http://www.w3.org/2000/01/rdf-schema#>
PREFIX CHEBI:<http://purl.obolibrary.org/obo/CHEBI_>
PREFIX chemrof: <https://w3id.org/chemrof/>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX is_conjugate_acid_of: <http://purl.obolibrary.org/obo/RO_0018034>
PREFIX is_conjugate_base_of: <http://purl.obolibrary.org/obo/RO_0018033>
SELECT
?chebi
WHERE {
# Specifically for lipids
BIND(CHEBI:18059 AS ?chebiClass)
{
?chebi rdfs:subClassOf+ ?chebiRestriction .
?chebiRestriction a owl:Restriction .
{
?chebiRestriction owl:onProperty is_conjugate_acid_of: .
} UNION {
?chebiRestriction owl:onProperty is_conjugate_base_of: .
}
?chebiRestriction owl:someValuesFrom ?chebiRelationTarget .
?chebiRelationTarget rdfs:subClassOf+ ?chebiClass .
FILTER(NOT EXISTS{
# Zwiterions should b excluded from being considered for transfering the hierarchy
?chebi rdfs:subClassOf CHEBI:27369 .
})
# If the charge is zero then don't expand the hierarchy.
OPTIONAL {
?chebi chemrof:charge "0"^^xsd:int .
BIND(true AS ?chebiChargeZero)
}
FILTER(!BOUND(?chebiChargeZero))
} UNION {
#Also look directly in the upper classes to follow the normal hierarchy path.
?chebi rdfs:subClassOf+ ?chebiClass .
}
}
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v3("?chebi"):::projected
v6("?chebiChargeZero")
v1("?chebiClass")
v5("?chebiRelationTarget")
v4("?chebiRestriction")
c10(["0^^xsd:int"]):::literal
c7(["is_conjugate_base_of:"]):::iri
c4(["owl:Restriction"]):::iri
c2(["CHEBI:27369"]):::iri
c6(["is_conjugate_acid_of:"]):::iri
bind0[/"'CHEBI:18059'"/]
bind0 --as--o v1
subgraph union0[" Union "]
subgraph union0l[" "]
style union0l fill:#abf,stroke-dasharray: 3 3;
v3 --"rdfs:subClassOf"--> v1
end
subgraph union0r[" "]
style union0r fill:#abf,stroke-dasharray: 3 3;
f1[["not bound(?chebiChargeZero)"]]
f1 --> v6
f2[["not "]]
subgraph f2e0["Exists Clause"]
e0v1 --"rdfs:subClassOf"--> e0c2
e0v1("?chebi"):::projected
e0c2(["CHEBI:27369"]):::iri
end
f2--EXISTS--> f2e0
f2 --> v3
f2 --> c1
f2 --> c2
v3 --"rdfs:subClassOf"--> c2
v3 --"rdfs:subClassOf"--> v4
v4 --"a"--> c4
subgraph union1[" Union "]
subgraph union1l[" "]
style union1l fill:#abf,stroke-dasharray: 3 3;
v4 --"owl:onProperty"--> c7
end
subgraph union1r[" "]
style union1r fill:#abf,stroke-dasharray: 3 3;
v4 --"owl:onProperty"--> c6
end
union1r <== or ==> union1l
end
v4 --"owl:someValuesFrom"--> v5
v5 --"rdfs:subClassOf"--> v1
subgraph optional0["(optional)"]
style optional0 fill:#bbf,stroke-dasharray: 5 5;
v3 -."chemrof:charge".-> c10
bind3[/"'true^^xsd:boolean'"/]
bind3 --as--o v6
end
end
union0r <== or ==> union0l
end