Examples of OBODoc


Examples of org.obolibrary.oboformat.model.OBODoc

    public static void convertURL(@Nonnull String iri, @Nonnull String outFile,
            @Nonnull OWLOntologyManager manager) throws IOException,
            OWLOntologyCreationException, OWLOntologyStorageException {
        OWLAPIObo2Owl bridge = new OWLAPIObo2Owl(manager);
        OBOFormatParser p = new OBOFormatParser();
        OBODoc obodoc = p.parse(new URL(iri));
        OWLOntology ontology = bridge.convert(obodoc);
        IRI outputStream = IRI.create(outFile);
        OWLDocumentFormat format = new RDFXMLDocumentFormat();
        LOG.info("saving to {} fmt={}", outputStream, format);
        manager.saveOntology(ontology, format, outputStream);
View Full Code Here

Examples of org.obolibrary.oboformat.model.OBODoc

            String defaultOnt, @Nonnull OWLOntologyManager manager)
            throws IOException, OWLOntologyCreationException,
            OWLOntologyStorageException {
        OWLAPIObo2Owl bridge = new OWLAPIObo2Owl(manager);
        OBOFormatParser p = new OBOFormatParser();
        OBODoc obodoc = p.parse(new URL(iri));
        obodoc.addDefaultOntologyHeader(defaultOnt);
        OWLOntology ontology = bridge.convert(obodoc);
        IRI outputStream = IRI.create(outFile);
        OWLDocumentFormat format = new RDFXMLDocumentFormat();
        LOG.info("saving to {} fmt={}", outputStream, format);
        manager.saveOntology(ontology, format, outputStream);
View Full Code Here

Examples of org.obolibrary.oboformat.model.OBODoc

     *
     * @return the oBO doc
     */
    @Nonnull
    protected OBODoc tr() {
        setObodoc(new OBODoc());
        preProcess();
        tr(getOWLOntology());
        for (OWLAxiom ax : getOWLOntology().getAxioms()) {
            if (ax instanceof OWLDeclarationAxiom) {
                tr((OWLDeclarationAxiom) ax);
View Full Code Here

Examples of org.obolibrary.oboformat.model.OBODoc

    public XrefExpander(@Nonnull OBODoc src) {
        sourceOBODoc = src;
        Frame shf = src.getHeaderFrame();
        String ontId = shf.getTagValue(OboFormatTag.TAG_ONTOLOGY, String.class);
        String tgtOntId = ontId + "/xref_expansions";
        targetOBODoc = new OBODoc();
        Frame thf = new Frame(FrameType.HEADER);
        thf.addClause(new Clause(OboFormatTag.TAG_ONTOLOGY, tgtOntId));
        targetOBODoc.setHeaderFrame(thf);
        sourceOBODoc.addImportedOBODoc(targetOBODoc);
        setUp();
View Full Code Here

Examples of org.obolibrary.oboformat.model.OBODoc

            } else {
                continue;
            }
            if (targetBase != null) {
                // create a new bridge ontology for every expansion macro
                OBODoc tgt = new OBODoc();
                Frame thf = new Frame(FrameType.HEADER);
                thf.addClause(new Clause(OboFormatTag.TAG_ONTOLOGY, targetBase
                        + "-" + idSpace.toLowerCase()));
                tgt.setHeaderFrame(thf);
                targetDocMap.put(idSpace, tgt);
                sourceOBODoc.addImportedOBODoc(tgt);
                if (relation != null) {
                    // See 4.4.2
                    // "In addition, any Typedef frames for relations used in a
                    // header macro
                    // are also copied into the corresponding bridge ontology
                    Frame tdf = sourceOBODoc.getTypedefFrame(relation);
                    if (tdf != null) {
                        try {
                            tgt.addTypedefFrame(tdf);
                        } catch (FrameMergeException e) {
                            LOG.debug("frame merge failed", e);
                        }
                    }
                }
View Full Code Here

Examples of org.obolibrary.oboformat.model.OBODoc

     *         parser exception
     */
    @Nonnull
    public OBODoc parse(BufferedReader reader) throws IOException {
        setReader(reader);
        OBODoc obodoc = new OBODoc();
        parseOBODoc(obodoc);
        // handle imports
        Frame hf = obodoc.getHeaderFrame();
        List<OBODoc> imports = new LinkedList<>();
        if (hf != null) {
            for (Clause cl : hf.getClauses(OboFormatTag.TAG_IMPORT)) {
                @SuppressWarnings("null")
                String path = resolvePath(cl.getValue(String.class));
                // TBD -- changing the relative path to absolute
                cl.setValue(path);
                if (followImport) {
                    // resolve OboDoc documents from import paths.
                    OBOFormatParser parser = new OBOFormatParser();
                    OBODoc doc = parser.parseURL(path);
                    imports.add(doc);
                }/*
                  * else{ //build a proxy document which reference import path
                  * as ontology id Frame importHeaer = new
                  * Frame(FrameType.HEADER); Clause ontologyCl = new Clause();
View Full Code Here

Examples of org.obolibrary.oboformat.model.OBODoc

        }

        @Nullable
        IRI getIRIByIdentifier(@Nonnull String id) {
            OWLAPIObo2Owl b = new OWLAPIObo2Owl(manager);
            b.setObodoc(new OBODoc());
            return b.oboIdToIRI(id);
        }
View Full Code Here

Examples of org.obolibrary.oboformat.model.OBODoc

public class RoundTripCardinalityTest extends RoundTripTest {

    @Test
    public void testRoundTripCardinality() throws Exception {
        // create minimal ontology
        OBODoc oboDocSource = parseOBOFile("roundtrip_cardinality.obo");
        // convert to OWL and retrieve def
        OWLAPIObo2Owl bridge = new OWLAPIObo2Owl(
                OWLManager.createOWLOntologyManager());
        OWLOntology owlOntology = bridge.convert(oboDocSource);
        OWLDataFactory factory = owlOntology.getOWLOntologyManager()
                .getOWLDataFactory();
        OWLClass c = factory.getOWLClass(bridge.oboIdToIRI("PR:000027136"));
        // Relations
        boolean foundRel1 = false;
        boolean foundRel2 = false;
        Set<OWLSubClassOfAxiom> axioms = owlOntology
                .getSubClassAxiomsForSubClass(c);
        assertEquals(3, axioms.size());
        for (OWLSubClassOfAxiom axiom : axioms) {
            OWLClassExpression superClass = axiom.getSuperClass();
            if (superClass instanceof OWLObjectExactCardinality) {
                OWLObjectExactCardinality cardinality = (OWLObjectExactCardinality) superClass;
                OWLClassExpression filler = cardinality.getFiller();
                assertFalse(filler.isAnonymous());
                IRI iri = filler.asOWLClass().getIRI();
                if (iri.equals(bridge.oboIdToIRI("PR:000005116"))) {
                    foundRel1 = true;
                    assertEquals(1, cardinality.getCardinality());
                } else if (iri.equals(bridge.oboIdToIRI("PR:000027122"))) {
                    foundRel2 = true;
                    assertEquals(2, cardinality.getCardinality());
                }
            }
        }
        assertTrue(foundRel1);
        assertTrue(foundRel2);
        // convert back to OBO
        OWLAPIOwl2Obo owl2Obo = new OWLAPIOwl2Obo(
                OWLManager.createOWLOntologyManager());
        OBODoc convertedOboDoc = owl2Obo.convert(owlOntology);
        Frame convertedFrame = convertedOboDoc.getTermFrame("PR:000027136");
        Collection<Clause> clauses = convertedFrame
                .getClauses(OboFormatTag.TAG_RELATIONSHIP);
        // check that round trip still contains relationships
        assertEquals(2, clauses.size());
        for (Clause clause : clauses) {
View Full Code Here

Examples of org.obolibrary.oboformat.model.OBODoc

    @Test
    public void testConvertXPs() throws Exception {
        OWLOntology owlOnt = convertOBOFile("dangling_roundtrip_test.obo");
        OWLAPIOwl2Obo revbridge = new OWLAPIOwl2Obo(
                OWLManager.createOWLOntologyManager());
        OBODoc d2 = revbridge.convert(owlOnt);
        Frame f = d2.getTermFrame("UBERON:0000020");
        Clause rc = f.getClause(OboFormatTag.TAG_NAME);
        assertEquals("sense organ", rc.getValue());
        OBOFormatWriter w = new OBOFormatWriter();
        w.setCheckStructure(true);
        w.write(d2, "/tmp/z.obo");
View Full Code Here

Examples of org.obolibrary.oboformat.model.OBODoc

@SuppressWarnings({ "javadoc", "null" })
public class DanglingOwl2OboTest extends OboFormatTestBasics {

    @Test
    public void testConversion() throws Exception {
        OBODoc doc = convert(parseOWLFile("dangling_owl2_obo_test.owl"));
        Frame f = doc.getTermFrame("UBERON:0000020");
        Clause rc = f.getClause(OboFormatTag.TAG_NAME);
        assertEquals("sense organ", rc.getValue());
        Collection<Clause> ics = f.getClauses(OboFormatTag.TAG_INTERSECTION_OF);
        assertEquals(2, ics.size());
        writeOBO(doc);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.