Package htsjdk.samtools.cram.structure
Class SubstitutionMatrix
java.lang.Object
htsjdk.samtools.cram.structure.SubstitutionMatrix
Substitution matrix, used to represent base substitutions for reference-based CRAM
compression.
The matrix is stored internally in two forms; the packed/encoded form used for serialization,
and an expanded in-memory form used for fast bi-directional interconversion between bases and
substitution codes during read and write.
This implementation allows both upper and lower case versions of a given reference base
to be substituted with the same (upper case) substitute base (except for 'N', which is only
handled for upper case) although it does not *generate* substitutions for lower case reference
bases.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionSubstitutionMatrix
(byte[] matrix) Create a SubstitutionMatrix from a serialized byte arraySubstitutionMatrix
(List<CRAMCompressionRecord> records) Create a SubstitutionMatrix given a list of CramCompressionRecord -
Method Summary
Modifier and TypeMethodDescriptionbyte
base
(byte refBase, byte code) Given a reference base and a substitution code, return the corresponding substitution base.byte
code
(byte refBase, byte readBase) Given a reference base and a read base, find the corresponding substitution codebyte[]
Return this substitution matrix as a byte array in a form suitable for serialization.toString()
-
Field Details
-
BASES_SIZE
public static final int BASES_SIZE
-
-
Constructor Details
-
SubstitutionMatrix
Create a SubstitutionMatrix given a list of CramCompressionRecord- Parameters:
records
- array of CramCompressionRecord with Substitutions
-
SubstitutionMatrix
public SubstitutionMatrix(byte[] matrix) Create a SubstitutionMatrix from a serialized byte array- Parameters:
matrix
- serialized substitution matrix from a CRAM stream
-
-
Method Details
-
code
public byte code(byte refBase, byte readBase) Given a reference base and a read base, find the corresponding substitution code- Parameters:
refBase
- reference base being substitutedreadBase
- read base to substitute for the reference base- Returns:
- code to be used for this refBase/readBase pair
-
base
public byte base(byte refBase, byte code) Given a reference base and a substitution code, return the corresponding substitution base.- Parameters:
refBase
- reference base being substitutedcode
- substitution code- Returns:
- base to be substituted for this (refBase, code) pair
-
getEncodedMatrix
public byte[] getEncodedMatrix()Return this substitution matrix as a byte array in a form suitable for serialization.- Returns:
- the encoded matrix in serialized form
-
toString
-