peakml.io
Class Vocabulary

java.lang.Object
  extended by peakml.io.Vocabulary
All Implemented Interfaces:
java.lang.Iterable<Vocabulary.Term>

public class Vocabulary
extends java.lang.Object
implements java.lang.Iterable<Vocabulary.Term>

This class is a simple implementation, which keeps track of a controlled vocabulary. Its most obvious use is the MS-vocabulary defined by the Proteomics Standards Initiative, which goes along with the mzml standard. In a controlled vocabulary terms are related, which have a fixed ID and a fixed meaning. An example of this is MS:1000484 'orbitrap'. This means that when a controlled vocabulary with id MS:1000484 is encountered, the meaning is orbitrap. This class can also be used for other controlled vocabularies.

Terms are stored in a hashmap which utilizes the term.id as the key in order to improve the speed of retrieving terms from the vocabulary.

This class is slated for disposal in favor of the sesame library.


Nested Class Summary
static class Vocabulary.Term
          This class is a simple implementation, which keeps track of a single term in a controlled vocabulary.
 
Constructor Summary
Vocabulary()
          Basic constructor for a vocabulary, which initializes an empty set.
Vocabulary(java.io.InputStream input)
          Basic constructor, which reads the contents of the given input-stream and stores them internally.
 
Method Summary
 void addTerm(Vocabulary.Term term)
          Adds the given term to the hashmap, with the Vocabulary.Term.id field used as a key.
 java.lang.String getDefaultNamespace()
          Returns the default namespace of this vocabulary.
 Vocabulary.Term getTerm(java.lang.String id)
          Returns the term with the given id.
static Vocabulary getVocabulary(java.lang.String filename)
           
 boolean isTermChildOf(Vocabulary.Term term, Vocabulary.Term parent)
          Determines whether the given term is a child of the given parent.
 java.util.Iterator<Vocabulary.Term> iterator()
           
 void parseOBO(java.io.InputStream input)
          Simple parser for OWL-files issued by the Open Biomedial Ontologies foundry.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Vocabulary

public Vocabulary()
Basic constructor for a vocabulary, which initializes an empty set.


Vocabulary

public Vocabulary(java.io.InputStream input)
           throws java.io.IOException
Basic constructor, which reads the contents of the given input-stream and stores them internally.

Parameters:
input - The input-stream to read from.
Throws:
java.io.IOException - Thrown when something goes wrong with the input-stream.
Method Detail

getDefaultNamespace

public java.lang.String getDefaultNamespace()
Returns the default namespace of this vocabulary.

Returns:
The default namespace.

getTerm

public Vocabulary.Term getTerm(java.lang.String id)
Returns the term with the given id. When the term-id is not available null is returned.

Parameters:
id - The id of the term to be retrieved.
Returns:
The retrieved term or null when not available.

addTerm

public void addTerm(Vocabulary.Term term)
Adds the given term to the hashmap, with the Vocabulary.Term.id field used as a key. When alternative id's (Vocabulary.Term.alt_id) are available, extra entries are made.

Parameters:
term - The term to be added to the vocabulary.

isTermChildOf

public boolean isTermChildOf(Vocabulary.Term term,
                             Vocabulary.Term parent)
Determines whether the given term is a child of the given parent. To do this, the function recursively iterates through all of the is_a relations.

Parameters:
term - The term to evaluate.
parent - The parent for the term.
Returns:
True when the term is a child, false otherwise.

iterator

public java.util.Iterator<Vocabulary.Term> iterator()
Specified by:
iterator in interface java.lang.Iterable<Vocabulary.Term>

parseOBO

public void parseOBO(java.io.InputStream input)
              throws java.io.IOException
Simple parser for OWL-files issued by the Open Biomedial Ontologies foundry. It is by no means a complete parser. The contents of the file are stored internally in this class.

Parameters:
input - The input-stream to read from.
Throws:
java.io.IOException

getVocabulary

public static Vocabulary getVocabulary(java.lang.String filename)
                                throws java.io.IOException
Throws:
java.io.IOException