36 bool use_first =
true;
41 int max_mismatches1 = 0;
46 SearchStrand strand1 = SearchStrand::FORWARD;
51 int max_mismatches2 = 0;
56 SearchStrand strand2 = SearchStrand::FORWARD;
61 DuplicateAction duplicates = DuplicateAction::ERROR;
86 const char* template_seq1,
size_t template_length1,
const BarcodePool& barcode_pool1,
87 const char* template_seq2,
size_t template_length2,
const BarcodePool& barcode_pool2,
88 const Options& options
96 opt.
strand = options.strand1;
108 opt.
strand = options.strand2;
114 randomized(options.random),
115 use_first(options.use_first)
117 num_options[0] = barcode_pool1.size();
118 num_options[1] = barcode_pool2.size();
128 State(
typename SimpleSingleMatch<max_size>::State s1,
typename SimpleSingleMatch<max_size>::State s2) : search1(std::move(s1)), search2(std::move(s2)) {}
130 std::vector<std::array<int, 2> >collected;
131 int barcode1_only = 0;
132 int barcode2_only = 0;
138 typename SimpleSingleMatch<max_size>::State search1;
139 typename SimpleSingleMatch<max_size>::State search2;
145 State initialize()
const {
146 return State(matcher1.initialize(), matcher2.initialize());
149 void reduce(State& s) {
150 matcher1.reduce(s.search1);
151 matcher2.reduce(s.search2);
152 combinations.insert(combinations.end(), s.collected.begin(), s.collected.end());
154 barcode1_only += s.barcode1_only;
155 barcode2_only += s.barcode2_only;
158 constexpr static bool use_names =
false;
167 void process(State& state,
const std::pair<const char*, const char*>& r1,
const std::pair<const char*, const char*>& r2)
const {
169 bool m1 = matcher1.search_first(r1.first, r1.second - r1.first, state.search1);
170 bool m2 = matcher2.search_first(r2.first, r2.second - r2.first, state.search2);
173 state.collected.emplace_back(std::array<int, 2>{ state.search1.index, state.search2.index });
174 }
else if (randomized) {
175 bool n1 = matcher1.search_first(r2.first, r2.second - r2.first, state.search1);
176 bool n2 = matcher2.search_first(r1.first, r1.second - r1.first, state.search2);
178 state.collected.emplace_back(std::array<int, 2>{ state.search1.index, state.search2.index });
181 ++state.barcode1_only;
182 }
else if (m2 || n2) {
183 ++state.barcode2_only;
188 ++state.barcode1_only;
190 ++state.barcode2_only;
195 bool m1 = matcher1.search_best(r1.first, r1.second - r1.first, state.search1);
196 bool m2 = matcher2.search_best(r2.first, r2.second - r2.first, state.search2);
200 state.collected.emplace_back(std::array<int, 2>{ state.search1.index, state.search2.index });
202 ++state.barcode1_only;
204 ++state.barcode2_only;
206 }
else if (m1 && m2) {
207 std::array<int, 2> candidate{ state.search1.index, state.search2.index };
208 int mismatches = state.search1.mismatches + state.search2.mismatches;
210 bool n1 = matcher1.search_best(r2.first, r2.second - r2.first, state.search1);
211 bool n2 = matcher2.search_best(r1.first, r1.second - r1.first, state.search2);
214 int rmismatches = state.search1.mismatches + state.search2.mismatches;
215 if (mismatches > rmismatches) {
216 state.collected.emplace_back(std::array<int, 2>{ state.search1.index, state.search2.index });
217 }
else if (mismatches < rmismatches) {
218 state.collected.emplace_back(candidate);
219 }
else if (candidate[0] == state.search1.index && candidate[1] == state.search2.index) {
222 state.collected.emplace_back(candidate);
225 state.collected.emplace_back(candidate);
228 bool n1 = matcher1.search_best(r2.first, r2.second - r2.first, state.search1);
229 bool n2 = matcher2.search_best(r1.first, r1.second - r1.first, state.search2);
232 state.collected.emplace_back(std::array<int, 2>{ state.search1.index, state.search2.index });
233 }
else if (m1 || n1) {
234 ++state.barcode1_only;
235 }
else if (m2 || n2) {
236 ++state.barcode2_only;
253 sort_combinations(combinations, num_options);
275 return barcode1_only;
282 return barcode2_only;
286 std::array<size_t, 2> num_options;
289 bool use_first =
true;
291 std::vector<std::array<int, 2> > combinations;
293 int barcode1_only = 0;
294 int barcode2_only = 0;