vg
tools for working with variation graphs
Public Member Functions | Public Attributes | Private Member Functions | Static Private Member Functions | Private Attributes | List of all members
vg::LoggedGapAlignmentScorer Class Reference

#include <logged_gap_alignment_scorer.hpp>

Inheritance diagram for vg::LoggedGapAlignmentScorer:
vg::AlignmentScorer

Public Member Functions

 LoggedGapAlignmentScorer (const Alignment &standard, double gc_content=default_gc_content)
 
int32_t score_alignment (const Alignment &aln) const override
 
double get_log_base () const override
 
- Public Member Functions inherited from vg::AlignmentScorer
virtual ~AlignmentScorer ()=default
 

Public Attributes

const size_t matches
 Number of matches in the standard alignment. More...
 
const size_t mismatches
 Number of mismatches in the standard alignment. More...
 
const std::vector< size_t > gap_lengths
 Lengths of all gaps in the standard alignment. More...
 
const double match = 1.0
 Marginal per-base match score under this scheme. Always 1.0. More...
 
const double mismatch
 Marginal per-base mismatch (and per-gap-open) score under this scheme. More...
 

Private Member Functions

 LoggedGapAlignmentScorer (const Alignment &standard, std::tuple< size_t, size_t, std::vector< size_t >> &&operation_counts, double gc_content=default_gc_content)
 Build a LoggedGapAlignmentScorer with precomputed operation counts. More...
 
int32_t score_from_counts (size_t matches, size_t mismatches, const std::vector< size_t > &gap_lengths) const
 Score a precomputed set of edit counts under this scheme. More...
 

Static Private Member Functions

static void count_alignment_operations (const Alignment &aln, size_t &matches, size_t &mismatches, std::vector< size_t > &gap_lengths)
 Walk an alignment and count matches, mismatches, and per-gap lengths. More...
 
static std::tuple< size_t, size_t, std::vector< size_t > > count_alignment_operations (const Alignment &aln)
 
static double compute_divergence (size_t matches, size_t mismatches, const std::vector< size_t > &gap_lengths)
 Helper function to compute the divergence estimate from edit information. More...
 

Private Attributes

const double divergence
 
double log_base
 Log base for interpreting scores. More...
 
const Alignmentstandard_address
 Address where the standard alignment is, so we can recognize it later. 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

Scorer implementing the minimap2 long-indel rescoring formula (Heng Li, Bioinformatics 2021, doi:10.1093/bioinformatics/btab705).

Constructed from a "standard" alignment that defines the scoring scheme. minimap2 only ever applies the scoring scheme back to that same alignment, but we allow applying it to others.

The case of applying the scoring scheme back to the standard alignment is handled specially for speed; you MUST NOT apply the scorer to a different alignment at the same address as the standard alignment. (An easy way to ensure this is to ensure that the standard alignment outlives this object and is not modified.)

Hides everything about the empirical minimap2 formula inside the class.

Constructor & Destructor Documentation

◆ LoggedGapAlignmentScorer() [1/2]

vg::LoggedGapAlignmentScorer::LoggedGapAlignmentScorer ( const Alignment standard,
double  gc_content = default_gc_content 
)
explicit

Construct a LoggedGapAlignmentScorer using the scoring scheme defined by standard.

standard must not be deallocated or modified between construction and any call to score_alignment() on any alignment at that address, because pointer identity is used to recognize that operations are on the standard alignment.

◆ LoggedGapAlignmentScorer() [2/2]

vg::LoggedGapAlignmentScorer::LoggedGapAlignmentScorer ( const Alignment standard,
std::tuple< size_t, size_t, std::vector< size_t >> &&  operation_counts,
double  gc_content = default_gc_content 
)
private

Build a LoggedGapAlignmentScorer with precomputed operation counts.

Member Function Documentation

◆ compute_divergence()

double vg::LoggedGapAlignmentScorer::compute_divergence ( size_t  matches,
size_t  mismatches,
const std::vector< size_t > &  gap_lengths 
)
staticprivate

Helper function to compute the divergence estimate from edit information.

◆ count_alignment_operations() [1/2]

std::tuple< size_t, size_t, std::vector< size_t > > vg::LoggedGapAlignmentScorer::count_alignment_operations ( const Alignment aln)
staticprivate

Walk an alignment and count matches, mismatches, and per-gap lengths. Returns the result in a format usable to construct a LoggedGapAlignmentScorer

◆ count_alignment_operations() [2/2]

void vg::LoggedGapAlignmentScorer::count_alignment_operations ( const Alignment aln,
size_t &  matches,
size_t &  mismatches,
std::vector< size_t > &  gap_lengths 
)
staticprivate

Walk an alignment and count matches, mismatches, and per-gap lengths.

◆ get_log_base()

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

Get the log base value used to probabilistically interpret scores. Implementations probably need to have a stores GC content to implement this.

Implements vg::AlignmentScorer.

◆ score_alignment()

int32_t vg::LoggedGapAlignmentScorer::score_alignment ( const Alignment aln) const
overridevirtual

Score an alignment under this scheme. Guaranteed to be O(1) when aln is at the address of standard.

Implements vg::AlignmentScorer.

◆ score_from_counts()

int32_t vg::LoggedGapAlignmentScorer::score_from_counts ( size_t  matches,
size_t  mismatches,
const std::vector< size_t > &  gap_lengths 
) const
private

Score a precomputed set of edit counts under this scheme.

Member Data Documentation

◆ divergence

const double vg::LoggedGapAlignmentScorer::divergence
private

Estimate of the divergence (what minimap2 calls "d"). This is used to initialize mismatch, and depends on the statistics, and so MUST appear between them.

◆ gap_lengths

const std::vector<size_t> vg::LoggedGapAlignmentScorer::gap_lengths

Lengths of all gaps in the standard alignment.

◆ log_base

double vg::LoggedGapAlignmentScorer::log_base
private

Log base for interpreting scores.

◆ match

const double vg::LoggedGapAlignmentScorer::match = 1.0

Marginal per-base match score under this scheme. Always 1.0.

◆ matches

const size_t vg::LoggedGapAlignmentScorer::matches

Number of matches in the standard alignment.

◆ mismatch

const double vg::LoggedGapAlignmentScorer::mismatch

Marginal per-base mismatch (and per-gap-open) score under this scheme.

◆ mismatches

const size_t vg::LoggedGapAlignmentScorer::mismatches

Number of mismatches in the standard alignment.

◆ standard_address

const Alignment* vg::LoggedGapAlignmentScorer::standard_address
private

Address where the standard alignment is, so we can recognize it later.


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