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 StringgetComment()CompoundSet<AminoAcidCompound>getCompoundSet()Returns theCompoundSeton which the matrix is defined.StringgetDescription()Returns the description of this matrix.short[][]getMatrix()Returns entire matrix.StringgetMatrixAsString()Returns this matrix as a formatted String withCompoundlabels along the axes.shortgetMax()shortgetMaxValue()Returns the maximum value in this matrix.shortgetMin()shortgetMinValue()Returns the minimum value in this matrix.StringgetName()Returns the name (short description) of this matrix.Map<AminoAcidCompound,Short>getRow(AminoAcidCompound row)List<AminoAcidCompound>getRows()intgetScale()shortgetValue(AminoAcidCompound from, AminoAcidCompound to)Returns value in matrix for conversion from firstCompoundto the second.SubstitutionMatrix<AminoAcidCompound>normalizeMatrix(short scale)Rescales the matrix so that toSubstitutionMatrix.getMaxValue()-SubstitutionMatrix.getMinValue()= scale.voidsetCols(List<AminoAcidCompound> cols)voidsetDescription(String description)Sets the description of this matrix.voidsetMatrix(short[][] matrix)voidsetMax(short max)voidsetMin(short min)voidsetName(String name)Sets the name (short description) of this matrix.voidsetRows(List<AminoAcidCompound> rows)voidsetScale(int scale)StringtoString()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:SubstitutionMatrixReturns the description of this matrix.- Specified by:
getDescriptionin interfaceSubstitutionMatrix<AminoAcidCompound>- Returns:
- description
-
setDescription
public void setDescription(String description)
Description copied from interface:SubstitutionMatrixSets the description of this matrix.- Specified by:
setDescriptionin interfaceSubstitutionMatrix<AminoAcidCompound>- Parameters:
description- new description
-
getName
public String getName()
Description copied from interface:SubstitutionMatrixReturns the name (short description) of this matrix.- Specified by:
getNamein interfaceSubstitutionMatrix<AminoAcidCompound>- Returns:
- name
-
setName
public void setName(String name)
Description copied from interface:SubstitutionMatrixSets the name (short description) of this matrix.- Specified by:
setNamein interfaceSubstitutionMatrix<AminoAcidCompound>- Parameters:
name- new name
-
getMatrix
public short[][] getMatrix()
Description copied from interface:SubstitutionMatrixReturns entire matrix.- Specified by:
getMatrixin 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:SubstitutionMatrixReturns theCompoundSeton which the matrix is defined.- Specified by:
getCompoundSetin interfaceSubstitutionMatrix<AminoAcidCompound>- Returns:
- the
CompoundSeton which the matrix is defined
-
getMatrixAsString
public String getMatrixAsString()
Description copied from interface:SubstitutionMatrixReturns this matrix as a formatted String withCompoundlabels along the axes.- Specified by:
getMatrixAsStringin interfaceSubstitutionMatrix<AminoAcidCompound>- Returns:
- this matrix as a formatted String
-
getMaxValue
public short getMaxValue()
Description copied from interface:SubstitutionMatrixReturns the maximum value in this matrix.- Specified by:
getMaxValuein interfaceSubstitutionMatrix<AminoAcidCompound>- Returns:
- the maximum value in this matrix
-
getMinValue
public short getMinValue()
Description copied from interface:SubstitutionMatrixReturns the minimum value in this matrix.- Specified by:
getMinValuein interfaceSubstitutionMatrix<AminoAcidCompound>- Returns:
- the minimum value in this matrix
-
getValue
public short getValue(AminoAcidCompound from, AminoAcidCompound to)
Description copied from interface:SubstitutionMatrixReturns value in matrix for conversion from firstCompoundto the second. If an argument does not belong to theCompoundSet, this could either throw anIllegalArgumentExceptionor it could returnSubstitutionMatrix.getMinValue().- Specified by:
getValuein interfaceSubstitutionMatrix<AminoAcidCompound>- Parameters:
from- originalCompoundto- replacementCompound- Returns:
- value in matrix for conversion from first
Compoundto the second
-
normalizeMatrix
public SubstitutionMatrix<AminoAcidCompound> normalizeMatrix(short scale)
Description copied from interface:SubstitutionMatrixRescales the matrix so that toSubstitutionMatrix.getMaxValue()-SubstitutionMatrix.getMinValue()= scale.- Specified by:
normalizeMatrixin interfaceSubstitutionMatrix<AminoAcidCompound>- Parameters:
scale- new normalization scale of this matrix
-
getRow
public Map<AminoAcidCompound,Short> getRow(AminoAcidCompound row)
- Specified by:
getRowin interfaceSubstitutionMatrix<AminoAcidCompound>
-
getColumn
public Map<AminoAcidCompound,Short> getColumn(AminoAcidCompound column)
- Specified by:
getColumnin interfaceSubstitutionMatrix<AminoAcidCompound>
-
-