org.peace_tools.data
Class ESTList

java.lang.Object
  extended by org.peace_tools.data.ESTList

public class ESTList
extends java.lang.Object

Class to encapsulate a list of ESTs. This class has been designed to contain a list of ESTs that are typically loaded from a FASTA file. The ESTs are maintained as an ordered list of values so that the index of the ESTs are used as IDs to look up ESTs.


Field Summary
private  java.util.ArrayList<EST> ests
          This instance variable contains the list of ESTs encapsulated in this ESTList class.
private  java.lang.String name
          A unique name or identifier associated with this EST list.
private  java.lang.Object prevClusterList
          This reference is used to track the object used to hold the list of DBClassifiers in the work space.
 
Constructor Summary
ESTList(java.lang.String name)
          Create an empty list of ESTs tagged with a given name.
 
Method Summary
 void classify(javax.swing.ProgressMonitor pm)
          Method classify all the ESTs in this list.
 double[] computeStatistics()
          Method to compute and return statistics about the set of ESTs encapsulated in this list.
 java.util.ArrayList<EST> getESTs()
          Obtain the list of ESTs encapsulated by this ESTList.
 java.lang.String getName()
          The name associated to identify this ESTList.
 boolean isClassified()
          Determine if the EST list is current with work space classifiers.
static ESTList loadESTs(java.io.File fastaFile)
          Load ESTs from a given FASTA file and build a new ESTList.
static ESTList loadESTs(java.lang.String fileName, java.io.InputStream is)
          Load ESTs from a stream that provides FASTA data.
 void writeESTs(java.io.File outFile)
          Writes ESTs in FASTA format to a given file.
 void writeESTs(java.io.PrintStream writer)
          Writes ESTs in FASTA format to a given writer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ests

private java.util.ArrayList<EST> ests
This instance variable contains the list of ESTs encapsulated in this ESTList class. The set of ESTs can be accessed via a call to the getESTs() method.


name

private final java.lang.String name
A unique name or identifier associated with this EST list. Typically the absolute path to the FASTA file from where the data was loaded is used as the identifier. This information helps to locate ESTs that were loaded from a given file.


prevClusterList

private java.lang.Object prevClusterList
This reference is used to track the object used to hold the list of DBClassifiers in the work space. This information is used to decide if the classifications need to be recomputed. This works because the classifiers are modified as a single complete batch of entries. Each time a new object is set and if the objects have changed then the classifications need to be recomputed for this cluster file.

Constructor Detail

ESTList

public ESTList(java.lang.String name)
Create an empty list of ESTs tagged with a given name.

Parameters:
name - An identifier to be associated with this ESTList. Typically the absolute path to the FASTA file from where the data was loaded is used as the identifier. This information helps to locate ESTs that were loaded from a given file.
Method Detail

getName

public java.lang.String getName()
The name associated to identify this ESTList.

Returns:
The name set for this ESTList when it was created. The name can be null if a name was not set.

getESTs

public java.util.ArrayList<EST> getESTs()
Obtain the list of ESTs encapsulated by this ESTList.

Returns:
The list of ESTs encapsulated by this EST list. The list may be empty.

loadESTs

public static ESTList loadESTs(java.io.File fastaFile)
                        throws java.io.IOException
Load ESTs from a given FASTA file and build a new ESTList. This method can be used to load ESTs from a given FASTA file into a new ESTList. The absolute path to the FASTA file is used as the name for the newly created ESTList.

Parameters:
fastaFile - The FASTA file from where the ESTs are to be loaded.
Returns:
The newly cerated EST list containing all the ESTs in the FASTA file.
Throws:
java.io.IOException - This method throws an IO exception on errors.

loadESTs

public static ESTList loadESTs(java.lang.String fileName,
                               java.io.InputStream is)
                        throws java.io.IOException
Load ESTs from a stream that provides FASTA data. This method can be used to load ESTs from a given input stream into a new ESTList. The absolute path to the FASTA file to be used to name/tag the newly created ESTList must be provided.

Parameters:
fileName - The absolute path to the FASTA file to be used to name/tag the newly created ESTList.
is - The input stream from where the EST data is to be read.
Returns:
The newly created EST list containing all the ESTs in the FASTA file.
Throws:
java.io.IOException - This method throws an IO exception on errors.

writeESTs

public void writeESTs(java.io.PrintStream writer)
               throws java.io.IOException
Writes ESTs in FASTA format to a given writer. This method can be used to write the ESTs encapsulated in this list to a given stream in FASTA format.

Parameters:
writer - The output stream to which the ESTs are to be written.
Throws:
java.io.IOException - This method throws an IO exception on errors.

writeESTs

public void writeESTs(java.io.File outFile)
               throws java.io.IOException
Writes ESTs in FASTA format to a given file. This method can be used to write the ESTs encapsulated in this list to a given stream in FASTA format.

Parameters:
outFile - The file to which the ESTs are to be written.
Throws:
java.io.IOException - This method throws an IO exception on errors.

computeStatistics

public double[] computeStatistics()
Method to compute and return statistics about the set of ESTs encapsulated in this list.

Returns:
This method returns an array of doubles containing the following information: estCount, minLen, maxLen, avgLen, lenSD.

isClassified

public boolean isClassified()
Determine if the EST list is current with work space classifiers. This method can be used to determine if this EST list has already been classified using the current set of classifiers configured for this work space.

Returns:
This method returns true if the EST list has already been classified using the current set of classifiers.

classify

public void classify(javax.swing.ProgressMonitor pm)
Method classify all the ESTs in this list.

This method is typically invoked directly from a view (rather than from the model associated with the view) to classify all the ESTs in the list based on the current classifications set in the work space. This method iterates over all the ESTs and has the ESTs compute their classifications.

This method recomputes classifications only if the classifier list in the work space has actually changed. Consequently, repeatedly calling this method does not have side effects. However, if classification is performed then it may be a long running process particularly, for large EST sets. Consequently, it is best to invoke this method from a separate thread so that the GUI does not appear to be hanging while classifications are computed.

Parameters:
pm - An optional progress monitor to be updated as ESTs are classified. The progress monitor provides feedback to the user about the progress. This parameter can be null.