|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--Algorithm | +--FM
This class implements the Fitch Margoliash algorithm described in the package.
Field Summary |
Fields inherited from class Algorithm |
ansField, ansFrame, ansLabel, answer, count, display, infoArea, inputTable, interNode, interTable, maxLength, maxName, mini, minj, minLength, names, nodes, numOfNodes, numOfNodesLeft, okAnsButton, okQuesButton, phyTreesControls, popUpQues, quesFrame, quesLabel, question, random_i, random_j, roots, runType, treeDisplay |
Constructor Summary | |
FM(PTCControls inPhyTreesControls)
Initializes specific GUI components used in the FM algorithm. |
Method Summary | |
void |
actionPerformed(java.awt.event.ActionEvent e)
Defines how to handle the actions of the OK buttons for the question and the answer windows in the FM algorithm. |
java.lang.String |
buildAnswer1()
Generates the answers for the type 1 questions in the FM algorithm. |
java.lang.String |
buildAnswer2()
Generates the answers for the type 2 questions in the FM algorithm. |
double |
calculateDistanceToOthers(int itself,
int notInclude)
Calculates the distance to the other nodes. |
void |
calculateNewDistance()
Implements the method in the Algorithm calss and defines how to calculate new distance matrix in the FM algorithm. |
void |
calculateOutputDistance()
Calculates the computed distance matrix. |
void |
closeBestTrees(java.util.Vector bestTreesFM)
Closes all best tree windows in the FM algorithm. |
void |
computeAllNonLeafDistance(Node leftRoot,
Node rightRoot,
double interDist)
Computes the distances among the nodes in two trees. |
int |
computeNumOfTrees(int n)
Computes the number of different trees for the given number of species. |
double |
computeSumOfSquares()
Computes the Sum Of Squares. |
BestTreeFM |
constructBestTreeFrame(int x,
int y)
Constructs the best tree window used in the FM algorithm. |
void |
constructComputeDistanceFrame()
Constructs the computed distance table window. |
double |
findAndCalculate()
Defines how to find the nodes to join and calculates branch lengths in the FM algorithm. |
void |
findMiniMinj()
Finds the next two nodes to be joined in the FM algorithm. |
boolean |
findOne()
Implements the method in the Algorithm class and indicates if one tree is found in the FM algorithm. |
void |
generateRandom_ij()
Generates random numbers for pop up questions in the FM algorithm. |
void |
getAllLeaves(Node node,
java.util.Vector leaves)
Gets the leaves of a node. |
double[][] |
getDistance()
Returns the distance matrix in the FM algorithm. |
java.lang.String |
getFlagString()
Returns the string corresponding to the negative branch length flag. |
boolean |
getNegativeFlag()
Returns the negative branch length flag in the FM algorithm. |
double |
getSumOfSquares()
Returns the Sum Of Squares in the FM algorithm. |
boolean |
init()
Overrides the method in the Algorithm class and initializes specific data components used in the FM algorithm. |
boolean |
isEnd()
Implements the method in the Algorithm class and indicates if the algorithm terminates in the FM algorithm. |
void |
join(double height)
Defines how to join the two nodes when there are more than two nodes left in the FM algorithm. |
void |
joinLastTwoNodes()
Defines how to join the last two nodes in the FM algorithm. |
void |
popUpQuestion1()
Generates type 1 pop up questions in the FM algorithm. |
void |
popUpQuestion2()
Generates type 2 pop up questions in the FM algorithm. |
void |
processLastTwoNodes()
Defines how to join last two nodes in the FM algorithm. |
void |
processMoreThanTwoNodes()
Defines how to join more than two nodes in the FM algorithm. |
void |
processOneTree()
Defines how to find one tree in the FM algorithm. |
void |
reset()
Overrides the method in the Algorithm class and resets all components in the FM algorithm. |
void |
run()
Implements the method in the Algorithm classs and defines how to run the FM algorithm. |
void |
setPathLength(Node node,
double interDist)
Sets the branch length form the node to its child. |
void |
trace()
Implements the method in the Algorithm class and defines how to trace the FM algorithm. |
void |
updateBestTree()
Defines how to update the best tree window. |
double |
updateBestTree(double bestValue,
java.util.Vector bestTreesFM,
BestTreeFM bestTreeFM,
java.lang.String flagString)
Define how to update one best tree window. |
void |
updateMiniMinj()
Updates the index of the nodes to be joined in the FM algorithm. |
void |
updateUI()
Defines how to update the tree and the intermediate distance table when there are more than two nodes left in the FM algorithm. |
void |
updateUILastTwoNodes()
Defines how to update the tree and the intermediate distance table when there are only two nodes left in the FM algorithm. |
void |
updateXY()
Updates the position of the next best tree window. |
Methods inherited from class Algorithm |
computeMaxName, computeMinMaxLength, constructAnsFrame, constructButton, constructQuesFrame, deleteNodes, findMin, getCount, getDisplay, getInterNode, getMaxLength, getMaxName, getMinLength, getNames, getNode, getNodes, getNumOfNodes, getNumOfNodesLeft, getRoots, randomInt, setPopUpQues, setRoots, setRunType, setThreeFractionDigit, updateTree |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public FM(PTCControls inPhyTreesControls)
inPhyTreesControls
- the PTCControls objectMethod Detail |
public double[][] getDistance()
public double getSumOfSquares()
public boolean getNegativeFlag()
true
- Negative branch lengths are allowed
false
- Negative branch lengths are not allowedpublic java.lang.String getFlagString()
public boolean init()
init
in class Algorithm
true
- the algorithm is properly initialized
false
- input data is not rightpublic void trace()
trace
in class Algorithm
public void run()
run
in class Algorithm
public void processOneTree()
public void processMoreThanTwoNodes()
public void processLastTwoNodes()
public double findAndCalculate()
public void join(double height)
public void updateUI()
public void joinLastTwoNodes()
public void updateUILastTwoNodes()
public void updateBestTree()
public double updateBestTree(double bestValue, java.util.Vector bestTreesFM, BestTreeFM bestTreeFM, java.lang.String flagString)
bestValue
- the best Sum Of SquaresbestTreesFM
- the vector to hold all best trees in the FM algorithmbestTreeFM
- the current best treeflagString
- the flag string displayed
public void updateMiniMinj()
public void findMiniMinj()
public double calculateDistanceToOthers(int itself, int notInclude)
itself
- the index of the node itselfnotInclude
- the index of the node joined with the node itself
public void calculateOutputDistance()
public void calculateNewDistance()
calculateNewDistance
in class Algorithm
public BestTreeFM constructBestTreeFrame(int x, int y)
x
- the x axis position in the screeny
- the y axis position in the screenpublic void updateXY()
public void setPathLength(Node node, double interDist)
node
- the node to be setinterDist
- the branch lengthpublic void computeAllNonLeafDistance(Node leftRoot, Node rightRoot, double interDist)
interDist
- the branch length between left node and right nodepublic void getAllLeaves(Node node, java.util.Vector leaves)
node
- the nodeleaves
- the leaves of the nodepublic double computeSumOfSquares()
public void constructComputeDistanceFrame()
public int computeNumOfTrees(int n)
n
- the number of species
public boolean findOne()
findOne
in class Algorithm
true
- one tree is found
false
- one tree is not foundpublic boolean isEnd()
isEnd
in class Algorithm
true
- the algorithm terminates
false
- the algorithm does not terminatepublic void reset()
reset
in class Algorithm
public void closeBestTrees(java.util.Vector bestTreesFM)
public void generateRandom_ij()
public void popUpQuestion1()
public java.lang.String buildAnswer1()
public void popUpQuestion2()
public java.lang.String buildAnswer2()
public void actionPerformed(java.awt.event.ActionEvent e)
e
- the ActionEvent object which is responsible for the action
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |