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

项目:owltools    文件:ClassTaxonMatrixTest.java   
@BeforeClass
public static void beforeClass() throws Exception {
    ParserWrapper pw = new ParserWrapper();
    OWLOntologyIRIMapper mapper = new CatalogXmlIRIMapper("src/test/resources/rules/ontology/extensions/catalog-v001.xml");
    pw.addIRIMapper(mapper);
    all = new OWLGraphWrapper(pw.parseOWL(IRI.create("http://purl.obolibrary.org/obo/go/extensions/x-taxon-importer.owl")));
    classes = new HashSet<OWLClass>();
    for(OWLClass cls : all.getSourceOntology().getClassesInSignature(true)) {
        String id = all.getIdentifier(cls);
        if (id.startsWith("GO:")) {
            classes.add(cls);
        }
    }
    rat = all.getOWLClassByIdentifier(TaxonTools.NCBI + "10114");
    yeast = all.getOWLClassByIdentifier(TaxonTools.NCBI + "4932");
}
项目:owltools    文件:AnnotationRulesEngineTest.java   
@BeforeClass
public static void setUpBeforeClass() throws Exception {
    elkLogger = Logger.getLogger("org.semanticweb.elk");
    elkLogLevel = elkLogger.getLevel();
    elkLogger.setLevel(Level.ERROR);

    String qcfile = LOCATION + "annotation_qc.xml";
    String xrfabbslocation = LOCATION + "GO.xrf_abbs";
    ParserWrapper p = new ParserWrapper();

    OWLOntologyIRIMapper mapper = new CatalogXmlIRIMapper(getResource("rules/ontology/extensions/catalog-v001.xml"));
    p.addIRIMapper(mapper);

    OWLOntology goTaxon = p.parse("http://purl.obolibrary.org/obo/go/extensions/go-plus.owl");
    OWLOntology gorel = p.parse("http://purl.obolibrary.org/obo/go/extensions/gorel.owl");
    OWLGraphWrapper graph = new OWLGraphWrapper(goTaxon);
    graph.addImport(gorel);
    eco = EcoMapperFactory.createTraversingEcoMapper(p, getResourceIRIString("eco.obo")).getMapper();

    AnnotationRulesFactory rulesFactory = new GoAnnotationRulesFactoryImpl(
            qcfile, xrfabbslocation, graph, eco, null);
    engine = new AnnotationRulesEngine(rulesFactory, true, false);
}
项目:owltools    文件:AnnotationRulesEngineSingleTest.java   
@BeforeClass
public static void setUpBeforeClass() throws Exception {
    elkLogger = Logger.getLogger("org.semanticweb.elk");
    elkLogLevel = elkLogger.getLevel();
    elkLogger.setLevel(Level.ERROR);

    String qcfile = LOCATION + "annotation_qc.xml";
    String xrfabbslocation = LOCATION + "GO.xrf_abbs";

    ParserWrapper p = new ParserWrapper();

    OWLOntologyIRIMapper mapper = new CatalogXmlIRIMapper(getResource("rules/ontology/extensions/catalog-v001.xml"));
    p.addIRIMapper(mapper);

    OWLOntology goTaxon = p.parse("http://purl.obolibrary.org/obo/go/extensions/go-plus.owl");
    OWLOntology gorel = p.parse("http://purl.obolibrary.org/obo/go/extensions/gorel.owl");
    OWLGraphWrapper graph = new OWLGraphWrapper(goTaxon);
    graph.addImport(gorel);
    eco = EcoMapperFactory.createTraversingEcoMapper(p, getResourceIRIString("eco.obo")).getMapper();

    AnnotationRulesFactory rulesFactory = new GoAnnotationRulesFactoryImpl(
            qcfile, xrfabbslocation, graph, eco, null);
    engine = new AnnotationRulesEngine(rulesFactory, true, false);
}
项目:sdlnot-rules    文件:MappingFileParser.java   
public static OWLOntologyIRIMapper getMappings(final File mf) {
    final Map<String, URI> map = parseMappings(mf);
    return new OWLOntologyIRIMapper() {

        @Override
        public IRI getDocumentIRI(IRI ontologyIRI) {
            final URI value = map.get(ontologyIRI.toString());

            if (value == null) {
                return null;
            } else {
                return IRI.create(value);
            }
        }
    };
}
项目:owltools    文件:ParserWrapper.java   
public void addIRIMappers(List<OWLOntologyIRIMapper> mappers) {
    List<OWLOntologyIRIMapper> reverse = new ArrayList<OWLOntologyIRIMapper>(mappers);
    Collections.reverse(reverse);
    for (OWLOntologyIRIMapper mapper : reverse) {
        addIRIMapper(mapper);
    }
}
项目:Pellet4Android    文件:OntologyManager.java   
/**
 * This method sets an alternative URI for an ontology.
 * 
 * @param ontURl
 *            original URI
 * @param ontFile
 *            alternative URI
 */

public void setMapping(final String ontURl, final String ontFile) {
    IRI ontologyUri = IRI.create(ontURl);
    IRI ontologyMapped = IRI.create(ontFile);

    OWLOntologyIRIMapper iriMapper = new SimpleIRIMapper(ontologyUri,
            ontologyMapped);
    getManager().addIRIMapper(iriMapper);
}
项目:minerva    文件:CoreMolecularModelManager.java   
static OWLOntology loadOntologyDocumentSource(final OWLOntologyDocumentSource source, boolean minimal, OWLOntologyManager manager) throws OWLOntologyCreationException {
    // silence the OBO parser in the OWL-API
    java.util.logging.Logger.getLogger("org.obolibrary").setLevel(java.util.logging.Level.SEVERE);
    final Set<OWLParserFactory> originalFactories = removeOBOParserFactories(manager);
    try {
        // load model from source
        if (minimal == false) {
            // add the obsolete imports to the ignored imports
            OWLOntology abox = loadOWLOntologyDocumentSource(source, manager);
            return abox;
        }
        else {
            // only load the model, skip imports
            // approach: return an empty ontology IRI for any IRI mapping request using.
            final OWLOntologyManager m = OWLManager.createOWLOntologyManager();
            final Set<IRI> emptyOntologies = new HashSet<IRI>();
            m.getIRIMappers().add(new OWLOntologyIRIMapper() {

                // generated
                private static final long serialVersionUID = -8200679663396870351L;

                @Override
                public IRI getDocumentIRI(IRI ontologyIRI) {

                    // quick check:
                    // do nothing for the original IRI and known empty ontologies
                    if (source.getDocumentIRI().equals(ontologyIRI) || emptyOntologies.contains(ontologyIRI)) {
                        return null;
                    }
                    emptyOntologies.add(ontologyIRI);
                    try {
                        OWLOntology emptyOntology = m.createOntology(ontologyIRI);
                        return emptyOntology.getOntologyID().getDefaultDocumentIRI().orNull();
                    } catch (OWLOntologyCreationException e) {
                        throw new RuntimeException(e);
                    }
                }
            });
            OWLOntology minimalAbox = loadOWLOntologyDocumentSource(source, m);
            return minimalAbox;
        }
    } finally {
        resetOBOParserFactories(manager, originalFactories);
    }
}
项目:pronto    文件:KBStandaloneLoader.java   
public ProbKnowledgeBase load(String uri) throws OntologyLoadingException {

        OWLOntologyManager manager = OWLManager.createOWLOntologyManager();
        //Take everything before the last "/"
        OWLOntologyIRIMapper iriMapper = new BaseIRIMapper(uri.substring( 0, uri.lastIndexOf( '/' ) )); 

        manager.addIRIMapper( iriMapper );

        try {

            return load(manager.loadOntology( IRI.create( uri ) ));

        } catch( OWLOntologyCreationException e ) {

            e.printStackTrace();

            throw new OntologyLoadingException(e);
        }
    }
项目:elk-reasoner    文件:EmptyImportTest.java   
/**
 * Loading ontologies from the test resources
 * 
 * @param man
 * @param name
 * @return the loaded ontology
 * @throws URISyntaxException
 * @throws OWLOntologyCreationException
 */
private OWLOntology loadOntology(OWLOntologyManager man, String name)
        throws URISyntaxException, OWLOntologyCreationException {

    final URI ontologyRoot = getClass().getClassLoader()
            .getResource("empty_import").toURI();

    OWLOntologyIRIMapper iriMapper = new ThisIRIMapper(ontologyRoot.toString());

    man.setIRIMappers(Collections.singleton(iriMapper));

    final URI mainOntology = getClass().getClassLoader()
            .getResource("empty_import/" + name).toURI();

    return man.loadOntologyFromOntologyDocument(new File(mainOntology));

}
项目:elk-reasoner    文件:ElkReasonerTest.java   
/**
 * Loading ontologies from the test resources
 * 
 * @param man
 * @param name
 * @return the loaded ontology
 * @throws URISyntaxException
 * @throws OWLOntologyCreationException
 */
private OWLOntology loadOntology(OWLOntologyManager man, String name)
        throws URISyntaxException, OWLOntologyCreationException {

    final URI ontologyRoot = getClass().getClassLoader()
            .getResource("ontologies").toURI();

    OWLOntologyIRIMapper iriMapper = new ThisIRIMapper(
            ontologyRoot.toString());

    man.setIRIMappers(Collections.singleton(iriMapper));

    final URI mainOntology = getClass().getClassLoader()
            .getResource("ontologies/" + name).toURI();

    return man.loadOntologyFromOntologyDocument(new File(mainOntology));

}
项目:elk-reasoner    文件:IgnoreChangesInNonImportedOntologiesTest.java   
/**
 * Loading ontologies from the test resources
 * 
 * @param man
 * @param name
 * @return the loaded ontology
 * @throws URISyntaxException
 * @throws OWLOntologyCreationException
 */
private OWLOntology loadOntology(OWLOntologyManager man, String name)
        throws URISyntaxException, OWLOntologyCreationException {

    final URI ontologyRoot = getClass().getClassLoader()
            .getResource("ontologies").toURI();

    OWLOntologyIRIMapper iriMapper = new ThisIRIMapper(ontologyRoot.toString());
    man.setIRIMappers(Collections.singleton(iriMapper));

    final URI mainOntology = getClass().getClassLoader()
            .getResource("ontologies/" + name).toURI();

    return man.loadOntologyFromOntologyDocument(new File(mainOntology));

}
项目:owltools    文件:ParserWrapper.java   
public void addIRIMapper(OWLOntologyIRIMapper mapper) {
    manager.getIRIMappers().add(mapper);
    mappers.add(0, mapper);
}
项目:owltools    文件:ParserWrapper.java   
public void removeIRIMapper(OWLOntologyIRIMapper mapper) {
    manager.getIRIMappers().remove(mapper);
    mappers.remove(mapper);
}
项目:owltools    文件:ParserWrapper.java   
public List<OWLOntologyIRIMapper> getIRIMappers() {
    return Collections.unmodifiableList(mappers);
}