Class TabIndexStore
- java.lang.Object
-
- org.biojava.bio.seq.db.TabIndexStore
-
- All Implemented Interfaces:
Serializable,IndexStore
public class TabIndexStore extends Object implements IndexStore, Serializable
Implements IndexStore as a serialized file for the java data and a tab-delimited file of offsets.
Use the constructor to create a new index store. Use the static factory method open() to load an existing store.
The tab-delimited file looks like:fileNumber \t offset \t id \n
- Author:
- Matthew Pocock, Thomas Down, Keith James, David Huen
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description TabIndexStore(File storeFile, File indexFile, String name, SequenceFormat format, SequenceBuilderFactory sbFactory, SymbolTokenization symbolParser)Create a new TabIndexStore.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidaddFile(File f)voidcommit()Commit the stored indices to permanent storage.protected voidcommitStore()Indexfetch(String id)Fetch an Index based upon an ID.protected intgetFileIndex(File file)SetgetFiles()Retrieve the Set of files that are currently indexed.SequenceFormatgetFormat()Retrieve the format of the index file.SetgetIDs()Retrieve the set of all current IDs.StringgetName()Retrieve the name of this store.SequenceBuilderFactorygetSBFactory()Retrieve the SequenceBuilderFactory used to build Sequence instances.SymbolTokenizationgetSymbolParser()Retrieve the symbol parser used to turn the sequence characters into Symobl objects.protected voidinitialize()static TabIndexStoreopen(File storeFile)Open an existing index store.voidrollback()Discard all uncommited changes.voidstore(Index indx)Add the Index to the store.
-
-
-
Constructor Detail
-
TabIndexStore
public TabIndexStore(File storeFile, File indexFile, String name, SequenceFormat format, SequenceBuilderFactory sbFactory, SymbolTokenization symbolParser) throws IOException, BioException
Create a new TabIndexStore.The store file and index file must not exist. This is to prevent you from accidentally destroying an existing index.
- Parameters:
storeFile- the file that will be used to persist this index storeindexFile- the file that will hold the actual indeciesname- the name that will be used by the database backed by this indexformat- the SequenceFormat for files being indexedsbFactory- the SequenceBuilderFactory used in building sequencessymbolParser- the SymbolTokenization to use- Throws:
IOException- if there was a problem writing the filesBioException- if any of the parameters were not acceptable
-
-
Method Detail
-
open
public static TabIndexStore open(File storeFile) throws IOException
Open an existing index store.- Parameters:
storeFile- the File encapsulating the store- Returns:
- a new TabIndexStore for that file
- Throws:
IOException- if the storeFile could not be processed
-
store
public void store(Index indx) throws IllegalIDException, BioException
Description copied from interface:IndexStoreAdd the Index to the store.This method should be transactional. If the store fails, the IndexStore should be left in its original state.
If the file of the Index is not known yet, it is the responsibility of the IndexStore to add it to the set returned by getFiles.
- Specified by:
storein interfaceIndexStore- Parameters:
indx- the Index to add- Throws:
IllegalIDException- if the index has an invalid ID fieldBioException- if the store failed
-
fetch
public Index fetch(String id) throws IllegalIDException, BioException
Description copied from interface:IndexStoreFetch an Index based upon an ID.- Specified by:
fetchin interfaceIndexStore- Parameters:
id- The ID of the sequence Index to retrieve- Throws:
IllegalIDException- if the ID couldn't be foundBioException- if the fetch fails in the underlying storage mechanism
-
commit
public void commit() throws BioException
Description copied from interface:IndexStoreCommit the stored indices to permanent storage.- Specified by:
commitin interfaceIndexStore- Throws:
BioException- if for any reason the commit fails
-
rollback
public void rollback()
Description copied from interface:IndexStoreDiscard all uncommited changes.- Specified by:
rollbackin interfaceIndexStore
-
getName
public String getName()
Description copied from interface:IndexStoreRetrieve the name of this store. This will be reflected as the name of the IndexedSequenceDB.- Specified by:
getNamein interfaceIndexStore- Returns:
- the String name of the index
-
getIDs
public Set getIDs()
Description copied from interface:IndexStoreRetrieve the set of all current IDs.This set should either be immutable, or modifiable totally separately from the IndexStore.
- Specified by:
getIDsin interfaceIndexStore- Returns:
- a Set of all legal IDs
-
getFiles
public Set getFiles()
Description copied from interface:IndexStoreRetrieve the Set of files that are currently indexed.- Specified by:
getFilesin interfaceIndexStore
-
getFormat
public SequenceFormat getFormat()
Description copied from interface:IndexStoreRetrieve the format of the index file.This set should either be immutable, or modifiable totally separately from the IndexStore.
- Specified by:
getFormatin interfaceIndexStore- Returns:
- a Set of all indexed files
-
getSBFactory
public SequenceBuilderFactory getSBFactory()
Description copied from interface:IndexStoreRetrieve the SequenceBuilderFactory used to build Sequence instances.- Specified by:
getSBFactoryin interfaceIndexStore- Returns:
- the associated SequenceBuilderFactory
-
getSymbolParser
public SymbolTokenization getSymbolParser()
Description copied from interface:IndexStoreRetrieve the symbol parser used to turn the sequence characters into Symobl objects.- Specified by:
getSymbolParserin interfaceIndexStore- Returns:
- the associated SymbolParser
-
commitStore
protected void commitStore() throws IOException
- Throws:
IOException
-
getFileIndex
protected int getFileIndex(File file)
-
initialize
protected void initialize() throws IOException
- Throws:
IOException
-
-