Package org.obolibrary.oboformat.model

Examples of org.obolibrary.oboformat.model.Frame


        OWLOntology original = parseOWLFile("untranslatable_axioms2.owl");
        OWLAPIOwl2Obo owl2Obo = new OWLAPIOwl2Obo(
                OWLManager.createOWLOntologyManager());
        OBODoc obo = owl2Obo.convert(original);
        renderOboToString(obo);
        Frame headerFrame = obo.getHeaderFrame();
        String owlAxiomString = headerFrame.getTagValue(
                OboFormatTag.TAG_OWL_AXIOMS, String.class);
        assertNotNull(owlAxiomString);
        OWLAPIObo2Owl obo2Owl = new OWLAPIObo2Owl(
                OWLManager.createOWLOntologyManager());
        OWLOntology converted = obo2Owl.convert(obo);
View Full Code Here


        }
        assertTrue(ok);
        // CONVERT BACK TO OBO
        OBODoc obodoc = convert(ontology);
        // test that transitive over is converted back
        Frame tf = obodoc.getTypedefFrame("regulates");
        assert tf != null;
        assertEquals(3, tf.getClauses().size());
        assertEquals("regulates", tf.getTagValue(OboFormatTag.TAG_ID));
        assertEquals("regulates", tf.getTagValue(OboFormatTag.TAG_NAME));
        Clause clause = tf.getClause(OboFormatTag.TAG_TRANSITIVE_OVER);
        assert clause != null;
        assertEquals(1, clause.getValues().size());
        assertEquals("part_of", clause.getValue());
        assertTrue(clause.getQualifierValues().isEmpty());
    }
View Full Code Here

    @Test
    public void testMultiLineDefinitions() throws Exception {
        // create minimal ontology
        OBODoc oboDocSource = new OBODoc();
        oboDocSource.setHeaderFrame(new Frame(FrameType.HEADER));
        oboDocSource.addDefaultOntologyHeader("caro");
        // add source frame that contains at least one new line
        Frame sourceFrame = new Frame(FrameType.TERM);
        sourceFrame.setId("CARO:0000049");
        sourceFrame
                .addClause(new Clause(
                        OboFormatTag.TAG_DEF,
                        "Sequential hermaphroditic organism that produces\ngametes first of the male sex, and then later of the\nfemale sex."));
        oboDocSource.addTermFrame(sourceFrame);
        // convert to OWL and retrieve def
        OWLAPIObo2Owl bridge = new OWLAPIObo2Owl(
                OWLManager.createOWLOntologyManager());
        OWLOntology owlOntology = bridge.convert(oboDocSource);
        OWLDataFactory factory = owlOntology.getOWLOntologyManager()
                .getOWLDataFactory();
        // IRI
        IRI iri = bridge.oboIdToIRI("CARO:0000049");
        OWLClass c = factory.getOWLClass(iri);
        // Def
        OWLAnnotationProperty defProperty = factory
                .getOWLAnnotationProperty(Obo2OWLVocabulary.IRI_IAO_0000115
                        .getIRI());
        int counter = 0;
        for (OWLAnnotationAssertionAxiom ax : owlOntology
                .getAnnotationAssertionAxioms(c.getIRI())) {
            if (ax.getProperty().equals(defProperty)) {
                counter++;
                assertTrue(ax.getValue() instanceof OWLLiteral);
                String owlDef = ((OWLLiteral) ax.getValue()).getLiteral();
                // check that owl def also contains at least one new line
                assertTrue(owlDef.indexOf('\n') > 0);
            }
        }
        assertEquals(1, counter);
        // convert back to OBO
        OWLAPIOwl2Obo owl2Obo = new OWLAPIOwl2Obo(
                OWLManager.createOWLOntologyManager());
        OBODoc convertedOboDoc = owl2Obo.convert(owlOntology);
        Frame convertedFrame = convertedOboDoc.getTermFrame("CARO:0000049");
        String convertedDef = convertedFrame.getTagValue(OboFormatTag.TAG_DEF,
                String.class);
        // check that round trip still contains newlines
        assertTrue(convertedDef.indexOf('\n') > 0);
    }
View Full Code Here

        boolean ok = !scas.isEmpty();
        assertTrue(ok);
        // CONVERT BACK TO OBO
        OBODoc obodoc = convert(ontology);
        // test that relation IDs are converted back to symbolic form
        Frame tf = obodoc.getTermFrame("X:1");
        Collection<Clause> clauses = tf
                .getClauses(OboFormatTag.TAG_RELATIONSHIP);
        assertEquals(2, clauses.size());
    }
View Full Code Here

        }
        assertTrue(ok);
        // CONVERT BACK TO OBO
        OBODoc obodoc = convert(ontology);
        // test that relation IDs are converted back to symbolic form
        Frame tf = obodoc.getTermFrame("GO:0000050");
        Clause c = tf.getClause(OboFormatTag.TAG_RELATIONSHIP);
        Object v = c.getValue();
        // should be converted back to symbolic form
        assertEquals("has_part", v);
        tf = obodoc.getTermFrame("GO:0004055");
        c = tf.getClause(OboFormatTag.TAG_RELATIONSHIP);
        v = c.getValue();
        // should be converted back to symbolic form
        assertEquals("part_of", v);
        tf = obodoc.getTypedefFrame("has_part");
        Collection<Clause> cs = tf.getClauses(OboFormatTag.TAG_XREF);
        assertEquals(1, cs.size());
        v = cs.iterator().next().getValue(Xref.class).getIdref();
        // should be converted back to symbolic form
        assertEquals("BFO:0000051", v);
    }
View Full Code Here

     * alphabetical ordering.
     */
    @Test
    public void testSortTermClausesIntersectionOf() {
        OBODoc oboDoc = parseOBOFile("equivtest.obo");
        Frame frame = oboDoc.getTermFrame("X:1");
        List<Clause> clauses = new ArrayList<>(
                frame.getClauses(OboFormatTag.TAG_INTERSECTION_OF));
        OBOFormatWriter.sortTermClauses(clauses);
        assertEquals("Y:1", clauses.get(0).getValue());
        assertEquals("R:1", clauses.get(1).getValue());
        assertEquals("Z:1", clauses.get(1).getValue2());
    }
View Full Code Here

    @Test
    public void testParseCARO() {
        OBODoc obodoc = parseOBOFile("caro.obo");
        assertTrue(obodoc.getTermFrames().size() > 2);
        Frame cc = obodoc.getTermFrame("CARO:0000014");
        assert cc != null;
        assertEquals("cell component", cc.getTagValue(OboFormatTag.TAG_NAME));
        assertEquals("Anatomical structure that is a direct part of the cell.",
                cc.getTagValue(OboFormatTag.TAG_DEF));
        Clause dc = cc.getClause(OboFormatTag.TAG_DEF);
        assert dc != null;
        Collection<Xref> dcxs = dc.getXrefs();
        assertEquals("CARO:MAH", dcxs.iterator().next().getIdref());
        /*
         * Collection<Xref> defxrefs = cc.getTagXrefs("def");
View Full Code Here

    @Test
    public void testParseOBOFile() {
        OBODoc obodoc = parseOBOFile("tag_test.obo");
        assertEquals(4, obodoc.getTermFrames().size());
        assertEquals(1, obodoc.getTypedefFrames().size());
        Frame frame = obodoc.getTermFrame("X:1");
        assertNotNull(frame);
        assertEquals("x1", frame.getTagValue(OboFormatTag.TAG_NAME));
    }
View Full Code Here

    @Test
    public void testParseOBODoc() {
        OBODoc obodoc = parseOBODoc("[Term]\nid: x\nname: foo\n\n\n[Term]\nid: y\nname: y");
        assertEquals(2, obodoc.getTermFrames().size());
        Frame frame = obodoc.getTermFrame("x");
        assertEquals("foo", frame.getTagValue(OboFormatTag.TAG_NAME));
    }
View Full Code Here

    @Test
    public void testParseFrames() {
        OBODoc obodoc = parseFrames("[Term]\nid: x\nname: foo");
        assertEquals(1, obodoc.getTermFrames().size());
        Frame frame = obodoc.getTermFrames().iterator().next();
        assertEquals("foo", frame.getTagValue(OboFormatTag.TAG_NAME));
    }
View Full Code Here

TOP

Related Classes of org.obolibrary.oboformat.model.Frame

Copyright © 2018 www.massapicom. 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.