kaori
A C++ library for barcode extraction and matching
Loading...
Searching...
No Matches
Classes | Public Member Functions | List of all members
kaori::SimpleSingleMatch< max_size > Class Template Reference

Search for a template with a single variable region. More...

#include <SimpleSingleMatch.hpp>

Classes

struct  Options
 Optional parameters for SimpleSingleMatch. More...
 
struct  State
 State of the search on a read sequence. More...
 

Public Member Functions

 SimpleSingleMatch (const char *template_seq, size_t template_length, const BarcodePool &barcode_pool, const Options &options)
 
State initialize () const
 
void reduce (State &state)
 
bool search_first (const char *read_seq, size_t read_length, State &state) const
 
bool search_best (const char *read_seq, size_t read_length, State &state) const
 

Detailed Description

template<size_t max_size>
class kaori::SimpleSingleMatch< max_size >

Search for a template with a single variable region.

This class implements the most common use case for barcode matching, where the template sequence has a single variable region. It will find a match to any valid barcoding element, i.e., the realization of the template where the variable region is replaced with one sequence from a pool of known barcodes. No restrictions are placed on the distribution of mismatches throughout the barcoding element.

Template Parameters
max_sizeMaximum length of the template sequence.

Constructor & Destructor Documentation

◆ SimpleSingleMatch()

template<size_t max_size>
kaori::SimpleSingleMatch< max_size >::SimpleSingleMatch ( const char *  template_seq,
size_t  template_length,
const BarcodePool barcode_pool,
const Options options 
)
inline
Parameters
[in]template_seqPointer to a character array containing the template sequence, see ScanTemplate.
template_lengthLength of the array pointed to by barcode_length. This should be less than or equal to max_size.
barcode_poolKnown sequences for the single variable region in template_seq.
optionsOptional parameters.

Member Function Documentation

◆ initialize()

template<size_t max_size>
State kaori::SimpleSingleMatch< max_size >::initialize ( ) const
inline

Initialize the search state for thread-safe execution.

Returns
A new State object.

◆ reduce()

template<size_t max_size>
void kaori::SimpleSingleMatch< max_size >::reduce ( State state)
inline

Incorporate search cache optimizations from state, see SimpleBarcodeSearch::reduce() for details. This allows regular consolidation and sharing of optimizations across threads. On return, optimizations from state are incorporated into this SimpleSingleMatch instance.

Parameters
stateA state object generated by initialize(). Typically this has been used in search_first() or search_best() at least once.

◆ search_best()

template<size_t max_size>
bool kaori::SimpleSingleMatch< max_size >::search_best ( const char *  read_seq,
size_t  read_length,
State state 
) const
inline

Search a read for the best match to a valid barcoding element. This is slower than search_first() but will find the matching position with the fewest mismatches. If multiple positions are tied for the fewest mismatches, no match is reported.

Parameters
[in]read_seqPointer to a character array containing the read sequence.
read_lengthLength of the read sequence.
stateState object, used to store the search result.
Returns
Whether a match was found. If true, state is filled with the details of the best match.

◆ search_first()

template<size_t max_size>
bool kaori::SimpleSingleMatch< max_size >::search_first ( const char *  read_seq,
size_t  read_length,
State state 
) const
inline

Search a read for the first match to a valid barcoding element. A match is only reported if the number of mismatches of the entire barcoding element's sequence to the read is no greater than max_mismatches (see the constructor) and there is exactly one barcode sequence with the fewest mismatches to the read sequence at the variable region.

Parameters
[in]read_seqPointer to a character array containing the read sequence.
read_lengthLength of the read sequence.
stateState object, used to store the search result.
Returns
Whether an appropriate match was found. If true, state is filled with the details of the first match.

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