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

#include <aligner.hpp>

Inheritance diagram for vg::Aligner:
vg::GSSWAligner vg::BaseAligner

Public Member Functions

 Aligner (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, double _gc_content=default_gc_content)
 
 Aligner (int8_t _match, int8_t _mismatch, int8_t _gap_open, int8_t _gap_extension, int8_t _full_length_bonus, double _gc_content, uint32_t _xdrop_max_gap_length)
 
 ~Aligner (void)=default
 
void align (Alignment &alignment, const HandleGraph &g, bool traceback_aln, bool print_score_matrices) const
 
void align (Alignment &alignment, const HandleGraph &g, const vector< handle_t > &topological_order, bool traceback_aln, bool print_score_matrices) const
 Same as previous, but takes advantage of a pre-computed topological order. More...
 
void align_pinned (Alignment &alignment, const HandleGraph &g, bool pin_left) const
 
void align_pinned (Alignment &alignment, const HandleGraph &g, const vector< handle_t > &topological_order, bool pin_left) const
 
void align_pinned_multi (Alignment &alignment, vector< Alignment > &alt_alignments, const HandleGraph &g, bool pin_left, int32_t max_alt_alns) const
 
void align_pinned_multi (Alignment &alignment, vector< Alignment > &alt_alignments, const HandleGraph &g, const vector< handle_t > &topological_order, bool pin_left, int32_t max_alt_alns) const
 
void align_global_banded (Alignment &alignment, const HandleGraph &g, int32_t band_padding=0, bool permissive_banding=true) const
 
void align_global_banded_multi (Alignment &alignment, vector< Alignment > &alt_alignments, const HandleGraph &g, int32_t max_alt_alns, int32_t band_padding=0, bool permissive_banding=true) const
 
void align_xdrop (Alignment &alignment, const HandleGraph &g, const vector< MaximalExactMatch > &mems, bool reverse_complemented) const
 
void align_xdrop_multi (Alignment &alignment, const HandleGraph &g, const vector< MaximalExactMatch > &mems, bool reverse_complemented, int32_t max_alt_alns) const
 
const XdropAlignerget_xdrop () const
 
int32_t score_exact_match (const Alignment &aln, size_t read_offset, size_t length) const
 
int32_t score_exact_match (const string &sequence, const string &base_quality) const
 
int32_t score_exact_match (string::const_iterator seq_begin, string::const_iterator seq_end, string::const_iterator base_qual_begin) const
 
int32_t score_exact_match (const string &sequence) const
 
int32_t score_exact_match (string::const_iterator seq_begin, string::const_iterator seq_end) const
 
int32_t score_mismatch (size_t length) const
 Score a mismatch given just the length. Only possible since we ignore qualities. More...
 
int32_t score_partial_alignment (const Alignment &alignment, const HandleGraph &graph, const Path &path, string::const_iterator seq_begin) const
 Compute the score of a path against the given range of subsequence with the given qualities. More...
 
- Public Member Functions inherited from vg::GSSWAligner
double max_possible_mapping_quality (int length) const
 
double estimate_max_possible_mapping_quality (int length, double min_diffs, double next_min_diffs) const
 
int32_t score_gap (size_t gap_length) const
 Returns the score of an insert or deletion of the given length. More...
 
void compute_mapping_quality (vector< Alignment > &alignments, int max_mapping_quality, bool fast_approximation, double cluster_mq, bool use_cluster_mq, int overlap_count, double mq_estimate, double maybe_mq_threshold, double identity_weight) const
 
void compute_paired_mapping_quality (pair< vector< Alignment >, vector< Alignment >> &alignment_pairs, const vector< double > &frag_weights, int max_mapping_quality1, int max_mapping_quality2, bool fast_approximation, double cluster_mq, bool use_cluster_mq, int overlap_count1, int overlap_count2, double mq_estimate1, double mq_estimate2, double maybe_mq_threshold, double identity_weight) const
 same function for paired reads, mapping qualities are stored in both alignments in the pair More...
 
int32_t compute_mapping_quality (const vector< double > &scores, bool fast_approximation, const vector< double > *multiplicities=nullptr) const
 
int32_t compute_group_mapping_quality (const vector< double > &scores, const vector< size_t > &group, const vector< double > *multiplicities=nullptr) const
 
double mapping_quality_score_diff (double mapping_quality) const
 
double score_to_unnormalized_likelihood_ln (double score) const
 
size_t longest_detectable_gap (const Alignment &alignment, const 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...
 
virtual int32_t score_gappy_alignment (const Alignment &aln, const function< size_t(pos_t, pos_t, size_t)> &estimate_distance, bool strip_bonuses=false) const
 
virtual int32_t score_ungapped_alignment (const Alignment &aln, bool strip_bonuses=false) const
 
virtual void load_scoring_matrix (std::istream &matrix_stream)
 
virtual int32_t remove_bonuses (const Alignment &aln, bool pinned=false, bool pin_left=false) const
 

Private Member Functions

void align_internal (Alignment &alignment, vector< Alignment > *multi_alignments, const HandleGraph &g, const vector< handle_t > *topological_order, bool pinned, bool pin_left, int32_t max_alt_alns, bool traceback_aln, bool print_score_matrices) const
 

Private Attributes

XdropAligner xdrop
 

Additional Inherited Members

- Static Public Member Functions inherited from vg::GSSWAligner
static double maximum_mapping_quality_exact (const vector< double > &scaled_scores, size_t *max_idx_out, const vector< double > *multiplicities=nullptr)
 
static double maximum_mapping_quality_approx (const vector< double > &scaled_scores, size_t *max_idx_out, const vector< double > *multiplicities=nullptr)
 
- Public Attributes inherited from vg::GSSWAligner
int8_t * nt_table = nullptr
 
int8_t * score_matrix = nullptr
 
int8_t match
 
int8_t mismatch
 
int8_t gap_open
 
int8_t gap_extension
 
int8_t full_length_bonus
 
double log_base = 0.0
 
- Protected Member Functions inherited from vg::GSSWAligner
 GSSWAligner ()=default
 
 ~GSSWAligner ()
 
gssw_graph * create_gssw_graph (const HandleGraph &g) const
 
gssw_graph * create_gssw_graph (const HandleGraph &g, const vector< handle_t > &topological_order) const
 
unordered_set< id_tidentify_pinning_points (const HandleGraph &graph) const
 
void unreverse_graph_mapping (gssw_graph_mapping *gm) const
 
void unreverse_graph (gssw_graph *graph) const
 
void gssw_mapping_to_alignment (gssw_graph *graph, gssw_graph_mapping *gm, Alignment &alignment, bool pinned, bool pin_left, bool print_score_matrices=false) const
 
string graph_cigar (gssw_graph_mapping *gm) const
 
double group_mapping_quality_exact (const vector< double > &scaled_scores, const vector< size_t > &group, const vector< double > *multiplicities=nullptr) const
 
double estimate_next_best_score (int length, double min_diffs) const
 
void init_mapping_quality (double gc_content)
 

Detailed Description

An ordinary aligner.

Constructor & Destructor Documentation

◆ Aligner() [1/2]

Aligner::Aligner ( 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,
double  _gc_content = default_gc_content 
)

◆ Aligner() [2/2]

Aligner::Aligner ( int8_t  _match,
int8_t  _mismatch,
int8_t  _gap_open,
int8_t  _gap_extension,
int8_t  _full_length_bonus,
double  _gc_content,
uint32_t  _xdrop_max_gap_length 
)

◆ ~Aligner()

vg::Aligner::~Aligner ( void  )
default

Member Function Documentation

◆ align() [1/2]

void Aligner::align ( Alignment alignment,
const HandleGraph g,
bool  traceback_aln,
bool  print_score_matrices 
) const
virtual

Store optimal local alignment against a graph in the Alignment object. Gives the full length bonus separately on each end of the alignment. Assumes that graph is topologically sorted by node index.

Implements vg::BaseAligner.

◆ align() [2/2]

void Aligner::align ( Alignment alignment,
const HandleGraph g,
const vector< handle_t > &  topological_order,
bool  traceback_aln,
bool  print_score_matrices 
) const
virtual

Same as previous, but takes advantage of a pre-computed topological order.

Implements vg::BaseAligner.

◆ align_global_banded()

void Aligner::align_global_banded ( Alignment alignment,
const HandleGraph g,
int32_t  band_padding = 0,
bool  permissive_banding = true 
) const
virtual

store optimal global alignment against a graph within a specified band in the Alignment object permissive banding auto detects the width of band needed so that paths can travel through every node in the graph

Implements vg::GSSWAligner.

◆ align_global_banded_multi()

void Aligner::align_global_banded_multi ( Alignment alignment,
vector< Alignment > &  alt_alignments,
const HandleGraph g,
int32_t  max_alt_alns,
int32_t  band_padding = 0,
bool  permissive_banding = true 
) const
virtual

store top scoring global alignments in the vector in descending score order up to a maximum number of alternate alignments (including the optimal alignment). if there are fewer than the maximum number of alignments in the return value, then the vector contains all possible alignments. the optimal alignment will be stored in both the vector and the original alignment object

Implements vg::GSSWAligner.

◆ align_internal()

void Aligner::align_internal ( Alignment alignment,
vector< Alignment > *  multi_alignments,
const HandleGraph g,
const vector< handle_t > *  topological_order,
bool  pinned,
bool  pin_left,
int32_t  max_alt_alns,
bool  traceback_aln,
bool  print_score_matrices 
) const
private

◆ align_pinned() [1/2]

void Aligner::align_pinned ( Alignment alignment,
const HandleGraph g,
bool  pin_left 
) const
virtual

store optimal alignment against a graph in the Alignment object with one end of the sequence guaranteed to align to a source/sink node

pinning left means that that the alignment starts with the first base of the read sequence and the first base of a source node sequence, pinning right means that the alignment starts with the final base of the read sequence and the final base of a sink node sequence

Gives the full length bonus only on the non-pinned end of the alignment.

Implements vg::GSSWAligner.

◆ align_pinned() [2/2]

void Aligner::align_pinned ( Alignment alignment,
const HandleGraph g,
const vector< handle_t > &  topological_order,
bool  pin_left 
) const
virtual

The topological order MUST be left to right, no matter whether you are pinning left or right. If alignment needs to proceed backward, it will be reversed internally.

Implements vg::GSSWAligner.

◆ align_pinned_multi() [1/2]

void Aligner::align_pinned_multi ( Alignment alignment,
vector< Alignment > &  alt_alignments,
const HandleGraph g,
bool  pin_left,
int32_t  max_alt_alns 
) const
virtual

store the top scoring pinned alignments in the vector in descending score order up to a maximum number of alignments (including the optimal one). if there are fewer than the maximum number in the return value, then it includes all alignments with a positive score. the optimal alignment will be stored in both the vector and in the main alignment object

assumes that graph is topologically sorted by node index

Implements vg::GSSWAligner.

◆ align_pinned_multi() [2/2]

void Aligner::align_pinned_multi ( Alignment alignment,
vector< Alignment > &  alt_alignments,
const HandleGraph g,
const vector< handle_t > &  topological_order,
bool  pin_left,
int32_t  max_alt_alns 
) const
virtual

The topological order MUST be left to right, no matter whether you are pinning left or right. If alignment needs to proceed backward, it will be reversed internally.

Implements vg::GSSWAligner.

◆ align_xdrop()

void Aligner::align_xdrop ( Alignment alignment,
const HandleGraph g,
const vector< MaximalExactMatch > &  mems,
bool  reverse_complemented 
) const
virtual

Implements vg::GSSWAligner.

◆ align_xdrop_multi()

void Aligner::align_xdrop_multi ( Alignment alignment,
const HandleGraph g,
const vector< MaximalExactMatch > &  mems,
bool  reverse_complemented,
int32_t  max_alt_alns 
) const
virtual

Implements vg::GSSWAligner.

◆ get_xdrop()

const XdropAligner & Aligner::get_xdrop ( ) const
virtual

Get a fresh XdropAligner instance to align with. TODO: make XdropAligner thread safe, and make it a thing you can get from GetAligner.

Implements vg::GSSWAligner.

◆ score_exact_match() [1/5]

int32_t Aligner::score_exact_match ( const Alignment aln,
size_t  read_offset,
size_t  length 
) const
virtual

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

Implements vg::GSSWAligner.

◆ score_exact_match() [2/5]

int32_t Aligner::score_exact_match ( const string &  sequence) const

◆ score_exact_match() [3/5]

int32_t Aligner::score_exact_match ( const string &  sequence,
const string &  base_quality 
) const
virtual

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

Implements vg::GSSWAligner.

◆ score_exact_match() [4/5]

int32_t Aligner::score_exact_match ( string::const_iterator  seq_begin,
string::const_iterator  seq_end 
) const

◆ score_exact_match() [5/5]

int32_t Aligner::score_exact_match ( string::const_iterator  seq_begin,
string::const_iterator  seq_end,
string::const_iterator  base_qual_begin 
) const
virtual

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::GSSWAligner.

◆ score_mismatch()

int32_t Aligner::score_mismatch ( size_t  length) const

Score a mismatch given just the length. Only possible since we ignore qualities.

◆ score_partial_alignment()

int32_t Aligner::score_partial_alignment ( const Alignment alignment,
const HandleGraph graph,
const Path path,
string::const_iterator  seq_begin 
) const
virtual

Compute the score of a path against the given range of subsequence with the given qualities.

Implements vg::GSSWAligner.

Member Data Documentation

◆ xdrop

XdropAligner vg::Aligner::xdrop
private

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