kaori
A C++ library for barcode extraction and matching
Loading...
Searching...
No Matches
kaori::SegmentedMismatches< num_segments_ > Class Template Reference

Search for barcodes with segmented mismatches. More...

#include <MismatchTrie.hpp>

Classes

struct  Result
 Result of the segmented search. More...
 

Public Member Functions

 SegmentedMismatches ()=default
 
 SegmentedMismatches (std::array< SeqLength, num_segments_ > segments, DuplicateAction duplicates)
 
TrieAddStatus add (const char *barcode_seq)
 
SeqLength length () const
 
BarcodeIndex size () const
 
void optimize ()
 
Result search (const char *search_seq, const std::array< int, num_segments_ > &max_mismatches) const
 

Detailed Description

template<int num_segments_>
class kaori::SegmentedMismatches< num_segments_ >

Search for barcodes with segmented mismatches.

Given an input sequence, this class will perform a segmented mismatch-aware search to a pool of known barcode sequences. Specifically, the sequence interval is split into multiple segments where a barcode is only considered to be matching the input if the number of mismatches in each segment is no greater than a segment-specific threshold, e.g., 1 mismatch in the first 4 bp, 3 mismatches for the next 10 bp, and so on. The aim is to enable searching for concatenations of sequences from multiple variable regions, where each segment is subject to a different number of mismatches. The barcode with the fewest total mismatches to the input sequence is then returned.

Template Parameters
num_segments_Number of segments to consider.

Constructor & Destructor Documentation

◆ SegmentedMismatches() [1/2]

template<int num_segments_>
kaori::SegmentedMismatches< num_segments_ >::SegmentedMismatches ( )
default

Default constructor. This is only provided to enable composition, the resulting object should not be used until it is copy-assigned to a properly constructed instance.

◆ SegmentedMismatches() [2/2]

template<int num_segments_>
kaori::SegmentedMismatches< num_segments_ >::SegmentedMismatches ( std::array< SeqLength, num_segments_ > segments,
DuplicateAction duplicates )
inline
Parameters
segmentsLength of each segment of the sequence. Each entry should be positive and the sum should be equal to the total length of the barcode sequence.
duplicatesHow duplicate sequences across add() calls should be handled.

Member Function Documentation

◆ add()

template<int num_segments_>
TrieAddStatus kaori::SegmentedMismatches< num_segments_ >::add ( const char * barcode_seq)
inline
Parameters
[in]barcode_seqPointer to a character array containing a barcode sequence. The array should have length equal to length() and should only contain IUPAC nucleotides or their lower-case equivalents (excepting U or gap characters).
Returns
The barcode sequence is added to the trie. The index of the newly added sequence is defined as the number of sequences that were previously added. The status of the addition is returned.

◆ length()

template<int num_segments_>
SeqLength kaori::SegmentedMismatches< num_segments_ >::length ( ) const
inline
Returns
The length of the barcode sequences.

◆ optimize()

template<int num_segments_>
void kaori::SegmentedMismatches< num_segments_ >::optimize ( )
inline

Attempt to optimize the trie for more cache-friendly look-ups. This is not necessary if sorted sequences are supplied in add().

◆ search()

template<int num_segments_>
Result kaori::SegmentedMismatches< num_segments_ >::search ( const char * search_seq,
const std::array< int, num_segments_ > & max_mismatches ) const
inline
Parameters
[in]search_seqPointer to a character array of length equal to length(), containing an input sequence to search against the barcode pool.
max_mismatchesMaximum number of mismatches for each segment. Each entry should be non-negative.
Returns
Result of the search, containing the index of the matching barcode and the number of mismatches to that barcode.

◆ size()

template<int num_segments_>
BarcodeIndex kaori::SegmentedMismatches< num_segments_ >::size ( ) const
inline
Returns
The number of barcode sequences added.

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