Class SimpleSubstitutionMatrix<C extends Compound>
- java.lang.Object
-
- org.biojava.nbio.core.alignment.matrices.SimpleSubstitutionMatrix<C>
-
- Type Parameters:
C
- each element of the matrix corresponds to a pair ofCompound
s of type C
- All Implemented Interfaces:
Serializable
,SubstitutionMatrix<C>
public class SimpleSubstitutionMatrix<C extends Compound> extends Object implements SubstitutionMatrix<C>, Serializable
Implements a data structure which holds the score (penalty or bonus) given during alignment for the exchange of oneCompound
in a sequence for another.- Author:
- Mark Chapman, Daniel Cameron, Paolo Pavan
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description SimpleSubstitutionMatrix(CompoundSet<C> compoundSet, short match, short replace)
Creates an identity substitution matrix from match and replace values.SimpleSubstitutionMatrix(CompoundSet<C> compoundSet, File fileInput)
Creates a substitution matrix by reading in a file.SimpleSubstitutionMatrix(CompoundSet<C> compoundSet, Reader input, String name)
Creates a substitution matrix by parsing some input.SimpleSubstitutionMatrix(CompoundSet<C> compoundSet, String matrixInput, String name)
Creates a substitution matrix by parsing a String.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static SubstitutionMatrix<AminoAcidCompound>
getBlosum62()
Map<C,Short>
getColumn(C column)
CompoundSet<C>
getCompoundSet()
Returns theCompoundSet
on which the matrix is defined.String
getDescription()
Returns the description of this matrix.short[][]
getMatrix()
Returns entire matrix.String
getMatrixAsString()
Returns this matrix as a formatted String withCompound
labels along the axes.short
getMaxValue()
Returns the maximum value in this matrix.short
getMinValue()
Returns the minimum value in this matrix.String
getName()
Returns the name (short description) of this matrix.Map<C,Short>
getRow(C row)
short
getValue(C from, C to)
Returns value in matrix for conversion from firstCompound
to the second.SubstitutionMatrix<C>
normalizeMatrix(short scale)
Rescales the matrix so that toSubstitutionMatrix.getMaxValue()
-SubstitutionMatrix.getMinValue()
= scale.void
setDescription(String description)
Sets the description of this matrix.void
setName(String name)
Sets the name (short description) of this matrix.String
toString()
Returns in a format similar to the standard NCBI files.
-
-
-
Constructor Detail
-
SimpleSubstitutionMatrix
public SimpleSubstitutionMatrix(CompoundSet<C> compoundSet, File fileInput) throws FileNotFoundException
Creates a substitution matrix by reading in a file.- Parameters:
compoundSet
- theCompoundSet
on which the matrix is definedfileInput
- file parsed for a substitution matrix- Throws:
FileNotFoundException
- if fileInput parameter cannot be read
-
SimpleSubstitutionMatrix
public SimpleSubstitutionMatrix(CompoundSet<C> compoundSet, Reader input, String name)
Creates a substitution matrix by parsing some input.- Parameters:
compoundSet
- theCompoundSet
on which the matrix is definedinput
- input parsed for a substitution matrixname
- the name (short description) of this matrix
-
SimpleSubstitutionMatrix
public SimpleSubstitutionMatrix(CompoundSet<C> compoundSet, String matrixInput, String name)
Creates a substitution matrix by parsing a String.- Parameters:
compoundSet
- theCompoundSet
on which the matrix is definedmatrixInput
- String parsed for a substitution matrixname
- the name (short description) of this matrix
-
SimpleSubstitutionMatrix
public SimpleSubstitutionMatrix(CompoundSet<C> compoundSet, short match, short replace)
Creates an identity substitution matrix from match and replace values.- Parameters:
compoundSet
- theCompoundSet
on which the matrix is definedmatch
- matrix value used for equivalentCompound
sreplace
- matrix value used for differingCompound
s
-
-
Method Detail
-
getBlosum62
public static SubstitutionMatrix<AminoAcidCompound> getBlosum62()
-
getCompoundSet
public CompoundSet<C> getCompoundSet()
Description copied from interface:SubstitutionMatrix
Returns theCompoundSet
on which the matrix is defined.- Specified by:
getCompoundSet
in interfaceSubstitutionMatrix<C extends Compound>
- Returns:
- the
CompoundSet
on which the matrix is defined
-
getDescription
public String getDescription()
Description copied from interface:SubstitutionMatrix
Returns the description of this matrix.- Specified by:
getDescription
in interfaceSubstitutionMatrix<C extends Compound>
- Returns:
- description
-
getMatrix
public short[][] getMatrix()
Description copied from interface:SubstitutionMatrix
Returns entire matrix.- Specified by:
getMatrix
in interfaceSubstitutionMatrix<C extends Compound>
- Returns:
- matrix
-
getMatrixAsString
public String getMatrixAsString()
Description copied from interface:SubstitutionMatrix
Returns this matrix as a formatted String withCompound
labels along the axes.- Specified by:
getMatrixAsString
in interfaceSubstitutionMatrix<C extends Compound>
- Returns:
- this matrix as a formatted String
-
getMaxValue
public short getMaxValue()
Description copied from interface:SubstitutionMatrix
Returns the maximum value in this matrix.- Specified by:
getMaxValue
in interfaceSubstitutionMatrix<C extends Compound>
- Returns:
- the maximum value in this matrix
-
getMinValue
public short getMinValue()
Description copied from interface:SubstitutionMatrix
Returns the minimum value in this matrix.- Specified by:
getMinValue
in interfaceSubstitutionMatrix<C extends Compound>
- Returns:
- the minimum value in this matrix
-
getName
public String getName()
Description copied from interface:SubstitutionMatrix
Returns the name (short description) of this matrix.- Specified by:
getName
in interfaceSubstitutionMatrix<C extends Compound>
- Returns:
- name
-
getValue
public short getValue(C from, C to)
Description copied from interface:SubstitutionMatrix
Returns value in matrix for conversion from firstCompound
to the second. If an argument does not belong to theCompoundSet
, this could either throw anIllegalArgumentException
or it could returnSubstitutionMatrix.getMinValue()
.
-
normalizeMatrix
public SubstitutionMatrix<C> normalizeMatrix(short scale)
Description copied from interface:SubstitutionMatrix
Rescales the matrix so that toSubstitutionMatrix.getMaxValue()
-SubstitutionMatrix.getMinValue()
= scale.- Specified by:
normalizeMatrix
in interfaceSubstitutionMatrix<C extends Compound>
- Parameters:
scale
- new normalization scale of this matrix
-
setDescription
public void setDescription(String description)
Description copied from interface:SubstitutionMatrix
Sets the description of this matrix.- Specified by:
setDescription
in interfaceSubstitutionMatrix<C extends Compound>
- Parameters:
description
- new description
-
setName
public void setName(String name)
Description copied from interface:SubstitutionMatrix
Sets the name (short description) of this matrix.- Specified by:
setName
in interfaceSubstitutionMatrix<C extends Compound>
- Parameters:
name
- new name
-
getRow
public Map<C,Short> getRow(C row)
- Specified by:
getRow
in interfaceSubstitutionMatrix<C extends Compound>
-
-