Package org.biojava.bio.seq.db
Class BioIndex
- java.lang.Object
-
- org.biojava.bio.seq.db.BioIndex
-
- All Implemented Interfaces:
IndexStore
public class BioIndex extends Object implements IndexStore
The original object for indexing sequence files.This class may not be thread-safe.
- Author:
- Matthew Pocock, Thomas Down
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
commit()
Commit the stored indices to permanent storage.Index
fetch(String id)
Fetch an Index based upon an ID.Set
getFiles()
Retrieve the Set of files that are currently indexed.SequenceFormat
getFormat()
Retrieve the format of the index file.Set
getIDs()
Retrieve the set of all current IDs.String
getName()
Retrieve the name of this store.SequenceBuilderFactory
getSBFactory()
Retrieve the SequenceBuilderFactory used to build Sequence instances.SymbolTokenization
getSymbolParser()
Retrieve the symbol parser used to turn the sequence characters into Symobl objects.int
guessRecLen(RandomAccessFile file)
void
rollback()
Discard all uncommited changes.void
store(Index indx)
Add the Index to the store.
-
-
-
Constructor Detail
-
BioIndex
public BioIndex(File indexDirectory, String namespace, int idLength) throws IOException, BioException
- Throws:
IOException
BioException
-
BioIndex
public BioIndex(File indexDirectory) throws IOException, BioException
Load an existing index file. If indexDirectory does not exist, or is not a bioindex stoore, this will barf.- Throws:
IOException
BioException
-
-
Method Detail
-
getName
public String getName()
Description copied from interface:IndexStore
Retrieve the name of this store. This will be reflected as the name of the IndexedSequenceDB.- Specified by:
getName
in interfaceIndexStore
- Returns:
- the String name of the index
-
guessRecLen
public int guessRecLen(RandomAccessFile file) throws IOException
- Throws:
IOException
-
fetch
public Index fetch(String id) throws IllegalIDException, BioException
Description copied from interface:IndexStore
Fetch an Index based upon an ID.- Specified by:
fetch
in 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
-
store
public void store(Index indx)
Description copied from interface:IndexStore
Add 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:
store
in interfaceIndexStore
- Parameters:
indx
- the Index to add
-
commit
public void commit() throws BioException
Description copied from interface:IndexStore
Commit the stored indices to permanent storage.- Specified by:
commit
in interfaceIndexStore
- Throws:
BioException
- if for any reason the commit fails
-
rollback
public void rollback()
Description copied from interface:IndexStore
Discard all uncommited changes.- Specified by:
rollback
in interfaceIndexStore
-
getIDs
public Set getIDs()
Description copied from interface:IndexStore
Retrieve the set of all current IDs.This set should either be immutable, or modifiable totally separately from the IndexStore.
- Specified by:
getIDs
in interfaceIndexStore
- Returns:
- a Set of all legal IDs
-
getFiles
public Set getFiles()
Description copied from interface:IndexStore
Retrieve the Set of files that are currently indexed.- Specified by:
getFiles
in interfaceIndexStore
-
getFormat
public SequenceFormat getFormat()
Description copied from interface:IndexStore
Retrieve the format of the index file.This set should either be immutable, or modifiable totally separately from the IndexStore.
- Specified by:
getFormat
in interfaceIndexStore
- Returns:
- a Set of all indexed files
-
getSBFactory
public SequenceBuilderFactory getSBFactory()
Description copied from interface:IndexStore
Retrieve the SequenceBuilderFactory used to build Sequence instances.- Specified by:
getSBFactory
in interfaceIndexStore
- Returns:
- the associated SequenceBuilderFactory
-
getSymbolParser
public SymbolTokenization getSymbolParser()
Description copied from interface:IndexStore
Retrieve the symbol parser used to turn the sequence characters into Symobl objects.- Specified by:
getSymbolParser
in interfaceIndexStore
- Returns:
- the associated SymbolParser
-
-