function [matrix, matrixInfo] = pam40
%PAM40 substitution matrix in 1/2 bit units,
%   Expected score = -4.27, Entropy = 2.26 bits
%   Lowest score = -15, Highest score = 13
%
%   Order:
%   A  R  N  D  C  Q  E  G  H  I  L  K  M  F  P  S  T  W  Y  V  B  Z  X  *
%
%   [MATRIX,MATRIXINFO] = PAM40 returns a structure of information about
%   the matrix with fields Name, Scale, Entropy, ExpectedScore, LowestScore,
%   HighestScore and Order.

% Source:  ftp://ftp.ncbi.nih.gov/blast/matrices/
%   $Revision: 1.5 $ 

matrix = [...
    6  -6  -3  -3  -6  -3  -2  -1  -6  -4  -5  -6  -4  -7  -1   0   0 -12  -7  -2  -3  -2  -3 -15;...
   -6   8  -5  -9  -7  -1  -8  -8  -1  -5  -8   1  -3  -8  -3  -2  -5  -1  -9  -7  -6  -3  -5 -15;...
   -3  -5   7   2  -9  -3  -1  -2   1  -4  -6   0  -7  -8  -5   0  -1  -7  -4  -7   6  -2  -3 -15;...
   -3  -9   2   7 -12  -2   3  -3  -3  -6 -11  -4  -9 -13  -7  -3  -4 -13 -10  -7   6   2  -5 -15;...
   -6  -7  -9 -12   9 -12 -12  -8  -7  -5 -13 -12 -12 -11  -7  -2  -7 -14  -3  -5 -11 -12  -8 -15;...
   -3  -1  -3  -2 -12   8   2  -6   1  -7  -4  -2  -3 -11  -2  -4  -5 -11 -10  -6  -2   6  -4 -15;...
   -2  -8  -1   3 -12   2   7  -3  -4  -5  -8  -4  -6 -12  -5  -4  -5 -15  -8  -6   2   6  -4 -15;...
   -1  -8  -2  -3  -8  -6  -3   6  -8  -9  -9  -6  -7  -8  -5  -1  -5 -13 -12  -5  -2  -4  -4 -15;...
   -6  -1   1  -3  -7   1  -4  -8   9  -8  -5  -5  -9  -5  -3  -5  -6  -6  -3  -6  -1   0  -4 -15;...
   -4  -5  -4  -6  -5  -7  -5  -9  -8   8  -1  -5   0  -2  -7  -6  -2 -12  -5   2  -5  -5  -4 -15;...
   -5  -8  -6 -11 -13  -4  -8  -9  -5  -1   7  -7   1  -2  -6  -7  -6  -5  -6  -2  -8  -6  -5 -15;...
   -6   1   0  -4 -12  -2  -4  -6  -5  -5  -7   6  -1 -12  -6  -3  -2 -10  -8  -8  -2  -3  -4 -15;...
   -4  -3  -7  -9 -12  -3  -6  -7  -9   0   1  -1  11  -3  -7  -5  -3 -11 -10  -1  -8  -4  -4 -15;...
   -7  -8  -8 -13 -11 -11 -12  -8  -5  -2  -2 -12  -3   9  -9  -6  -8  -4   2  -7  -9 -12  -7 -15;...
   -1  -3  -5  -7  -7  -2  -5  -5  -3  -7  -6  -6  -7  -9   8  -1  -3 -12 -12  -5  -6  -3  -4 -15;...
    0  -2   0  -3  -2  -4  -4  -1  -5  -6  -7  -3  -5  -6  -1   6   1  -4  -6  -5  -1  -4  -2 -15;...
    0  -5  -1  -4  -7  -5  -5  -5  -6  -2  -6  -2  -3  -8  -3   1   7 -11  -6  -2  -2  -5  -3 -15;...
  -12  -1  -7 -13 -14 -11 -15 -13  -6 -12  -5 -10 -11  -4 -12  -4 -11  13  -4 -14  -9 -13  -9 -15;...
   -7  -9  -4 -10  -3 -10  -8 -12  -3  -5  -6  -8 -10   2 -12  -6  -6  -4  10  -6  -6  -8  -7 -15;...
   -2  -7  -7  -7  -5  -6  -6  -5  -6   2  -2  -8  -1  -7  -5  -5  -2 -14  -6   7  -7  -6  -4 -15;...
   -3  -6   6   6 -11  -2   2  -2  -1  -5  -8  -2  -8  -9  -6  -1  -2  -9  -6  -7   6   1  -4 -15;...
   -2  -3  -2   2 -12   6   6  -4   0  -5  -6  -3  -4 -12  -3  -4  -5 -13  -8  -6   1   6  -4 -15;...
   -3  -5  -3  -5  -8  -4  -4  -4  -4  -4  -5  -4  -4  -7  -4  -2  -3  -9  -7  -4  -4  -4  -4 -15;...
  -15 -15 -15 -15 -15 -15 -15 -15 -15 -15 -15 -15 -15 -15 -15 -15 -15 -15 -15 -15 -15 -15 -15   1;...
    ];

if nargout >1
    matrixInfo.Name = 'PAM40';
    matrixInfo.Scale = 1/2;
    matrixInfo.Entropy = 2.26 ;
    matrixInfo.ExpectedScore = -4.27;
    matrixInfo.LowestScore = -15;
    matrixInfo.HighestScore = 13;
    matrixInfo.Order = 'ARNDCQEGHILKMFPSTWYVBZX*';
end

