kaori
A C++ library for barcode extraction and matching
Loading...
Searching...
No Matches
kaori::AnyMismatches Class Reference

Search for barcodes with mismatches anywhere. More...

#include <MismatchTrie.hpp>

Classes

struct  Result
 Results of search(). More...
 

Public Member Functions

 AnyMismatches ()=default
 
 AnyMismatches (SeqLength barcode_length, DuplicateAction duplicates)
 
TrieAddStatus add (const char *barcode_seq)
 
SeqLength length () const
 
BarcodeIndex size () const
 
void optimize ()
 
Result search (const char *search_seq, int max_mismatches) const
 

Detailed Description

Search for barcodes with mismatches anywhere.

Given an input sequence, this class performs a mismatch-aware search to a trie containing a pool of known barcode sequences. It will then return the barcode with the fewest mismatches to the input sequence. Any number of mismatches are supported, distributed anywhere throughout the sequence.

Constructor & Destructor Documentation

◆ AnyMismatches() [1/2]

kaori::AnyMismatches::AnyMismatches ( )
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.

◆ AnyMismatches() [2/2]

kaori::AnyMismatches::AnyMismatches ( SeqLength barcode_length,
DuplicateAction duplicates )
inline
Parameters
barcode_lengthLength of the barcode sequences.
duplicatesHow duplicate sequences across add() calls should be handled.

Member Function Documentation

◆ add()

TrieAddStatus kaori::AnyMismatches::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()

SeqLength kaori::AnyMismatches::length ( ) const
inline
Returns
The length of the barcode sequences.

◆ optimize()

void kaori::AnyMismatches::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()

Result kaori::AnyMismatches::search ( const char * search_seq,
int 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 to consider in the search. This value 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()

BarcodeIndex kaori::AnyMismatches::size ( ) const
inline
Returns
The number of barcode sequences added across all calls to add().

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