public class ProteinTreeComponentsFactory extends Object
Modifier and Type | Field and Description |
---|---|
static String |
dbName
The name of the db to use.
|
static String |
defaultDbFolderPath
The folder containing the databases.
|
static String |
folderSeparator
The splitter in the key between database name and database version.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes the factory, closes all connection and deletes the file.
|
boolean |
delete()
Sets the currently loaded database as corrupted and tries to delete it.
|
File |
getDbFolder()
Returns the folder where the db in the sequence factory is stored.
|
String |
getDbFolderName()
Returns the folder name where to store information about the protein
sequence database loaded in the sequence factory.
|
Integer |
getInitialSize()
Retrieves the initial tag size from the db.
|
static ProteinTreeComponentsFactory |
getInstance()
Static method returning the instance of the factory.
|
Node |
getNode(String tag)
Retrieves the node of the given tag.
|
Integer |
getProteinLength(String accession)
Retrieves the length of a protein.
|
String |
getVersion()
Returns the version.
|
boolean |
importComplete()
Returns a boolean indicating whether the import was complete.
|
boolean |
initiate()
Initiates the connection to the database and indicates whether the
corresponding folder is already created.
|
boolean |
isCorrupted()
Returns a boolean indicating whether the database is corrupted.
|
void |
loadParameters()
Loads all tree parameters.
|
void |
loadProteinLenths()
Loads all protein lengths in cache.
|
void |
loadTags()
Loads the tags implemented in the database.
|
void |
saveInitialSize(int size)
Saves the initial tag size in the parameters table of the DB.
|
void |
saveNode(String tag,
Node node)
Adds a node to the database.
|
void |
saveNodes(HashMap<String,Object> nodes)
Adds nodes to the database.
|
void |
saveProteinLengths(HashMap<String,Object> lengths)
Adds a protein length to the database.
|
void |
setCorrupted(boolean corrupted)
Sets whether the database is corrupted.
|
void |
setImportComplete(boolean completed)
Sets whether the import was completed.
|
void |
setVersion(String version)
Sets the version.
|
public static final String defaultDbFolderPath
public static final String folderSeparator
public static final String dbName
public static ProteinTreeComponentsFactory getInstance() throws IOException
IOException
public boolean initiate() throws SQLException, IOException
SQLException
- exception thrown whenever an error occurred while
attempting to connect to the databaseIOException
- exception thrown whenever an error occurred while
attempting to connect to the databasepublic boolean delete() throws IOException
IOException
public void close() throws IOException, SQLException
IOException
SQLException
- exception thrown if closing the db failedpublic String getDbFolderName()
public File getDbFolder() throws IOException
IOException
public void saveNode(String tag, Node node) throws SQLException, IOException
tag
- the tag referring to the node of interestnode
- the nodeSQLException
- exception thrown whenever an error occurred while
loading data in the databaseIOException
- exception thrown whenever an error occurred while
loading data in the databasepublic void saveNodes(HashMap<String,Object> nodes) throws SQLException, IOException
nodes
- map of the nodesSQLException
- exception thrown whenever an error occurred while
loading data in the databaseIOException
- exception thrown whenever an error occurred while
loading data in the databasepublic Node getNode(String tag) throws SQLException, ClassNotFoundException, IOException
tag
- the tag of interestSQLException
ClassNotFoundException
IOException
public void saveProteinLengths(HashMap<String,Object> lengths) throws SQLException, IOException
lengths
- the lengthsSQLException
- exception thrown whenever an error occurred while
loading data in the databaseIOException
- exception thrown whenever an error occurred while
loading data in the databasepublic Integer getProteinLength(String accession) throws SQLException, ClassNotFoundException, IOException
accession
- the accession of the protein of interestSQLException
ClassNotFoundException
IOException
public void saveInitialSize(int size) throws SQLException, IOException
size
- the initial tag sizeSQLException
IOException
public Integer getInitialSize() throws SQLException, IOException, ClassNotFoundException
SQLException
IOException
ClassNotFoundException
public void loadProteinLenths() throws SQLException, ClassNotFoundException, IOException, InterruptedException
public void loadParameters() throws SQLException, ClassNotFoundException, IOException, InterruptedException
public void setImportComplete(boolean completed) throws SQLException, IOException
completed
- SQLException
IOException
public boolean importComplete() throws SQLException, IOException, ClassNotFoundException
SQLException
IOException
ClassNotFoundException
public void setCorrupted(boolean corrupted) throws SQLException, IOException
corrupted
- SQLException
IOException
public boolean isCorrupted() throws SQLException, IOException, ClassNotFoundException
SQLException
IOException
ClassNotFoundException
public void setVersion(String version) throws SQLException, IOException
version
- the versionSQLException
IOException
public String getVersion() throws SQLException, IOException, ClassNotFoundException
SQLException
IOException
ClassNotFoundException
public void loadTags() throws SQLException
SQLException
Copyright © 2013. All Rights Reserved.