Class DpMatrix<T>


  • public class DpMatrix<T>
    extends Object
    DpMatrix is a matrix used in dynamic programming. Two sequences to be aligned are passed to this class in a form of List of Object. Each cell (DpMatrixCell) of the matrix records the alignment score of the two elements. The score is calculated by DpFunction class that is passed to the constructor. The alignment result is returned as a List of DpMatrixCell.
    • Constructor Detail

    • Method Detail

      • align

        public List<DpMatrixCell> align()
        Align the two sequences. The result is returned as a List of DpMatrixCell in order from the start to the end. Each DpMatrixCell may indicate the match, insertion or deletion of the elements. Some may even indicate the 1:n, n:1 or n:n match. The match state should be queried to DpMatrixCell.
        Returns:
        List of DpMatrixCell
      • getAlignmentElementX

        public T getAlignmentElementX​(int p_xIdx)
        Returns an element of X sequence.
        Parameters:
        p_xIdx - index of X sequence. The index starts with 1. The rule of sum is to specify the same index as the cell's X index, then you'll get what you want. If 0 is specified, IndexOutOfBoundsException will be thrown.
        Returns:
        DpMatrix
      • getAlignmentElementY

        public T getAlignmentElementY​(int p_yIdx)
        Returns an element of Y sequence.
        Parameters:
        p_yIdx - index of Y sequence. The index starts with 1. The rule of sum is to specify the same index as the cell's Y index, then you'll get what you want. If 0 is specified, IndexOutOfBoundsException will be thrown.
        Returns:
        DpMatrix
      • getAlignmentElementsX

        public List<T> getAlignmentElementsX​(int p_xFromIdx,
                                             int p_xToIdx)
        Returns a List of X sequence elements starting at p_xFromIdx (inclusive) and ending at p_xToIdx (exclusive).
        Parameters:
        p_xFromIdx - start index of X sequence (inclusive). The index starts with 1. Usually, a return value of DpMatrixCell#getMultiMatchXIndexBegin() is specified.
        p_xToIdx - end index of X sequence (exclusive). The index starts with 1. Usually, a return value of DpMatrixCell#getMultiMatchXIndexEnd() is specified.
        Returns:
        List of X sequence elements
      • getAlignmentElementsY

        public List<T> getAlignmentElementsY​(int p_yFromIdx,
                                             int p_yToIdx)
        Returns a List of Y sequence elements starting at p_yFromIdx (inclusive) and ending at p_yToIdx (exclusive).
        Parameters:
        p_yFromIdx - start index of Y sequence (inclusive). The index starts with 1. Usually, a return value of DpMatrixCell#getMultiMatchYIndexBegin() is specified.
        p_yToIdx - end index of Y sequence (exclusive). The index starts with 1. Usually, a return value of DpMatrixCell#getMultiMatchYIndexEnd() is specified.
        Returns:
        List of Y sequence elements
      • getCell

        public DpMatrixCell getCell​(int p_xIdx,
                                    int p_yIdx)
        Return a cell of the matrix.
        Parameters:
        p_xIdx - Index of X axis. The index starts with 0.
        p_yIdx - Index of Y axis. The index starts with 0.
        Returns:
        DpMatrixCell object