Package pal.distance
Class DistanceMatrix
java.lang.Object
pal.distance.DistanceMatrix
- All Implemented Interfaces:
Serializable,IdGroup
- Direct Known Subclasses:
AlignmentDistanceMatrix,JukesCantorDistanceMatrix,ReadDistanceMatrix,SUPGMADistanceMatrix,TreeDistanceMatrix
storage for pairwise distance matrices.
features: - printing in in PHYLIP format, - computation of (weighted) squared distance to other distance matrix - Fills in all of array...
- Version:
- $Id: DistanceMatrix.java,v 1.11 2003/07/20 02:36:08 matt Exp $
- Author:
- Korbinian Strimmer, Alexei Drummond
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface pal.misc.IdGroup
IdGroup.Utils -
Constructor Summary
ConstructorsConstructorDescriptionconstructorDistanceMatrix(double[][] distance, IdGroup idGroup) constructor taking distances array and IdGroupconstructor that takes a distance matrix and clones the distances but uses the same idGroup.DistanceMatrix(DistanceMatrix dm, IdGroup subset) constructor that takes a distance matrix and clones the distances, of a the identifiers in idGroup. -
Method Summary
Modifier and TypeMethodDescriptiondoublecompute absolute distance to second distance matrixvoidaddDistance(int i, int j, double delta) Adds a delta to both upper and lower triangle distances.final double[][]Returns the distances as a 2-dimensional array of doubles.intgetClosestIndex(int fromIndex, int[] exclusion) intgetClosestIndex(String fromID, String[] exclusion) final doublegetDistance(int row, int col) protected final double[][]Returns the distances as a 2-dimensional array of doubles (in the actual array used to store the distances)intReturns the number of identifiers in this groupgetIdentifier(int i) Returns the ith identifier.Deprecated.distance matrix now implements IdGroupintgetSize()Returns the number of rows and columns that the distance matrix has.booleantest whether this matrix is a symmetric distance matrixdoubleReturns the mean pairwise distance of this matrixvoidprintPHYLIP(PrintWriter out) print alignment (PHYLIP format)voidsetDistance(int i, int j, double dist) Sets both upper and lower triangles.protected final voidsetDistances(double[][] matrix) voidsetIdentifier(int i, Identifier ident) Sets the ith identifier.protected final voidsetIdGroup(IdGroup base) doublesquaredDistance(DistanceMatrix mat, boolean weighted) compute squared distance to second distance matrixtoString()returns representation of this alignment as a stringintwhichIdNumber(String name) returns the index of the identifier with the given name.
-
Constructor Details
-
DistanceMatrix
public DistanceMatrix()constructor -
DistanceMatrix
constructor taking distances array and IdGroup -
DistanceMatrix
constructor that takes a distance matrix and clones the distances but uses the same idGroup. -
DistanceMatrix
constructor that takes a distance matrix and clones the distances, of a the identifiers in idGroup.
-
-
Method Details
-
printPHYLIP
print alignment (PHYLIP format) -
toString
returns representation of this alignment as a string -
squaredDistance
compute squared distance to second distance matrix -
absoluteDistance
compute absolute distance to second distance matrix -
getSize
public int getSize()Returns the number of rows and columns that the distance matrix has. -
getClonedDistances
public final double[][] getClonedDistances()Returns the distances as a 2-dimensional array of doubles. Matrix is cloned first so it can be altered freely. -
getDistances
protected final double[][] getDistances()Returns the distances as a 2-dimensional array of doubles (in the actual array used to store the distances) -
getDistance
public final double getDistance(int row, int col) -
setDistance
public void setDistance(int i, int j, double dist) Sets both upper and lower triangles. -
addDistance
public void addDistance(int i, int j, double delta) Adds a delta to both upper and lower triangle distances. -
meanDistance
public double meanDistance()Returns the mean pairwise distance of this matrix -
getIdentifier
Description copied from interface:IdGroupReturns the ith identifier.- Specified by:
getIdentifierin interfaceIdGroup
-
setIdentifier
Description copied from interface:IdGroupSets the ith identifier.- Specified by:
setIdentifierin interfaceIdGroup
-
getIdCount
public int getIdCount()Description copied from interface:IdGroupReturns the number of identifiers in this group- Specified by:
getIdCountin interfaceIdGroup
-
whichIdNumber
Description copied from interface:IdGroupreturns the index of the identifier with the given name.- Specified by:
whichIdNumberin interfaceIdGroup
-
getIdGroup
Deprecated.distance matrix now implements IdGroupReturn id group of this alignment. -
isSymmetric
public boolean isSymmetric()test whether this matrix is a symmetric distance matrix -
getClosestIndex
- Parameters:
fromID- the thing (taxa,sequence) from which we want to find the closest (excluding self)exlcusion- indexes of things that should not be considered, may be null- Returns:
- the index of the thing closest to the specified
-
getClosestIndex
public int getClosestIndex(int fromIndex, int[] exclusion) - Parameters:
fromIndex- the index of the thing (taxa,sequence) from which we want to find the closest (excluding self)exlcusion- indexes of things that should not be considered, may be null- Returns:
- the index of the member closes to the specified
-
setIdGroup
-
setDistances
protected final void setDistances(double[][] matrix)
-