Package htsjdk.samtools.cram.structure
Class SubstitutionMatrix
- java.lang.Object
-
- htsjdk.samtools.cram.structure.SubstitutionMatrix
-
public class SubstitutionMatrix extends Object
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 Modifier and Type Field Description static int
BASES_SIZE
-
Constructor Summary
Constructors Constructor Description SubstitutionMatrix(byte[] matrix)
Create a SubstitutionMatrix from a serialized byte arraySubstitutionMatrix(List<CRAMCompressionRecord> records)
Create a SubstitutionMatrix given a list of CramCompressionRecord
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description byte
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[]
getEncodedMatrix()
Return this substitution matrix as a byte array in a form suitable for serialization.String
toString()
-
-
-
Constructor Detail
-
SubstitutionMatrix
public SubstitutionMatrix(List<CRAMCompressionRecord> records)
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 Detail
-
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
-
-