Class BioStoreFactory


  • public class BioStoreFactory
    extends java.lang.Object
    BioStoreFactory creates BioStore instances. These are directory and file structures which index flat files according to the OBDA specification.
    Author:
    Matthew Pocock, Keith James, Greg Cox
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String KEYS
      KEYS is the key used to identify the secondary namespaces in the OBDA config.dat files.
      static AnnotationType META_DATA_TYPE
      AnnotationType that all meta-data files should fit.
      static java.lang.String PRIMARY_KEY_NAME
      PRIMARY_KEY_NAME is the key used to identify the primary namespace in the OBDA config.dat files.
      static java.lang.String SEQUENCE_FORMAT
      SEQUENCE_FORMAT is the key used to identify the format of the indexed sequence files represented by the store in the OBDA config.dat files.
      static java.lang.String STORE_NAME
      STORE_NAME is the key used to identify the arbitrary name of the store in the OBDA config.dat files.
    • Constructor Summary

      Constructors 
      Constructor Description
      BioStoreFactory()
      Creates a new BioStoreFactory.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addKey​(java.lang.String keyName, int length)
      addKey adds a new identifier namespace.
      static int calculatePrimRecLen​(int idLen)
      calculatePrimRecLen calculates the byte length of primary namespace records.
      static int calculateSecRecLen​(int idLen, java.lang.String primaryKey, java.util.Map keys)
      calculateSecRecLen calculates the byte length of secondary namespace records.
      BioStore createBioStore()
      createBioStore creates a BioStore reflecting the current state of the factory and returns a reference to it.
      java.util.Set getKeys()  
      java.lang.String getPrimaryKey()
      getPrimaryKey returns the primary identifier namespace.
      LifeScienceIdentifier getSequenceFormat()
      getSequenceFormat returns the current sequence format name.
      java.io.File getStoreLocation()
      getStoreLocation returns the directory of the bew index.
      java.lang.String getStoreName()
      getStoreName returns the name to be given to the new index.
      static java.io.File makeConfigFile​(java.io.File storeLoc)
      makeConfigFile returns a file which represents an OBDA "config.dat" in the specified index directory.
      static java.io.File makePrimaryKeyFile​(java.io.File storeLoc, java.lang.String key)
      makePrimaryKeyFile returns a file which represents an OBDA "key_<primary namespace>.key" primary key file on the specified index directory.
      static java.io.File makeSecondaryFile​(java.io.File storeLoc, java.lang.String key)
      makeSecondaryFile returns a file which represents an OBDA "id_<secondary namespace>.index" secondary key file on the specified.
      void removeKey​(java.lang.String keyName)
      removeKey removes the specified key.
      void setPrimaryKey​(java.lang.String primaryKey)
      setPrimaryKey sets the primary identifier namespace.
      void setSequenceFormat​(LifeScienceIdentifier format)
      setSequenceFormat sets the sequence format name which will be indicated in the index.
      void setStoreLocation​(java.io.File storeLoc)
      setStoreLocation sets the directory of the new index.
      void setStoreName​(java.lang.String name)
      setStoreName sets the name to be given to the new index.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • STORE_NAME

        public static final java.lang.String STORE_NAME
        STORE_NAME is the key used to identify the arbitrary name of the store in the OBDA config.dat files.
        See Also:
        Constant Field Values
      • SEQUENCE_FORMAT

        public static final java.lang.String SEQUENCE_FORMAT
        SEQUENCE_FORMAT is the key used to identify the format of the indexed sequence files represented by the store in the OBDA config.dat files.
        See Also:
        Constant Field Values
      • PRIMARY_KEY_NAME

        public static final java.lang.String PRIMARY_KEY_NAME
        PRIMARY_KEY_NAME is the key used to identify the primary namespace in the OBDA config.dat files.
        See Also:
        Constant Field Values
      • KEYS

        public static final java.lang.String KEYS
        KEYS is the key used to identify the secondary namespaces in the OBDA config.dat files.
        See Also:
        Constant Field Values
    • Constructor Detail

    • Method Detail

      • setStoreName

        public void setStoreName​(java.lang.String name)
        setStoreName sets the name to be given to the new index.
        Parameters:
        name - a String.
      • getStoreName

        public java.lang.String getStoreName()
        getStoreName returns the name to be given to the new index.
        Returns:
        a String.
      • setStoreLocation

        public void setStoreLocation​(java.io.File storeLoc)
        setStoreLocation sets the directory of the new index.
        Parameters:
        storeLoc - a File.
      • getStoreLocation

        public java.io.File getStoreLocation()
        getStoreLocation returns the directory of the bew index.
        Returns:
        a File.
      • setSequenceFormat

        public void setSequenceFormat​(LifeScienceIdentifier format)
        setSequenceFormat sets the sequence format name which will be indicated in the index.
        Parameters:
        format - a LifeScienceIdentifier which must be one of those mandated by the OBDA flatfile indexing specification.
      • setPrimaryKey

        public void setPrimaryKey​(java.lang.String primaryKey)
        setPrimaryKey sets the primary identifier namespace.
        Parameters:
        primaryKey - a String.
      • getPrimaryKey

        public java.lang.String getPrimaryKey()
        getPrimaryKey returns the primary identifier namespace.
        Returns:
        a String.
      • addKey

        public void addKey​(java.lang.String keyName,
                           int length)
        addKey adds a new identifier namespace.
        Parameters:
        keyName - a String.
        length - an int indicating the byte length of the key records.
      • getKeys

        public java.util.Set getKeys()
      • removeKey

        public void removeKey​(java.lang.String keyName)
        removeKey removes the specified key.
        Parameters:
        keyName - a String.
      • createBioStore

        public BioStore createBioStore()
                                throws BioException
        createBioStore creates a BioStore reflecting the current state of the factory and returns a reference to it.
        Returns:
        a BioStore.
        Throws:
        BioException - if an error occurs.
      • makeConfigFile

        public static java.io.File makeConfigFile​(java.io.File storeLoc)
                                           throws java.io.IOException
        makeConfigFile returns a file which represents an OBDA "config.dat" in the specified index directory.
        Parameters:
        storeLoc - a File indicating the index directory.
        Returns:
        a File representing "config.dat".
        Throws:
        java.io.IOException - if an error occurs.
      • makePrimaryKeyFile

        public static java.io.File makePrimaryKeyFile​(java.io.File storeLoc,
                                                      java.lang.String key)
                                               throws java.io.IOException
        makePrimaryKeyFile returns a file which represents an OBDA "key_<primary namespace>.key" primary key file on the specified index directory.
        Parameters:
        storeLoc - a File indicating the parent path.
        key - a String primary key namespace.
        Returns:
        a File representing a "key_<primary namespace>.key".
        Throws:
        java.io.IOException - if an error occurs.
      • makeSecondaryFile

        public static java.io.File makeSecondaryFile​(java.io.File storeLoc,
                                                     java.lang.String key)
                                              throws java.io.IOException
        makeSecondaryFile returns a file which represents an OBDA "id_<secondary namespace>.index" secondary key file on the specified.
        Parameters:
        storeLoc - a File indicating the parent path.
        key - a String secondary key namespace.
        Returns:
        a File representing an "id_<secondary namespace>.index" file.
        Throws:
        java.io.IOException - if an error occurs.
      • calculatePrimRecLen

        public static int calculatePrimRecLen​(int idLen)
        calculatePrimRecLen calculates the byte length of primary namespace records.
        Parameters:
        idLen - an int the number of bytes required to hold the primary namespace ID.
        Returns:
        an int record length in bytes.
      • calculateSecRecLen

        public static int calculateSecRecLen​(int idLen,
                                             java.lang.String primaryKey,
                                             java.util.Map keys)
        calculateSecRecLen calculates the byte length of secondary namespace records.
        Parameters:
        idLen - an int the number of bytes required to hold the secondary namespace ID.
        primaryKey - a String the primary namespace ID.
        keys - a Map of secondary keys to their byte lengths.
        Returns:
        an int record length in bytes.