public class SequenceFactory extends Object
Modifier and Type | Method and Description |
---|---|
void |
appendDecoySequences(File destinationFile)
Appends decoy sequences to the desired file.
|
void |
appendDecoySequences(File destinationFile,
WaitingHandler waitingHandler)
Appends decoy sequences to the desired file while displaying progress.
|
void |
clearFactory()
Clears the factory getInstance() needs to be called afterwards.
|
void |
closeFile()
Closes the opened file.
|
double |
computeMolecularWeight(String accession)
Returns the protein's molecular weight.
|
boolean |
concatenatedTargetDecoy()
Indicates whether the database loaded contains decoy sequences.
|
void |
emptyCache()
Empties the cache of the factory.
|
HashMap<String,Integer> |
getAAOccurrences(JProgressBar progressBar)
Returns the occurrence of every amino acid in the database.
|
ArrayList<String> |
getAccessions()
Returns the sequences present in the database.
|
Header |
getHeader(String accession)
Returns the desired header for the protein in 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,
WaitingHandler waitingHandler)
Loads a new FASTA file in the factory.
|
void |
setnCache(int nCache)
Sets the size of the cache.
|
public static SequenceFactory getInstance()
public static SequenceFactory getInstance(int nCache)
nCache
- the new cache sizepublic void clearFactory()
public void emptyCache()
public Protein getProtein(String accession) throws IOException, IllegalArgumentException, InterruptedException
accession
- accession of the desired proteinIOException
- thrown whenever an error is encountered while reading
the FASTA fileIllegalArgumentException
- thrown whenever an error is encountered
while reading the FASTA fileInterruptedException
public Header getHeader(String accession) throws IOException, IllegalArgumentException, InterruptedException
accession
- accession of the desired proteinIOException
- exception thrown whenever an error occurred while
reading the FASTA fileIllegalArgumentException
- exception thrown whenever a protein is
not foundInterruptedException
public void loadFastaFile(File fastaFile) throws FileNotFoundException, IOException, ClassNotFoundException
fastaFile
- the FASTA file to loadFileNotFoundException
- exception thrown if the file was not foundIOException
- exception thrown if an error occurred while reading
the FASTA fileClassNotFoundException
- exception thrown whenever an error
occurred while deserializing the file indexpublic void loadFastaFile(File fastaFile, WaitingHandler waitingHandler) throws FileNotFoundException, IOException, ClassNotFoundException, StringIndexOutOfBoundsException, IllegalArgumentException
fastaFile
- the FASTA file to loadwaitingHandler
- a waitingHandler showing the progressFileNotFoundException
- exception thrown if the file was not foundIOException
- exception thrown if an error occurred while reading
the FASTA fileClassNotFoundException
- exception thrown whenever an error
occurred while deserializing the file indexStringIndexOutOfBoundsException
- thrown if issues occur during the
parsing of the protein headersIllegalArgumentException
- if non unique accession numbers are
foundpublic void closeFile() throws IOException
IOException
- exception thrown whenever an error occurred while
closing the filepublic static boolean isDecoy(String proteinAccession)
proteinAccession
- The accession of the proteinpublic boolean concatenatedTargetDecoy()
public int getNTargetSequences()
public void appendDecoySequences(File destinationFile) throws IOException, IllegalArgumentException, InterruptedException, FileNotFoundException, ClassNotFoundException
destinationFile
- the destination fileIOException
- exception thrown whenever an error occurred while
reading or writing a fileIllegalArgumentException
InterruptedException
FileNotFoundException
ClassNotFoundException
public void appendDecoySequences(File destinationFile, WaitingHandler waitingHandler) throws IOException, IllegalArgumentException, InterruptedException, FileNotFoundException, ClassNotFoundException
destinationFile
- the destination filewaitingHandler
- the waiting handlerIOException
- exception thrown whenever an error occurred while
reading or writing a fileIllegalArgumentException
- exception thrown whenever a protein is
not foundInterruptedException
FileNotFoundException
ClassNotFoundException
public ArrayList<String> getAccessions()
public int getnCache()
public void setnCache(int nCache)
nCache
- the new size of the cachepublic HashMap<String,Integer> getAAOccurrences(JProgressBar progressBar) throws IOException, IllegalArgumentException, InterruptedException
progressBar
- a progress bar, can be nullIOException
- exception thrown whenever an error occurred while
reading the databaseIllegalArgumentException
InterruptedException
public double computeMolecularWeight(String accession) throws IOException, IllegalArgumentException, InterruptedException
accession
- the protein's accession numberIOException
IllegalArgumentException
InterruptedException
Copyright © 2013. All Rights Reserved.