Package pal.distance

Class DistanceMatrix

    • Method Summary

      All Methods Instance Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      double absoluteDistance​(DistanceMatrix mat)
      compute absolute distance to second distance matrix
      void addDistance​(int i, int j, double delta)
      Adds a delta to both upper and lower triangle distances.
      double[][] getClonedDistances()
      Returns the distances as a 2-dimensional array of doubles.
      int getClosestIndex​(int fromIndex, int[] exclusion)  
      int getClosestIndex​(java.lang.String fromID, java.lang.String[] exclusion)  
      double getDistance​(int row, int col)  
      protected double[][] getDistances()
      Returns the distances as a 2-dimensional array of doubles (in the actual array used to store the distances)
      int getIdCount()
      Returns the number of identifiers in this group
      Identifier getIdentifier​(int i)
      Returns the ith identifier.
      IdGroup getIdGroup()
      Deprecated.
      distance matrix now implements IdGroup
      int getSize()
      Returns the number of rows and columns that the distance matrix has.
      boolean isSymmetric()
      test whether this matrix is a symmetric distance matrix
      double meanDistance()
      Returns the mean pairwise distance of this matrix
      void printPHYLIP​(java.io.PrintWriter out)
      print alignment (PHYLIP format)
      void setDistance​(int i, int j, double dist)
      Sets both upper and lower triangles.
      protected void setDistances​(double[][] matrix)  
      void setIdentifier​(int i, Identifier ident)
      Sets the ith identifier.
      protected void setIdGroup​(IdGroup base)  
      double squaredDistance​(DistanceMatrix mat, boolean weighted)
      compute squared distance to second distance matrix
      java.lang.String toString()
      returns representation of this alignment as a string
      int whichIdNumber​(java.lang.String name)
      returns the index of the identifier with the given name.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • DistanceMatrix

        public DistanceMatrix()
        constructor
      • DistanceMatrix

        public DistanceMatrix​(double[][] distance,
                              IdGroup idGroup)
        constructor taking distances array and IdGroup
      • DistanceMatrix

        public DistanceMatrix​(DistanceMatrix dm)
        constructor that takes a distance matrix and clones the distances but uses the same idGroup.
      • DistanceMatrix

        public DistanceMatrix​(DistanceMatrix dm,
                              IdGroup subset)
        constructor that takes a distance matrix and clones the distances, of a the identifiers in idGroup.
    • Method Detail

      • printPHYLIP

        public void printPHYLIP​(java.io.PrintWriter out)
        print alignment (PHYLIP format)
      • toString

        public java.lang.String toString()
        returns representation of this alignment as a string
        Overrides:
        toString in class java.lang.Object
      • squaredDistance

        public double squaredDistance​(DistanceMatrix mat,
                                      boolean weighted)
        compute squared distance to second distance matrix
      • absoluteDistance

        public double absoluteDistance​(DistanceMatrix mat)
        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
      • setIdentifier

        public void setIdentifier​(int i,
                                  Identifier ident)
        Description copied from interface: IdGroup
        Sets the ith identifier.
        Specified by:
        setIdentifier in interface IdGroup
      • getIdCount

        public int getIdCount()
        Description copied from interface: IdGroup
        Returns the number of identifiers in this group
        Specified by:
        getIdCount in interface IdGroup
      • whichIdNumber

        public int whichIdNumber​(java.lang.String name)
        Description copied from interface: IdGroup
        returns the index of the identifier with the given name.
        Specified by:
        whichIdNumber in interface IdGroup
      • getIdGroup

        public IdGroup getIdGroup()
        Deprecated.
        distance matrix now implements IdGroup
        Return id group of this alignment.
      • isSymmetric

        public boolean isSymmetric()
        test whether this matrix is a symmetric distance matrix
      • getClosestIndex

        public int getClosestIndex​(java.lang.String fromID,
                                   java.lang.String[] exclusion)
        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

        protected final void setIdGroup​(IdGroup base)
      • setDistances

        protected final void setDistances​(double[][] matrix)