|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--Algorithm | +--MP
This class implements the Maximum Parsimony 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 | |
MP(PTCControls inPhyTreesControls)
Initializes specific GUI components used in the MP 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 MP algorithm. |
java.lang.String |
buildAns1()
Generates the answers for the type 1 questions in the MP algorithm. |
java.lang.String |
buildAnswer2()
Generates the answers for the type 2 questions in the MP algorithm. |
void |
calculateNewDistance()
This method does nothing in the MP algorithm |
void |
calculateNumOfSubstitutions()
Defines how to calculate the number of substitutions table in the MP algorithm |
void |
calculateTotalNumOfSubstitutions(int columns,
int[][] subs)
Defines how to calculate the total number of substitutions for a given column in a given table |
void |
computeAllSitesSubstitutions(java.util.Vector bestInterNodes,
java.lang.String[][] bestCharacters,
int[][] allNumOfSubs)
Defines how to calculate the total number of substitutions table for all sites in the MP algorithm |
int |
computeNumOfTrees(int n)
Computes the number of different trees for the given number of species. |
BestTreeMP |
constructBestTreeFrame(int x,
int y)
Constructs the best tree window used in the MP algorithm. |
void |
displayOneBestTree(java.util.Vector bestInterNodes,
java.lang.String[][] bestCharacters,
int[][] allNumOfSubs,
TreeDisplay bestTreeDisplay,
javax.swing.JFrame bestTreeFrame)
Defines how to display one tree in the MP algorithm. |
void |
find()
Defines how to find the nodes to join in the MP algorithm. |
void |
findInformativeSites()
Finds the informative sites for a given input |
void |
findMiniMinj()
Finds the next two nodes to be joined in the MP algorithm. |
boolean |
findOne()
Implements the method in the Algorithm class and indicates if one tree is found in the MP algorithm. |
boolean |
finishStepTwo()
Indicates if the algorithm has finished the second step of the MP algorithm. |
void |
generateRandom_ij()
Generates random numbers for pop up questions in the MP algorithm. |
int |
getAllSitesSubs()
Gets the total number of substituions for all sites used in the MP algorithm. |
int |
getBestTotalNumOfSubstitutions()
Gets the best minimum total number of substituions for informative sites used in the MP algorithm. |
java.lang.String[][] |
getCharacters()
Gets the characters table used in the MP algorithm. |
boolean |
getFind()
Gets the status if the one tree has finished to compute the number of substitutions table. |
java.util.Vector |
getInfoSites()
Gets the informative sites found in the MP algorithm. |
java.util.Vector |
getInterNodes()
Gets the names of the inter nodes used in the MP algorithm. |
java.lang.String |
getInterSection(java.lang.String s1,
java.lang.String s2)
Defines the set intersection operation |
boolean |
getNoInfoSites()
Gets the status if any informative sites are found in the MP algorithm. |
int[][] |
getNumOfSubstitutions()
Gets the number of substituions table used in the MP algorithm. |
int |
getTotalNumOfSubstitutions()
Gets the total number of substituions for informative sites used in the MP algorithm. |
java.lang.String |
getUnion(java.lang.String s1,
java.lang.String s2)
Defines the set union operation |
boolean |
init()
Overrides the method in the Algorithm class and initializes specific data components used in the MP algorithm. |
boolean |
interSection(java.lang.String s1,
java.lang.String s2)
Indicates if the intersection of two sets are empty |
boolean |
isEnd()
Implements the method in the Algorithm class and indicates if the algorithm terminates in the MP algorithm. |
void |
joinAndCalculate()
Defines how to join nodes and calculates the characters in the MP algorithm. |
void |
joinLastTwoNodes()
Defines how to join the last two nodes in the MP algorithm. |
void |
popUpQuestion1(int random_site)
Generates type 1 pop up questions in the MP algorithm. |
void |
popUpQuestion2()
Generates type 2 pop up questions in the MP algorithm. |
void |
processLastTwoNodes()
Defines how to join last two nodes in the MP algorithm. |
void |
processMoreThanTwoNodes()
Defines how to join more than two nodes in the MP algorithm. |
void |
processOneTree()
Defines how to find one tree in the MP algorithm. |
void |
reset()
Overrides the method in the Algorithm class and resets all components in the MP algorithm. |
void |
run()
Implements the method in the Algorithm classs and defines how to run the FM algorithm. |
void |
trace()
Implements the method in the Algorithm class and defines how to trace the MP algorithm. |
void |
updateAllNodes(java.util.Vector roots,
java.lang.String[][] bestCharacters)
Defines how to update all nodes information in the best tree window to display all sites in the MP algorithm |
void |
updateBestTree()
Defines how to update the best tree window in the MP algorithm. |
void |
updateBestTreeFrameUI(javax.swing.JFrame bestTreeFrame,
int[][] allNumOfSubs)
Defines how to update the best tree window to add the number of substitutions table in the MP algorithm |
void |
updateMiniMinj()
Updates the index of the nodes to be joined in the MP algorithm. |
void |
updateNodeSeq(Node node,
java.lang.String[][] bestCharacters)
Defines how to update one node information in the best tree window to display all sites in the MP algorithm |
void |
updateOneBestTree()
Defines how to update one tree in the MP algorithm. |
void |
updateUI()
Defines how to update the tree and the intermediate number of substitutions table in the MP algorithm. |
void |
updateUILastTwoNodes()
Defines how to update the tree and the intermediate distance table when there are only two nodes left in the MP 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 MP(PTCControls inPhyTreesControls)
inPhyTreesControls
- the PTCControls objectMethod Detail |
public boolean getFind()
true
- the one tree has finished to compute the number of substitutions table
false
- the one tree has not finished to compute the number of substitutions tablepublic int[][] getNumOfSubstitutions()
public java.lang.String[][] getCharacters()
public java.util.Vector getInfoSites()
public java.util.Vector getInterNodes()
public int getTotalNumOfSubstitutions()
public int getBestTotalNumOfSubstitutions()
public int getAllSitesSubs()
public boolean getNoInfoSites()
true
- there are informative sites in the input
false
- no informative sites are found in the inputpublic 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 findInformativeSites()
public void processOneTree()
public void displayOneBestTree(java.util.Vector bestInterNodes, java.lang.String[][] bestCharacters, int[][] allNumOfSubs, TreeDisplay bestTreeDisplay, javax.swing.JFrame bestTreeFrame)
bestInterNodes
- the interior nodes in the best tree in the MP algorithmbestCharacters
- the characters of the nodes in the best tree in the MP algorithmallNumOfSubs
- the total number of subsititutions table in the best tree in the MP algorithmbestTreeDisplay
- the tree display object in the best tree in the MP algorithmbestTreeFrame
- the best tree window in the MP algorithmpublic void updateOneBestTree()
public void processMoreThanTwoNodes()
public void processLastTwoNodes()
public void updateBestTree()
public BestTreeMP constructBestTreeFrame(int x, int y)
x
- the x axis position in the screeny
- the y axis position in the screenpublic void updateXY()
public void find()
public void joinAndCalculate()
public void updateUI()
public void joinLastTwoNodes()
public void updateUILastTwoNodes()
public void calculateNumOfSubstitutions()
public boolean interSection(java.lang.String s1, java.lang.String s2)
s1
- the one set to be operateds2
- the other set to be operated
true
- the intersection of the two sets are not empty
false
- the intersection of the two sets is emptypublic java.lang.String getInterSection(java.lang.String s1, java.lang.String s2)
s1
- the one set to be operateds2
- the other set to be operated
public java.lang.String getUnion(java.lang.String s1, java.lang.String s2)
s1
- the one set to be operateds2
- the other set to be operated
public void calculateTotalNumOfSubstitutions(int columns, int[][] subs)
columns
- the column indexsubs
- the number of substitutions tablepublic void updateBestTreeFrameUI(javax.swing.JFrame bestTreeFrame, int[][] allNumOfSubs)
bestTreeFrame
- the best tree windowallNumOfSubs
- the total number of substitutions table for all sitespublic void computeAllSitesSubstitutions(java.util.Vector bestInterNodes, java.lang.String[][] bestCharacters, int[][] allNumOfSubs)
bestInterNodes
- the names of the interior nodes in the best treebestCharacters
- the characters of the interior nodes in the best treeallNumOfSubs
- the total number of substitutions table for all sitespublic void updateAllNodes(java.util.Vector roots, java.lang.String[][] bestCharacters)
roots
- the roots of the best treebestCharacters
- the characters of the interior nodes in the best treepublic void updateNodeSeq(Node node, java.lang.String[][] bestCharacters)
node
- the node to be updatedbestCharacters
- the characters of the node in the best treepublic void updateMiniMinj()
public void findMiniMinj()
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 boolean finishStepTwo()
true
- the algorithm has finished the second step
false
- the algorithm has not finished the second steppublic void calculateNewDistance()
calculateNewDistance
in class Algorithm
public void reset()
reset
in class Algorithm
public void generateRandom_ij()
public void popUpQuestion1(int random_site)
public java.lang.String buildAns1()
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 |