Class SubstitutionMatrix

java.lang.Object
org.biojava.bio.alignment.SubstitutionMatrix
All Implemented Interfaces:
Serializable

public class SubstitutionMatrix extends Object implements Serializable

This object is able to read a substitution matrix file and constructs a short matrix in memory. Every single element of the matrix can be accessed by the method getValueAt with the parameters being two BioJava symbols. This is why it is not necessary to access the matrix directly. If there is no value for the two specified Symbols an Exception is thrown.

Substitution matrix files, are available at the NCBI FTP directory.

Author:
Andreas Dräger invalid input: '<'andreas.draeger@uni-tuebingen.de>
See Also:
  • Constructor Details

  • Method Details

    • getSubstitutionMatrix

      This constructor can be used to guess the alphabet of this substitution matrix. However, it is recommended to apply another constructor if the alphabet is known.
      Parameters:
      reader -
      Throws:
      NumberFormatException
      BioException
      IOException
    • getSubstitutionMatrix

      Return a new substitution matrix with the specified alphabet.
      Parameters:
      alphabet - alphabet, must not be null
      reader - reader, must not be null
      Returns:
      a new substitution matrix with the specified alphabet
      Throws:
      BioException - if an error occurs
      IOException - if an I/O error occurs
    • getSubstitutionMatrix

      Return a new substitution matrix with the specified alphabet and name.
      Parameters:
      alphabet - alphabet, must not be null
      reader - reader, must not be null
      name - name, must not be null
      Returns:
      a new substitution matrix with the specified alphabet and name
      Throws:
      BioException - if an error occurs
      IOException - if an I/O error occurs
    • getBlosum100

      Return the BLOSUM100 amino acid substitution matrix.
      Returns:
      the BLOSUM100 amino acid substitution matrix
    • getBlosum100_50

      Return the BLOSUM100.50 amino acid substitution matrix.
      Returns:
      the BLOSUM100.50 amino acid substitution matrix
    • getBlosum30

      Return the BLOSUM30 amino acid substitution matrix.
      Returns:
      the BLOSUM30 amino acid substitution matrix
    • getBlosum30_50

      Return the BLOSUM30.50 amino acid substitution matrix.
      Returns:
      the BLOSUM30.50 amino acid substitution matrix
    • getBlosum35

      Return the BLOSUM35 amino acid substitution matrix.
      Returns:
      the BLOSUM35 amino acid substitution matrix
    • getBlosum35_50

      Return the BLOSUM35.50 amino acid substitution matrix.
      Returns:
      the BLOSUM35.50 amino acid substitution matrix
    • getBlosum40

      Return the BLOSUM40 amino acid substitution matrix.
      Returns:
      the BLOSUM40 amino acid substitution matrix
    • getBlosum40_50

      Return the BLOSUM40.50 amino acid substitution matrix.
      Returns:
      the BLOSUM40.50 amino acid substitution matrix
    • getBlosum45

      Return the BLOSUM45 amino acid substitution matrix.
      Returns:
      the BLOSUM45 amino acid substitution matrix
    • getBlosum45_50

      Return the BLOSUM45.50 amino acid substitution matrix.
      Returns:
      the BLOSUM45.50 amino acid substitution matrix
    • getBlosum50

      Return the BLOSUM50 amino acid substitution matrix.
      Returns:
      the BLOSUM50 amino acid substitution matrix
    • getBlosum50_50

      Return the BLOSUM50.50 amino acid substitution matrix.
      Returns:
      the BLOSUM50.50 amino acid substitution matrix
    • getBlosum55

      Return the BLOSUM55 amino acid substitution matrix.
      Returns:
      the BLOSUM55 amino acid substitution matrix
    • getBlosum55_50

      Return the BLOSUM55.50 amino acid substitution matrix.
      Returns:
      the BLOSUM55.50 amino acid substitution matrix
    • getBlosum60

      Return the BLOSUM60 amino acid substitution matrix.
      Returns:
      the BLOSUM60 amino acid substitution matrix
    • getBlosum60_50

      Return the BLOSUM60.50 amino acid substitution matrix.
      Returns:
      the BLOSUM60.50 amino acid substitution matrix
    • getBlosum62

      Return the BLOSUM62 amino acid substitution matrix.
      Returns:
      the BLOSUM62 amino acid substitution matrix
    • getBlosum62_50

      Return the BLOSUM62.50 amino acid substitution matrix.
      Returns:
      the BLOSUM62.50 amino acid substitution matrix
    • getBlosum65

      Return the BLOSUM65 amino acid substitution matrix.
      Returns:
      the BLOSUM65 amino acid substitution matrix
    • getBlosum65_50

      Return the BLOSUM65.50 amino acid substitution matrix.
      Returns:
      the BLOSUM65.50 amino acid substitution matrix
    • getBlosum70

      Return the BLOSUM70 amino acid substitution matrix.
      Returns:
      the BLOSUM70 amino acid substitution matrix
    • getBlosum70_50

      Return the BLOSUM70.50 amino acid substitution matrix.
      Returns:
      the BLOSUM70.50 amino acid substitution matrix
    • getBlosum75

      Return the BLOSUM75 amino acid substitution matrix.
      Returns:
      the BLOSUM75 amino acid substitution matrix
    • getBlosum75_50

      Return the BLOSUM75.50 amino acid substitution matrix.
      Returns:
      the BLOSUM75.50 amino acid substitution matrix
    • getBlosum80

      Return the BLOSUM80 amino acid substitution matrix.
      Returns:
      the BLOSUM80 amino acid substitution matrix
    • getBlosum80_50

      Return the BLOSUM80.50 amino acid substitution matrix.
      Returns:
      the BLOSUM80.50 amino acid substitution matrix
    • getBlosum85

      Return the BLOSUM85 amino acid substitution matrix.
      Returns:
      the BLOSUM85 amino acid substitution matrix
    • getBlosum85_50

      Return the BLOSUM85.50 amino acid substitution matrix.
      Returns:
      the BLOSUM85.50 amino acid substitution matrix
    • getBlosum90

      Return the BLOSUM90 amino acid substitution matrix.
      Returns:
      the BLOSUM90 amino acid substitution matrix
    • getBlosum90_50

      Return the BLOSUM90.50 amino acid substitution matrix.
      Returns:
      the BLOSUM90.50 amino acid substitution matrix
    • getBlosumn

      public static SubstitutionMatrix getBlosumn()
      Return the BLOSUMN amino acid substitution matrix.
      Returns:
      the BLOSUMN amino acid substitution matrix
    • getBlosumn_50

      Return the BLOSUMN.50 amino acid substitution matrix.
      Returns:
      the BLOSUMN.50 amino acid substitution matrix
    • getDayhoff

      public static SubstitutionMatrix getDayhoff()
      Return the DAYHOFF amino acid substitution matrix.
      Returns:
      the DAYHOFF amino acid substitution matrix
    • getGonnet

      public static SubstitutionMatrix getGonnet()
      Return the GONNET amino acid substitution matrix.
      Returns:
      the GONNET amino acid substitution matrix
    • getIdentity

      Return the IDENTITY amino acid substitution matrix.
      Returns:
      the IDENTITY amino acid substitution matrix
    • getMatch

      public static SubstitutionMatrix getMatch()
      Return the MATCH amino acid substitution matrix.
      Returns:
      the MATCH amino acid substitution matrix
    • getNuc4_2

      public static SubstitutionMatrix getNuc4_2()
      Return the NUC.4.2 nucleotide substitution matrix.
      Returns:
      the NUC.4.2 nucleotide substitution matrix
    • getNuc4_4

      public static SubstitutionMatrix getNuc4_4()
      Return the NUC.4.4 nucleotide substitution matrix.
      Returns:
      the NUC.4.4 nucleotide substitution matrix
    • getPam10

      public static SubstitutionMatrix getPam10()
      Return the PAM10 amino acid substitution matrix.
      Returns:
      the PAM10 amino acid substitution matrix
    • getPam100

      public static SubstitutionMatrix getPam100()
      Return the PAM100 amino acid substitution matrix.
      Returns:
      the PAM100 amino acid substitution matrix
    • getPam110

      public static SubstitutionMatrix getPam110()
      Return the PAM110 amino acid substitution matrix.
      Returns:
      the PAM110 amino acid substitution matrix
    • getPam120

      public static SubstitutionMatrix getPam120()
      Return the PAM120 amino acid substitution matrix.
      Returns:
      the PAM120 amino acid substitution matrix
    • getPam130

      public static SubstitutionMatrix getPam130()
      Return the PAM130 amino acid substitution matrix.
      Returns:
      the PAM130 amino acid substitution matrix
    • getPam140

      public static SubstitutionMatrix getPam140()
      Return the PAM140 amino acid substitution matrix.
      Returns:
      the PAM140 amino acid substitution matrix
    • getPam150

      public static SubstitutionMatrix getPam150()
      Return the PAM150 amino acid substitution matrix.
      Returns:
      the PAM150 amino acid substitution matrix
    • getPam160

      public static SubstitutionMatrix getPam160()
      Return the PAM160 amino acid substitution matrix.
      Returns:
      the PAM160 amino acid substitution matrix
    • getPam170

      public static SubstitutionMatrix getPam170()
      Return the PAM170 amino acid substitution matrix.
      Returns:
      the PAM170 amino acid substitution matrix
    • getPam180

      public static SubstitutionMatrix getPam180()
      Return the PAM180 amino acid substitution matrix.
      Returns:
      the PAM180 amino acid substitution matrix
    • getPam190

      public static SubstitutionMatrix getPam190()
      Return the PAM190 amino acid substitution matrix.
      Returns:
      the PAM190 amino acid substitution matrix
    • getPam20

      public static SubstitutionMatrix getPam20()
      Return the PAM20 amino acid substitution matrix.
      Returns:
      the PAM20 amino acid substitution matrix
    • getPam200

      public static SubstitutionMatrix getPam200()
      Return the PAM200 amino acid substitution matrix.
      Returns:
      the PAM200 amino acid substitution matrix
    • getPam210

      public static SubstitutionMatrix getPam210()
      Return the PAM210 amino acid substitution matrix.
      Returns:
      the PAM210 amino acid substitution matrix
    • getPam220

      public static SubstitutionMatrix getPam220()
      Return the PAM220 amino acid substitution matrix.
      Returns:
      the PAM220 amino acid substitution matrix
    • getPam230

      public static SubstitutionMatrix getPam230()
      Return the PAM230 amino acid substitution matrix.
      Returns:
      the PAM230 amino acid substitution matrix
    • getPam240

      public static SubstitutionMatrix getPam240()
      Return the PAM240 amino acid substitution matrix.
      Returns:
      the PAM240 amino acid substitution matrix
    • getPam250

      public static SubstitutionMatrix getPam250()
      Return the PAM250 amino acid substitution matrix.
      Returns:
      the PAM250 amino acid substitution matrix
    • getPam260

      public static SubstitutionMatrix getPam260()
      Return the PAM260 amino acid substitution matrix.
      Returns:
      the PAM260 amino acid substitution matrix
    • getPam270

      public static SubstitutionMatrix getPam270()
      Return the PAM270 amino acid substitution matrix.
      Returns:
      the PAM270 amino acid substitution matrix
    • getPam280

      public static SubstitutionMatrix getPam280()
      Return the PAM280 amino acid substitution matrix.
      Returns:
      the PAM280 amino acid substitution matrix
    • getPam290

      public static SubstitutionMatrix getPam290()
      Return the PAM290 amino acid substitution matrix.
      Returns:
      the PAM290 amino acid substitution matrix
    • getPam30

      public static SubstitutionMatrix getPam30()
      Return the PAM30 amino acid substitution matrix.
      Returns:
      the PAM30 amino acid substitution matrix
    • getPam300

      public static SubstitutionMatrix getPam300()
      Return the PAM300 amino acid substitution matrix.
      Returns:
      the PAM300 amino acid substitution matrix
    • getPam310

      public static SubstitutionMatrix getPam310()
      Return the PAM310 amino acid substitution matrix.
      Returns:
      the PAM310 amino acid substitution matrix
    • getPam320

      public static SubstitutionMatrix getPam320()
      Return the PAM320 amino acid substitution matrix.
      Returns:
      the PAM320 amino acid substitution matrix
    • getPam330

      public static SubstitutionMatrix getPam330()
      Return the PAM330 amino acid substitution matrix.
      Returns:
      the PAM330 amino acid substitution matrix
    • getPam340

      public static SubstitutionMatrix getPam340()
      Return the PAM340 amino acid substitution matrix.
      Returns:
      the PAM340 amino acid substitution matrix
    • getPam350

      public static SubstitutionMatrix getPam350()
      Return the PAM350 amino acid substitution matrix.
      Returns:
      the PAM350 amino acid substitution matrix
    • getPam360

      public static SubstitutionMatrix getPam360()
      Return the PAM360 amino acid substitution matrix.
      Returns:
      the PAM360 amino acid substitution matrix
    • getPam370

      public static SubstitutionMatrix getPam370()
      Return the PAM370 amino acid substitution matrix.
      Returns:
      the PAM370 amino acid substitution matrix
    • getPam380

      public static SubstitutionMatrix getPam380()
      Return the PAM380 amino acid substitution matrix.
      Returns:
      the PAM380 amino acid substitution matrix
    • getPam390

      public static SubstitutionMatrix getPam390()
      Return the PAM390 amino acid substitution matrix.
      Returns:
      the PAM390 amino acid substitution matrix
    • getPam40

      public static SubstitutionMatrix getPam40()
      Return the PAM40 amino acid substitution matrix.
      Returns:
      the PAM40 amino acid substitution matrix
    • getPam400

      public static SubstitutionMatrix getPam400()
      Return the PAM400 amino acid substitution matrix.
      Returns:
      the PAM400 amino acid substitution matrix
    • getPam410

      public static SubstitutionMatrix getPam410()
      Return the PAM410 amino acid substitution matrix.
      Returns:
      the PAM410 amino acid substitution matrix
    • getPam420

      public static SubstitutionMatrix getPam420()
      Return the PAM420 amino acid substitution matrix.
      Returns:
      the PAM420 amino acid substitution matrix
    • getPam430

      public static SubstitutionMatrix getPam430()
      Return the PAM430 amino acid substitution matrix.
      Returns:
      the PAM430 amino acid substitution matrix
    • getPam440

      public static SubstitutionMatrix getPam440()
      Return the PAM440 amino acid substitution matrix.
      Returns:
      the PAM440 amino acid substitution matrix
    • getPam450

      public static SubstitutionMatrix getPam450()
      Return the PAM450 amino acid substitution matrix.
      Returns:
      the PAM450 amino acid substitution matrix
    • getPam460

      public static SubstitutionMatrix getPam460()
      Return the PAM460 amino acid substitution matrix.
      Returns:
      the PAM460 amino acid substitution matrix
    • getPam470

      public static SubstitutionMatrix getPam470()
      Return the PAM470 amino acid substitution matrix.
      Returns:
      the PAM470 amino acid substitution matrix
    • getPam480

      public static SubstitutionMatrix getPam480()
      Return the PAM480 amino acid substitution matrix.
      Returns:
      the PAM480 amino acid substitution matrix
    • getPam490

      public static SubstitutionMatrix getPam490()
      Return the PAM490 amino acid substitution matrix.
      Returns:
      the PAM490 amino acid substitution matrix
    • getPam50

      public static SubstitutionMatrix getPam50()
      Return the PAM50 amino acid substitution matrix.
      Returns:
      the PAM50 amino acid substitution matrix
    • getPam500

      public static SubstitutionMatrix getPam500()
      Return the PAM500 amino acid substitution matrix.
      Returns:
      the PAM500 amino acid substitution matrix
    • getPam60

      public static SubstitutionMatrix getPam60()
      Return the PAM60 amino acid substitution matrix.
      Returns:
      the PAM60 amino acid substitution matrix
    • getPam70

      public static SubstitutionMatrix getPam70()
      Return the PAM70 amino acid substitution matrix.
      Returns:
      the PAM70 amino acid substitution matrix
    • getPam80

      public static SubstitutionMatrix getPam80()
      Return the PAM80 amino acid substitution matrix.
      Returns:
      the PAM80 amino acid substitution matrix
    • getPam90

      public static SubstitutionMatrix getPam90()
      Return the PAM90 amino acid substitution matrix.
      Returns:
      the PAM90 amino acid substitution matrix
    • getValueAt

      public short getValueAt(Symbol row, Symbol col) throws BioException
      There are some substitution matrices containing more columns than lines. This has to do with the ambiguous symbols. Lines are always good, columns might not contain the whole information. The matrix is supposed to be symmetric anyway, so you can always set the ambiguous symbol to be the first argument.
      Parameters:
      row - Symbol of the line
      col - Symbol of the column
      Returns:
      expenses for the exchange of symbol row and symbol column.
      Throws:
      BioException
    • getDescription

      This gives you the description of this matrix if there is one. Normally substitution matrix files like BLOSUM contain some lines of description.
      Returns:
      the comment of the matrix
    • getName

      public String getName()
      Every substitution matrix has a name like "BLOSUM30" or "PAM160". This will be returned by this method.
      Returns:
      the name of the matrix.
    • getMin

      public short getMin()
      The minimum score of this matrix.
      Returns:
      minimum of the matrix.
    • getMax

      public short getMax()
      The maximum score in this matrix.
      Returns:
      maximum of the matrix.
    • setDescription

      public void setDescription(String desc)
      Sets the description to the given value.
      Parameters:
      desc - a description. This doesn't have to start with '#'.
    • getAlphabet

      Gives the alphabet used by this matrix.
      Returns:
      the alphabet of this matrix.
    • stringnifyMatrix

      Creates a String representation of this matrix.
      Returns:
      a string representation of this matrix without the description.
    • stringnifyDescription

      Converts the description of the matrix to a String.
      Returns:
      Gives a description with approximately 60 letters on every line separated by System.getProperty("line.separator"). Every line starts with #.
    • toString

      public String toString()
      Overrides the inherited method.
      Overrides:
      toString in class Object
      Returns:
      Gives a string representation of the SubstitutionMatrix. This is a valid input for the constructor which needs a matrix string. This String also contains the description of the matrix if there is one.
    • printMatrix

      public void printMatrix()
      Just to perform some test. It prints the matrix on the screen.
    • normalizeMatrix

      With this method you can get a “normalized” SubstitutionMatrix object; however, since this implementation uses an short matrix, the normalized matrix will be scaled by ten. If you need values between zero and one, you have to divide every value returned by getValueAt by ten.
      Returns:
      a new and normalized SubstitutionMatrix object given by this substitution matrix. Because this uses an short matrix, all values are scaled by 10.
      Throws:
      BioException
      IOException
      NumberFormatException