kaori
A C++ library for barcode extraction and matching
Loading...
Searching...
No Matches
BarcodePool.hpp
Go to the documentation of this file.
1#ifndef KAORI_BARCODE_POOL_HPP
2#define KAORI_BARCODE_POOL_HPP
3
4#include <vector>
5#include <string>
6#include <cstddef>
7
8#include "utils.hpp"
9
16namespace kaori {
17
25public:
29 BarcodePool() = default;
30
36 BarcodePool(std::vector<const char*> barcode_pool, std::size_t barcode_length) : my_pool(std::move(barcode_pool)), my_length(barcode_length) {}
37
42 BarcodePool(const std::vector<std::string>& barcode_pool) {
43 if (barcode_pool.size()) {
44 my_length = barcode_pool.front().size();
45 my_pool.reserve(barcode_pool.size());
46 for (const auto& x : barcode_pool) {
47 if (x.size() != my_length) {
48 throw std::runtime_error("sequences for a given variable region should be of a constant length");
49 }
50 my_pool.push_back(x.c_str());
51 }
52 }
53 }
54
55private:
56 std::vector<const char*> my_pool;
57 std::size_t my_length = 0;
58
59public:
63 const std::vector<const char*>& pool() const {
64 return my_pool;
65 }
66
70 SeqLength length() const {
71 return my_length;
72 }
73
78 return my_pool.size();
79 }
80
85 const char* operator[](BarcodeIndex i) const {
86 return my_pool[i];
87 }
88};
89
90}
91
92#endif
Pool of barcode sequences.
Definition BarcodePool.hpp:24
const char * operator[](BarcodeIndex i) const
Definition BarcodePool.hpp:85
BarcodePool()=default
const std::vector< const char * > & pool() const
Definition BarcodePool.hpp:63
SeqLength length() const
Definition BarcodePool.hpp:70
BarcodePool(std::vector< const char * > barcode_pool, std::size_t barcode_length)
Definition BarcodePool.hpp:36
BarcodeIndex size() const
Definition BarcodePool.hpp:77
BarcodePool(const std::vector< std::string > &barcode_pool)
Definition BarcodePool.hpp:42
Namespace for the kaori barcode-matching library.
Definition BarcodePool.hpp:16
std::size_t SeqLength
Definition utils.hpp:37
std::vector< constchar * >::size_type BarcodeIndex
Definition utils.hpp:43
Utilites for sequence matching.