Java 类org.semanticweb.owlapi.model.OWLDataFactory 实例源码

项目:jcel    文件:ReverseAxiomTranslator.java   
@Override
public OWLAxiom visit(RI3Axiom axiom) {
    Objects.requireNonNull(axiom);
    OWLObjectProperty owlLeftSubProperty = translator.getTranslationRepository()
            .getOWLObjectProperty(axiom.getLeftSubProperty());
    OWLObjectProperty owlRightSubProperty = translator.getTranslationRepository()
            .getOWLObjectProperty(axiom.getRightSubProperty());
    OWLObjectProperty owlSuperProperty = translator.getTranslationRepository()
            .getOWLObjectProperty(axiom.getSuperProperty());
    Set<OWLAnnotation> owlAnnotations = translateAnnotations(axiom.getAnnotations());
    OWLDataFactory dataFactory = ontology.getOWLOntologyManager().getOWLDataFactory();
    List<OWLObjectProperty> owlPropertyList = new ArrayList<>();
    owlPropertyList.add(owlLeftSubProperty);
    owlPropertyList.add(owlRightSubProperty);
    return dataFactory.getOWLSubPropertyChainOfAxiom(owlPropertyList, owlSuperProperty, owlAnnotations);
}
项目:minerva    文件:FindTaxonTool.java   
public String getEntityTaxon(String curie, OWLOntology model) throws UnknownIdentifierException {
    if (curie == null || curie.isEmpty()) {
        return null;
    }
    OWLDataFactory df = model.getOWLOntologyManager().getOWLDataFactory();
    OWLClass cls = df.getOWLClass(curieHandler.getIRI(curie));
    String taxon = getEntityTaxon(cls, model);
    if (taxon == null) {
        OWLGraphWrapper g = new OWLGraphWrapper(model);
        cls = g.getOWLClassByIdentifier(curie);
        if (cls != null) {
            taxon = getEntityTaxon(cls, model);
        }
        IOUtils.closeQuietly(g);
    }
    return taxon;
}
项目:minerva    文件:GafToLegoTranslator.java   
private void addBioEntity(OWLClass pr, OWLOntology lego, Bioentity bioentity) {
    Set<OWLDeclarationAxiom> declarationAxioms = lego.getDeclarationAxioms(pr);
    if (declarationAxioms == null || declarationAxioms.isEmpty()) {
        // add class declaration and add label
        OWLOntologyManager m = lego.getOWLOntologyManager();
        OWLDataFactory f = m.getOWLDataFactory();

        Set<OWLAxiom> axioms = new HashSet<OWLAxiom>();
        axioms.add(f.getOWLDeclarationAxiom(pr));

        String label = bioentity.getSymbol()+" - "+bioentity.getFullName();

        axioms.add(f.getOWLAnnotationAssertionAxiom(f.getRDFSLabel(), pr.getIRI(), f.getOWLLiteral(label)));

        m.addAxioms(lego, axioms);
    }
}
项目:owltools    文件:NCBI2OWLTest.java   
private void testExactSynonym(OWLOntology ontology) {
    IRI iri = IRI.create("http://www.geneontology.org/formats/oboInOwl#hasExactSynonym");
    OWLDataFactory df = ontology.getOWLOntologyManager().
        getOWLDataFactory();
    OWLAnnotationProperty property = df.getOWLAnnotationProperty(iri);
    assertTrue("Exact Synonym property in signature",
        ontology.containsAnnotationPropertyInSignature(iri));

    // Check axioms
    Set<OWLAnnotationAxiom> axioms = ontology.getAxioms(property, Imports.EXCLUDED);
    assertEquals("Count class axioms", 0, axioms.size());

    // Check annotations
    List<String> values = new ArrayList<String>();
    values.add("AnnotationAssertion(rdfs:label <http://www.geneontology.org/formats/oboInOwl#hasExactSynonym> \"has_exact_synonym\"^^xsd:string)");

    Set<OWLAnnotationAssertionAxiom> annotations = 
        ontology.getAnnotationAssertionAxioms(iri);
    assertEquals("Count annotations for Exact", 1, annotations.size());

    checkAnnotations(annotations, values);
}
项目:owltools    文件:OwlSimUtil.java   
public static void addElementToAttributeAssociationsFromFile(OWLOntology ont, File file) throws IOException {
    OWLOntologyManager m = OWLManager.createOWLOntologyManager();
    OWLDataFactory df = m.getOWLDataFactory();
    List<String> lines = FileUtils.readLines(file);
    for (String line : lines) {
        if (line.startsWith("#"))
            continue;
        String[] colVals = line.split("\t");
        if (colVals.length != 2) {
            throw new IOException("Incorrect number of value: "+line);
        }
        OWLNamedIndividual i = df.getOWLNamedIndividual(getIRIById(colVals[0]));
        OWLClass c = df.getOWLClass(getIRIById(colVals[1]));
        m.addAxiom(ont, df.getOWLClassAssertionAxiom(c, i));
    }
}
项目:minerva    文件:CoreMolecularModelManager.java   
private static Pair<OWLNamedIndividual, Set<OWLAxiom>> createIndividualInternal(IRI iri, OWLOntology abox, OWLClassExpression ce, Set<OWLAnnotation> annotations) {
    LOG.info("Generating individual for IRI: "+iri);
    OWLDataFactory f = abox.getOWLOntologyManager().getOWLDataFactory();
    OWLNamedIndividual i = f.getOWLNamedIndividual(iri);

    // create axioms
    Set<OWLAxiom> axioms = new HashSet<OWLAxiom>();
    // declaration
    axioms.add(f.getOWLDeclarationAxiom(i));
    // annotation assertions
    if(annotations != null) {
        for(OWLAnnotation annotation : annotations) {
            axioms.add(f.getOWLAnnotationAssertionAxiom(iri, annotation));
        }
    }

    if (ce != null) {
        OWLClassAssertionAxiom typeAxiom = createType(f, i, ce);
        if (typeAxiom != null) {
            axioms.add(typeAxiom);
        }
    }

    return Pair.of(i, axioms);
}
项目:owltools    文件:GMTParser.java   
private void parseRow(String[] row) {
    OWLDataFactory df = graph.getDataFactory();
    OWLOntologyManager mgr = graph.getManager();
    String geneSetId = row[0];
    IRI geneSetIRI = IRI.create(prefix + geneSetId);
    String desc = row[1];
    OWLClass geneSetCls = df.getOWLClass(geneSetIRI);
    OWLAxiom ax = df.getOWLAnnotationAssertionAxiom(df.getRDFSLabel(),geneSetIRI, literal(desc));
    mgr.addAxiom(graph.getSourceOntology(), ax);

    // assume each value is an entity, e.g. gene
    for (int i=2; i < row.length; i++) {
        OWLNamedIndividual individual = df.getOWLNamedIndividual(IRI.create(prefix + row[i]));
        mgr.addAxiom(graph.getSourceOntology(), df.getOWLClassAssertionAxiom(geneSetCls, individual));
    }
}
项目:owltools    文件:OWLGraphManipulatorTest.java   
/**
 * Test that two {@code OWLClass}es that are equal have a same hashcode, 
 * because the OWLGraphEdge bug get me paranoid. 
 */
@Test
public void testOWLClassHashCode()
{
     OWLOntologyManager manager = OWLManager.createOWLOntologyManager();
     OWLDataFactory factory = manager.getOWLDataFactory(); 
     IRI iri = IRI.create("http://www.foo.org/#A");
     OWLClass class1 = factory.getOWLClass(iri);
     //get the class by another way, even if if I suspect the two references 
     //will point to the same object
     PrefixManager pm = new DefaultPrefixManager("http://www.foo.org/#"); 
     OWLClass class2 = factory.getOWLClass(":A", pm);

     assertTrue("The two references point to different OWLClass objects", 
             class1 == class2);
     //then of course the hashcodes will be the same...
     assertTrue("Two OWLClasses are equal but have different hashcode", 
             class1.equals(class2) && class1.hashCode() == class2.hashCode());
}
项目:pronto    文件:KBStandaloneLoader.java   
private void addAutoGeneratedClassNames(OWLOntologyManager manager,
                                        OWLOntology ontology,
                                        Map<String, OWLClassExpression> nameMap) {

    OWLDataFactory factory = manager.getOWLDataFactory();
    List<OWLOntologyChange> changes = new ArrayList<OWLOntologyChange>();

    for (Map.Entry<String, OWLClassExpression> entry : nameMap.entrySet()) {

        OWLClass subClass = factory.getOWLClass( IRI.create(entry.getKey()) );
        OWLAxiom declAxiom = factory.getOWLEquivalentClassesAxiom( subClass, entry.getValue() );

        changes.addAll( manager.addAxiom( ontology, declAxiom ) );
    }

    manager.applyChanges( changes );
}
项目:pronto    文件:KBEmbeddedLoader.java   
private void addAutoGeneratedClassNames(OWLOntologyManager manager,
                                        OWLOntology ontology,
                                        Map<String, OWLClassExpression> nameMap) {

    OWLDataFactory factory = manager.getOWLDataFactory();
    List<OWLOntologyChange> changes = new ArrayList<OWLOntologyChange>();

    for (Map.Entry<String, OWLClassExpression> entry : nameMap.entrySet()) {

        OWLClass subClass = factory.getOWLClass( IRI.create(entry.getKey()) );
        OWLAxiom declAxiom = factory.getOWLEquivalentClassesAxiom( subClass, entry.getValue() );

        changes.addAll( manager.addAxiom( ontology, declAxiom ) );
    }

    manager.applyChanges( changes );
}
项目:pronto    文件:PKBXMLSerializer.java   
protected void addPTBoxConstraints(OWLOntology ontology, PTBox ptbox,
                                        OWLOntologyManager manager, OWLDataFactory  factory) {

    ConceptConverter converter = new ConceptConverter(ptbox.getClassicalKnowledgeBase(), factory); 

    for (ConditionalConstraint cc : ptbox.getDefaultConstraints()) {

        OWLAnnotationProperty annProp = factory.getOWLAnnotationProperty( IRI.create(Constants.CERTAINTY_ANNOTATION_URI ));
        OWLAnnotationValue annValue = factory.getOWLStringLiteral( cc.getLowerBound() + ";" + cc.getUpperBound() );
        OWLAnnotation annotation = factory.getOWLAnnotation( annProp, annValue );   
        OWLClassExpression clsEv = (OWLClassExpression)converter.convert( cc.getEvidence() );
        OWLClassExpression clsCn = (OWLClassExpression)converter.convert( cc.getConclusion() );
        OWLAxiom axiom = factory.getOWLSubClassOfAxiom( clsEv, clsCn, Collections.singleton( annotation ) );

        try {

            manager.applyChange( new AddAxiom(ontology, axiom) );

        } catch( OWLOntologyChangeException e ) {

            e.printStackTrace();
        }
    }
}
项目:Hermit_1.3.8_android    文件:Reasoner.java   
public Map<OWLNamedIndividual, Set<OWLNamedIndividual>> getObjectPropertyInstances(
        OWLObjectProperty property) {
    checkPreConditions(property);
    Map<OWLNamedIndividual, Set<OWLNamedIndividual>> result = new HashMap<OWLNamedIndividual, Set<OWLNamedIndividual>>();
    if (!m_isConsistent) {
        Set<OWLNamedIndividual> all = getAllNamedIndividuals();
        for (OWLNamedIndividual ind : all)
            result.put(ind, all);
        return result;
    }
    initialisePropertiesInstanceManager();
    AtomicRole role = H(property);
    Map<Individual, Set<Individual>> relations = m_instanceManager
            .getObjectPropertyInstances(role);
    OWLDataFactory factory = getDataFactory();
    for (Individual individual : relations.keySet()) {
        Set<OWLNamedIndividual> successors = new HashSet<OWLNamedIndividual>();
        result.put(factory.getOWLNamedIndividual(IRI.create(individual
                .getIRI())), successors);
        for (Individual successorIndividual : relations.get(individual))
            successors.add(factory.getOWLNamedIndividual(IRI
                    .create(successorIndividual.getIRI())));
    }
    return result;
}
项目:Wolpertinger    文件:WolpertingerTest.java   
/**
   * Atomic clash
   */
  public void testUnsatifiabilityDueToClashInABoxAssertions() {
    OWLDataFactory factory = OWLManager.getOWLDataFactory();
    OWLOntologyManager manager = OWLManager.createOWLOntologyManager();

    OWLClassExpression expr1 = factory.getOWLClass(IRI.create(String.format("%s#%s", PREFIX, "A")));
    OWLClassExpression expr2 = factory.getOWLObjectComplementOf(expr1);
    OWLNamedIndividual indiv = factory.getOWLNamedIndividual(IRI.create(String.format("%s#%s", PREFIX, "a")));

    OWLIndividualAxiom fact1 = factory.getOWLClassAssertionAxiom(expr1, indiv);
    OWLIndividualAxiom fact2 = factory.getOWLClassAssertionAxiom(expr2, indiv);

    try {
    OWLOntology ontology = manager.createOntology();
    manager.addAxiom(ontology, fact1);
    manager.addAxiom(ontology, fact2);

    Wolpertinger wolpertinger = new Wolpertinger(ontology);

    assertFalse(wolpertinger.isConsistent());
} catch (OWLOntologyCreationException e) {
    e.printStackTrace();
    fail();
}
  }
项目:owltools    文件:OWLSimReferenceBasedStatistics.java   
protected DescriptiveStatistics computeDescriptiveStatistics(Set<OWLClass> attributes) throws UnknownOWLClassException  {
    DescriptiveStatistics statsPerAttSet = new DescriptiveStatistics();
    OWLDataFactory g = sourceOntology.getOWLOntologyManager().getOWLDataFactory();

    for (OWLClass c : attributes) {
        Double ic;
        try {
            ic = owlsim.getInformationContentForAttribute(c);
            if (ic == null) { 
                if (g.getOWLClass(c.getIRI()) != null) {
                    ic = owlsim.getSummaryStatistics().max.getMax();
                } else {
                    throw new UnknownOWLClassException(c); }
            }
            if (ic.isInfinite() || ic.isNaN()) {
                ic = owlsim.getSummaryStatistics().max.getMax();
            }
            statsPerAttSet.addValue(ic);    

        } catch (UnknownOWLClassException e) {
            LOG.info("Unknown class "+c.toStringID()+" submitted for summary stats. Removed from calculation.");
            continue;
        }
    }
    return statsPerAttSet;
}
项目:owltools    文件:TableToAxiomConverter.java   
public void parse(File myFile) throws IOException {
    try (BufferedReader reader = new BufferedReader(new FileReader(myFile))) {
        for(String line : IOUtils.readLines(reader)) {
            String[] row = line.split("\t");
            if (config.defaultCol1 != null)
                row[0] = config.defaultCol1;
            if (config.defaultCol2 != null) {
                String[] row2 = new String[2];
                row2[0] = row[0];
                row = row2;
                row[1] = config.defaultCol2;
            }
            addRow(row);
        }
    }

    if (config.individualsType != null) {
        OWLDataFactory df = graph.getDataFactory();
        graph.getManager().applyChange(new AddAxiom(graph.getSourceOntology(), 
                df.getOWLDeclarationAxiom(config.individualsType)));
    }

}
项目:jopa    文件:OwlapiUtils.java   
/**
 * Creates OWLLiteral from the specified Java instance.
 *
 * @param value       The value to transform
 * @param dataFactory Data factory
 * @param lang        Ontology language
 * @return OWLLiteral representing the value
 * @throws IllegalArgumentException If {@code value} is of unsupported type
 */
public static OWLLiteral createOWLLiteralFromValue(Object value, OWLDataFactory dataFactory, String lang) {
    Objects.requireNonNull(value);
    if (value instanceof Integer) {
        // Java implementations map int/Integer to xsd:int, because xsd:integer is unbounded, whereas xsd:int is 32-bit signed, same as Java
        return dataFactory.getOWLLiteral(value.toString(), OWL2Datatype.XSD_INT);
    } else if (value instanceof Long) {
        return dataFactory.getOWLLiteral(value.toString(), OWL2Datatype.XSD_LONG);
    } else if (value instanceof Boolean) {
        return dataFactory.getOWLLiteral((Boolean) value);
    } else if (value instanceof Double) {
        return dataFactory.getOWLLiteral((Double) value);
    } else if (value instanceof String) {
        return dataFactory.getOWLLiteral((String) value, lang);
    } else if (value instanceof Date) {
        SimpleDateFormat sdf = new SimpleDateFormat(DATE_TIME_FORMAT);
        return dataFactory.getOWLLiteral(sdf.format(((Date) value)),
                dataFactory.getOWLDatatype(OWL2Datatype.XSD_DATE_TIME.getIRI()));
    } else if (value.getClass().isEnum()) {
        return dataFactory.getOWLLiteral(value.toString());
    } else {
        throw new IllegalArgumentException("Unsupported value " + value + " of type " + value.getClass());
    }
}
项目:HermiT-android    文件:Reasoner.java   
protected Set<HierarchyNode<AtomicConcept>> getDisjointConceptNodes(
        HierarchyNode<AtomicConcept> node) {
    if (m_directDisjointClasses.containsKey(node))
        return m_directDisjointClasses.get(node);
    else {
        Set<HierarchyNode<AtomicConcept>> result = new HashSet<HierarchyNode<AtomicConcept>>();
        OWLDataFactory factory = getDataFactory();
        OWLClassExpression negated = factory
                .getOWLObjectComplementOf(factory.getOWLClass(IRI
                        .create(node.getRepresentative().getIRI())));
        HierarchyNode<AtomicConcept> equivalentToComplement = getHierarchyNode(negated);
        for (AtomicConcept equiv : equivalentToComplement
                .getEquivalentElements()) {
            if (!Prefixes.isInternalIRI(equiv.getIRI())) {
                HierarchyNode<AtomicConcept> rootDisjoint = m_atomicConceptHierarchy
                        .getNodeForElement(equiv);
                result = Collections.singleton(rootDisjoint);
                m_directDisjointClasses.put(node, result);
                return result;
            }
        }
        result = equivalentToComplement.getChildNodes();
        m_directDisjointClasses.put(node, result);
        return result;
    }
}
项目:HermiT-android    文件:Reasoner.java   
public Map<OWLNamedIndividual, Set<OWLNamedIndividual>> getObjectPropertyInstances(
        OWLObjectProperty property) {
    checkPreConditions(property);
    Map<OWLNamedIndividual, Set<OWLNamedIndividual>> result = new HashMap<OWLNamedIndividual, Set<OWLNamedIndividual>>();
    if (!m_isConsistent) {
        Set<OWLNamedIndividual> all = getAllNamedIndividuals();
        for (OWLNamedIndividual ind : all)
            result.put(ind, all);
        return result;
    }
    initialisePropertiesInstanceManager();
    AtomicRole role = H(property);
    Map<Individual, Set<Individual>> relations = m_instanceManager
            .getObjectPropertyInstances(role);
    OWLDataFactory factory = getDataFactory();
    for (Individual individual : relations.keySet()) {
        Set<OWLNamedIndividual> successors = new HashSet<OWLNamedIndividual>();
        result.put(factory.getOWLNamedIndividual(IRI.create(individual
                .getIRI())), successors);
        for (Individual successorIndividual : relations.get(individual))
            successors.add(factory.getOWLNamedIndividual(IRI
                    .create(successorIndividual.getIRI())));
    }
    return result;
}
项目:HermiT-android    文件:Reasoner.java   
protected Node<OWLObjectPropertyExpression> objectPropertyHierarchyNodeToNode(
        HierarchyNode<Role> hierarchyNode) {
    Set<OWLObjectPropertyExpression> result = new HashSet<OWLObjectPropertyExpression>();
    OWLDataFactory factory = getDataFactory();
    for (Role role : hierarchyNode.getEquivalentElements()) {
        if (role instanceof AtomicRole)
            result.add(factory.getOWLObjectProperty(IRI
                    .create(((AtomicRole) role).getIRI())));
        else {
            OWLObjectPropertyExpression ope = factory
                    .getOWLObjectProperty(IRI.create(((InverseRole) role)
                            .getInverseOf().getIRI()));
            result.add(factory.getOWLObjectInverseOf(ope));
        }
    }
    return new OWLObjectPropertyNode(result);
}
项目:FAIRsharing-Owl2Neo    文件:Owl2Neo4jLoaderTest.java   
@Before
public void setUp() throws Exception {
    graphDb = new GraphDatabaseFactory().newEmbeddedDatabase(new File(TEST_GRAPH_DB_PATH));
    OWLOntologyManager manager = OWLManager.createOWLOntologyManager();
    OWLOntology ontology = manager.loadOntologyFromOntologyDocument(file.getFile());
    OWLDataFactory factory = manager.getOWLDataFactory();
    loader = new Owl2Neo4jLoader(graphDb, ontology, factory);
}
项目:OWLAx    文件:EditorToolBar.java   
public Set<OWLDatatype> getBuiltinDatatypes(OWLModelManager owlModelManager) {
    Set<OWLDatatype> datatypes = new HashSet<>();
    final OWLDataFactory df = owlModelManager.getOWLDataFactory();

    datatypes.add(df.getTopDatatype());
    for (OWL2Datatype dt : OWL2Datatype.values()) {
        datatypes.add(df.getOWLDatatype(dt.getIRI()));
    }
    return datatypes;
}
项目:owltools    文件:AxiomCopier.java   
/**
 * make annotations to be placed on axiom
 * 
 * @param df
 * @param srcClass
 * @param isXrefAnn if true use hasDbXref not source
 * @return annotations
 */
private Set<? extends OWLAnnotation> anns(OWLDataFactory df, OWLClass srcClass, boolean isXrefAnn) {
    String iri = srcClass.getIRI().toString();
    iri = iri.replaceAll(".*/", "");
    iri = iri.replaceAll("_", ":");
    String pn = "source";
    if (isXrefAnn) {
        pn = "hasDbXref";
    }
    OWLAnnotationProperty p = df.getOWLAnnotationProperty(IRI.create("http://www.geneontology.org/formats/oboInOwl#"+pn));
    OWLAnnotation ann = df.getOWLAnnotation(p, df.getOWLLiteral(iri));
    return Collections.singleton(ann);
}
项目:owltools    文件:ImportedXrefTest.java   
@Test
public void test() throws Exception {
    // load the base ontology
    ParserWrapper pw = new ParserWrapper();
    OWLOntology direct = pw.parseOBO(getResourceIRIString("graph/xref_test.obo"));

    OWLGraphWrapper directGraph = new OWLGraphWrapper(direct);

    // check that the test class has the expected number of xrefs
    OWLClass c = directGraph.getOWLClassByIdentifier("FOO:0001");

    List<String> directDefXrefs = directGraph.getDefXref(c);
    assertEquals(2, directDefXrefs.size());

    List<String> directXrefs = directGraph.getXref(c);
    assertEquals(2, directXrefs.size());

    // create an ontology using an import
    OWLOntologyManager manager = pw.getManager();
    OWLDataFactory factory = manager.getOWLDataFactory();
    OWLOntology importer = manager.createOntology();
    OWLImportsDeclaration importDeclaration = factory.getOWLImportsDeclaration(direct.getOntologyID().getOntologyIRI().orNull());
    manager.applyChange(new AddImport(importer, importDeclaration));

    OWLGraphWrapper importerGraph = new OWLGraphWrapper(importer);

    // check that the wrapper uses also imports for lookups of xrefs
    List<String> importedDefXrefs = importerGraph.getDefXref(c);
    assertEquals(2, importedDefXrefs.size());

    List<String> importedXrefs = importerGraph.getXref(c);
    assertEquals(2, importedXrefs.size());
}
项目:Hermit_1.3.8_android    文件:OWLNormalization.java   
public OWLNormalization(OWLDataFactory factory,OWLAxioms axioms,int firstReplacementIndex) {
    m_factory=factory;
    m_axioms=axioms;
    m_firstReplacementIndex=firstReplacementIndex;
    m_definitions=new HashMap<OWLClassExpression,OWLClassExpression>();
    m_definitionsForNegativeNominals=new HashMap<OWLObjectOneOf,OWLClass>();
    m_expressionManager=new ExpressionManager(m_factory);
    m_plVisitor=new PLVisitor();
    m_dataRangeDefinitions=new HashMap<OWLDataRange,OWLDatatype>();
}
项目:owltools    文件:AbstractOwlSim.java   
public SummaryStatistics computeAttributeSetSimilarityStats(Set<OWLClass> atts)  {

        SummaryStatistics statsPerAttSet = new SummaryStatistics();
        //      Set<OWLClass> allClasses = getSourceOntology().getClassesInSignature(true);
        OWLDataFactory g = getSourceOntology().getOWLOntologyManager().getOWLDataFactory();

        for (OWLClass c : atts) {
            Double ic;
            try {
                ic = this.getInformationContentForAttribute(c);
                if (ic == null) { 
                    //If a class hasn't been annotated in the loaded corpus, we will
                    //assume that it is very rare, and assign MaxIC
                    if (g.getOWLClass(c.getIRI()) != null) {
                        ic = this.getSummaryStatistics().max.getMax();
                    } else {
                        throw new UnknownOWLClassException(c); }
                }
                if (ic.isInfinite() || ic.isNaN()) {
                    //If a class hasn't been annotated in the loaded corpus, we will
                    //assume that it is very rare, and assign MaxIC
                    //a different option would be to skip adding this value, 
                    //but i'm not sure that's wise
                    ic = this.getSummaryStatistics().max.getMax();
                }
                //LOG.info("IC for "+c.toString()+"is: "+ic);
                statsPerAttSet.addValue(ic);    

            } catch (UnknownOWLClassException e) {
                //This is an extra catch here, but really it should be caught upstream.
                LOG.info("Unknown class "+c.toStringID()+" submitted for summary stats. Removed from calculation.");
                continue;
            }
        }
        return statsPerAttSet;
    }
项目:elk-reasoner    文件:IgnoreChangesInNonImportedOntologiesTest.java   
/**
 * Testing correctness of the reasoner with respect to ontology changes
 */
@Test
public void ignoreChangesInNonImportedOntologies() throws Exception {

    OWLOntologyManager man = TestOWLManager.createOWLOntologyManager();
    OWLDataFactory dataFactory = man.getOWLDataFactory();

    // set up resolution of prefixes
    DefaultPrefixManager pm = new DefaultPrefixManager();
    pm.setDefaultPrefix("http://www.example.com/main#");
    pm.setPrefix("A:", "http://www.example.com/A#");
    pm.setPrefix("B:", "http://www.example.com/B#");

    OWLClass extA = dataFactory.getOWLClass("A:A", pm);
    OWLClass extB = dataFactory.getOWLClass("B:B", pm);

    // loading the root ontology
    OWLOntology root = loadOntology(man, "root.owl");

    // Create an ELK reasoner.
    ElkReasoner reasoner = (ElkReasoner) new ElkReasonerFactory()
            .createReasoner(root);
    // make sure the reasoner loads the ontology
    reasoner.flush();
    reasoner.isConsistent();

    try {
        OWLOntology nonImported = loadOntology(man, "nonImported.owl");

        OWLAxiom axiom = dataFactory.getOWLSubClassOfAxiom(extA, extB);
        man.removeAxiom(nonImported, axiom);
        reasoner.flush();

        AbstractReasonerState state = reasoner.getInternalReasoner();

        assertTrue(state.stageManager.inputLoadingStage.isCompleted());
    } finally {
        reasoner.dispose();
    }
}
项目:jcel    文件:ReverseAxiomTranslator.java   
@Override
public OWLAxiom visit(RI2Axiom axiom) {
    Objects.requireNonNull(axiom);
    OWLObjectProperty owlSubProperty = translator.getTranslationRepository()
            .getOWLObjectProperty(axiom.getSubProperty());
    OWLObjectProperty owlSuperProperty = translator.getTranslationRepository()
            .getOWLObjectProperty(axiom.getSuperProperty());
    Set<OWLAnnotation> owlAnnotations = translateAnnotations(axiom.getAnnotations());
    OWLDataFactory dataFactory = ontology.getOWLOntologyManager().getOWLDataFactory();
    return dataFactory.getOWLSubObjectPropertyOfAxiom(owlSubProperty, owlSuperProperty, owlAnnotations);
}
项目:minerva    文件:GafToLegoTranslator.java   
public GafToLegoTranslator(OWLGraphWrapper graph, Map<String,String> gp2protein) {
    this.graph = graph;
    allOWLObjectsByAltId = graph.getAllOWLObjectsByAltId();
    this.gp2protein = gp2protein;
    OWLDataFactory df = graph.getDataFactory();
    partOf = OBOUpperVocabulary.BFO_part_of.getObjectProperty(df);
    occursIn = OBOUpperVocabulary.BFO_occurs_in.getObjectProperty(df);

    mf = OBOUpperVocabulary.GO_molecular_function.getOWLClass(df);
    enabledBy = OBOUpperVocabulary.GOREL_enabled_by.getObjectProperty(df);
    geneProductOf = OBOUpperVocabulary.RO_gene_product_of.getObjectProperty(df);
}
项目:minerva    文件:ModelCreator.java   
private Set<OWLAnnotation> addDefaultModelState(Set<OWLAnnotation> existing, OWLDataFactory f) {
    IRI iri = AnnotationShorthand.modelstate.getAnnotationProperty();
    OWLAnnotationProperty property = f.getOWLAnnotationProperty(iri);
    OWLAnnotation ann = f.getOWLAnnotation(property, f.getOWLLiteral(defaultModelState));
    if (existing == null || existing.isEmpty()) {
        return Collections.singleton(ann);
    }
    existing.add(ann);
    return existing;
}
项目:Hermit_1.3.8_android    文件:OWLClausification.java   
public NormalizedDataRangeAxiomClausifier(DataRangeConverter dataRangeConverter,OWLDataFactory factory,Set<String> definedDatatypeIRIs) {
    m_dataRangeConverter=dataRangeConverter;
    m_definedDatatypeIRIs=definedDatatypeIRIs;
    m_headAtoms=new ArrayList<Atom>();
    m_bodyAtoms=new ArrayList<Atom>();
    m_factory=factory;
}
项目:owltools    文件:BridgeExtractor.java   
private void addObjectProperty(OWLObjectProperty p, OWLOntology xOnt) {
    if (xOnt.getDeclarationAxioms(p).size() > 0) {
        return;
    }
    OWLOntologyManager m = ontology.getOWLOntologyManager();
    OWLDataFactory df = m.getOWLDataFactory();
    m.addAxiom(xOnt, df.getOWLDeclarationAxiom(p));
    for (OWLAxiom ax : ontology.getAxioms(p, Imports.EXCLUDED)) {
        m.addAxiom(xOnt, ax);
    }
    // TODO

}
项目:jcel    文件:ReverseAxiomTranslator.java   
@Override
public OWLAxiom visit(FunctObjectPropAxiom axiom) {
    Objects.requireNonNull(axiom);
    OWLObjectProperty owlProperty = translator.getTranslationRepository().getOWLObjectProperty(axiom.getProperty());
    Set<OWLAnnotation> owlAnnotations = translateAnnotations(axiom.getAnnotations());
    OWLDataFactory dataFactory = ontology.getOWLOntologyManager().getOWLDataFactory();
    return dataFactory.getOWLFunctionalObjectPropertyAxiom(owlProperty, owlAnnotations);
}
项目:minerva    文件:OperationsImpl.java   
private void updateAnnotationsForDelete(DeleteInformation info, ModelContainer model, String userId, Set<String> providerGroups, UndoMetadata token, UndoAwareMolecularModelManager m3) throws UnknownIdentifierException {
    final OWLDataFactory f = model.getOWLDataFactory();
    final OWLAnnotation annotation = createDateAnnotation(f);
    final Set<OWLAnnotation> generated = new HashSet<OWLAnnotation>();
    addGeneratedAnnotations(userId, providerGroups, generated, f);
    for(IRI subject : info.touched) {
        m3.updateAnnotation(model, subject, annotation, token);
        m3.addAnnotations(model, subject, generated, token);
    }
    if (info.updated.isEmpty() == false) {
        Set<OWLObjectPropertyAssertionAxiom> newAxioms = 
                m3.updateAnnotation(model, info.updated, annotation, token);
        m3.addAnnotations(model, newAxioms, generated, token);
    }
}
项目:minerva    文件:ModelSeeding.java   
Relations(OWLDataFactory f, CurieHandler curieHandler) {
    part_of = OBOUpperVocabulary.BFO_part_of.getObjectProperty(f);
    part_of_id = curieHandler.getCuri(part_of);
    occurs_in = OBOUpperVocabulary.BFO_occurs_in.getObjectProperty(f);
    occurs_in_id = curieHandler.getCuri(occurs_in);
    enabled_by = OBOUpperVocabulary.GOREL_enabled_by.getObjectProperty(f);
    enabled_by_id = curieHandler.getCuri(enabled_by);
}
项目:HermiT-android    文件:OWLClausification.java   
public NormalizedAxiomClausifier(DataRangeConverter dataRangeConverter,Set<Atom> positiveFacts,OWLDataFactory factory) {
    m_dataRangeConverter=dataRangeConverter;
    m_headAtoms=new ArrayList<Atom>();
    m_bodyAtoms=new ArrayList<Atom>();
    m_positiveFacts=positiveFacts;
    m_factory=factory;
}
项目:Hermit_1.3.8_android    文件:ExpressionManager.java   
public ExpressionManager(OWLDataFactory factory) {
    m_factory=factory;
    m_descriptionNNFVisitor=new DescriptionNNFVisitor();
    m_dataRangeNNFVisitor=new DataRangeNNFVisitor();
    m_descriptionComplementNNFVisitor=new DescriptionComplementNNFVisitor();
    m_dataRangeComplementNNFVisitor=new DataRangeComplementNNFVisitor();
    m_descriptionSimplificationVisitor=new DescriptionSimplificationVisitor();
    m_dataRangeSimplificationVisitor=new DataRangeSimplificationVisitor();
}
项目:minerva    文件:DataPropertyTest.java   
@Test
public void testDataProperyRenderer() throws Exception {
    OWLOntologyManager m = OWLManager.createOWLOntologyManager();
    OWLOntology ontology = m.createOntology(IRI.generateDocumentIRI());
    final IRI clsIRI = IRI.generateDocumentIRI();
    final IRI propIRI = IRI.generateDocumentIRI();

    // create a test ontology with one data property and one class
    OWLDataFactory f = m.getOWLDataFactory();
    OWLDataProperty prop = f.getOWLDataProperty(propIRI);
    m.addAxiom(ontology, f.getOWLDeclarationAxiom(prop));
    m.addAxiom(ontology, f.getOWLAnnotationAssertionAxiom(propIRI, f.getOWLAnnotation(f.getRDFSLabel(), f.getOWLLiteral("fake-data-property"))));

    OWLClass cls = f.getOWLClass(clsIRI);
    m.addAxiom(ontology, f.getOWLDeclarationAxiom(cls));
    m.addAxiom(ontology, f.getOWLAnnotationAssertionAxiom(clsIRI, f.getOWLAnnotation(f.getRDFSLabel(), f.getOWLLiteral("fake-cls"))));

    // graph and m3
    OWLGraphWrapper graph = new OWLGraphWrapper(ontology);
    final UndoMetadata metadata = new UndoMetadata("foo-user");
    UndoAwareMolecularModelManager m3 = createM3(graph);

    final ModelContainer model = m3.generateBlankModel(metadata);
    final OWLNamedIndividual individual = m3.createIndividual(model, cls, metadata);
    m3.addDataProperty(model, individual, prop, f.getOWLLiteral(10), metadata);

    MolecularModelJsonRenderer r = new MolecularModelJsonRenderer(model, null, curieHandler);
    final JsonModel jsonModel = r.renderModel();
    assertEquals(1, jsonModel.individuals.length);
    assertEquals(1, jsonModel.individuals[0].annotations.length);
    {
        JsonAnnotation ann = jsonModel.individuals[0].annotations[0];
        assertEquals(propIRI.toString(), ann.key);
        assertEquals("10", ann.value);
        assertEquals("xsd:integer", ann.valueType);
    }
}
项目:minerva    文件:JsonTools.java   
public static OWLAnnotationValue createAnnotationValue(JsonAnnotation ann, OWLDataFactory f) {
    OWLAnnotationValue annotationValue;
    if (isIRIValue(ann)) {
        annotationValue = IRI.create(ann.value);
    }
    else {
        annotationValue = createLiteralInternal(ann, f);
    }
    return annotationValue;
}
项目:HermiT-android    文件:OWLClausification.java   
public NormalizedDataRangeAxiomClausifier(DataRangeConverter dataRangeConverter,OWLDataFactory factory,Set<String> definedDatatypeIRIs) {
    m_dataRangeConverter=dataRangeConverter;
    m_definedDatatypeIRIs=definedDatatypeIRIs;
    m_headAtoms=new ArrayList<Atom>();
    m_bodyAtoms=new ArrayList<Atom>();
    m_factory=factory;
}
项目:owltools    文件:OWLHandler.java   
private void addSomeValuesFromClassAssertion(OWLOntology ont,
        OWLIndividual i, OWLClass j, OWLObjectProperty p) {
    OWLDataFactory df = ont.getOWLOntologyManager().getOWLDataFactory();
    OWLObjectSomeValuesFrom svf = 
            df.getOWLObjectSomeValuesFrom(p, j);
    addAxiom(ont, df.getOWLClassAssertionAxiom(svf, i));
}