Class ScaledSubstitutionMatrix
- java.lang.Object
-
- org.biojava.nbio.core.alignment.matrices.ScaledSubstitutionMatrix
-
- All Implemented Interfaces:
SubstitutionMatrix<AminoAcidCompound>
public class ScaledSubstitutionMatrix extends Object implements SubstitutionMatrix<AminoAcidCompound>
The biojava-alignment module represents substitution matrices with short values. This is for performance reasons. Some substitution matrices, however, are provided as float values with up to 2 decimal places.In order to be able to use them in the alignment module these are scaled in order to be able to represent as short values. The method
getScale()
provides access to the scaling factor.- Author:
- Andreas Prlic
-
-
Constructor Summary
Constructors Constructor Description ScaledSubstitutionMatrix()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description List<AminoAcidCompound>
getCols()
Map<AminoAcidCompound,Short>
getColumn(AminoAcidCompound column)
static String
getComment()
CompoundSet<AminoAcidCompound>
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
getMax()
short
getMaxValue()
Returns the maximum value in this matrix.short
getMin()
short
getMinValue()
Returns the minimum value in this matrix.String
getName()
Returns the name (short description) of this matrix.Map<AminoAcidCompound,Short>
getRow(AminoAcidCompound row)
List<AminoAcidCompound>
getRows()
int
getScale()
short
getValue(AminoAcidCompound from, AminoAcidCompound to)
Returns value in matrix for conversion from firstCompound
to the second.SubstitutionMatrix<AminoAcidCompound>
normalizeMatrix(short scale)
Rescales the matrix so that toSubstitutionMatrix.getMaxValue()
-SubstitutionMatrix.getMinValue()
= scale.void
setCols(List<AminoAcidCompound> cols)
void
setDescription(String description)
Sets the description of this matrix.void
setMatrix(short[][] matrix)
void
setMax(short max)
void
setMin(short min)
void
setName(String name)
Sets the name (short description) of this matrix.void
setRows(List<AminoAcidCompound> rows)
void
setScale(int scale)
String
toString()
Returns in a format similar to the standard NCBI files.
-
-
-
Constructor Detail
-
ScaledSubstitutionMatrix
public ScaledSubstitutionMatrix()
-
-
Method Detail
-
getScale
public int getScale()
-
setScale
public void setScale(int scale)
-
getDescription
public String getDescription()
Description copied from interface:SubstitutionMatrix
Returns the description of this matrix.- Specified by:
getDescription
in interfaceSubstitutionMatrix<AminoAcidCompound>
- Returns:
- description
-
setDescription
public void setDescription(String description)
Description copied from interface:SubstitutionMatrix
Sets the description of this matrix.- Specified by:
setDescription
in interfaceSubstitutionMatrix<AminoAcidCompound>
- Parameters:
description
- new description
-
getName
public String getName()
Description copied from interface:SubstitutionMatrix
Returns the name (short description) of this matrix.- Specified by:
getName
in interfaceSubstitutionMatrix<AminoAcidCompound>
- Returns:
- name
-
setName
public void setName(String name)
Description copied from interface:SubstitutionMatrix
Sets the name (short description) of this matrix.- Specified by:
setName
in interfaceSubstitutionMatrix<AminoAcidCompound>
- Parameters:
name
- new name
-
getMatrix
public short[][] getMatrix()
Description copied from interface:SubstitutionMatrix
Returns entire matrix.- Specified by:
getMatrix
in interfaceSubstitutionMatrix<AminoAcidCompound>
- Returns:
- matrix
-
setMatrix
public void setMatrix(short[][] matrix)
-
getMax
public short getMax()
-
setMax
public void setMax(short max)
-
getMin
public short getMin()
-
setMin
public void setMin(short min)
-
getRows
public List<AminoAcidCompound> getRows()
-
setRows
public void setRows(List<AminoAcidCompound> rows)
-
getCols
public List<AminoAcidCompound> getCols()
-
setCols
public void setCols(List<AminoAcidCompound> cols)
-
getComment
public static String getComment()
-
getCompoundSet
public CompoundSet<AminoAcidCompound> getCompoundSet()
Description copied from interface:SubstitutionMatrix
Returns theCompoundSet
on which the matrix is defined.- Specified by:
getCompoundSet
in interfaceSubstitutionMatrix<AminoAcidCompound>
- Returns:
- the
CompoundSet
on which the matrix is defined
-
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<AminoAcidCompound>
- 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<AminoAcidCompound>
- 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<AminoAcidCompound>
- Returns:
- the minimum value in this matrix
-
getValue
public short getValue(AminoAcidCompound from, AminoAcidCompound 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()
.- Specified by:
getValue
in interfaceSubstitutionMatrix<AminoAcidCompound>
- Parameters:
from
- originalCompound
to
- replacementCompound
- Returns:
- value in matrix for conversion from first
Compound
to the second
-
normalizeMatrix
public SubstitutionMatrix<AminoAcidCompound> normalizeMatrix(short scale)
Description copied from interface:SubstitutionMatrix
Rescales the matrix so that toSubstitutionMatrix.getMaxValue()
-SubstitutionMatrix.getMinValue()
= scale.- Specified by:
normalizeMatrix
in interfaceSubstitutionMatrix<AminoAcidCompound>
- Parameters:
scale
- new normalization scale of this matrix
-
getRow
public Map<AminoAcidCompound,Short> getRow(AminoAcidCompound row)
- Specified by:
getRow
in interfaceSubstitutionMatrix<AminoAcidCompound>
-
getColumn
public Map<AminoAcidCompound,Short> getColumn(AminoAcidCompound column)
- Specified by:
getColumn
in interfaceSubstitutionMatrix<AminoAcidCompound>
-
-