com.compomics.util.experiment.identification.protein_inference.proteintree
Class ProteinTreeComponentsFactory

java.lang.Object
  extended by com.compomics.util.experiment.identification.protein_inference.proteintree.ProteinTreeComponentsFactory

public class ProteinTreeComponentsFactory
extends Object

This factory stores and returns protein trees components from databases.

Author:
Marc Vaudel

Field Summary
static String dbFolderPath
          The folder containing the databases.
static String dbName
          The name of the db to use.
static String folderSeparator
          The splitter in the key between database name and database version.
 
Method Summary
 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.
 ArrayList<String> getAddedTags()
          Returns arraylist of added tags
 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 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 saveProteinLength(String accession, int length)
          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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

dbFolderPath

public static final String dbFolderPath
The folder containing the databases.


folderSeparator

public static final String folderSeparator
The splitter in the key between database name and database version.

See Also:
Constant Field Values

dbName

public static final String dbName
The name of the db to use.

See Also:
Constant Field Values
Method Detail

getInstance

public static ProteinTreeComponentsFactory getInstance()
                                                throws IOException
Static method returning the instance of the factory. Note: the serialization folder should have been already set.

Returns:
the instance of the factory
Throws:
IOException

initiate

public boolean initiate()
                 throws SQLException,
                        IOException
Initiates the connection to the database and indicates whether the corresponding folder is already created.

Returns:
a boolean indicating whether the database folder is already created
Throws:
SQLException - exception thrown whenever an error occurred while attempting to connect to the database
IOException - exception thrown whenever an error occurred while attempting to connect to the database

delete

public boolean delete()
Sets the currently loaded database as corrupted and tries to delete it.

Returns:
true if deletion was successful

close

public void close()
           throws IOException,
                  SQLException
Closes the factory, closes all connection and deletes the file.

Throws:
IOException
SQLException - exception thrown if closing the db failed

getDbFolderName

public String getDbFolderName()
Returns the folder name where to store information about the protein sequence database loaded in the sequence factory.

Returns:
the folder name where to store information about the protein sequence database loaded in the sequence factory

getDbFolder

public File getDbFolder()
Returns the folder where the db in the sequence factory is stored.

Returns:
the folder where the db in the sequence factory is stored

getAddedTags

public ArrayList<String> getAddedTags()
Returns arraylist of added tags

Returns:
the arraylist of already added tags

saveNode

public void saveNode(String tag,
                     Node node)
              throws SQLException,
                     IOException
Adds a node to the database.

Parameters:
tag - the tag referring to the node of interest
node - the node
Throws:
SQLException - exception thrown whenever an error occurred while loading data in the database
IOException - exception thrown whenever an error occurred while loading data in the database

saveNodes

public void saveNodes(HashMap<String,Object> nodes)
               throws SQLException,
                      IOException
Adds nodes to the database.

Parameters:
nodes - map of the nodes
Throws:
SQLException - exception thrown whenever an error occurred while loading data in the database
IOException - exception thrown whenever an error occurred while loading data in the database

getNode

public Node getNode(String tag)
             throws SQLException,
                    ClassNotFoundException,
                    IOException
Retrieves the node of the given tag.

Parameters:
tag - the tag of interest
Returns:
the node at this tag
Throws:
SQLException
ClassNotFoundException
IOException

saveProteinLength

public void saveProteinLength(String accession,
                              int length)
                       throws SQLException,
                              IOException
Adds a protein length to the database.

Parameters:
accession - the protein accession
length - the length
Throws:
SQLException - exception thrown whenever an error occurred while loading data in the database
IOException - exception thrown whenever an error occurred while loading data in the database

getProteinLength

public Integer getProteinLength(String accession)
                         throws SQLException,
                                ClassNotFoundException,
                                IOException
Retrieves the length of a protein.

Parameters:
accession - the accession of the protein of interest
Returns:
the length of this protein
Throws:
SQLException
ClassNotFoundException
IOException

saveInitialSize

public void saveInitialSize(int size)
                     throws SQLException,
                            IOException
Saves the initial tag size in the parameters table of the DB.

Parameters:
size - the initial tag size
Throws:
SQLException
IOException

getInitialSize

public Integer getInitialSize()
                       throws SQLException,
                              IOException,
                              ClassNotFoundException
Retrieves the initial tag size from the db.

Returns:
the initial tag size
Throws:
SQLException
IOException
ClassNotFoundException

loadProteinLenths

public void loadProteinLenths()
                       throws SQLException,
                              ClassNotFoundException,
                              IOException,
                              InterruptedException
Loads all protein lengths in cache.

Throws:
SQLException
ClassNotFoundException
IOException
InterruptedException

loadParameters

public void loadParameters()
                    throws SQLException,
                           ClassNotFoundException,
                           IOException,
                           InterruptedException
Loads all tree parameters.

Throws:
SQLException
ClassNotFoundException
IOException
InterruptedException

setImportComplete

public void setImportComplete(boolean completed)
                       throws SQLException,
                              IOException
Sets whether the import was completed.

Parameters:
completed -
Throws:
SQLException
IOException

importComplete

public boolean importComplete()
                       throws SQLException,
                              IOException,
                              ClassNotFoundException
Returns a boolean indicating whether the import was complete. False if not set.

Returns:
true if the import was complete
Throws:
SQLException
IOException
ClassNotFoundException

setCorrupted

public void setCorrupted(boolean corrupted)
                  throws SQLException,
                         IOException
Sets whether the database is corrupted.

Parameters:
corrupted -
Throws:
SQLException
IOException

isCorrupted

public boolean isCorrupted()
                    throws SQLException,
                           IOException,
                           ClassNotFoundException
Returns a boolean indicating whether the database is corrupted. False if not set.

Returns:
true if the database is corrupted
Throws:
SQLException
IOException
ClassNotFoundException

setVersion

public void setVersion(String version)
                throws SQLException,
                       IOException
Sets the version.

Parameters:
version - the version
Throws:
SQLException
IOException

getVersion

public String getVersion()
                  throws SQLException,
                         IOException,
                         ClassNotFoundException
Returns the version. Null if not set.

Returns:
the version
Throws:
SQLException
IOException
ClassNotFoundException


Copyright © 2013. All Rights Reserved.