Search in sources :

Example 1 with OBOTermRelationships

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

the class TermCrossProductsManager method getCrossProduct.

@Nonnull
public OBOTermCrossProduct getCrossProduct(@Nonnull OWLClass term) {
    Optional<OWLEquivalentClassesAxiom> axiom = getCrossProductEquivalentClassesAxiom(term);
    if (!axiom.isPresent()) {
        return OBOTermCrossProduct.emptyOBOTermCrossProduct();
    }
    Set<OWLObjectSomeValuesFrom> relationships = new HashSet<>();
    Optional<OWLClass> genus = Optional.empty();
    for (OWLClassExpression operand : axiom.get().getClassExpressionsMinus(term)) {
        Set<OWLClassExpression> conjuncts = operand.asConjunctSet();
        for (OWLClassExpression conjunct : conjuncts) {
            if (conjunct instanceof OWLObjectSomeValuesFrom) {
                OWLObjectSomeValuesFrom svf = (OWLObjectSomeValuesFrom) conjunct;
                if (!svf.getProperty().isAnonymous() && !svf.getFiller().isAnonymous()) {
                    relationships.add((OWLObjectSomeValuesFrom) conjunct);
                }
            } else if (conjunct instanceof OWLClass) {
                genus = Optional.of((OWLClass) conjunct);
            }
        }
    }
    Optional<OWLClassData> visualCls = genus.map(renderingManager::getRendering);
    Set<OBORelationship> discriminatingRelationships = relationships.stream().map(relationshipConverter::toOboRelationship).collect(toSet());
    return new OBOTermCrossProduct(visualCls, new OBOTermRelationships(discriminatingRelationships));
}
Also used : OBOTermCrossProduct(edu.stanford.bmir.protege.web.shared.obo.OBOTermCrossProduct) 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) Nonnull(javax.annotation.Nonnull)

Example 2 with OBOTermRelationships

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

the class OBOTermRelationshipPortletPresenter method commitChangesForEntity.

@Override
protected void commitChangesForEntity(OWLEntity entity) {
    if (!(entity instanceof OWLClass)) {
        return;
    }
    List<OBORelationship> relationships = editor.getValue().orElse(Collections.emptyList());
    dispatch.execute(new SetOboTermRelationshipsAction(getProjectId(), entity, new OBOTermRelationships(Sets.newHashSet(relationships))), result -> {
    });
}
Also used : OBORelationship(edu.stanford.bmir.protege.web.shared.obo.OBORelationship) OBOTermRelationships(edu.stanford.bmir.protege.web.shared.obo.OBOTermRelationships) OWLClass(org.semanticweb.owlapi.model.OWLClass) SetOboTermRelationshipsAction(edu.stanford.bmir.protege.web.shared.obo.SetOboTermRelationshipsAction)

Example 3 with OBOTermRelationships

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

the class OBOTermCrossProductEditorImpl method getValue.

@Override
public java.util.Optional<OBOTermCrossProduct> getValue() {
    if (!genusField.getValue().isPresent()) {
        return java.util.Optional.empty();
    }
    if (!relationshipsField.getValue().isPresent()) {
        return java.util.Optional.empty();
    }
    final OWLClassData genus = (OWLClassData) genusField.getValue().get();
    final OBOTermRelationships relationships = new OBOTermRelationships(new HashSet<OBORelationship>(relationshipsField.getValue().get()));
    return java.util.Optional.of(new OBOTermCrossProduct(Optional.of(genus), relationships));
}
Also used : OWLClassData(edu.stanford.bmir.protege.web.shared.entity.OWLClassData) OBORelationship(edu.stanford.bmir.protege.web.shared.obo.OBORelationship) OBOTermCrossProduct(edu.stanford.bmir.protege.web.shared.obo.OBOTermCrossProduct) OBOTermRelationships(edu.stanford.bmir.protege.web.shared.obo.OBOTermRelationships)

Example 4 with OBOTermRelationships

use of edu.stanford.bmir.protege.web.shared.obo.OBOTermRelationships 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)

Aggregations

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