org.biojava.ontology.io
Class TabDelimParser

java.lang.Object
  extended by org.biojava.ontology.io.TabDelimParser

public class TabDelimParser
extends java.lang.Object

Parse tab-delimited ontology files into Ontology objects.

The tab-delimited ontology files have three types of lines. Lines that are pure white space can be discarded. Comment lines begin with a hash (#) and can be discarded. The payload lines contain three fields seperated by tabs. These are subject, predicate and object. By convention, the content of each field contains no spaces.

By convention, if there are comment lines beginning with name: or description: and these appear before any predicate declarations then they become the name and description of the ontology. Otherwise, the name and description will be the empty string.

Term names normally will be just a term name like predicate or person. There are also terms that represent collections of triples. For example, here is the declaration for the 'triple' type in the core ontology.

 ...
 triple is-a    any
 triple has-a   source
 triple has-a   target
 triple has-a   predicate
 (triple,has-a,any)     size    3
 ...
 

The first four lines just associate triple with some type with a predicate (e.g. is-a or has-a). The fifth line says that something must have a size of three. The 'something' is (triple,has-a,any) size 3 and is short-hand for a collection of triples that state that the source must be triple, the target must be any and the predicate must be has-a. This whole expression states that a triple has exactly three has-a relationships; that is, exactly three properties.

Author:
Matthew Pocock

Constructor Summary
TabDelimParser()
           
 
Method Summary
 Ontology parse(java.io.BufferedReader in, OntologyFactory of)
          Parse an ontology from a reader.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TabDelimParser

public TabDelimParser()
Method Detail

parse

public Ontology parse(java.io.BufferedReader in,
                      OntologyFactory of)
               throws java.io.IOException,
                      OntologyException
Parse an ontology from a reader. The reader will be emptied of text. It is the caller's responsibility to close the reader.

Parameters:
in - the BufferedReader to read from
of - an OntologyFactory used to create the Ontology instance
Returns:
a new Ontology
Throws:
java.io.IOException - if there is some problem with the buffered reader
OntologyException - if it was not possible to instantiate a new ontology