OBO Parser - Getting Started

From GO Wiki
Revision as of 17:04, 15 September 2006 by Maria (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Java Event Based Parser for OBO - Getting Started:

The Java event-based parser is part of the OBO-Edit source code, in the org.geneontology.oboedit.dataadapter package. The OBO-Edit sources are available from our sourceforge CVS repository. For information on accessing the repository, go to:


We apologize in advance for the very sparse documentation in these source files.

The classes of interest are:

  • GOBOParser
  • DefaultGOBOParser
  • GOBOParseEngine

The basic idea is that GOBOParseEngine reads and parses a Collection of OBO files to generate events (like "readID" and "readDefinition"). Each GOBOParseEngine is associated with an implementation of GOBOParser. Each time GOBOParseEngine generates an event, the corresponding GOBOParser method is called. Thus, if GOBOParseEngine sees the line "name: kinase" in an OBO file, it will call GOBOParseEngine.readName("kinase", null).

DefaultGOBOParser is an implementation of GOBOParser that populates the OBO-Edit datamodels from an OBO file. If you want to use OBO-Edit's datamodels, you can use DefaultGOBOParser like so:

    public static OBOSession getSession(String path) {
        DefaultGOBOParser parser = new DefaultGOBOParser();
        GOBOParseEngine engine = new GOBOParseEngine(parser);
        //GOBOParseEngine can parse several files at once
	//and create one munged-together ontology,
	//so we need to provide a Collection to the setPaths() method
        Collection paths = new LinkedList();
        OBOSession session = parser.getSession();
        return session;

If you're populating a database, or doing something else where it would just be a waste of memory to use the OBO-Edit datamodels, you can create your own implementation of GOBOParser, and skip the datamodel generation step altogether.