public final class IndexedSequenceDB extends AbstractSequenceDB implements SequenceDB, Serializable
This class implements SequenceDB on top of a set of sequence files and sequence offsets within these files.
This class is primarily responsible for managing the sequence
IO, such as calculating the sequence file offsets, and parsing
individual sequences based upon file offsets. The actual persistant
storage of all this information is delegated to an instance of
IndexStore
, such as TabIndexStore.
// create a new index store and populate it // this may take some time TabIndexStore indexStore = new TabIndexStore( storeFile, indexFile, dbName, format, sbFactory, symbolParser ); IndexedSequenceDB seqDB = new IndexedSequenceDB(indexStore); for(int i = 0; i < files; i++) { seqDB.addFile(files[i]); } // load an existing index store and fetch a sequence // this should be quite quick TabIndexStore indexStore = TabIndexStore.open(storeFile); SequenceDB seqDB = new IndexedSequenceDB(indexStore); Sequence seq = seqDB.getSequence(id);
Note: We may be able to improve the indexing speed further by discarding all feature creation & annotation requests during index parsing.
TabIndexStore
,
Serialized FormSEQUENCES
Constructor and Description |
---|
IndexedSequenceDB(IDMaker idMaker,
IndexStore indexStore)
Create an IndexedSequenceDB by specifying both the IDMaker and
IndexStore used.
|
IndexedSequenceDB(IndexStore indexStore)
Create an IndexedSequenceDB by specifying IndexStore used.
|
Modifier and Type | Method and Description |
---|---|
void |
addFile(File seqFile)
Add sequences from a file to the sequence database.
|
IndexStore |
getIndexStore()
Retrieve the IndexStore.
|
String |
getName()
Get the name of this sequence database.
|
Sequence |
getSequence(String id)
Retrieve a single sequence by its id.
|
Set |
ids()
Get an immutable set of all of the IDs in the database.
|
SequenceIterator |
sequenceIterator()
Returns a SequenceIterator over all sequences in the database.
|
addSequence, filter, removeSequence
addChangeListener, addChangeListener, generateChangeSupport, getChangeSupport, hasListeners, hasListeners, isUnchanging, removeChangeListener, removeChangeListener
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
filter
addSequence, removeSequence
addChangeListener, addChangeListener, isUnchanging, removeChangeListener, removeChangeListener
public IndexedSequenceDB(IDMaker idMaker, IndexStore indexStore)
The IDMaker will be used to calculate the ID for each Sequence. It will delegate the storage and retrieval of the sequence offsets to the IndexStore.
idMaker
- the IDMaker used to calculate Sequence IDsindexStore
- the IndexStore delegatepublic IndexedSequenceDB(IndexStore indexStore)
IDMaker.byName will be used to calculate the ID for each Sequence. It will delegate the storage and retrieval of the sequence offsets to the IndexStore.
indexStore
- the IndexStore delegatepublic IndexStore getIndexStore()
public void addFile(File seqFile) throws IllegalIDException, BioException, ChangeVetoException
seqFile
- the file containing the sequence or set of sequencesBioException
- if for any reason the sequences can't be read
correctlyChangeVetoException
- if there is a listener that vetoes adding
the filesIllegalIDException
public String getName()
getName
in interface SequenceDBLite
public Sequence getSequence(String id) throws IllegalIDException, BioException
SequenceDBLite
getSequence
in interface SequenceDBLite
id
- the id to retrieve byIllegalIDException
- if the database doesn't know about the idBioException
- if there was a failure in retrieving the sequencepublic SequenceIterator sequenceIterator()
SequenceDB
sequenceIterator
in interface SequenceDB
sequenceIterator
in class AbstractSequenceDB
public Set ids()
SequenceDB
ids
in interface SequenceDB
Copyright © 2014 BioJava. All rights reserved.