vg
tools for working with variation graphs
Public Member Functions | Public Attributes | Protected Attributes | List of all members
vg::MatrixAlignmentScorer Class Reference

#include <alignment_scorer.hpp>

Inheritance diagram for vg::MatrixAlignmentScorer:
vg::EditAlignmentScorer vg::AlignmentScorer vg::QualAdjAlignmentScorer

Public Member Functions

 MatrixAlignmentScorer (const int8_t *score_matrix_4x4=default_score_matrix, int8_t gap_open=default_gap_open, int8_t gap_extension=default_gap_extension, int8_t full_length_bonus=default_full_length_bonus, double gc_content=default_gc_content)
 
 ~MatrixAlignmentScorer () override
 
 MatrixAlignmentScorer (const MatrixAlignmentScorer &)=delete
 
MatrixAlignmentScoreroperator= (const MatrixAlignmentScorer &)=delete
 
double get_log_base () const override
 Retrieve the log base value that was computed at construction. More...
 
int32_t score_exact_match (const Alignment &aln, size_t read_offset, size_t length) const override
 
int32_t score_exact_match (const std::string &sequence, const std::string &base_quality) const override
 
int32_t score_exact_match (std::string::const_iterator seq_begin, std::string::const_iterator seq_end, std::string::const_iterator base_qual_begin) const override
 
int32_t score_exact_match (const std::string &sequence) const
 Score an exact match of unspecified sequence and the given length. More...
 
int32_t score_exact_match (std::string::const_iterator seq_begin, std::string::const_iterator seq_end) const
 
int32_t score_mismatch (std::string::const_iterator seq_begin, std::string::const_iterator seq_end, std::string::const_iterator base_qual_begin) const override
 
int32_t score_mismatch (size_t length) const
 
int32_t score_full_length_bonus (bool left_side, std::string::const_iterator seq_begin, std::string::const_iterator seq_end, std::string::const_iterator base_qual_begin) const override
 
int32_t score_full_length_bonus (bool left_side, const Alignment &alignment) const override
 
int32_t score_partial_alignment (const Alignment &alignment, const HandleGraph &graph, const path_t &path, std::string::const_iterator seq_begin, bool no_read_end_scoring=false) const override
 
- Public Member Functions inherited from vg::EditAlignmentScorer
 EditAlignmentScorer (int8_t match=default_match, int8_t mismatch=default_mismatch, int8_t gap_open=default_gap_open, int8_t gap_extension=default_gap_extension, int8_t full_length_bonus=default_full_length_bonus)
 
int32_t score_alignment (const Alignment &aln) const override
 Score an alignment as a contiguous alignment, including full-length bonuses. More...
 
virtual int32_t score_gap (size_t gap_length) const
 Returns the score of an insert or deletion of the given length. More...
 
virtual int32_t score_discontiguous_alignment (const Alignment &aln, const std::function< size_t(pos_t, pos_t, size_t)> &estimate_distance, bool allow_left_bonus=true, bool allow_right_bonus=true) const
 
virtual int32_t score_contiguous_alignment (const Alignment &aln, bool allow_left_bonus=true, bool allow_right_bonus=true) const
 Score the given alignment assuming there are no gaps between Mappings. More...
 
virtual int32_t remove_bonuses (const Alignment &aln, bool pinned=false, bool pin_left=false) const
 
size_t longest_detectable_gap (const Alignment &alignment, const std::string::const_iterator &read_pos) const
 The longest gap detectable from a read position without soft-clipping. More...
 
size_t longest_detectable_gap (size_t read_length, size_t read_pos) const
 The longest gap detectable from a read position without soft-clipping, for a generic read. More...
 
size_t longest_detectable_gap (const Alignment &alignment) const
 The longest gap detectable from any read position without soft-clipping. More...
 
size_t longest_detectable_gap (size_t read_length) const
 The longest gap detectable from any read position without soft-clipping, for a generic read. More...
 
- Public Member Functions inherited from vg::AlignmentScorer
virtual ~AlignmentScorer ()=default
 

Public Attributes

int8_t * score_matrix
 
int8_t * nt_table
 Char->int nt translation. Owned by this class. More...
 
- Public Attributes inherited from vg::EditAlignmentScorer
int8_t match
 
int8_t mismatch
 
int8_t gap_open
 
int8_t gap_extension
 
int8_t full_length_bonus
 

Protected Attributes

double log_base
 We remember our computed log base. More...
 

Additional Inherited Members

- Static Protected Member Functions inherited from vg::AlignmentScorer
static double recover_log_base (const double matrix[16], double gc_content, double tol=1e-12)
 

Detailed Description

An alignment scorer that scores bassed on a score matrix.

Takes 4x4 matrices for construction, but internally uses 5x5 N-padded, GSSW-compatible matrices.

Constructor & Destructor Documentation

◆ MatrixAlignmentScorer() [1/2]

vg::MatrixAlignmentScorer::MatrixAlignmentScorer ( const int8_t *  score_matrix_4x4 = default_score_matrix,
int8_t  gap_open = default_gap_open,
int8_t  gap_extension = default_gap_extension,
int8_t  full_length_bonus = default_full_length_bonus,
double  gc_content = default_gc_content 
)

Build from a 4x4 substitution matrix and gap parameters.

Fills in the generic base match and mismatch values from the matrix.

◆ ~MatrixAlignmentScorer()

vg::MatrixAlignmentScorer::~MatrixAlignmentScorer ( )
override

◆ MatrixAlignmentScorer() [2/2]

vg::MatrixAlignmentScorer::MatrixAlignmentScorer ( const MatrixAlignmentScorer )
delete

Member Function Documentation

◆ get_log_base()

double vg::MatrixAlignmentScorer::get_log_base ( ) const
overridevirtual

Retrieve the log base value that was computed at construction.

Implements vg::AlignmentScorer.

◆ operator=()

MatrixAlignmentScorer& vg::MatrixAlignmentScorer::operator= ( const MatrixAlignmentScorer )
delete

◆ score_exact_match() [1/5]

int32_t vg::MatrixAlignmentScorer::score_exact_match ( const Alignment aln,
size_t  read_offset,
size_t  length 
) const
overridevirtual

Compute the score of an exact match in the given alignment, from the given offset, of the given length.

Implements vg::EditAlignmentScorer.

Reimplemented in vg::QualAdjAlignmentScorer.

◆ score_exact_match() [2/5]

int32_t vg::MatrixAlignmentScorer::score_exact_match ( const std::string &  sequence) const

Score an exact match of unspecified sequence and the given length.

◆ score_exact_match() [3/5]

int32_t vg::MatrixAlignmentScorer::score_exact_match ( const std::string &  sequence,
const std::string &  base_quality 
) const
overridevirtual

Compute the score of an exact match of the given sequence with the given qualities. Qualities may be ignored by some implementations.

Implements vg::EditAlignmentScorer.

Reimplemented in vg::QualAdjAlignmentScorer.

◆ score_exact_match() [4/5]

int32_t vg::MatrixAlignmentScorer::score_exact_match ( std::string::const_iterator  seq_begin,
std::string::const_iterator  seq_end 
) const

◆ score_exact_match() [5/5]

int32_t vg::MatrixAlignmentScorer::score_exact_match ( std::string::const_iterator  seq_begin,
std::string::const_iterator  seq_end,
std::string::const_iterator  base_qual_begin 
) const
overridevirtual

Compute the score of an exact match of the given range of sequence with the given qualities. Qualities may be ignored by some implementations.

Implements vg::EditAlignmentScorer.

Reimplemented in vg::QualAdjAlignmentScorer.

◆ score_full_length_bonus() [1/2]

int32_t vg::MatrixAlignmentScorer::score_full_length_bonus ( bool  left_side,
const Alignment alignment 
) const
overridevirtual

Compute the score bonus that would be achieved by a full-length alignment of the given end of the given read. Does not check whether that end actually has a full-lenght alignment.

Implements vg::EditAlignmentScorer.

Reimplemented in vg::QualAdjAlignmentScorer.

◆ score_full_length_bonus() [2/2]

int32_t vg::MatrixAlignmentScorer::score_full_length_bonus ( bool  left_side,
std::string::const_iterator  seq_begin,
std::string::const_iterator  seq_end,
std::string::const_iterator  base_qual_begin 
) const
overridevirtual

Compute the score bonus that would be achieved by a full-length alignment of the given end of the given read.

Implements vg::EditAlignmentScorer.

Reimplemented in vg::QualAdjAlignmentScorer.

◆ score_mismatch() [1/2]

int32_t vg::MatrixAlignmentScorer::score_mismatch ( size_t  length) const

Score a mismatch of unspecified sequence of the given length. This usually produces a negative score.

◆ score_mismatch() [2/2]

int32_t vg::MatrixAlignmentScorer::score_mismatch ( std::string::const_iterator  seq_begin,
std::string::const_iterator  seq_end,
std::string::const_iterator  base_qual_begin 
) const
overridevirtual

Compute the score of a mismatch of the given range of sequence with the given qualities. Qualities may be ignored by some implementations. Note that the return value is SIGNED, and almost certainly NEGATIVE, because mismatches are bad.

Implements vg::EditAlignmentScorer.

Reimplemented in vg::QualAdjAlignmentScorer.

◆ score_partial_alignment()

int32_t vg::MatrixAlignmentScorer::score_partial_alignment ( const Alignment alignment,
const HandleGraph graph,
const path_t path,
std::string::const_iterator  seq_begin,
bool  no_read_end_scoring = false 
) const
overridevirtual

Compute the score of a path against the given range of subsequence with the given qualities. The Alignment is just to find the sequence begin and end to compare to seq_begin. seq_begin is the first read base involved in the provided path to be scored.

Implements vg::EditAlignmentScorer.

Reimplemented in vg::QualAdjAlignmentScorer.

Member Data Documentation

◆ log_base

double vg::MatrixAlignmentScorer::log_base
protected

We remember our computed log base.

◆ nt_table

int8_t* vg::MatrixAlignmentScorer::nt_table

Char->int nt translation. Owned by this class.

◆ score_matrix

int8_t* vg::MatrixAlignmentScorer::score_matrix

5x5 GSSW-style N-padded matrix in row-major order, possibly with multiple levels. Owned by this class.

This class makes this a 5x5x1 matrix, but subclasses can make this have more dimensions.


The documentation for this class was generated from the following files: