org.peace_tools.data
Class MST

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

public class MST
extends java.lang.Object

The top-level class that encapsulates all the pertinent information regarding a MST data file. This class deserializes the information in a MST data file generated by PEACE and stores it in memory. The in-memory storage format for the core MST information is achieved using an hierarchically nested set of MSTNode objects. In addition, this class also maintains any generated information that is placed in the file by PEACE.

Note that the in-memory format represented by this class has been primarily designed to provide more convenient access to the related information and for display in a GUI. However, this class does not directly perform any GUI related task. Instead, the GUI display is organized using the MVC (Model-View-Controller) design pattern. This class constitutes the "model" as in the MVC terminology.

Note: In order to create a valid MST use the loadMST(File) static method.


Field Summary
private  java.lang.String fileName
          The file name from where the data has been read.
private  boolean haveAlignmentInfo
          Flag to indicate if the MST data contains initial, pre-assembly alignment metric that is useful to detect where overlaps between two adjacent (parent-child) fragments occur to obtain the given alignment metric.
private  java.util.ArrayList<Pair> metadata
          The set of meta data that was loaded from the MST file.
private  MSTNode root
          The root of the MST node.
 
Constructor Summary
private MST(java.lang.String fileName)
          The constructor creates an empty MST object.
 
Method Summary
 java.lang.String getFileName()
          The absolute path to the file name from where the MST data was originally loaded.
 MSTNode getRoot()
          Obtain the root node of this MST.
 boolean hasAlignmentInfo()
          Determine if all nodes in this MST have alignment information.
static MST loadMST(java.io.File mstFile)
          This method loads MST data into an in-memory format.
static MST loadMST(java.lang.String fileName, java.io.InputStream is)
          This method loads MST data into an in-memory format.
protected static Pair makeMetadataEntry(java.lang.String line)
          This is a helper method that is used to parse a line of meta data entry (line starts with a '#' character) and convert it to a a Pair containing a name, value pair and returns the meta data as a pair.
protected static boolean makeMSTNode(java.util.HashMap<java.lang.Integer,MSTNode> nodeList, java.lang.String line)
          Helper method to process a comma separated set of values representing a MST node.
 void print(java.io.PrintStream out)
          Method to print the MST in a simple text-based format.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

fileName

private java.lang.String fileName
The file name from where the data has been read. This is typically the absolute path of the file from where the data was read.


root

private MSTNode root
The root of the MST node. Typically there is at least one root node.


haveAlignmentInfo

private boolean haveAlignmentInfo
Flag to indicate if the MST data contains initial, pre-assembly alignment metric that is useful to detect where overlaps between two adjacent (parent-child) fragments occur to obtain the given alignment metric. This value is set when the MST is loaded from a data file.


metadata

private java.util.ArrayList<Pair> metadata
The set of meta data that was loaded from the MST file. The meta data is stored as a list of name, value pairs.

Constructor Detail

MST

private MST(java.lang.String fileName)
The constructor creates an empty MST object. This method is called from the loastMST method. This object is filled in later on as data is read from the MST file.

Parameters:
fileName - The absolute path to the file from where the MST data was loaded. This file name is used as an identifier to locate the files.
Method Detail

getFileName

public java.lang.String getFileName()
The absolute path to the file name from where the MST data was originally loaded.

Returns:
The absolute path to the file that uniquely identifies the contents of the MST.

print

public void print(java.io.PrintStream out)
Method to print the MST in a simple text-based format. This method is primarily used for validating the MST data to ensure that the data was processed correctly.

Parameters:
out - The output stream to which the MST data is to be written.

getRoot

public MSTNode getRoot()
Obtain the root node of this MST.

Returns:
The root node of this MST data.

hasAlignmentInfo

public boolean hasAlignmentInfo()
Determine if all nodes in this MST have alignment information. This method can be used to determine if all the nodes in this MST have alignment information. This information is handy to organize the fragments in the nodes in a more intuitive form to illustrate overlaps and for other visual analysis.

Returns:
This method returns true if all the nodes in this MST have alignment information. Otherwise (even if one node does not have alignment information) then this method returns false.
See Also:
OverlapModel

loadMST

public static MST loadMST(java.io.File mstFile)
                   throws java.lang.Exception
This method loads MST data into an in-memory format. This method must be used to load MST data from a PEACE generated MST data file and deserialize the information into the in-memory format. The in-memory format provides an hierarchical organization that is a bit more streamlined and easier to display in the GUI.

Parameters:
mstFile - The MST file (generated by PEACE) from where the data is to be loaded in the in-memory format.
Returns:
On success this method returns a valid MST data structure loaded from the file.
Throws:
java.lang.Exception - This method throws an exception on errors.

loadMST

public static MST loadMST(java.lang.String fileName,
                          java.io.InputStream is)
                   throws java.lang.Exception
This method loads MST data into an in-memory format. This method must be used to load MST data from a PEACE generated MST data file and deserialize the information into the in-memory format. The in-memory format provides an hierarchical organization that is a bit more streamlined and easier to display in the GUI.

Parameters:
fileName - The absolute path to the file from where the data is being read.
is - The input stream from where the data is to be read.
Returns:
On success this method returns a valid MST data structure loaded from the file.
Throws:
java.lang.Exception - This method throws an exception on errors.

makeMSTNode

protected static boolean makeMSTNode(java.util.HashMap<java.lang.Integer,MSTNode> nodeList,
                                     java.lang.String line)
                              throws java.io.IOException
Helper method to process a comma separated set of values representing a MST node. This method is a helper method that is used to parse a data line from the MST file and convert it to a MSTNode. This method reads and validates the data. It then creates a MSTNode and adds it to its parent (if one is present) and to the nodeList.

Parameters:
nodeList - The list of nodes that have been read so far.
line - The line containing node data to be processed and converted to a MSTNode.
Returns:
This method returns true if the line contained an alignment information.
Throws:
java.io.IOException - This method throws an exception if the data was invalid or not read.

makeMetadataEntry

protected static Pair makeMetadataEntry(java.lang.String line)
This is a helper method that is used to parse a line of meta data entry (line starts with a '#' character) and convert it to a a Pair containing a name, value pair and returns the meta data as a pair. It assumes that the name and value are separated by ':'.

Parameters:
line - The line from the MST file to be processed.
Returns:
A pair object containing the name, value pair.