public class SequenceFactory extends Object
| Modifier and Type | Class and Description |
|---|---|
class |
SequenceFactory.HeaderIterator
Convenience iterator iterating the headers of a FASTA file without using
the cache.
|
class |
SequenceFactory.ProteinIterator
Convenience iterator iterating all proteins in a FASTA file without using
index or cache.
|
| Modifier and Type | Field and Description |
|---|---|
static long |
timeOut
The time out in milliseconds when querying the file.
|
| 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.
|
boolean |
deleteProteinTree()
Try to delete the default protein tree.
|
void |
emptyCache()
Empties the cache of the factory.
|
HashMap<String,Integer> |
getAAOccurrences(JProgressBar progressBar)
Returns the occurrence of every amino acid in the database.
|
Set<String> |
getAccessions()
Returns the sequences present in the database.
|
File |
getCurrentFastaFile()
Returns the currently loaded fasta file.
|
FastaIndex |
getCurrentFastaIndex()
Returns the FASTA index of the currently loaded file.
|
static String |
getDefaultDecoyAccession(String targetAccession)
Returns the default decoy accession for a target accession.
|
static String |
getDefaultDecoyAccessionSuffix()
Returns the default suffix for a decoy accession.
|
static String |
getDefaultDecoyDescription(String targetDescription)
Returns the default description for a decoy protein.
|
ProteinTree |
getDefaultProteinTree()
Returns the default protein tree corresponding to the database loaded in
factory.
|
ProteinTree |
getDefaultProteinTree(WaitingHandler waitingHandler)
Returns the default protein tree corresponding to the database loaded in
factory.
|
ProteinTree |
getDefaultProteinTree(WaitingHandler waitingHandler,
boolean displayProgress)
Returns the default protein tree corresponding to the database loaded in
factory
|
static String |
getDefaultTargetAccession(String decoyAccession)
Returns the default target accession of a given decoy protein.
|
String |
getFileName()
Returns the name of the loaded FASTA file.
|
Header |
getHeader(String accession)
Returns the desired header for the protein in the FASTA file.
|
SequenceFactory.HeaderIterator |
getHeaderIterator(boolean targetOnly)
Returns an iterator of all the headers 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 |
getNodesInCache()
Returns the number of nodes currently loaded in cache.
|
int |
getNSequences()
Returns the number of sequences in the FASTA file.
|
int |
getNTargetSequences()
Returns the number of target sequences in the database.
|
Protein |
getProtein(String accession)
Returns the desired protein.
|
SequenceFactory.ProteinIterator |
getProteinIterator(boolean targetOnly)
Returns an iterator of all the proteins in the FASTA file.
|
static String |
getTargetDecoyFileNameTag()
Returns the target-decoy file name tag.
|
boolean |
hasEnoughSequences()
Indicates whether the database contained enough protein sequences for
reliability of the target/decoy based statistics.
|
boolean |
isClosed()
Indicates whether the connection to the random access file has been
closed.
|
static boolean |
isDecoy(String proteinAccession)
Deprecated.
deprecated, use the isDecoy(proteinAccession, flag) with file
dependent flag or isDecoyAccession(String proteinAccession) instead.
|
static boolean |
isDecoy(String proteinAccession,
String decoyFlag)
Returns a boolean indicating whether a protein is decoy or not based on
the protein accession and a given decoy flag.
|
boolean |
isDecoyAccession(String proteinAccession)
Indicates whether a protein is a decoy in the selected loaded FASTA file.
|
boolean |
isDefaultReversed()
Indicates whether the decoy sequences are reversed versions of the target
and the decoy accessions built based on the sequence factory methods.
|
void |
loadFastaFile(File fastaFile)
Deprecated.
use the version with the WaitingHandler instead
|
void |
loadFastaFile(File fastaFile,
WaitingHandler waitingHandler)
Loads a new FASTA file in the factory.
|
void |
reduceNodeCacheSize(double share)
Reduces the node cache size of the protein tree by the given share.
|
void |
resetConnection()
Resets the connection to the random access file.
|
static String |
reverseSequence(String sequence)
Reverses a protein sequence.
|
void |
saveIndex()
Saves the index.
|
void |
setnCache(int nCache)
Sets the size of the cache.
|
static void |
setTargetDecoyFileNameTag(String targetDecoyFileNameTag)
Set the target-decoy file name tag.
|
public static final long timeOut
public static SequenceFactory getInstance()
public static SequenceFactory getInstance(int nCache)
nCache - the new cache sizepublic boolean hasEnoughSequences()
public void clearFactory()
throws IOException,
SQLException
IOExceptionSQLExceptionpublic void emptyCache()
public void reduceNodeCacheSize(double share)
share - the share of the cache to remove. 0.5 means 50%public int getNodesInCache()
public Protein getProtein(String accession) throws IOException, IllegalArgumentException, InterruptedException, FileNotFoundException, ClassNotFoundException
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 fileInterruptedExceptionFileNotFoundExceptionClassNotFoundExceptionpublic Header getHeader(String accession) throws IOException, IllegalArgumentException, InterruptedException, FileNotFoundException, ClassNotFoundException
accession - accession of the desired proteinIOException - exception thrown whenever an error occurred while
reading the FASTA fileIllegalArgumentException - exception thrown whenever a protein is
not foundInterruptedExceptionFileNotFoundExceptionClassNotFoundExceptionpublic void loadFastaFile(File fastaFile) throws FileNotFoundException, IOException, ClassNotFoundException, StringIndexOutOfBoundsException, IllegalArgumentException
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 indexStringIndexOutOfBoundsException - thrown if issues occur during the
parsing of the protein headersIllegalArgumentException - if non unique accession numbers are
foundpublic 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 boolean isClosed()
public void resetConnection()
throws IOException
IOExceptionpublic void saveIndex()
throws IOException
IOExceptionpublic void closeFile()
throws IOException,
SQLException
IOException - exception thrown whenever an error occurred while
closing the fileSQLExceptionpublic static boolean isDecoy(String proteinAccession, String decoyFlag)
proteinAccession - The accession of the proteindecoyFlag - the decoy flagpublic boolean isDecoyAccession(String proteinAccession)
proteinAccession - the protein accession of interest.public static boolean isDecoy(String proteinAccession)
proteinAccession - the accession of interestpublic boolean concatenatedTargetDecoy()
public boolean isDefaultReversed()
public int getNTargetSequences()
public int getNSequences()
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 fileIllegalArgumentExceptionInterruptedExceptionFileNotFoundExceptionClassNotFoundExceptionpublic 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 foundInterruptedExceptionFileNotFoundExceptionClassNotFoundExceptionpublic static String reverseSequence(String sequence)
sequence - the protein sequencepublic Set<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, FileNotFoundException, ClassNotFoundException
progressBar - a progress bar, can be nullIOException - exception thrown whenever an error occurred while
reading the databaseIllegalArgumentExceptionInterruptedExceptionFileNotFoundExceptionClassNotFoundExceptionpublic double computeMolecularWeight(String accession) throws IOException, IllegalArgumentException, InterruptedException, FileNotFoundException, ClassNotFoundException
accession - the protein's accession numberIOExceptionIllegalArgumentExceptionInterruptedExceptionFileNotFoundExceptionClassNotFoundExceptionpublic static String getTargetDecoyFileNameTag()
public static void setTargetDecoyFileNameTag(String targetDecoyFileNameTag)
targetDecoyFileNameTag - the targetDecoyFileNameTag to setpublic String getFileName()
public File getCurrentFastaFile()
public static String getDefaultDecoyAccessionSuffix()
public static String getDefaultDecoyAccession(String targetAccession)
targetAccession - the target accessionpublic static String getDefaultDecoyDescription(String targetDescription)
targetDescription - the description of a target proteinpublic static String getDefaultTargetAccession(String decoyAccession)
decoyAccession - the decoy accessionpublic FastaIndex getCurrentFastaIndex()
public ProteinTree getDefaultProteinTree() throws IOException, InterruptedException, ClassNotFoundException, IllegalArgumentException, SQLException
IOExceptionInterruptedExceptionClassNotFoundExceptionIllegalArgumentExceptionSQLExceptionpublic ProteinTree getDefaultProteinTree(WaitingHandler waitingHandler) throws IOException, InterruptedException, ClassNotFoundException, IllegalArgumentException, SQLException
waitingHandler - waiting handler displaying progress to the user
during the initiation of the treeIOExceptionInterruptedExceptionClassNotFoundExceptionIllegalArgumentExceptionSQLExceptionpublic ProteinTree getDefaultProteinTree(WaitingHandler waitingHandler, boolean displayProgress) throws IOException, InterruptedException, ClassNotFoundException, IllegalArgumentException, SQLException
waitingHandler - waiting handler displaying progress to the user
during the initiation of the treedisplayProgress - display progressIOExceptionInterruptedExceptionClassNotFoundExceptionIllegalArgumentExceptionSQLExceptionpublic boolean deleteProteinTree()
public SequenceFactory.HeaderIterator getHeaderIterator(boolean targetOnly) throws FileNotFoundException
targetOnly - boolean indicating whether only target accessions shall
be iteratedFileNotFoundExceptionpublic SequenceFactory.ProteinIterator getProteinIterator(boolean targetOnly) throws FileNotFoundException
targetOnly - boolean indicating whether only target accessions shall
be iteratedFileNotFoundExceptionCopyright © 2014. All rights reserved.