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

Namespace for the kaori barcode-matching library. More...

Classes

class  AnyMismatches
 Search for barcodes with mismatches anywhere. More...
 
class  BarcodePool
 Pool of barcode sequences. More...
 
class  CombinationHash
 Hash a combination of barcode indices. More...
 
class  CombinatorialBarcodesPairedEnd
 Handler for paired-end combinatorial barcodes. More...
 
class  CombinatorialBarcodesSingleEnd
 Handler for single-end combinatorial barcodes. More...
 
class  DualBarcodesPairedEnd
 Handler for dual barcodes. More...
 
class  DualBarcodesPairedEndWithDiagnostics
 Handler for dual barcodes with extra diagnostics. More...
 
class  DualBarcodesSingleEnd
 Handler for single-end dual barcodes. More...
 
class  DualBarcodesSingleEndWithDiagnostics
 Handler for dual barcodes with extra diagnostics. More...
 
class  FastqReader
 Stream reads from a FASTQ file. More...
 
struct  ProcessPairedEndDataOptions
 Options for process_paired_end_data(). More...
 
struct  ProcessSingleEndDataOptions
 Options for process_single_end_data(). More...
 
class  RandomBarcodeSingleEnd
 Handler for single-end random barcodes. More...
 
class  ScanTemplate
 Scan a read sequence for the template sequence. More...
 
class  SegmentedBarcodeSearch
 Search against known barcode sequences with segmented mismatches. More...
 
class  SegmentedMismatches
 Search for barcodes with segmented mismatches. More...
 
class  SimpleBarcodeSearch
 Search against known barcodes. More...
 
class  SimpleSingleMatch
 Search for a template with a single variable region. More...
 
class  SingleBarcodePairedEnd
 Handler for paired-end single barcodes. More...
 
class  SingleBarcodeSingleEnd
 Handler for single-end single barcodes. More...
 
struct  TrieAddStatus
 Status of barcode sequence addition to the trie. More...
 

Typedefs

typedef std::size_t SeqLength
 
typedef std::vector< constchar * >::size_type BarcodeIndex
 
typedef unsigned long long Count
 

Enumerations

enum class  DuplicateAction : char { FIRST , LAST , NONE , ERROR }
 
enum class  SearchStrand : char { FORWARD , REVERSE , BOTH }
 

Functions

template<typename Pointer_ , class Handler_ >
void process_single_end_data (Pointer_ input, Handler_ &handler, const ProcessSingleEndDataOptions &options)
 
template<class Pointer_ , class Handler_ >
void process_paired_end_data (Pointer_ input1, Pointer_ input2, Handler_ &handler, const ProcessPairedEndDataOptions &options)
 
bool is_barcode_index_ok (BarcodeIndex index)
 

Variables

constexpr BarcodeIndex STATUS_UNMATCHED = static_cast<BarcodeIndex>(-1)
 
constexpr BarcodeIndex STATUS_AMBIGUOUS = static_cast<BarcodeIndex>(-2)
 

Detailed Description

Namespace for the kaori barcode-matching library.

Typedef Documentation

◆ BarcodeIndex

typedef std::vector<constchar*>::size_type kaori::BarcodeIndex

Integer type for barcode indices in a pool of known barcodes (specifically, inside a BarcodePool). This can have the special values STATUS_UNMATCHED and STATUS_AMBIGUOUS, see is_barcode_index_ok() to check for these error codes.

◆ Count

typedef unsigned long long kaori::Count

Integer type to count the frequency of each barcode.

◆ SeqLength

typedef std::size_t kaori::SeqLength

Integer type for the sequence lengths. This is used for barcodes, templates and reads.

Enumeration Type Documentation

◆ DuplicateAction

enum class kaori::DuplicateAction : char
strong

How to deal with duplicated sequences in the pool of known barcodes.

  • FIRST: keep the first encountered instance of a set of duplicates.
  • LAST: keep the last encountered instance of a set of duplicates.
  • NONE: do not keep any duplicate sequences.
  • ERROR: throw an error upon observing a duplicate sequence.

◆ SearchStrand

enum class kaori::SearchStrand : char
strong

Strands of the read sequence to search.

Function Documentation

◆ is_barcode_index_ok()

bool kaori::is_barcode_index_ok ( BarcodeIndex index)
inline
Parameters
indexA barcode index.
Returns
Whether index corresponds to an actual barcode. If false, index represents one of the error codes, i.e., STATUS_MISSING or STATUS_AMBIGUOUS.

◆ process_paired_end_data()

template<class Pointer_ , class Handler_ >
void kaori::process_paired_end_data ( Pointer_ input1,
Pointer_ input2,
Handler_ & handler,
const ProcessPairedEndDataOptions & options )

Run a handler for each read in paired-end data, by calling handler.process() on each read pair. It is expected that the results are stored in handler for retrieval by the caller.

Template Parameters
Pointer_Pointer to a class that serves as a source of input bytes. The pointed-to class should satisfy the byteme::Reader interface; it may also be a concrete byteme::Reader subclass to enable devirtualization. Either a smart or raw pointer may be supplied depending on how the caller wants to manage the lifetime of the pointed-to object.
Handler_A class that implements a handler for paired-end data.
Parameters
input1Pointer to an input byte source containing data from one of the paired-end FASTQ files. This may or may not need to be specifically "read 1", depending on the handler.
input2Pointer to an input byte source containing data from the other paired-end FASTQ file. This may or may not need to be specifically "read 2", depending on the handler.
handlerHandler instance for paired-end data.
optionsFurther options.

Paired-end handler requirements

The Handler class is expected to implement the following methods:

  • initialize(): this should be a thread-safe const method that returns a state object (denoted here as having type State, though the exact name may vary). The idea is to store results in the state object for thread-safe execution. The state object should be default-constructible.
  • reduce(State& state): this should merge the results from the state object into the Handler instance. This will be called in a serial section and does not have to be thread-safe.

The Handler should have a static constexpr variable use_names, indicating whether or not names should be passed to the process() method.

If use_names is false, the Handler class should implement:

  • process(State& state, const std::pair<const char*, const char*>& seq1, const std::pair<const char*, const char*>& seq2): this should be a const method that processes the paired reads in seq1 and seq2, and stores its results in state. seq1 and seq2 will contain pointers to the start and one-past-the-end of the sequences of the paired reads.

Otherwise, if use_names is true, the class should implement:

  • process(State& state, const std::pair<const char*, const char*>& name1, const std::pair<const char*, const char*>& seq1, const std::pair<const char*, const char*>& name2, const std::pair<const char*, const char*>& seq2): this should be a const method that processes the paired reads in seq1 and seq2, and stores its results in state. name1 and name2 will contain pointers to the start and one-past-the-end of the read names. seq1 and seq2 will contain pointers to the start and one-past-the-end of the read sequences.

◆ process_single_end_data()

template<typename Pointer_ , class Handler_ >
void kaori::process_single_end_data ( Pointer_ input,
Handler_ & handler,
const ProcessSingleEndDataOptions & options )

Run a handler for each read in single-end data, by calling handler.process() on each read. It is expected that the results are stored in handler for retrieval by the caller.

Template Parameters
Pointer_Pointer to a class that serves as a source of input bytes. The pointed-to class should satisfy the byteme::Reader interface; it may also be a concrete byteme::Reader subclass to enable devirtualization. Either a smart or raw pointer may be supplied depending on how the caller wants to manage the lifetime of the pointed-to object.
Handler_Class that implements a handler for single-end data.
Parameters
inputPointer to an input byte source containing data from a single-end FASTQ file.
handlerHandler instance for single-end data.
optionsFurther options.

Single-end handler requirements

The Handler_ class is expected to implement the following methods:

  • initialize(): this should be a thread-safe const method that returns a state object (denoted here as having type State, though the exact name may vary). The idea is to store results in the state object for thread-safe execution. The state object should be default-constructible.
  • reduce(State& state): this should merge the results from the state object into the Handler instance. This will be called in a serial section and does not have to be thread-safe.

The Handler should have a static constexpr variable use_names, indicating whether or not names should be passed to the process() method.

If use_names is false, the Handler class should implement:

  • process(State& state, const std::pair<const char*, const char*>& seq): this should be a const method that processes the read in seq and stores its results in state. seq will contain pointers to the start and one-past-the-end of the read sequence.

Otherwise, if use_names is true, the class should implement:

  • process(State& state, const std::pair<const char*, const char*>& name, const std::pair<const char*, const char*>& seq): this should be a const method that processes the read in seq and stores its results in state. name will contain pointers to the start and one-past-the-end of the read name. seq will contain pointers to the start and one-past-the-end of the read sequence.

Variable Documentation

◆ STATUS_AMBIGUOUS

BarcodeIndex kaori::STATUS_AMBIGUOUS = static_cast<BarcodeIndex>(-2)
inlineconstexpr

Ambiguous match to two or more known barcodes.

◆ STATUS_UNMATCHED

BarcodeIndex kaori::STATUS_UNMATCHED = static_cast<BarcodeIndex>(-1)
inlineconstexpr

No match to a known barcode.