Search in sources :

Example 1 with OBOTermSynonym

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

the class TermSynonymsManager method getSynonyms.

public Collection<OBOTermSynonym> getSynonyms(OWLEntity term) {
    Set<OBOTermSynonym> result = new HashSet<>();
    for (OWLOntology ontology : rootOntology.getImportsClosure()) {
        Set<OWLAnnotationAssertionAxiom> annotationAssertionAxioms = ontology.getAnnotationAssertionAxioms(term.getIRI());
        for (OWLAnnotationAssertionAxiom ax : annotationAssertionAxioms) {
            OBOTermSynonymScope synonymScope = getSynonymScope(ax);
            if (synonymScope != null) {
                OBOTermSynonym termSynonym = new OBOTermSynonym(xRefExtractor.getXRefs(ax), getStringValue(ax), synonymScope);
                result.add(termSynonym);
            }
        }
    }
    return result;
}
Also used : OBOTermSynonymScope(edu.stanford.bmir.protege.web.shared.obo.OBOTermSynonymScope) OBOTermSynonym(edu.stanford.bmir.protege.web.shared.obo.OBOTermSynonym)

Example 2 with OBOTermSynonym

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

the class OBOTermSynonymEditorImpl method getValue.

@Override
public Optional<OBOTermSynonym> getValue() {
    final String synonymName = getSynonymName();
    if (synonymName.isEmpty()) {
        return Optional.empty();
    }
    final List<OBOXRef> xrefs = xrefListField.getValue().orElse(Collections.emptyList());
    return Optional.of(new OBOTermSynonym(xrefs, synonymName, getSynonymScope()));
}
Also used : OBOXRef(edu.stanford.bmir.protege.web.shared.obo.OBOXRef) OBOTermSynonym(edu.stanford.bmir.protege.web.shared.obo.OBOTermSynonym)

Example 3 with OBOTermSynonym

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

the class TermSynonymsManager method setSynonyms.

public void setSynonyms(@Nonnull UserId userId, @Nonnull OWLEntity term, @Nonnull Collection<OBOTermSynonym> synonyms) {
    List<OWLOntologyChange> changes = new ArrayList<>();
    rootOntology.getAnnotationAssertionAxioms(term.getIRI()).stream().filter(ax -> getSynonymScope(ax) != null).map(ax -> new RemoveAxiom(rootOntology, ax)).forEach(changes::add);
    for (OBOTermSynonym synonym : synonyms) {
        OWLAnnotationProperty synonymProperty = getSynonymAnnoationProperty(df, synonym.getScope());
        OWLLiteral synonymNameLiteral = df.getOWLLiteral(synonym.getName());
        Set<OWLAnnotation> synonymXRefs = synonym.getXRefs().stream().filter(x -> !x.isEmpty()).map(xRefConverter::toAnnotation).collect(Collectors.toSet());
        OWLAnnotationAssertionAxiom synonymAnnotationAssertion = df.getOWLAnnotationAssertionAxiom(synonymProperty, term.getIRI(), synonymNameLiteral, synonymXRefs);
        changes.add(new AddAxiom(rootOntology, synonymAnnotationAssertion));
    }
    if (!changes.isEmpty()) {
        changeManager.applyChanges(userId, new FixedChangeListGenerator<>(changes, term, "Edited term synonyms"));
    }
}
Also used : FixedChangeListGenerator(edu.stanford.bmir.protege.web.server.change.FixedChangeListGenerator) ChangeManager(edu.stanford.bmir.protege.web.server.project.ChangeManager) java.util(java.util) org.semanticweb.owlapi.model(org.semanticweb.owlapi.model) OboUtil.getStringValue(edu.stanford.bmir.protege.web.server.obo.OboUtil.getStringValue) OBOFormatConstants(org.obolibrary.oboformat.parser.OBOFormatConstants) Collectors(java.util.stream.Collectors) Inject(javax.inject.Inject) OBOTermSynonymScope(edu.stanford.bmir.protege.web.shared.obo.OBOTermSynonymScope) UserId(edu.stanford.bmir.protege.web.shared.user.UserId) Obo2OWLConstants(org.obolibrary.obo2owl.Obo2OWLConstants) OboUtil.getIRI(edu.stanford.bmir.protege.web.server.obo.OboUtil.getIRI) OBOTermSynonym(edu.stanford.bmir.protege.web.shared.obo.OBOTermSynonym) Nonnull(javax.annotation.Nonnull) Nullable(javax.annotation.Nullable) OBOTermSynonym(edu.stanford.bmir.protege.web.shared.obo.OBOTermSynonym)

Aggregations

OBOTermSynonym (edu.stanford.bmir.protege.web.shared.obo.OBOTermSynonym)3 OBOTermSynonymScope (edu.stanford.bmir.protege.web.shared.obo.OBOTermSynonymScope)2 FixedChangeListGenerator (edu.stanford.bmir.protege.web.server.change.FixedChangeListGenerator)1 OboUtil.getIRI (edu.stanford.bmir.protege.web.server.obo.OboUtil.getIRI)1 OboUtil.getStringValue (edu.stanford.bmir.protege.web.server.obo.OboUtil.getStringValue)1 ChangeManager (edu.stanford.bmir.protege.web.server.project.ChangeManager)1 OBOXRef (edu.stanford.bmir.protege.web.shared.obo.OBOXRef)1 UserId (edu.stanford.bmir.protege.web.shared.user.UserId)1 java.util (java.util)1 Collectors (java.util.stream.Collectors)1 Nonnull (javax.annotation.Nonnull)1 Nullable (javax.annotation.Nullable)1 Inject (javax.inject.Inject)1 Obo2OWLConstants (org.obolibrary.obo2owl.Obo2OWLConstants)1 OBOFormatConstants (org.obolibrary.oboformat.parser.OBOFormatConstants)1 org.semanticweb.owlapi.model (org.semanticweb.owlapi.model)1