public class SubstitutionMatrix
extends java.lang.Object
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.
| Modifier and Type | Field and Description |
|---|---|
protected FiniteAlphabet |
alphabet |
protected java.util.Map<Symbol,java.lang.Integer> |
colSymbols |
protected java.lang.String |
description |
protected short[][] |
matrix |
protected short |
max |
protected short |
min |
protected java.lang.String |
name |
protected java.util.Map<Symbol,java.lang.Integer> |
rowSymbols |
| Constructor and Description |
|---|
SubstitutionMatrix(java.io.File file)
This constructor can be used to guess the alphabet of this substitution
matrix.
|
SubstitutionMatrix(FiniteAlphabet alpha,
java.io.File matrixFile)
This constructs a
SubstitutionMatrix object that contains
two Map data structures having BioJava symbols as keys and
the value being the index of the matrix containing the substitution score. |
SubstitutionMatrix(FiniteAlphabet alpha,
short match,
short replace)
Constructs a SubstitutionMatrix with every Match and every Replace having
the same expenses given by the parameters.
|
SubstitutionMatrix(FiniteAlphabet alpha,
java.lang.String matrixString,
java.lang.String name)
With this constructor it is possible to construct a SubstitutionMatrix
object from a substitution matrix file.
|
| Modifier and Type | Method and Description |
|---|---|
FiniteAlphabet |
getAlphabet()
Gives the alphabet used by this matrix.
|
java.lang.String |
getDescription()
This gives you the description of this matrix if there is one.
|
short |
getMax()
The maximum score in this matrix.
|
short |
getMin()
The minimum score of this matrix.
|
java.lang.String |
getName()
Every substitution matrix has a name like "BLOSUM30" or "PAM160".
|
static SubstitutionMatrix |
getSubstitutionMatrix(java.io.BufferedReader reader)
This constructor can be used to guess the alphabet of this substitution
matrix.
|
short |
getValueAt(Symbol row,
Symbol col)
There are some substitution matrices containing more columns than lines.
|
SubstitutionMatrix |
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. |
void |
printMatrix()
Just to perform some test.
|
void |
setDescription(java.lang.String desc)
Sets the description to the given value.
|
java.lang.String |
stringnifyDescription()
Converts the description of the matrix to a String.
|
java.lang.String |
stringnifyMatrix()
Creates a
String representation of this matrix. |
java.lang.String |
toString()
Overrides the inherited method.
|
protected java.util.Map<Symbol,java.lang.Integer> rowSymbols
protected java.util.Map<Symbol,java.lang.Integer> colSymbols
protected short[][] matrix
protected short min
protected short max
protected FiniteAlphabet alphabet
protected java.lang.String description
protected java.lang.String name
public SubstitutionMatrix(FiniteAlphabet alpha, java.io.File matrixFile) throws BioException, java.lang.NumberFormatException, java.io.IOException
SubstitutionMatrix object that contains
two Map data structures having BioJava symbols as keys and
the value being the index of the matrix containing the substitution score.alpha - the alphabet of the matrix (e.g., DNA, RNA or PROTEIN, or
PROTEIN-TERM)matrixFile - the file containing the substitution matrix. Lines starting with '#'
are comments. The line starting with a white space, is the table
head. Every line has to start with the one letter representation
of the Symbol and then the values for the exchange.java.io.IOExceptionBioExceptionjava.lang.NumberFormatExceptionpublic SubstitutionMatrix(FiniteAlphabet alpha, java.lang.String matrixString, java.lang.String name) throws BioException, java.lang.NumberFormatException, java.io.IOException
System.getProperty("line.separator").
Everything else is the same than for the constructor above.alpha - The FiniteAlphabet to usematrixString - name - of the matrix.BioExceptionjava.io.IOExceptionjava.lang.NumberFormatExceptionpublic SubstitutionMatrix(FiniteAlphabet alpha, short match, short replace)
alpha - match - replace - public SubstitutionMatrix(java.io.File file)
throws java.lang.NumberFormatException,
java.util.NoSuchElementException,
BioException,
java.io.IOException
file - A file containing a substitution matrix.java.lang.NumberFormatExceptionjava.util.NoSuchElementExceptionBioExceptionjava.io.IOExceptionpublic static SubstitutionMatrix getSubstitutionMatrix(java.io.BufferedReader reader) throws java.lang.NumberFormatException, BioException, java.io.IOException
reader - java.lang.NumberFormatExceptionBioExceptionjava.io.IOExceptionpublic short getValueAt(Symbol row, Symbol col) throws BioException
row - Symbol of the linecol - Symbol of the columnBioExceptionpublic java.lang.String getDescription()
public java.lang.String getName()
public short getMin()
public short getMax()
public void setDescription(java.lang.String desc)
desc - a description. This doesn't have to start with '#'.public FiniteAlphabet getAlphabet()
public java.lang.String stringnifyMatrix()
String representation of this matrix.public java.lang.String stringnifyDescription()
System.getProperty("line.separator").
Every line starts with #.public java.lang.String toString()
toString in class java.lang.Objectpublic void printMatrix()
public SubstitutionMatrix normalizeMatrix() throws BioException, java.lang.NumberFormatException, java.io.IOException
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.SubstitutionMatrix object given
by this substitution matrix. Because this uses an
short matrix, all values are scaled by 10.BioExceptionjava.io.IOExceptionjava.lang.NumberFormatException