java.lang.Object | +--java.awt.Component | +--java.awt.Container | +--java.awt.Window | +--java.awt.Frame | +--phylogeny.UpdownDistance
UpdownDistance is a class designed to compute the Updown distance in two phylogenetic trees. Currently, the system can be utilized by execution from the command line. All that is required to use the system once it is running is for the input of two Newick formatted trees (the query and data strings).
Nested Class Summary | |
static class |
UpdownDistance.Node
This class allows for a dynamically allocated tree structure. |
Field Summary |
Fields inherited from class java.awt.Frame |
CROSSHAIR_CURSOR, DEFAULT_CURSOR, E_RESIZE_CURSOR, HAND_CURSOR, ICONIFIED, MAXIMIZED_BOTH, MAXIMIZED_HORIZ, MAXIMIZED_VERT, MOVE_CURSOR, N_RESIZE_CURSOR, NE_RESIZE_CURSOR, NORMAL, NW_RESIZE_CURSOR, S_RESIZE_CURSOR, SE_RESIZE_CURSOR, SW_RESIZE_CURSOR, TEXT_CURSOR, W_RESIZE_CURSOR, WAIT_CURSOR |
Fields inherited from class java.awt.Window |
|
Fields inherited from class java.awt.Container |
|
Fields inherited from class java.awt.Component |
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT |
Fields inherited from interface java.awt.image.ImageObserver |
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH |
Constructor Summary | |
UpdownDistance()
|
Method Summary | |
static UpdownDistance.Node |
build(java.lang.String s,
UpdownDistance.Node parent,
int from,
int to)
Method for supporting Newick Trees with that include an edge length parameter. |
static UpdownDistance.Node |
buildReduced
(UpdownDistance.Node n,
UpdownDistance.Node lowestMarkedNode)
This method performs additional error checking to verify correctness of input string. |
static UpdownDistance.Node |
buildSimple(java.lang.String s,
UpdownDistance.Node parent,
int from,
int to)
Recursive method for creating a tree structure through the use of the node class. |
static boolean |
checkNewick(java.lang.String treeNewick)
This method performs Newick String Validation |
static java.lang.String |
createSVGTree
(UpdownDistance.Node n,
boolean checkMark)
This method is used for creating xml SVG visual diagrams of trees. |
static int[][] |
distanceMatrix
(UpdownDistance.Node n,
java.lang.String nodeNameList,
int type,
boolean checkMark)
Create a double array representing the distance matrix of all nodes in an array. |
static java.lang.String |
edgeSVG
(UpdownDistance.Node n,
int level,
double xLoc,
double xLocParent,
int nodeSpreadX,
boolean checkMark)
This method is used by createSVG for drawing edges and nodes for the graphically represented tree. |
static void |
fileWriter(java.lang.String source,
java.lang.String fname)
This method opens a file and writes a string to it. |
static int |
findLocation(java.lang.String[] nameArray,
java.lang.String nameINode)
This is a utility method for determining which location a node name is at in an array. |
static java.lang.String |
formatTitle(java.lang.String title,
int maxWidth)
Utility method for formatting node names when listing Up Distance matrices |
static java.lang.String |
getInputTree(java.lang.String typeEntry)
This method handles the input of Newick formatted trees. |
static java.lang.String[] |
intersectionPD
(UpdownDistance.Node PRoot,
UpdownDistance.Node DRoot)
Computes the intersecting nodes of two trees. |
static void |
listMatrix(java.lang.String labelMatrix,
int[][] varMatrix)
Output method for drawing a computed distance matrix double array. |
static int |
lookup
(UpdownDistance.Node n,
java.lang.String nameNode,
int level,
boolean checkMark)
Recursive method to traverse a tree and determine how many relative levels deep a given node is. |
static UpdownDistance.Node |
lowestCommonAncestor
(UpdownDistance.Node parent,
java.lang.String nameNodeN1,
java.lang.String nameNodeN2,
int level)
This method is responsible for performing the work required to find the lowest common ancestor for two particular node names. |
static void |
main(java.lang.String[] args)
Currently the main method drives the input/output functions |
static java.lang.String |
nodeNames
(UpdownDistance.Node n,
boolean checkMark)
Generates node names when a root node is passed, operates through recursion. |
static UpdownDistance.Node |
parse(java.lang.String s)
Kick-off method for supporting Newick Trees with that include an edge length parameter. |
static java.lang.String |
readFile(java.lang.String fileName)
This method uses command line argument data to open and read in a Newick Formatted Tree. |
static boolean |
ruleCheck
(UpdownDistance.Node PRoot,
java.lang.String[] PNameArray,
UpdownDistance.Node DRoot,
java.lang.String[] DNameArray)
This method ensures that Updown Distance should be calculated based on specific rules |
static int |
treeReductionStep1
(UpdownDistance.Node parentTreeP,
UpdownDistance.Node parentTreeD)
The first step for tree reduction is to mark all nodes that happen to have some lower node also present in I (the intersection). |
static int |
treeReductionStep15
(UpdownDistance.Node parentTreeP,
UpdownDistance.Node parentTreeD)
This method is one version of the second step for tree reduction. |
static int |
treeReductionStep2
(UpdownDistance.Node parentTreeD)
This additional tree reduction step can be called upon to remove a marking if any particular marked node has less than 2 marked children |
static int |
UpdownDistanceP(int[][] P,
java.lang.String PNames)
Leverage input values to compute the Up Down distance between two trees. |
static int |
UpdownDistancePD(int[][] P,
java.lang.String PNames,
int[][] D,
java.lang.String DNames)
Leverage input values to compute the Up Down distance between two trees. |
static boolean |
validateTree(java.lang.String inputTree)
This method performs additional error checking to verify correctness of input string. |
static boolean |
validateTree2
(UpdownDistance.Node n,
boolean rootNode)
This method validates phylogenetic tree integrity by ensuring that each unlabeled node has at least two (2) children. |
Methods inherited from class java.awt.Frame |
addNotify, finalize, getAccessibleContext, getCursorType, getExtendedState, getFrames, getIconImage, getMaximizedBounds, getMenuBar, getState, getTitle, isResizable, isUndecorated, paramString, remove, removeNotify, setCursor, setExtendedState, setIconImage, setMaximizedBounds, setMenuBar, setResizable, setState, setTitle, setUndecorated |
Methods inherited from class java.awt.Window |
addPropertyChangeListener, addPropertyChangeListener, addWindowFocusListener, addWindowListener, addWindowStateListener, applyResourceBundle, applyResourceBundle, createBufferStrategy, createBufferStrategy, dispose, getBufferStrategy, getFocusableWindowState, getFocusCycleRootAncestor, getFocusOwner, getFocusTraversalKeys, getGraphicsConfiguration, getInputContext, getListeners, getLocale, getMostRecentFocusOwner, getOwnedWindows, getOwner, getToolkit, getWarningString, getWindowFocusListeners, getWindowListeners, getWindowStateListeners, hide, isActive, isFocusableWindow, isFocusCycleRoot, isFocused, isShowing, pack, postEvent, processEvent, processWindowEvent, processWindowFocusEvent, processWindowStateEvent, removeWindowFocusListener, removeWindowListener, removeWindowStateListener, setCursor, setFocusableWindowState, setFocusCycleRoot, setLocationRelativeTo, show, toBack, toFront |
Methods inherited from class java.awt.Container |
add, add, add, add, add, addContainerListener, addImpl, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalPolicy, getInsets, getLayout, getMaximumSize, getMinimumSize, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paint, paintComponents, preferredSize, print, printComponents, processContainerEvent, remove, remove, removeAll, removeContainerListener, setFocusTraversalKeys, setFocusTraversalPolicy, setFont, setLayout, transferFocusBackward, transferFocusDownCycle, update, validate, validateTree |
Methods inherited from class java.awt.Component |
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isOpaque, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, size, toString, transferFocus, transferFocusUpCycle |
Methods inherited from class java.lang.Object |
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface java.awt.MenuContainer |
getFont, postEvent |
Constructor Detail |
public UpdownDistance()
Method Detail |
public static UpdownDistance.Node parse(java.lang.String s)
s
- the Newick tree string to be parsed
public static UpdownDistance.Node build(java.lang.String s, UpdownDistance.Node parent, int from, int to)
s
- the Newick tree string to be parsedparent
- the current node parentfrom
- current location in Newick string during parsingto
- end location in Newick String during parsing
public static UpdownDistance.Node buildSimple(java.lang.String s, UpdownDistance.Node parent, int from, int to)
s
- the Newick tree string to be parsedparent
- the current node parentfrom
- current location in Newick string during parsingto
- end location in Newick String during parsing
public static int lookup(UpdownDistance.Node n, java.lang.String nameNode, int level, boolean checkMark)
n
- Starting nodenameNode
- The name of the node we are searching forlevel
- The current depthcheckMark
- If we should increment level for "reduced" nodes
public static int treeReductionStep1 (UpdownDistance.Node parentTreeP, UpdownDistance.Node parentTreeD)
parentTreeP
- The query tree root nodeparentTreeD
- The data tree root node
public static int treeReductionStep15 (UpdownDistance.Node parentTreeP, UpdownDistance.Node parentTreeD)
parentTreeP
- The query tree root nodeparentTreeD
- The data tree root node
public static int treeReductionStep2 (UpdownDistance.Node parentTreeD)
parentTreeD
- The data tree root node
public static UpdownDistance.Node lowestCommonAncestor (UpdownDistance.Node parent, java.lang.String nameNodeN1, java.lang.String nameNodeN2, int level)
parent
- The parent node to begin searching undernameNodeN1
- The first node name in questionnameNodeN2
- The second node name in questionlevel
- The current level
public static int[][] distanceMatrix (UpdownDistance.Node n, java.lang.String nodeNameList, int type, boolean checkMark)
n
- The parent node to begin searching undernodeNameList
- A list of nodes in the tree with root node ntype
- Search flag designating horiz or vertical searchcheckMark
- Tree to determine if tree reduction is being enforced
public static void listMatrix(java.lang.String labelMatrix, int[][] varMatrix)
labelMatrix
- The labels (node names) for a treevarMatrix
- The double array to be outputpublic static java.lang.String formatTitle(java.lang.String title, int maxWidth)
title
- The character string to be printedmaxWidth
- The desired width for spacing
public static java.lang.String nodeNames (UpdownDistance.Node n, boolean checkMark)
n
- Node for which to retrieve lower node namescheckMark
- Flag to designate whether tree reduction should be enforced.
public static java.lang.String[] intersectionPD (UpdownDistance.Node PRoot, UpdownDistance.Node DRoot)
PRoot
- The root of the Query treeDRoot
- The root of the Data tree
public static int UpdownDistancePD(int[][] P, java.lang.String PNames, int[][] D, java.lang.String DNames)
P
- The Up Down distance matrix of PPNames
- The node names for query tree PD
- The Up Down distance matrix of DDNames
- The node names for data tree D
public static int UpdownDistanceP(int[][] P, java.lang.String PNames)
P
- The Up Down distance matrix of PPNames
- The node names for query tree P
public static int findLocation(java.lang.String[] nameArray, java.lang.String nameINode)
nameArray
- The array of node namesnameINode
- The node name in question
public static java.lang.String createSVGTree (UpdownDistance.Node n, boolean checkMark)
n
- A root node of a treecheckMark
- Boolean flag to determine if a reduced data tree is being drawn
public static java.lang.String edgeSVG (UpdownDistance.Node n, int level, double xLoc, double xLocParent, int nodeSpreadX, boolean checkMark)
n
- The parent node.level
- The depth or current level in the tree hierarchy (used for
calculating y coordinates)xLoc
- The current horizontal locationxLocParent
- The horizontal location of the parent nodenodeSpreadX
- The desired seperation width of nodes on the levelcheckMark
- Boolean flag to determine if reduction should be enforced
public static void fileWriter(java.lang.String source, java.lang.String fname)
source
- The text to be printed to the filefname
- The desired filenamepublic static java.lang.String getInputTree(java.lang.String typeEntry)
typeEntry
- Parameter for determining if the tree entered is query or data
public static boolean validateTree(java.lang.String inputTree)
inputTree
- The input string to verify
public static UpdownDistance.Node buildReduced (UpdownDistance.Node n, UpdownDistance.Node lowestMarkedNode)
public static boolean validateTree2 (UpdownDistance.Node n, boolean rootNode)
n
- The input tree to verify (root node)
public static boolean checkNewick(java.lang.String treeNewick)
public static boolean ruleCheck (UpdownDistance.Node PRoot, java.lang.String[] PNameArray, UpdownDistance.Node DRoot, java.lang.String[] DNameArray)
PRoot
- The Query tree to verify (root node)DRoot
- The Data tree to verify (root node)
public static java.lang.String readFile(java.lang.String fileName)
fileName
- The name of the file to open and read
public static void main(java.lang.String[] args)
args
- Any command line arguments