Class UnigeneTools
Usefull tools for working with Unigene.
This class is the main port-of-call for users of the Unigene package. It provides the core APIs for finding a Unigene database as well as registering your own Unigene drivers. Additionaly, it contains methods to return parsers for each of the main Unigene flat-file types. If you wish to bypass the biojava object model entirely, you can choose to use these parsers instead.
Example use
Creating a Unigene instance from your local Unigene directory (assuming that you have read/write privileges to the directory)
UnigeneDB unigene = UnigeneTools.createUnigene( new URL("file:///usr/local/biodata/unigene") );
Fetch a unigene cluster
UnigeneDB unigene = UnigeneTools.loadUnigene( new URL("file:///usr/local/biodata/unigene") ); UnigeneCluster cluster = unigenge.getCluster("Aga001"); System.out.println("Title: " + cluster.getTitle());
Parse a data file yourself
BufferedReader br = new BufferedReader(new FileReader(unigeneFile)); Parser = new Parser(); TagValueListener echo = new Echo(); ParserListener pl = UnigeneTools.buildDataParser(echo); while(parser.read(br, pl.getParser(), pl.getListener())) { // read an entry }
- Author:
- Matthew Pocock
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final AnnotationType
Annotation schema for all Unigene libraries.static final AnnotationType
Annotation schema for all UnigeneCluster instances. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic ParserListener
buildDataParser
(TagValueListener listener) Generate a tag-value parser for unigene data files that will pass all parsing events on to your listener.static ParserListener
buildLibInfoParser
(TagValueListener listener) Generate a tag-value parser for the library info unigene files.static UnigeneDB
createUnigene
(URL dbURL) Create a new UnigeneDB instance referred to by a URL.static UnigeneFactory
findFactory
(URL dbURL) Find the UnigeneFactory that can accept a URL.static String
getSpeciesForShortName
(String name) Converts short species names (like Hs) to long species names (like Homo Sapiens).static UnigeneDB
loadUnigene
(URL dbURL) Load a UnigeneDB instance referred to by a URL.static void
registerFactory
(UnigeneFactory factory) Register a UnigeneFactory.static void
unregisterFactory
(UnigeneFactory factory) Register a UnigeneFactory.
-
Field Details
-
UNIGENE_ANNOTATION
Annotation schema for all UnigeneCluster instances. This states what propperties can be expected to be associated with a cluster and how many values they may have.
-
LIBRARY_ANNOTATION
Annotation schema for all Unigene libraries. This states what propperties can be expected to be associated with a library and how many values they may have.
-
-
Constructor Details
-
UnigeneTools
public UnigeneTools()
-
-
Method Details
-
getSpeciesForShortName
Converts short species names (like Hs) to long species names (like Homo Sapiens).- Parameters:
name
- the short name- Returns:
- the long name
-
buildDataParser
Generate a tag-value parser for unigene data files that will pass all parsing events on to your listener.- Parameters:
listener
- the TagValueListener to pass events onto- Returns:
- a ParserListener that is ready to consume unigene data documents
- Throws:
ParserException
-
buildLibInfoParser
public static ParserListener buildLibInfoParser(TagValueListener listener) throws IOException, ParserException Generate a tag-value parser for the library info unigene files.- Parameters:
listener
- the TagValueListener to pass events onto- Returns:
- a ParserListener that is ready to consume unigene lib.info files
- Throws:
IOException
ParserException
-
registerFactory
Register a UnigeneFactory.
This method is for developers who have written their own UnigeneFactory implementations. By default, jdbc and file URLs are handled by built-in factories.
When you register a factory, it will be used for all URLs that is can accept. If a factory is registered afterwards that can accept the same URL, the first factory registered will be used.
- Parameters:
factory
- the UnigeneFactory to register
-
unregisterFactory
Register a UnigeneFactory.
This method is for developers who wish to unregister a factory.
- Parameters:
factory
- the UnigeneFactory to unregister
-
loadUnigene
Load a UnigeneDB instance referred to by a URL.- Parameters:
dbURL
- the URL location the database- Returns:
- a UnigeneDB instance
- Throws:
BioException
- if there was no UnigeneFactory able to process that URL or if there was some error connecting
-
createUnigene
Create a new UnigeneDB instance referred to by a URL.- Parameters:
dbURL
- the URL location the database- Returns:
- a UnigeneDB instance
- Throws:
BioException
- if there was no UnigeneFactory able to process that URL or if there was some error creating it
-
findFactory
Find the UnigeneFactory that can accept a URL.This method is for developers only. The normal way to interact with factories is to call UnigeneTools.loadUnigene() and UnigeneTools.createUnigene()
- Parameters:
dbURL
- the URL to find a factory for- Returns:
- the UnigeneFactory that accepts that URL
- Throws:
BioException
- if there is no factory for that type of URL
-