com.compomics.util.experiment.identification
Class SequenceFactory

java.lang.Object
  extended by com.compomics.util.experiment.identification.SequenceFactory

public class SequenceFactory
extends Object

factory retrieving the information of the loaded fasta file

Author:
marc

Field Summary
static String[] decoyFlags
          Recognized flags for a decoy protein
 
Method Summary
 void appendDecoySequences(File destinationFile)
          Appends decoy sequences to the desired file
 void appendDecoySequences(File destinationFile, ProgressDialogX progressDialog)
          Appends decoy sequences to the desired file while displaying progress
 void closeFile()
          Closes the opened file
 boolean concatenatedTargetDecoy()
          Indicates whether the database loaded contains decoy sequences
static FastaIndex createFastaIndex(File fastaFile)
          static method to create a fasta index for a fasta file
static FastaIndex createFastaIndex(File fastaFile, ProgressDialogX progressDialog)
          static method to create a fasta index for a fasta file
 ArrayList<String> getAccessions()
          Returns the sequences present in the database
 FastaIndex getFastaIndex(File fastaFile)
          Returns the file index of a fasta file
 FastaIndex getFastaIndex(File fastaFile, ProgressDialogX progressDialog)
          Returns the file index of a fasta file
 Header getHeader(String accession)
          returns the desired header for the protein in the fasta file
 FastaIndex getIndex(File fastaIndex)
          Deserializes the index of the fasta file
static SequenceFactory getInstance()
          static method returning the instance of the factory
static SequenceFactory getInstance(int nCache)
          returns the instance of the factory with the specified cache size
 int getnCache()
          Returns the size of the cache
 int getNTargetSequences()
          Returns the number of target sequences in the database
 Protein getProtein(String accession)
          Returns the desired protein
static boolean isDecoy(String proteinAccession)
          Returns a boolean indicating whether a protein is decoy or not based on the protein accession.
 void loadFastaFile(File fastaFile)
          loads a new fasta file in the factory.
 void loadFastaFile(File fastaFile, ProgressDialogX progressDialog)
          loads a new fasta file in the factory.
 void setnCache(int nCache)
          Sets the size of the cache
 void writeIndex(FastaIndex fastaIndex, File directory)
          serializes the fasta file index in a given directory
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

decoyFlags

public static final String[] decoyFlags
Recognized flags for a decoy protein

Method Detail

getInstance

public static SequenceFactory getInstance()
static method returning the instance of the factory

Returns:
the instance of the factory

getInstance

public static SequenceFactory getInstance(int nCache)
returns the instance of the factory with the specified cache size

Parameters:
nCache - the new cache size
Returns:
the instance of the factory with the specified cache size

getProtein

public Protein getProtein(String accession)
                   throws IOException
Returns the desired protein

Parameters:
accession - accession of the desired protein
Returns:
the desired protein
Throws:
IOException - exception thrown whenever an error is encountered while reading the fasta file

getHeader

public Header getHeader(String accession)
                 throws IOException
returns the desired header for the protein in the fasta file

Parameters:
accession - accession of the desired protein
Returns:
the corresponding header
Throws:
IOException - exception thrown whenever an error occurred while reading the fasta file

loadFastaFile

public void loadFastaFile(File fastaFile)
                   throws FileNotFoundException,
                          IOException,
                          ClassNotFoundException
loads a new fasta file in the factory. Only one fasta file can be loaded at a time

Parameters:
fastaFile - the fasta file to load
Throws:
FileNotFoundException - exception thrown if the file was not found
IOException - exception thrown if an error occurred while reading the fasta file
ClassNotFoundException - exception thrown whenever an error occurred while deserializing the file index

loadFastaFile

public void loadFastaFile(File fastaFile,
                          ProgressDialogX progressDialog)
                   throws FileNotFoundException,
                          IOException,
                          ClassNotFoundException
loads a new fasta file in the factory. Only one fasta file can be loaded at a time

Parameters:
fastaFile - the fasta file to load
progressDialog - a progress dialog showing the progress
Throws:
FileNotFoundException - exception thrown if the file was not found
IOException - exception thrown if an error occurred while reading the fasta file
ClassNotFoundException - exception thrown whenever an error occurred while deserializing the file index

getFastaIndex

public FastaIndex getFastaIndex(File fastaFile)
                         throws FileNotFoundException,
                                IOException,
                                ClassNotFoundException
Returns the file index of a fasta file

Parameters:
fastaFile - the fasta file
Returns:
the index of the fasta file
Throws:
FileNotFoundException - exception thrown if the file was not found
IOException - exception thrown if an error occurred while reading the fasta file
ClassNotFoundException - exception thrown whenever an error occurred while deserializing the file index

getFastaIndex

public FastaIndex getFastaIndex(File fastaFile,
                                ProgressDialogX progressDialog)
                         throws FileNotFoundException,
                                IOException,
                                ClassNotFoundException
Returns the file index of a fasta file

Parameters:
fastaFile - the fasta file
progressDialog - a progress dialog showing the progress
Returns:
the index of the fasta file
Throws:
FileNotFoundException - exception thrown if the file was not found
IOException - exception thrown if an error occurred while reading the fasta file
ClassNotFoundException - exception thrown whenever an error occurred while deserializing the file index

writeIndex

public void writeIndex(FastaIndex fastaIndex,
                       File directory)
                throws IOException
serializes the fasta file index in a given directory

Parameters:
fastaIndex - the index of the fasta file
directory - the directory where to write the file
Throws:
IOException - exception thrown whenever an error occurred while writing the file

getIndex

public FastaIndex getIndex(File fastaIndex)
                    throws FileNotFoundException,
                           IOException,
                           ClassNotFoundException
Deserializes the index of the fasta file

Parameters:
fastaIndex - the fasta cui index file
Returns:
the corresponding FastaIndex instance
Throws:
FileNotFoundException - exception thrown if the file was not found
IOException - exception thrown if an error occurred while reading the fasta file
ClassNotFoundException - exception thrown whenever an error occurred while deserializing the file index

closeFile

public void closeFile()
               throws IOException
Closes the opened file

Throws:
IOException - exception thrown whenever an error occurred while closing the file

createFastaIndex

public static FastaIndex createFastaIndex(File fastaFile)
                                   throws FileNotFoundException,
                                          IOException
static method to create a fasta index for a fasta file

Parameters:
fastaFile - the fasta file
Returns:
the corresponding fasta index
Throws:
FileNotFoundException - exception thrown if the fasta file was not found
IOException - exception thrown whenever an error occurred while reading the file

createFastaIndex

public static FastaIndex createFastaIndex(File fastaFile,
                                          ProgressDialogX progressDialog)
                                   throws FileNotFoundException,
                                          IOException
static method to create a fasta index for a fasta file

Parameters:
fastaFile - the fasta file
progressDialog - a progress dialog showing the progress
Returns:
the corresponding fasta index
Throws:
FileNotFoundException - exception thrown if the fasta file was not found
IOException - exception thrown whenever an error occurred while reading the file

isDecoy

public static boolean isDecoy(String proteinAccession)
Returns a boolean indicating whether a protein is decoy or not based on the protein accession. Recognized flags for decoy proteins are listed as a static field.

Parameters:
proteinAccession - The accession of the protein
Returns:
a boolean indicating whether the protein is Decoy.

concatenatedTargetDecoy

public boolean concatenatedTargetDecoy()
Indicates whether the database loaded contains decoy sequences

Returns:
a boolean indicating whether the database loaded contains decoy sequences

getNTargetSequences

public int getNTargetSequences()
Returns the number of target sequences in the database

Returns:
the number of target sequences in the database

appendDecoySequences

public void appendDecoySequences(File destinationFile)
                          throws IOException
Appends decoy sequences to the desired file

Parameters:
destinationFile - the destination file
Throws:
IOException - exception thrown whenever an error occurred while reading or writing a file

appendDecoySequences

public void appendDecoySequences(File destinationFile,
                                 ProgressDialogX progressDialog)
                          throws IOException
Appends decoy sequences to the desired file while displaying progress

Parameters:
destinationFile - the destination file
progressDialog - the progress dialog
Throws:
IOException - exception thrown whenever an error occurred while reading or writing a file

getAccessions

public ArrayList<String> getAccessions()
Returns the sequences present in the database

Returns:
the sequences present in the database

getnCache

public int getnCache()
Returns the size of the cache

Returns:
the size of the cache

setnCache

public void setnCache(int nCache)
Sets the size of the cache

Parameters:
nCache - the new size of the cache


Copyright © 2011. All Rights Reserved.