kaori
A C++ library for barcode extraction and matching
Loading...
Searching...
No Matches
DualBarcodesSingleEndWithDiagnostics.hpp
Go to the documentation of this file.
1#ifndef KAORI_DUAL_BARCODES_SINGLE_END_WITH_DIAGNOSTICS_HPP
2#define KAORI_DUAL_BARCODES_SINGLE_END_WITH_DIAGNOSTICS_HPP
3
6#include "../utils.hpp"
7
14namespace kaori {
15
25template<size_t max_size, size_t num_variable>
27public:
37 const char* template_seq,
38 size_t template_length,
39 const std::vector<BarcodePool>& barcode_pools,
40 const typename DualBarcodesSingleEnd<max_size>::Options& options
41 ) :
42 dual_handler(template_seq, template_length, barcode_pools, options),
43
44 combo_handler(template_seq, template_length, barcode_pools,
45 [&]{
47 combopt.use_first = options.use_first;
48
49 combopt.max_mismatches = options.max_mismatches;
50 combopt.strand = options.strand;
51
52 // we allow duplicates in the trie for each individual barcode, as only the combinations are unique in the dual barcode setup.
53 combopt.duplicates = DuplicateAction::FIRST;
54 return combopt;
55 }()
56 )
57 {}
58
59private:
60 DualBarcodesSingleEnd<max_size> dual_handler;
61 CombinatorialBarcodesSingleEnd<max_size, num_variable> combo_handler;
62
63public:
67 struct State {
68 State() {}
69 State(typename DualBarcodesSingleEnd<max_size>::State ds, typename CombinatorialBarcodesSingleEnd<max_size, num_variable>::State cs) : dual_state(std::move(ds)), combo_state(std::move(cs)) {}
70
74 typename DualBarcodesSingleEnd<max_size>::State dual_state;
75 typename CombinatorialBarcodesSingleEnd<max_size, num_variable>::State combo_state;
79 };
80
81 State initialize() const {
82 return State(dual_handler.initialize(), combo_handler.initialize());
83 }
84
85 void reduce(State& s) {
86 dual_handler.reduce(s.dual_state);
87 combo_handler.reduce(s.combo_state);
88 }
89
90 constexpr static bool use_names = false;
95public:
99 void process(State& state, const std::pair<const char*, const char*>& x) const {
100 // Only searching for combinations if we couldn't find a proper dual barcode match.
101 if (!dual_handler.process(state.dual_state, x)) {
102 combo_handler.process(state.combo_state, x);
103 }
104 }
109public:
114 void sort() {
115 combo_handler.sort();
116 }
117
123 const std::vector<int>& get_counts() const {
124 return dual_handler.get_counts();
125 }
126
131 const std::vector<std::array<int, num_variable> >& get_combinations() const {
132 return combo_handler.get_combinations();
133 }
134
138 int get_total() const {
139 return dual_handler.get_total();
140 }
141};
142
143}
144
145#endif
Process single-end combinatorial barcodes.
Process single-end dual barcodes.
Handler for dual barcodes with extra diagnostics.
Definition DualBarcodesSingleEndWithDiagnostics.hpp:26
DualBarcodesSingleEndWithDiagnostics(const char *template_seq, size_t template_length, const std::vector< BarcodePool > &barcode_pools, const typename DualBarcodesSingleEnd< max_size >::Options &options)
Definition DualBarcodesSingleEndWithDiagnostics.hpp:36
int get_total() const
Definition DualBarcodesSingleEndWithDiagnostics.hpp:138
const std::vector< std::array< int, num_variable > > & get_combinations() const
Definition DualBarcodesSingleEndWithDiagnostics.hpp:131
const std::vector< int > & get_counts() const
Definition DualBarcodesSingleEndWithDiagnostics.hpp:123
void sort()
Definition DualBarcodesSingleEndWithDiagnostics.hpp:114
Namespace for the kaori barcode-matching library.
Definition BarcodePool.hpp:13
Optional parameters for CombinatorialBarcodeSingleEnd.
Definition CombinatorialBarcodesSingleEnd.hpp:36
SearchStrand strand
Definition CombinatorialBarcodesSingleEnd.hpp:50
int max_mismatches
Definition CombinatorialBarcodesSingleEnd.hpp:40
bool use_first
Definition CombinatorialBarcodesSingleEnd.hpp:45
DuplicateAction duplicates
Definition CombinatorialBarcodesSingleEnd.hpp:55
Optional parameters for DualBarcodeSingleEnd.
Definition DualBarcodesSingleEnd.hpp:36
SearchStrand strand
Definition DualBarcodesSingleEnd.hpp:50
bool use_first
Definition DualBarcodesSingleEnd.hpp:45
int max_mismatches
Definition DualBarcodesSingleEnd.hpp:40