public class UnigeneTools extends Object
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.
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 }
Modifier and Type | Field and Description |
---|---|
static AnnotationType |
LIBRARY_ANNOTATION
Annotation schema for all Unigene libraries.
|
static AnnotationType |
UNIGENE_ANNOTATION
Annotation schema for all UnigeneCluster instances.
|
Constructor and Description |
---|
UnigeneTools() |
Modifier and Type | Method and Description |
---|---|
static 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.
|
public static final AnnotationType 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.
public static final AnnotationType 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.
public UnigeneTools()
public static String getSpeciesForShortName(String name)
name
- the short namepublic static ParserListener buildDataParser(TagValueListener listener) throws ParserException
listener
- the TagValueListener to pass events ontoParserException
public static ParserListener buildLibInfoParser(TagValueListener listener) throws IOException, ParserException
listener
- the TagValueListener to pass events ontoIOException
ParserException
public static void registerFactory(UnigeneFactory factory)
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.
factory
- the UnigeneFactory to registerpublic static void unregisterFactory(UnigeneFactory factory)
Register a UnigeneFactory.
This method is for developers who wish to unregister a factory.
factory
- the UnigeneFactory to unregisterpublic static UnigeneDB loadUnigene(URL dbURL) throws BioException
dbURL
- the URL location the databaseBioException
- if there was no UnigeneFactory able to process that
URL or if there was some error connectingpublic static UnigeneDB createUnigene(URL dbURL) throws BioException
dbURL
- the URL location the databaseBioException
- if there was no UnigeneFactory able to process that
URL or if there was some error creating itpublic static UnigeneFactory findFactory(URL dbURL) throws BioException
This method is for developers only. The normal way to interact with factories is to call UnigeneTools.loadUnigene() and UnigeneTools.createUnigene()
dbURL
- the URL to find a factory forBioException
- if there is no factory for that type of URLCopyright © 2014 BioJava. All rights reserved.