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

Scan a read sequence for the template sequence. More...

#include <ScanTemplate.hpp>

Classes

struct  State
 Details on the current match to the read sequence. More...
 

Public Member Functions

 ScanTemplate ()
 
 ScanTemplate (const char *template_seq, size_t template_length, SearchStrand strand)
 
State initialize (const char *read_seq, size_t read_length) const
 
void next (State &state) const
 
template<bool reverse = false>
const std::vector< std::pair< int, int > > & variable_regions () const
 

Detailed Description

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

Scan a read sequence for the template sequence.

When searching for barcodes, kaori first searches for a "template sequence" in the read sequence. The template sequence contains constant regions interspersed with one or more variable regions. The template is realized into the full barcoding element by replacing each variable region with one sequence from the corresponding pool of barcodes.

This class will scan read sequence to find a location that matches the constant regions of the template, give or take any number of substitutions. Multiple locations on the read may match the template, provided next() is called repeatedly. For efficiency, the search itself is done after converting all base sequences into a bit encoding. The maximum size of this encoding is determined at compile-time by the max_length template parameter.

Once a match is found, the sequence of the read at each variable region can be matched against a pool of known barcode sequences. See the BarcodePool class for details.

Template Parameters
max_sizeMaximum length of the template sequence.

Constructor & Destructor Documentation

◆ ScanTemplate() [1/2]

template<size_t max_size>
kaori::ScanTemplate< max_size >::ScanTemplate ( )
inline

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.

◆ ScanTemplate() [2/2]

template<size_t max_size>
kaori::ScanTemplate< max_size >::ScanTemplate ( const char template_seq,
size_t  template_length,
SearchStrand  strand 
)
inline
Parameters
[in]template_seqPointer to a character array containing the template sequence. Constant sequences should only contain A, C, G or T (or their lower-case equivalents). Variable regions should be marked with -.
template_lengthLength of the array pointed to by template_seq. This should be less than or equal to max_size.
strandStrand(s) of the read sequence to search.

Member Function Documentation

◆ initialize()

template<size_t max_size>
State kaori::ScanTemplate< max_size >::initialize ( const char read_seq,
size_t  read_length 
) const
inline

Begin a new search for the template in a read sequence.

Parameters
[in]read_seqPointer to an array containing the read sequence.
read_lengthLength of the read sequence.
Returns
An empty State object. If its finished member is false, it should be passed to next() before accessing its other members. If true, the read sequence was too short for any match to be found.

◆ next()

template<size_t max_size>
void kaori::ScanTemplate< max_size >::next ( State state) const
inline

Find the next match in the read sequence. The first invocation will search for a match at position 0; this can be repeatedly called until match.finished is true.

Parameters
stateA State object produced by initialize(). On return, state is updated with the details of the current match at a particular position on the read sequence.

◆ variable_regions()

template<size_t max_size>
template<bool reverse = false>
const std::vector< std::pair< int, int > > & kaori::ScanTemplate< max_size >::variable_regions ( ) const
inline

Extract details about the variable regions in the template sequence.

Template Parameters
reverseShould we return the coordinates of the variable regions when searching on the reverse strand?
Returns
A vector of pairs where each pair specifies the start and one-past-the-end position of each variable region in the template. Coordinates are reported relative to the start of the template. Pairs are ordered by the start positions. If reverse = true, coordinates are reported after reverse-complementing the template sequence.

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