Search in sources :

Example 6 with OBORelationship

use of edu.stanford.bmir.protege.web.shared.obo.OBORelationship in project webprotege by protegeproject.

the class TermRelationshipsManager method getRelationships.

public OBOTermRelationships getRelationships(OWLClass term) {
    OWLClass cls = dataFactory.getOWLClass(term.getIRI());
    Set<OWLSubClassOfAxiom> subClassOfAxioms = rootOntology.getSubClassAxiomsForSubClass(cls);
    Set<OBORelationship> rels = new HashSet<>();
    for (OWLSubClassOfAxiom ax : subClassOfAxioms) {
        Set<OWLObjectSomeValuesFrom> relationships = new HashSet<>();
        Set<OWLClassExpression> conjuncts = ax.getSuperClass().asConjunctSet();
        for (OWLClassExpression conjunct : conjuncts) {
            if (conjunct instanceof OWLObjectSomeValuesFrom) {
                OWLObjectSomeValuesFrom svf = (OWLObjectSomeValuesFrom) conjunct;
                if (!svf.getProperty().isAnonymous() && !svf.getFiller().isAnonymous()) {
                    relationships.add((OWLObjectSomeValuesFrom) conjunct);
                }
            }
        }
        if (relationships.size() == conjuncts.size()) {
            for (OWLObjectSomeValuesFrom rel : relationships) {
                OWLObjectPropertyData property = renderingManager.getRendering(rel.getProperty().asOWLObjectProperty());
                OWLClassData filler = renderingManager.getRendering(rel.getFiller().asOWLClass());
                OBORelationship oboRel = new OBORelationship(property, filler);
                rels.add(oboRel);
            }
        }
    }
    return new OBOTermRelationships(rels);
}
Also used : OWLObjectPropertyData(edu.stanford.bmir.protege.web.shared.entity.OWLObjectPropertyData) OBOTermRelationships(edu.stanford.bmir.protege.web.shared.obo.OBOTermRelationships) OWLClassData(edu.stanford.bmir.protege.web.shared.entity.OWLClassData) OBORelationship(edu.stanford.bmir.protege.web.shared.obo.OBORelationship) HashSet(java.util.HashSet)

Example 7 with OBORelationship

use of edu.stanford.bmir.protege.web.shared.obo.OBORelationship in project webprotege by protegeproject.

the class TermCrossProductsManager method setCrossProduct.

public void setCrossProduct(@Nonnull UserId userId, @Nonnull OWLClass term, @Nonnull OBOTermCrossProduct crossProduct) {
    Set<OWLClassExpression> intersectionOperands = new HashSet<>();
    Optional<OWLClassData> genus = crossProduct.getGenus();
    if (genus.isPresent()) {
        OWLClass cls = genus.get().getEntity();
        intersectionOperands.add(cls);
    }
    for (OBORelationship relationship : crossProduct.getRelationships().getRelationships()) {
        OWLObjectSomeValuesFrom someValuesFrom = relationshipConverter.toSomeValuesFrom(relationship);
        intersectionOperands.add(someValuesFrom);
    }
    OWLObjectIntersectionOf intersectionOf = df.getOWLObjectIntersectionOf(intersectionOperands);
    OWLEquivalentClassesAxiom newXPAxiom = df.getOWLEquivalentClassesAxiom(term, intersectionOf);
    Optional<OWLEquivalentClassesAxiom> existingXPAxiom = getCrossProductEquivalentClassesAxiom(term);
    List<OWLOntologyChange> changes = new ArrayList<>();
    changes.add(new AddAxiom(rootOntology, newXPAxiom));
    existingXPAxiom.ifPresent(ax -> changes.add(new RemoveAxiom(rootOntology, ax)));
    changeManager.applyChanges(userId, new FixedChangeListGenerator<>(changes, term, "Set cross product values"));
}
Also used : OWLClassData(edu.stanford.bmir.protege.web.shared.entity.OWLClassData) OBORelationship(edu.stanford.bmir.protege.web.shared.obo.OBORelationship)

Example 8 with OBORelationship

use of edu.stanford.bmir.protege.web.shared.obo.OBORelationship in project webprotege by protegeproject.

the class RelationshipConverter method toOboRelationship.

@Nonnull
public OBORelationship toOboRelationship(@Nonnull OWLObjectSomeValuesFrom someValuesFrom) {
    OWLObjectPropertyData property = renderingManager.getRendering(someValuesFrom.getProperty().asOWLObjectProperty());
    OWLClassData filler = renderingManager.getRendering(someValuesFrom.getFiller().asOWLClass());
    return new OBORelationship(property, filler);
}
Also used : OWLClassData(edu.stanford.bmir.protege.web.shared.entity.OWLClassData) OBORelationship(edu.stanford.bmir.protege.web.shared.obo.OBORelationship) OWLObjectPropertyData(edu.stanford.bmir.protege.web.shared.entity.OWLObjectPropertyData) Nonnull(javax.annotation.Nonnull)

Aggregations

OBORelationship (edu.stanford.bmir.protege.web.shared.obo.OBORelationship)8 OWLClassData (edu.stanford.bmir.protege.web.shared.entity.OWLClassData)5 OBOTermRelationships (edu.stanford.bmir.protege.web.shared.obo.OBOTermRelationships)4 OWLObjectPropertyData (edu.stanford.bmir.protege.web.shared.entity.OWLObjectPropertyData)2 OBOTermCrossProduct (edu.stanford.bmir.protege.web.shared.obo.OBOTermCrossProduct)2 ArrayList (java.util.ArrayList)2 HashSet (java.util.HashSet)2 Nonnull (javax.annotation.Nonnull)2 OWLClass (org.semanticweb.owlapi.model.OWLClass)2 GetOboTermRelationshipsAction (edu.stanford.bmir.protege.web.shared.obo.GetOboTermRelationshipsAction)1 SetOboTermRelationshipsAction (edu.stanford.bmir.protege.web.shared.obo.SetOboTermRelationshipsAction)1 OWLEntity (org.semanticweb.owlapi.model.OWLEntity)1