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

Search against known barcode sequences with segmented mismatches. More...

#include <BarcodeSearch.hpp>

Classes

struct  Options
 Optional parameters for a SegmentedBarcodeSearch. More...
 
struct  State
 State of the search. More...
 

Public Member Functions

 SegmentedBarcodeSearch ()=default
 
 SegmentedBarcodeSearch (const BarcodePool &barcode_pool, std::array< SeqLength, num_segments_ > segments, const Options &options)
 
State initialize () const
 
void reduce (State &state)
 
void search (const std::string &search_seq, State &state) const
 
void search (const std::string &search_seq, State &state, std::array< int, num_segments_ > allowed_mismatches) const
 

Detailed Description

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

Search against known barcode sequences with segmented mismatches.

Given an input sequence, this class performs exact and mismatch-aware searches for known sequences with "segmented" mismatches. Specifically, we split the sequence into segments whereby the number of mismatches in each segment is limited - see SegmentedMismatches for details. We use caching to avoid redundant work when a mismatching sequence has been previously encountered.

Template Parameters
num_segments_Number of segments to consider.

Constructor & Destructor Documentation

◆ SegmentedBarcodeSearch() [1/2]

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

Default constructor. This is only provided for composition purposes; methods of this class should only be called on properly constructed instance.

◆ SegmentedBarcodeSearch() [2/2]

template<int num_segments_>
kaori::SegmentedBarcodeSearch< num_segments_ >::SegmentedBarcodeSearch ( const BarcodePool & barcode_pool,
std::array< SeqLength, num_segments_ > segments,
const Options & options )
inline
Parameters
barcode_poolPool of barcode sequences.
segmentsSize of each segment. All values should be positive and their sum should be equal to the barcode length in barcode_pool.
optionsOptional parameters.

Member Function Documentation

◆ initialize()

template<int num_segments_>
State kaori::SegmentedBarcodeSearch< num_segments_ >::initialize ( ) const
inline

Initialize the search state for thread-safe execution.

Returns
A new state object for use in search() and reduce().

◆ reduce()

template<int num_segments_>
void kaori::SegmentedBarcodeSearch< num_segments_ >::reduce ( State & state)
inline

Incorporate the mismatch cache from state into the cache for this SegmentedBarcodeSEarch instance. This enables regular synchronization of the cache (and its related search optimizations) across threads.

Parameters
stateA state object generated by initialize(). Typically this has already been used in search().

◆ search() [1/2]

template<int num_segments_>
void kaori::SegmentedBarcodeSearch< num_segments_ >::search ( const std::string & search_seq,
State & state ) const
inline

Search the known sequences in the barcode pool against an input sequence. The number of allowed mismatches in each segment is equal to the Options::max_mismatches specified in the constructor.

Parameters
search_seqThe input sequence to use for searching. This is expected to have the same length as the known sequences.
stateA state object generated by initialize(). On return, state is filled with the details of the best-matching barcode sequence, if any exists.

◆ search() [2/2]

template<int num_segments_>
void kaori::SegmentedBarcodeSearch< num_segments_ >::search ( const std::string & search_seq,
State & state,
std::array< int, num_segments_ > allowed_mismatches ) const
inline

Search the known sequences in the barcode pool for an input sequence with a user-supplied number of allowed mismatches in each segment. It is expected that each element of allowed_mismatches is no greater than the corresponding element of Options::max_mismatches specified in the constructor. Lower values can improve efficiency in situations where some mismatches have already been "used up", e.g., by matching the template sequence in ScanTemplate.

Parameters
search_seqThe input sequence to use for searching. This is expected to have the same length as the known sequences.
stateA state object generated by initialize(). On return, state is filled with the details of the best-matching barcode sequence, if any exists.
allowed_mismatchesAllowed number of mismatches in each segment. Each value should not be greater than the corresponding value of Options::max_mismatches specified in the constructor.

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