PTreeGenerator
1.0
Simple phylogenetic tree generation from multiple sequence alignment.
|
Basically a wrapper around a numpy array obejct representing the alignment distance matrix. More...
Public Member Functions | |
def | __init__ |
Takes any "matrix-like" object and tries to convert it to a numpy array. | |
def | size |
A getter for the matrix size (number of columns/taxa). | |
def | distMatrix |
A getter for a copy of the whole distance matrix. | |
def | columnNames |
A getter for a list of column/taxa names. | |
def | getSeparation |
Returns a separation of value used in the Neigbor-joining algorithm. | |
def | getNearestNeigbors |
Finds the pair of nearest sequences. | |
def | getDistance |
Returns the distance from one sequence to another. | |
def | getIdx |
Finds the position of a sequence in the distance matrix. | |
def | getName |
Finds the name of a sequence based on its position in the matrix. | |
def | removeData |
Removes rows and columns for the specified sequences. | |
def | appendData |
Adds a row and a column for the specified sequence. |
Private Attributes | |
_distMatrix | |
Distance matrix as a numpy array object. | |
_columnNames | |
List of column names (the identification strings of the sequences). |
Basically a wrapper around a numpy array obejct representing the alignment distance matrix.
Performs some other additional operations usefull for tree building.
Definition at line 13 of file distance_matrix.py.
def ptreegen.distance_matrix.DistanceMatrix.__init__ | ( | self, | |
matrix, | |||
names = None |
|||
) |
Takes any "matrix-like" object and tries to convert it to a numpy array.
matrix | a "matrix-like" object |
names | optional parameter with column and row names (the taxa names) |
Definition at line 21 of file distance_matrix.py.
def ptreegen.distance_matrix.DistanceMatrix.appendData | ( | self, | |
data, | |||
name | |||
) |
Adds a row and a column for the specified sequence.
name | the identification of the sequence |
data | data to be appended as an iterable |
Definition at line 141 of file distance_matrix.py.
References ptreegen.distance_matrix.DistanceMatrix._distMatrix.
def ptreegen.distance_matrix.DistanceMatrix.columnNames | ( | self | ) |
A getter for a list of column/taxa names.
Definition at line 54 of file distance_matrix.py.
References ptreegen.distance_matrix.DistanceMatrix._columnNames.
def ptreegen.distance_matrix.DistanceMatrix.distMatrix | ( | self | ) |
A getter for a copy of the whole distance matrix.
Definition at line 47 of file distance_matrix.py.
References ptreegen.distance_matrix.DistanceMatrix._distMatrix.
def ptreegen.distance_matrix.DistanceMatrix.getDistance | ( | self, | |
name_i, | |||
name_j | |||
) |
Returns the distance from one sequence to another.
Based on the value from the distance matrix.
Definition at line 106 of file distance_matrix.py.
References ptreegen.distance_matrix.DistanceMatrix._distMatrix.
def ptreegen.distance_matrix.DistanceMatrix.getIdx | ( | self, | |
name | |||
) |
Finds the position of a sequence in the distance matrix.
name | the identification of the sequence |
Definition at line 114 of file distance_matrix.py.
def ptreegen.distance_matrix.DistanceMatrix.getName | ( | self, | |
idx | |||
) |
Finds the name of a sequence based on its position in the matrix.
idx | the position in the matrix |
Definition at line 122 of file distance_matrix.py.
References ptreegen.distance_matrix.DistanceMatrix._columnNames.
def ptreegen.distance_matrix.DistanceMatrix.getNearestNeigbors | ( | self | ) |
Finds the pair of nearest sequences.
Finds the pair of closest sequences according to the rule from the Neigbor-Joining algorithm.
Definition at line 87 of file distance_matrix.py.
References ptreegen.distance_matrix.DistanceMatrix._columnNames, ptreegen.distance_matrix.DistanceMatrix._distMatrix, ptreegen.distance_matrix.DistanceMatrix.getSeparation(), and ptreegen.distance_matrix.DistanceMatrix.size().
def ptreegen.distance_matrix.DistanceMatrix.getSeparation | ( | self, | |
name = None |
|||
) |
Returns a separation of value used in the Neigbor-joining algorithm.
It can be computed for one sequence only (parameter name) or for all sequences (no parameter).
The separation value is computed as follows: sum(d_ik) / (L - 2), where sum(d_ik) is the sum of distances from one sequence to all the other sequences and L is the total number of sequences.
name | identification of one sequence |
Definition at line 71 of file distance_matrix.py.
References ptreegen.distance_matrix.DistanceMatrix._distMatrix, and ptreegen.distance_matrix.DistanceMatrix.size().
Referenced by ptreegen.distance_matrix.DistanceMatrix.getNearestNeigbors().
def ptreegen.distance_matrix.DistanceMatrix.removeData | ( | self, | |
names | |||
) |
Removes rows and columns for the specified sequences.
names | the identifications of the sequences as an iterable |
Definition at line 129 of file distance_matrix.py.
References ptreegen.distance_matrix.DistanceMatrix._distMatrix.
def ptreegen.distance_matrix.DistanceMatrix.size | ( | self | ) |
A getter for the matrix size (number of columns/taxa).
Definition at line 40 of file distance_matrix.py.
References ptreegen.distance_matrix.DistanceMatrix._distMatrix.
Referenced by ptreegen.distance_matrix.DistanceMatrix.getNearestNeigbors(), and ptreegen.distance_matrix.DistanceMatrix.getSeparation().
|
private |
List of column names (the identification strings of the sequences).
Definition at line 30 of file distance_matrix.py.
Referenced by ptreegen.distance_matrix.DistanceMatrix.columnNames(), ptreegen.distance_matrix.DistanceMatrix.getName(), and ptreegen.distance_matrix.DistanceMatrix.getNearestNeigbors().
|
private |
Distance matrix as a numpy array object.
Definition at line 22 of file distance_matrix.py.
Referenced by ptreegen.distance_matrix.DistanceMatrix.appendData(), ptreegen.distance_matrix.DistanceMatrix.distMatrix(), ptreegen.distance_matrix.DistanceMatrix.getDistance(), ptreegen.distance_matrix.DistanceMatrix.getNearestNeigbors(), ptreegen.distance_matrix.DistanceMatrix.getSeparation(), ptreegen.distance_matrix.DistanceMatrix.removeData(), and ptreegen.distance_matrix.DistanceMatrix.size().