PTreeGenerator
1.0
Simple phylogenetic tree generation from multiple sequence alignment.
|
Represents a solution to the small parsimony problem (tree is known and we are intersted in the parsimony score of the tree). More...
Public Member Functions | |
def | __init__ |
Constructor takes tree and a corresponding alignment as input and saves references to them as SmallParsimony::_tree and SmallParsimony::_alignment. | |
def | cost |
A getter for the cost value. |
Private Member Functions | |
def | _solve |
Iteraterates over each column of the alignment and computes the parsimony score for each. | |
def | _assign |
Recursive method implementing the Fitch's algorithm. |
Private Attributes | |
_tree | |
Refernce to the tree being scored. | |
_alignment | |
Refernce to the coresponding alignment. | |
_sequencesDict | |
Associates sequence id string with a sequence instance. | |
_treeCharacterDict | |
A dictionary that stores the character sets asigned to each node everytime the SmallParsimony::_assign() method is executed for each column of the alignment. | |
_cost | |
Variable to store the intermediate results. |
Represents a solution to the small parsimony problem (tree is known and we are intersted in the parsimony score of the tree).
It implements the Fitch's algorithm to score the tree, therefore the input tree should be a rooted binary tree, even though this implementation is extended to work with any type of tree.
Definition at line 26 of file parsimony.py.
def ptreegen.parsimony.SmallParsimony.__init__ | ( | self, | |
tree, | |||
alignment | |||
) |
Constructor takes tree and a corresponding alignment as input and saves references to them as SmallParsimony::_tree and SmallParsimony::_alignment.
tree | the tree to be scored |
alignment | alignment corresponding to the input tree |
Definition at line 35 of file parsimony.py.
|
private |
Recursive method implementing the Fitch's algorithm.
It traverses the tree from an arbitrary node (preferably root) and computes the overall parsimony score.
node | the node to start traversing the tree from (preferably root) |
site_idx | index of the column in the alignment that is being processed |
Definition at line 81 of file parsimony.py.
References ptreegen.parsimony.SmallParsimony._assign(), ptreegen.parsimony.SmallParsimony._cost, ptreegen.parsimony.SmallParsimony._sequencesDict, and ptreegen.parsimony.SmallParsimony._treeCharacterDict.
Referenced by ptreegen.parsimony.SmallParsimony._assign(), and ptreegen.parsimony.SmallParsimony._solve().
|
private |
Iteraterates over each column of the alignment and computes the parsimony score for each.
It calls the SmallParsimony::_assign() method to score each column and add the score to the SmallParsimony::_cost member.
Definition at line 69 of file parsimony.py.
References ptreegen.parsimony.SmallParsimony._assign(), ptreegen.parsimony.SmallParsimony._tree, and ptreegen.parsimony.SmallParsimony._treeCharacterDict.
Referenced by ptreegen.parsimony.SmallParsimony.cost().
def ptreegen.parsimony.SmallParsimony.cost | ( | self | ) |
A getter for the cost value.
Calls the SmallParsimony::_solve() method to compute it.
Definition at line 57 of file parsimony.py.
References ptreegen.parsimony.SmallParsimony._cost, and ptreegen.parsimony.SmallParsimony._solve().
|
private |
Refernce to the coresponding alignment.
Definition at line 37 of file parsimony.py.
Referenced by ptreegen.parsimony.LargeParsimony.cost(), and ptreegen.parsimony.LargeParsimony.getOptimalQuartets().
|
private |
Variable to store the intermediate results.
Definition at line 49 of file parsimony.py.
Referenced by ptreegen.parsimony.SmallParsimony._assign(), and ptreegen.parsimony.SmallParsimony.cost().
|
private |
Associates sequence id string with a sequence instance.
Definition at line 38 of file parsimony.py.
Referenced by ptreegen.parsimony.SmallParsimony._assign().
|
private |
Refernce to the tree being scored.
Definition at line 36 of file parsimony.py.
Referenced by ptreegen.parsimony.SmallParsimony._solve(), ptreegen.visualization.Visualization.printToStdout(), and ptreegen.parsimony.LargeParsimony.tree().
|
private |
A dictionary that stores the character sets asigned to each node everytime the SmallParsimony::_assign() method is executed for each column of the alignment.
Definition at line 48 of file parsimony.py.
Referenced by ptreegen.parsimony.SmallParsimony._assign(), and ptreegen.parsimony.SmallParsimony._solve().