cs195z.support
Class PSpeciesNode

java.lang.Object
  extended by cs195z.support.PSpeciesNode

public class PSpeciesNode
extends Object

Modify this node to change information held at each position in the tree. This node has a name, knows the depth in the tree, and stores: 1) Sequence: a sequence of characters at this position 2) Cost: an "array" of integer costs for Sankoff 3) Likelihood: an "array" of floating point likelihoods for Felsenstein

Author:
apstewar

Constructor Summary
PSpeciesNode()
          To simplify the constructor, it takes in no arguments.
 
Method Summary
 void addCharacter(ZCharacter z)
          Adds a character to the back of the stored sequence.
 void addToCost(ZCharacter z, int cost)
          Increases the cost for a character by the value of "cost".
 void clearCost()
          Initializes the cost value array.
 void clearLikelihood()
          Clears the likelihood probability array.
 int getCost(ZCharacter z)
          Gives the stored cost for this character in the cost array.
 double getLikelihood(ZCharacter z)
          Retrieves a likelihood probability for a character.
 String getName()
           
 ZCharacter[] getSequence()
          Gives the ordered sequence of characters at this position
 int getTreeLevel()
          Gives the depth of this node in the tree.
 void setCharacter(int index, ZCharacter z)
          Can be used to replace a character at a certain array position.
 void setCost(ZCharacter z, int cost)
          Stores a cost value for the character.
 void setLikelihood(ZCharacter z, double d)
          Store a likelihood probability for a character.
 void setName(String s)
           
 void setSequence(ZCharacter[] z)
          Sets an entire sequence of characters at once.
 void setTreeLevel(int level)
          Stores the tree level.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PSpeciesNode

public PSpeciesNode()
To simplify the constructor, it takes in no arguments. For this reason, users should call the other methods of the class to interact with it.

Method Detail

getName

public String getName()

setName

public void setName(String s)

getSequence

public ZCharacter[] getSequence()
Gives the ordered sequence of characters at this position

Returns:
array of ZCharacters

addCharacter

public void addCharacter(ZCharacter z)
Adds a character to the back of the stored sequence.

Parameters:
z - character to store

setCharacter

public void setCharacter(int index,
                         ZCharacter z)
Can be used to replace a character at a certain array position.

Parameters:
index - number of ZCharacter to replace in getSequence
z - character to store

setSequence

public void setSequence(ZCharacter[] z)
Sets an entire sequence of characters at once.

Parameters:
z - an ordered array of characters

getCost

public int getCost(ZCharacter z)
Gives the stored cost for this character in the cost array.

Parameters:
z - character to lookup
Returns:
integer cost

setCost

public void setCost(ZCharacter z,
                    int cost)
Stores a cost value for the character.

Parameters:
z - character reference
cost -

addToCost

public void addToCost(ZCharacter z,
                      int cost)
Increases the cost for a character by the value of "cost".

Parameters:
z - character reference
cost - value to increase

clearCost

public void clearCost()
Initializes the cost value array.


getTreeLevel

public int getTreeLevel()
Gives the depth of this node in the tree. Can be used for debugging purposes, or other evaluation of the output.

Returns:
depth in tree (default INFINITY, if not set)

setTreeLevel

public void setTreeLevel(int level)
Stores the tree level. This must be set at construction of node.

Parameters:
level - 0 if root, 1 for next level, etc.

getLikelihood

public double getLikelihood(ZCharacter z)
Retrieves a likelihood probability for a character.

Parameters:
z - character reference
Returns:
probability

setLikelihood

public void setLikelihood(ZCharacter z,
                          double d)
Store a likelihood probability for a character.

Parameters:
z - character reference
d - probability

clearLikelihood

public void clearLikelihood()
Clears the likelihood probability array.