Package org.biojava.bio.program.indexdb
Class BioStoreFactory
- java.lang.Object
-
- org.biojava.bio.program.indexdb.BioStoreFactory
-
public class BioStoreFactory extends java.lang.ObjectBioStoreFactorycreatesBioStoreinstances. 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.StringKEYSKEYSis the key used to identify the secondary namespaces in the OBDA config.dat files.static AnnotationTypeMETA_DATA_TYPEAnnotationType that all meta-data files should fit.static java.lang.StringPRIMARY_KEY_NAMEPRIMARY_KEY_NAMEis the key used to identify the primary namespace in the OBDA config.dat files.static java.lang.StringSEQUENCE_FORMATSEQUENCE_FORMATis 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.StringSTORE_NAMESTORE_NAMEis 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 newBioStoreFactory.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddKey(java.lang.String keyName, int length)addKeyadds a new identifier namespace.static intcalculatePrimRecLen(int idLen)calculatePrimRecLencalculates the byte length of primary namespace records.static intcalculateSecRecLen(int idLen, java.lang.String primaryKey, java.util.Map keys)calculateSecRecLencalculates the byte length of secondary namespace records.BioStorecreateBioStore()createBioStorecreates aBioStorereflecting the current state of the factory and returns a reference to it.java.util.SetgetKeys()java.lang.StringgetPrimaryKey()getPrimaryKeyreturns the primary identifier namespace.LifeScienceIdentifiergetSequenceFormat()getSequenceFormatreturns the current sequence format name.java.io.FilegetStoreLocation()getStoreLocationreturns the directory of the bew index.java.lang.StringgetStoreName()getStoreNamereturns the name to be given to the new index.static java.io.FilemakeConfigFile(java.io.File storeLoc)makeConfigFilereturns a file which represents an OBDA "config.dat" in the specified index directory.static java.io.FilemakePrimaryKeyFile(java.io.File storeLoc, java.lang.String key)makePrimaryKeyFilereturns a file which represents an OBDA "key_<primary namespace>.key" primary key file on the specified index directory.static java.io.FilemakeSecondaryFile(java.io.File storeLoc, java.lang.String key)makeSecondaryFilereturns a file which represents an OBDA "id_<secondary namespace>.index" secondary key file on the specified.voidremoveKey(java.lang.String keyName)removeKeyremoves the specified key.voidsetPrimaryKey(java.lang.String primaryKey)setPrimaryKeysets the primary identifier namespace.voidsetSequenceFormat(LifeScienceIdentifier format)setSequenceFormatsets the sequence format name which will be indicated in the index.voidsetStoreLocation(java.io.File storeLoc)setStoreLocationsets the directory of the new index.voidsetStoreName(java.lang.String name)setStoreNamesets the name to be given to the new index.
-
-
-
Field Detail
-
STORE_NAME
public static final java.lang.String STORE_NAME
STORE_NAMEis 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_FORMATis 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_NAMEis 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
KEYSis the key used to identify the secondary namespaces in the OBDA config.dat files.- See Also:
- Constant Field Values
-
META_DATA_TYPE
public static final AnnotationType META_DATA_TYPE
AnnotationType that all meta-data files should fit.
-
-
Method Detail
-
setStoreName
public void setStoreName(java.lang.String name)
setStoreNamesets the name to be given to the new index.- Parameters:
name- aString.
-
getStoreName
public java.lang.String getStoreName()
getStoreNamereturns the name to be given to the new index.- Returns:
- a
String.
-
setStoreLocation
public void setStoreLocation(java.io.File storeLoc)
setStoreLocationsets the directory of the new index.- Parameters:
storeLoc- aFile.
-
getStoreLocation
public java.io.File getStoreLocation()
getStoreLocationreturns the directory of the bew index.- Returns:
- a
File.
-
setSequenceFormat
public void setSequenceFormat(LifeScienceIdentifier format)
setSequenceFormatsets the sequence format name which will be indicated in the index.- Parameters:
format- aLifeScienceIdentifierwhich must be one of those mandated by the OBDA flatfile indexing specification.
-
getSequenceFormat
public LifeScienceIdentifier getSequenceFormat()
getSequenceFormatreturns the current sequence format name.- Returns:
- a
LifeScienceIdentifier.
-
setPrimaryKey
public void setPrimaryKey(java.lang.String primaryKey)
setPrimaryKeysets the primary identifier namespace.- Parameters:
primaryKey- aString.
-
getPrimaryKey
public java.lang.String getPrimaryKey()
getPrimaryKeyreturns the primary identifier namespace.- Returns:
- a
String.
-
addKey
public void addKey(java.lang.String keyName, int length)addKeyadds a new identifier namespace.- Parameters:
keyName- aString.length- anintindicating the byte length of the key records.
-
getKeys
public java.util.Set getKeys()
-
removeKey
public void removeKey(java.lang.String keyName)
removeKeyremoves the specified key.- Parameters:
keyName- aString.
-
createBioStore
public BioStore createBioStore() throws BioException
createBioStorecreates aBioStorereflecting 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.IOExceptionmakeConfigFilereturns a file which represents an OBDA "config.dat" in the specified index directory.- Parameters:
storeLoc- aFileindicating the index directory.- Returns:
- a
Filerepresenting "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.IOExceptionmakePrimaryKeyFilereturns a file which represents an OBDA "key_<primary namespace>.key" primary key file on the specified index directory.- Parameters:
storeLoc- aFileindicating the parent path.key- aStringprimary key namespace.- Returns:
- a
Filerepresenting 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.IOExceptionmakeSecondaryFilereturns a file which represents an OBDA "id_<secondary namespace>.index" secondary key file on the specified.- Parameters:
storeLoc- aFileindicating the parent path.key- aStringsecondary key namespace.- Returns:
- a
Filerepresenting an "id_<secondary namespace>.index" file. - Throws:
java.io.IOException- if an error occurs.
-
calculatePrimRecLen
public static int calculatePrimRecLen(int idLen)
calculatePrimRecLencalculates the byte length of primary namespace records.- Parameters:
idLen- anintthe number of bytes required to hold the primary namespace ID.- Returns:
- an
intrecord length in bytes.
-
calculateSecRecLen
public static int calculateSecRecLen(int idLen, java.lang.String primaryKey, java.util.Map keys)calculateSecRecLencalculates the byte length of secondary namespace records.- Parameters:
idLen- anintthe number of bytes required to hold the secondary namespace ID.primaryKey- aStringthe primary namespace ID.keys- aMapof secondary keys to their byte lengths.- Returns:
- an
intrecord length in bytes.
-
-