Class TabIndexStore

  • All Implemented Interfaces:
    java.io.Serializable, IndexStore

    public class TabIndexStore
    extends java.lang.Object
    implements IndexStore, java.io.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 Detail

      • TabIndexStore

        public TabIndexStore​(java.io.File storeFile,
                             java.io.File indexFile,
                             java.lang.String name,
                             SequenceFormat format,
                             SequenceBuilderFactory sbFactory,
                             SymbolTokenization symbolParser)
                      throws java.io.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 store
        indexFile - the file that will hold the actual indecies
        name - the name that will be used by the database backed by this index
        format - the SequenceFormat for files being indexed
        sbFactory - the SequenceBuilderFactory used in building sequences
        symbolParser - the SymbolTokenization to use
        Throws:
        java.io.IOException - if there was a problem writing the files
        BioException - if any of the parameters were not acceptable
    • Method Detail

      • open

        public static TabIndexStore open​(java.io.File storeFile)
                                  throws java.io.IOException
        Open an existing index store.
        Parameters:
        storeFile - the File encapsulating the store
        Returns:
        a new TabIndexStore for that file
        Throws:
        java.io.IOException - if the storeFile could not be processed
      • store

        public void store​(Index indx)
                   throws IllegalIDException,
                          BioException
        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 interface IndexStore
        Parameters:
        indx - the Index to add
        Throws:
        IllegalIDException - if the index has an invalid ID field
        BioException - if the store failed
      • commit

        public void commit()
                    throws BioException
        Description copied from interface: IndexStore
        Commit the stored indices to permanent storage.
        Specified by:
        commit in interface IndexStore
        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 interface IndexStore
      • getName

        public java.lang.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 interface IndexStore
        Returns:
        the String name of the index
      • getIDs

        public java.util.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 interface IndexStore
        Returns:
        a Set of all legal IDs
      • getFiles

        public java.util.Set getFiles()
        Description copied from interface: IndexStore
        Retrieve the Set of files that are currently indexed.
        Specified by:
        getFiles in interface IndexStore
      • 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 interface IndexStore
        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 interface IndexStore
        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 interface IndexStore
        Returns:
        the associated SymbolParser
      • commitStore

        protected void commitStore()
                            throws java.io.IOException
        Throws:
        java.io.IOException
      • addFile

        protected void addFile​(java.io.File f)
      • getFileIndex

        protected int getFileIndex​(java.io.File file)
      • initialize

        protected void initialize()
                           throws java.io.IOException
        Throws:
        java.io.IOException