| 
 | NeoBio API | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object
  |
  +--neobio.alignment.ScoringScheme
        |
        +--neobio.alignment.ScoringMatrix
This class implements a scoring scheme based on a substitution matrix. It is useful
 to represent PAM and BLOSUM family of amino acids scoring matrices. Its constructor
 loads such matrices from a file (or any other character stream). The following is an
 extract of a BLOSUM62 scoring matrix file:
 
       A  R  N  D  C  Q  E  G  H  I  L  K  M  F  P  S  T  W  Y  V  B  Z  X  *
    A  4 -1 -2 -2  0 -1 -1  0 -2 -1 -1 -1 -1 -2 -1  1  0 -3 -2  0 -2 -1  0 -4
    R -1  5  0 -2 -3  1  0 -2  0 -3 -2  2 -1 -3 -2 -1 -1 -3 -2 -3 -1  0 -1 -4
    ...
    B -2 -1  3  4 -3  0  1 -1  0 -3 -4  0 -3 -3 -2  0 -1 -4 -3 -3  4  1 -1 -4
    Z -1  0  0  1 -3  3  4 -2  0 -3 -3  1 -1 -3 -1  0 -1 -3 -2 -2  1  4 -1 -4
    X  0 -1 -1 -1 -2 -1 -1 -1 -1 -1 -1 -1 -1 -1 -2  0  0 -2 -1 -1 -1 -1 -1 -4
    * -4 -4 -4 -4 -4 -4 -4 -4 -4 -4 -4 -4 -4 -4 -4 -4 -4 -4 -4 -4 -4 -4 -4  1
 
Matrices are expected to follow this format. They must have one row an one column for each defined character (not necessarily in the same order). Each row and column must start with a distinct character (no repetition) and all row characters must have a correspondent column, and vice versa.
Value at position (i,j) represent the score of substituting character of row i for
 character of column j. Insertion penalties are specified by the last row while deletion
 penalties must be located at the last column (both represented by the special character
 defined by the INDEL_CHAR constant). Note that it only supports an
 additive gap cost function. In case any of this rules are not followed, an
 InvalidScoringMatrixException exception is raised by the constructor.
If a scoring operation (substitution, insertion or deletion) involves a character not found in the matrix, an exception is raised.
InvalidScoringMatrixException| Field Summary | |
| protected  java.lang.String | col_codesStores matrix column headers in the order they were found. | 
| protected static char | COMMENT_CHARThe character used to start a comment line in the scoring matrix file. | 
| protected  int | dimensionDimension of the (squared) matrix. | 
| protected static char | INDEL_CHARThe character that indicates the row and column for insertion and deletion penalties in the matrix. | 
| protected  int[][] | matrixStores values for each operation (substitution, insertion or deletion) defined by this matrix. | 
| protected  int | max_absolute_scoreThe maximum absolute score that this matrix can return for any substitution, deletion or insertion. | 
| protected  java.lang.String | row_codesStores matrix row headers in the order they were found. | 
| Fields inherited from class neobio.alignment.ScoringScheme | 
| case_sensitive | 
| Constructor Summary | |
| ScoringMatrix(java.io.Reader input)Creates a new instance of a substitution matrix loaded from the character stream. | |
| ScoringMatrix(java.io.Reader input,
                           boolean case_sensitive)Creates a new instance of a substitution matrix loaded from the character stream. | |
| Method Summary | |
|  boolean | isPartialMatchSupported()Tells whether this scoring scheme supports partial matches, which it does, although a particular scoring matrix loaded by this instace might not. | 
|  int | maxAbsoluteScore()Returns the maximum absolute score that this scoring scheme can return for any substitution, deletion or insertion. | 
|  int | scoreDeletion(char a)Returns the score of a deletion of character aaccording to this
 scoring matrix. | 
|  int | scoreInsertion(char a)Returns the score of an insertion of character aaccording to this
 scoring matrix. | 
|  int | scoreSubstitution(char a,
                                   char b)Returns the score of a substitution of character afor characterbaccording to this scoring matrix. | 
|  java.lang.String | toString()Returns a String representation of this scoring matrix. | 
| Methods inherited from class neobio.alignment.ScoringScheme | 
| isCaseSensitive | 
| Methods inherited from class java.lang.Object | 
| clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait | 
| Field Detail | 
protected static final char INDEL_CHAR
protected static final char COMMENT_CHAR
protected java.lang.String col_codes
protected java.lang.String row_codes
protected int[][] matrix
protected int dimension
protected int max_absolute_score
| Constructor Detail | 
public ScoringMatrix(java.io.Reader input)
              throws java.io.IOException,
                     InvalidScoringMatrixException
input - character stream from where the matrix is read
java.io.IOException - if an I/O operation fails when reading from input
InvalidScoringMatrixException - if the matrix does not comply with the
 specification
public ScoringMatrix(java.io.Reader input,
                     boolean case_sensitive)
              throws java.io.IOException,
                     InvalidScoringMatrixException
case_sensitive is true, the case of characters is
 significant when subsequently computing their score; otherwise the case is
 ignored.
input - character stream from where the matrix is readcase_sensitive - true if the case of characters must be
java.io.IOException - if an I/O operation fails when reading from input
InvalidScoringMatrixException - if the matrix does not comply with the
 specification| Method Detail | 
public int scoreSubstitution(char a,
                             char b)
                      throws IncompatibleScoringSchemeException
a for character
 b according to this scoring matrix.
scoreSubstitution in class ScoringSchemea - first characterb - second character
a for b
IncompatibleScoringSchemeException - if this substitution is not defined
public int scoreInsertion(char a)
                   throws IncompatibleScoringSchemeException
a according to this
 scoring matrix.
scoreInsertion in class ScoringSchemea - character to be inserted
a
IncompatibleScoringSchemeException - if this character is not recognised
public int scoreDeletion(char a)
                  throws IncompatibleScoringSchemeException
a according to this
 scoring matrix.
scoreDeletion in class ScoringSchemea - character to be deleted
a
IncompatibleScoringSchemeException - if this character is not recognisedpublic boolean isPartialMatchSupported()
isPartialMatchSupported in class ScoringSchemetruepublic int maxAbsoluteScore()
maxAbsoluteScore in class ScoringSchemepublic java.lang.String toString()
toString in class java.lang.Object| 
 |  | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||