/
aligner_seed2.h
1820 lines (1820 loc) · 34.2 KB
/
aligner_seed2.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#ifndef ALIGNER_SEED2_H_
#define ALIGNER_SEED2_H_
#include <stdint.h>
#include <math.h>
#include <utility>
#include <limits>
#include "assert_helpers.h"
#include "random_util.h"
#include "aligner_result.h"
#include "aln_idx.h"
#include "simple_func.h"
#include "scoring.h"
#include "edit.h"
#include "read.h"
#include "ds.h"
#include "group_walk.h"
#include "btypes.h"
typedef size_t TReadOff;
typedef int64_t TScore;
typedef float TRootPri;
typedef size_t TDescentId;
typedef size_t TRootId;
enum
{
DESC_EX_NONE = 1,
DESC_EX_FROM_1ST_BRANCH = 2,
DESC_EX_EACH_EDGE = 3
};
struct DescentMetrics
{
DescentMetrics() { reset(); }
void reset()
{
bwops = bwops_1 = bwops_bi = recalc = branch = branch_mm =
branch_del = branch_ins = heap_max = descent_max = descentpos_max =
nex = 0;
}
uint64_t bwops;
uint64_t bwops_1;
uint64_t bwops_bi;
uint64_t recalc;
uint64_t branch;
uint64_t branch_mm;
uint64_t branch_del;
uint64_t branch_ins;
uint64_t heap_max;
uint64_t descent_max;
uint64_t descentpos_max;
uint64_t nex;
};
struct DescentPriority
{
DescentPriority() { reset(); }
DescentPriority(
TScore pen_,
size_t depth_,
TIndexOffU width_,
float rootpri_)
{
pen = pen_;
depth = depth_;
width = width_;
rootpri = rootpri_;
}
void init(TScore pen_, size_t depth_, TIndexOffU width_, float rootpri_)
{
pen = pen_;
depth = depth_;
width = width_;
rootpri = rootpri_;
}
void reset()
{
width = 0;
}
bool inited() const
{
return width > 0;
}
bool operator<(const DescentPriority &o) const
{
assert(inited());
assert(o.inited());
if (pen < o.pen)
return true;
if (pen > o.pen)
return false;
if (depth > o.depth)
return true;
if (depth < o.depth)
return false;
if (width < o.width)
return true;
if (width > o.width)
return false;
if (rootpri > o.rootpri)
return true;
return false;
}
bool operator<=(const DescentPriority &o) const
{
assert(inited());
assert(o.inited());
if (pen < o.pen)
return true;
if (pen > o.pen)
return false;
if (depth > o.depth)
return true;
if (depth < o.depth)
return false;
if (width < o.depth)
return true;
if (width > o.width)
return false;
if (rootpri > o.rootpri)
return true;
return true;
}
bool operator==(const DescentPriority &o) const
{
assert(inited());
assert(o.inited());
return pen == o.pen && depth == o.depth && width == o.width && rootpri == o.rootpri;
}
TScore pen;
size_t depth;
TIndexOffU width;
float rootpri;
};
static inline std::ostream &operator<<(
std::ostream &os,
const DescentPriority &o)
{
os << "[" << o.pen << ", " << o.depth << ", " << o.width << ", " << o.rootpri << "]";
return os;
}
static inline std::ostream &operator<<(
std::ostream &os,
const std::pair<DescentPriority, TDescentId> &o)
{
os << "{[" << o.first.pen << ", " << o.first.depth << ", "
<< o.first.width << ", " << o.first.rootpri << "], " << o.second << "}";
return os;
}
typedef std::pair<DescentPriority, TDescentId> TDescentPair;
struct DescentConstraints
{
DescentConstraints() { reset(); }
DescentConstraints(size_t nzero, double exp)
{
init(nzero, exp);
}
void init(size_t nzero_, double exp_)
{
nzero = nzero_ > 0 ? nzero_ : 1;
exp = exp_;
#ifndef NDEBUG
for (size_t i = 1; i < nzero_ + 5; i++)
{
assert_geq(get(i, nzero_ + 10, 100), get(i - 1, nzero_ + 10, 100));
}
#endif
}
void reset()
{
nzero = 0;
exp = -1.0f;
}
bool inited() const
{
return exp >= 0.0f;
}
inline TScore get(TReadOff off, TReadOff rdlen, TAlScore maxpen) const
{
if (off < nzero || nzero >= rdlen)
{
return 0;
}
double frac = (double)(off - nzero) / (rdlen - nzero);
if (fabs(exp - 1.0f) > 0.00001)
{
if (fabs(exp - 2.0f) < 0.00001)
{
frac *= frac;
}
else
{
frac = pow(frac, exp);
}
}
return (TAlScore)(frac * maxpen + 0.5f);
}
size_t nzero;
double exp;
};
struct DescentConfig
{
DescentConfig() { reset(); }
void reset() { expol = 0; }
bool inited() const { return expol != 0; }
DescentConstraints cons;
int expol;
};
struct DescentRedundancyKey
{
DescentRedundancyKey() { reset(); }
DescentRedundancyKey(
TReadOff al5pf_,
size_t rflen_,
TIndexOffU topf_,
TIndexOffU botf_)
{
init(al5pf_, rflen_, topf_, botf_);
}
void reset()
{
al5pf = 0;
rflen = 0;
topf = botf = 0;
}
bool inited() const { return rflen > 0; }
void init(
TReadOff al5pf_,
size_t rflen_,
TIndexOffU topf_,
TIndexOffU botf_)
{
al5pf = al5pf_;
rflen = rflen_;
topf = topf_;
botf = botf_;
}
bool operator==(const DescentRedundancyKey &o) const
{
return al5pf == o.al5pf && rflen == o.rflen && topf == o.topf && botf == o.botf;
}
bool operator<(const DescentRedundancyKey &o) const
{
if (al5pf < o.al5pf)
return true;
if (al5pf > o.al5pf)
return false;
if (rflen < o.rflen)
return true;
if (rflen > o.rflen)
return false;
if (topf < o.topf)
return true;
if (topf > o.topf)
return false;
return botf < o.botf;
}
TReadOff al5pf;
size_t rflen;
TIndexOffU topf;
TIndexOffU botf;
};
class DescentRedundancyChecker
{
public:
DescentRedundancyChecker() { reset(); }
void clear() { reset(); }
void reset()
{
bits_.reset();
inited_ = false;
totsz_ = 0;
totcap_ = 0;
}
const static int NPARTS = 8;
const static int PART_MASK = 7;
const static int NBITS = (1 << 16);
void init(TReadOff rdlen)
{
reset();
bits_.resize(NBITS);
maplist_fl_.resize(NPARTS);
maplist_fr_.resize(NPARTS);
maplist_rl_.resize(NPARTS);
maplist_rr_.resize(NPARTS);
for (int i = 0; i < NPARTS; i++)
{
maplist_fl_[i].resize(rdlen);
maplist_fr_[i].resize(rdlen);
maplist_rl_[i].resize(rdlen);
maplist_rr_[i].resize(rdlen);
totcap_ += maplist_fl_[i].totalCapacityBytes();
totcap_ += maplist_fr_[i].totalCapacityBytes();
totcap_ += maplist_rl_[i].totalCapacityBytes();
totcap_ += maplist_rr_[i].totalCapacityBytes();
for (size_t j = 0; j < rdlen; j++)
{
maplist_fl_[i][j].clear();
maplist_fr_[i][j].clear();
maplist_rl_[i][j].clear();
maplist_rr_[i][j].clear();
totcap_ += maplist_fl_[i][j].totalCapacityBytes();
totcap_ += maplist_fr_[i][j].totalCapacityBytes();
totcap_ += maplist_rl_[i][j].totalCapacityBytes();
totcap_ += maplist_rr_[i][j].totalCapacityBytes();
}
}
inited_ = true;
}
bool inited() const
{
return inited_;
}
bool check(
bool fw,
bool l2r,
TReadOff al5pi,
TReadOff al5pf,
size_t rflen,
TIndexOffU topf,
TIndexOffU botf,
TScore pen)
{
assert(inited_);
assert(topf > 0 || botf > 0);
DescentRedundancyKey k(al5pf, rflen, topf, botf);
size_t i = std::numeric_limits<size_t>::max();
size_t mask = topf & PART_MASK;
EMap<DescentRedundancyKey, TScore> &map =
(fw ? (l2r ? maplist_fl_[mask][al5pi] : maplist_fr_[mask][al5pi]) : (l2r ? maplist_rl_[mask][al5pi] : maplist_rr_[mask][al5pi]));
size_t key = (topf & 255) | ((botf & 255) << 8);
if (bits_.test(key) && map.containsEx(k, i))
{
assert_lt(i, map.size());
assert_geq(pen, map[i].second);
return false;
}
assert(!map.containsEx(k, i));
size_t oldsz = map.totalSizeBytes();
size_t oldcap = map.totalCapacityBytes();
map.insert(make_pair(k, pen));
bits_.set(key);
totsz_ += (map.totalSizeBytes() - oldsz);
totcap_ += (map.totalCapacityBytes() - oldcap);
return true;
}
bool contains(
bool fw,
bool l2r,
TReadOff al5pi,
TReadOff al5pf,
size_t rflen,
TIndexOffU topf,
TIndexOffU botf,
TScore pen)
{
assert(inited_);
size_t key = (topf & 255) | ((botf & 255) << 8);
if (!bits_.test(key))
{
return false;
}
DescentRedundancyKey k(al5pf, rflen, topf, botf);
size_t mask = topf & PART_MASK;
EMap<DescentRedundancyKey, TScore> &map =
(fw ? (l2r ? maplist_fl_[mask][al5pi] : maplist_fr_[mask][al5pi]) : (l2r ? maplist_rl_[mask][al5pi] : maplist_rr_[mask][al5pi]));
return map.contains(k);
}
size_t totalSizeBytes() const
{
return totsz_;
}
size_t totalCapacityBytes() const
{
return totcap_;
}
protected:
bool inited_;
size_t totsz_;
size_t totcap_;
ELList<EMap<DescentRedundancyKey, TScore>, NPARTS, 100> maplist_fl_;
ELList<EMap<DescentRedundancyKey, TScore>, NPARTS, 100> maplist_rl_;
ELList<EMap<DescentRedundancyKey, TScore>, NPARTS, 100> maplist_fr_;
ELList<EMap<DescentRedundancyKey, TScore>, NPARTS, 100> maplist_rr_;
EBitList<128> bits_;
};
struct DescentRoot
{
DescentRoot() { reset(); }
DescentRoot(
size_t off5p_,
bool l2r_,
bool fw_,
size_t landing_,
size_t len,
float pri_)
{
init(off5p_, l2r_, fw_, landing_, len, pri_);
}
void init(
size_t off5p_,
bool l2r_,
bool fw_,
size_t landing_,
size_t len,
float pri_)
{
off5p = off5p_;
l2r = l2r_;
fw = fw_;
landing = landing_;
pri = pri_;
assert_lt(off5p, len);
}
void reset()
{
off5p = std::numeric_limits<size_t>::max();
}
bool inited() const
{
return off5p == std::numeric_limits<size_t>::max();
}
bool operator==(const DescentRoot &o) const
{
return pri == o.pri && off5p == o.off5p && l2r == o.l2r &&
fw == o.fw && landing == o.landing;
}
bool operator<(const DescentRoot &o) const
{
if (pri > o.pri)
return true;
if (pri < o.pri)
return false;
if (off5p < o.off5p)
return true;
if (off5p > o.off5p)
return false;
if (fw != o.fw)
return fw;
if (l2r != o.l2r)
return l2r;
if (landing < o.landing)
return true;
if (landing > o.landing)
return false;
return false;
}
bool operator<=(const DescentRoot &o) const
{
return (*this) < o || (*this) == o;
}
TReadOff off5p;
bool l2r;
bool fw;
size_t landing;
float pri;
};
struct DescentPosFlags
{
DescentPosFlags() { reset(); }
void reset()
{
mm_a = mm_c = mm_g = mm_t = rdg_a = rdg_c = rdg_g = rdg_t = rfg = 1;
reserved = 0;
}
bool exhausted() const
{
return ((uint16_t *)this)[0] == 0;
}
bool mmExplore(int c)
{
assert_range(0, 3, c);
if (c == 0)
{
return mm_a;
}
else if (c == 1)
{
return mm_c;
}
else if (c == 2)
{
return mm_g;
}
else
{
return mm_t;
}
}
bool mmSet(int c)
{
assert_range(0, 3, c);
if (c == 0)
{
bool ret = mm_a;
mm_a = 0;
return ret;
}
else if (c == 1)
{
bool ret = mm_c;
mm_c = 0;
return ret;
}
else if (c == 2)
{
bool ret = mm_g;
mm_g = 0;
return ret;
}
else
{
bool ret = mm_t;
mm_t = 0;
return ret;
}
}
bool rdgExplore(int c)
{
assert_range(0, 3, c);
if (c == 0)
{
return rdg_a;
}
else if (c == 1)
{
return rdg_c;
}
else if (c == 2)
{
return rdg_g;
}
else
{
return rdg_t;
}
}
bool rdgSet(int c)
{
assert_range(0, 3, c);
if (c == 0)
{
bool ret = rdg_a;
rdg_a = 0;
return ret;
}
else if (c == 1)
{
bool ret = rdg_c;
rdg_c = 0;
return ret;
}
else if (c == 2)
{
bool ret = rdg_g;
rdg_g = 0;
return ret;
}
else
{
bool ret = rdg_t;
rdg_t = 0;
return ret;
}
}
bool rfgExplore()
{
return rfg;
}
bool rfgSet()
{
bool ret = rfg;
rfg = 0;
return ret;
}
uint16_t mm_a : 1;
uint16_t mm_c : 1;
uint16_t mm_g : 1;
uint16_t mm_t : 1;
uint16_t rdg_a : 1;
uint16_t rdg_c : 1;
uint16_t rdg_g : 1;
uint16_t rdg_t : 1;
uint16_t rfg : 1;
uint16_t reserved : 7;
};
struct DescentPos
{
void reset()
{
topf[0] = topf[1] = topf[2] = topf[3] = 0;
botf[0] = botf[1] = botf[2] = botf[3] = 0;
topb[0] = topb[1] = topb[2] = topb[3] = 0;
botb[0] = botb[1] = botb[2] = botb[3] = 0;
c = -1;
flags.reset();
}
bool inited() const
{
return c >= 0;
}
#ifndef NDEBUG
bool repOk() const
{
assert_range(0, 3, (int)c);
return true;
}
#endif
TIndexOffU topf[4];
TIndexOffU botf[4];
TIndexOffU topb[4];
TIndexOffU botb[4];
char c;
DescentPosFlags flags;
};
struct DescentEdge
{
DescentEdge() { reset(); }
DescentEdge(
Edit e_,
TReadOff off5p_,
DescentPriority pri_,
size_t posFlag_,
TReadOff nex_
#ifndef NDEBUG
,
size_t d_,
TIndexOffU topf_,
TIndexOffU botf_,
TIndexOffU topb_,
TIndexOffU botb_
#endif
)
{
init(e_, off5p_, pri_, posFlag_
#ifndef NDEBUG
,
d_, topf_, botf_, topb_, botb_
#endif
);
}
bool inited() const { return e.inited(); }
void reset() { e.reset(); }
void init(
Edit e_,
TReadOff off5p_,
DescentPriority pri_,
size_t posFlag_
#ifndef NDEBUG
,
size_t d_,
TIndexOffU topf_,
TIndexOffU botf_,
TIndexOffU topb_,
TIndexOffU botb_
#endif
)
{
e = e_;
off5p = off5p_;
pri = pri_;
posFlag = posFlag_;
#ifndef NDEBUG
d = d_;
topf = topf_;
botf = botf_;
topb = topb_;
botb = botb_;
#endif
}
void updateFlags(EFactory<DescentPos> &pf)
{
if (inited())
{
if (e.isReadGap())
{
assert_neq('-', e.chr);
pf[posFlag].flags.rdgSet(asc2dna[e.chr]);
}
else if (e.isRefGap())
{
pf[posFlag].flags.rfgSet();
}
else
{
assert_neq('-', e.chr);
pf[posFlag].flags.mmSet(asc2dna[e.chr]);
}
}
}
bool operator<(const DescentEdge &o) const
{
if (inited() && !o.inited())
{
return true;
}
else if (!inited())
{
return false;
}
return pri < o.pri;
}
DescentPriority pri;
TReadOff nex;
size_t posFlag;
#ifndef NDEBUG
size_t d;
TIndexOffU topf, botf, topb, botb;
#endif
Edit e;
TReadOff off5p;
};
class DescentOutgoing
{
public:
DescentEdge rotate()
{
DescentEdge tmp = best1;
assert(!(best2 < tmp));
best1 = best2;
assert(!(best3 < best2));
best2 = best3;
assert(!(best4 < best3));
best3 = best4;
assert(!(best5 < best4));
best4 = best5;
best5.reset();
return tmp;
}
void update(DescentEdge e)
{
if (!best1.inited())
{
best1 = e;
}
else if (e < best1)
{
best5 = best4;
best4 = best3;
best3 = best2;
best2 = best1;
best1 = e;
}
else if (!best2.inited())
{
best2 = e;
}
else if (e < best2)
{
best5 = best4;
best4 = best3;
best3 = best2;
best2 = e;
}
else if (!best3.inited())
{
best3 = e;
}
else if (e < best3)
{
best5 = best4;
best4 = best3;
best3 = e;
}
else if (!best4.inited())
{
best4 = e;
}
else if (e < best4)
{
best5 = best4;
best4 = e;
}
else if (!best5.inited() || e < best5)
{
best5 = e;
}
}
void clear()
{
best1.reset();
best2.reset();
best3.reset();
best4.reset();
best5.reset();
}
bool empty() const
{
return !best1.inited();
}
DescentPriority bestPri() const
{
assert(!empty());
return best1.pri;
}
DescentEdge best1;
DescentEdge best2;
DescentEdge best3;
DescentEdge best4;
DescentEdge best5;
};
class DescentAlignmentSink;
class Descent
{
public:
Descent() { reset(); }
bool init(
const Read &q,
TRootId rid,
const Scoring &sc,
TAlScore minsc,
TAlScore maxpen,
TReadOff al5pi,
TReadOff al5pf,
TIndexOffU topf,
TIndexOffU botf,
TIndexOffU topb,
TIndexOffU botb,
bool l2r,
size_t descid,
TDescentId parent,
TScore pen,
const Edit &e,
const Ebwt &ebwtFw,
const Ebwt &ebwtBw,
DescentRedundancyChecker &re,
EFactory<Descent> &df,
EFactory<DescentPos> &pf,
const EList<DescentRoot> &rs,
const EList<DescentConfig> &cs,
EHeap<TDescentPair> &heap,
DescentAlignmentSink &alsink,
DescentMetrics &met,
PerReadMetrics &prm);
bool init(
const Read &q,
TRootId rid,
const Scoring &sc,
TAlScore minsc,
TAlScore maxpen,
size_t descid,
const Ebwt &ebwtFw,
const Ebwt &ebwtBw,
DescentRedundancyChecker &re,
EFactory<Descent> &df,
EFactory<DescentPos> &pf,
const EList<DescentRoot> &rs,
const EList<DescentConfig> &cs,
EHeap<TDescentPair> &heap,
DescentAlignmentSink &alsink,
DescentMetrics &met,
PerReadMetrics &prm);
bool inited() const
{
return descid_ != std::numeric_limits<size_t>::max();
}
void reset()
{
lastRecalc_ = true;
descid_ = std::numeric_limits<size_t>::max();
}
bool root() const
{
return parent_ == std::numeric_limits<TDescentId>::max();
}
const Edit &edit() const
{
return edit_;
}
TDescentId parent() const
{
return parent_;
}
void followBestOutgoing(
const Read &q,
const Ebwt &ebwtFw,
const Ebwt &ebwtBw,
const Scoring &sc,
TAlScore minsc,
TAlScore maxpen,
DescentRedundancyChecker &re,
EFactory<Descent> &df,
EFactory<DescentPos> &pf,
const EList<DescentRoot> &rs,
const EList<DescentConfig> &cs,
EHeap<TDescentPair> &heap,
DescentAlignmentSink &alsink,
DescentMetrics &met,
PerReadMetrics &prm);
bool empty() const { return lastRecalc_ && out_.empty(); }
#ifndef NDEBUG
bool repOk(const Read *q) const
{
assert(!root() || !edit_.inited());
assert_eq(botf_ - topf_, botb_ - topb_);
if (q != NULL)
{
assert_leq(len_, q->length());
}
return true;
}
#endif
size_t al5pi() const
{
return al5pi_;
}
size_t al5pf() const { return al5pf_; }
bool l2r() const { return l2r_; }
void print(
std::ostream *os,
const char *prefix,
const Read &q,
size_t trimLf,
size_t trimRg,
bool fw,
const EList<Edit> &edits,
size_t ei,
size_t en,
BTDnaString &rf) const;
void collectEdits(
EList<Edit> &edits,
const Edit *e,
EFactory<Descent> &df)
{
size_t nuninited = 0;
size_t ei = edits.size();
size_t en = 0;
if (e != NULL && e->inited())
{
edits.push_back(*e);
en++;
}
size_t cur = descid_;
while (cur != std::numeric_limits<TDescentId>::max())
{
if (!df[cur].edit().inited())
{
nuninited++;
assert_leq(nuninited, 2);
}
else
{
edits.push_back(df[cur].edit());
en++;
}
cur = df[cur].parent();
}
edits.sortPortion(ei, en);
}
TIndexOffU topf() const { return topf_; }
TIndexOffU botf() const { return botf_; }
protected:
bool bounce(
const Read &q,
TIndexOffU topf,
TIndexOffU botf,
TIndexOffU topb,
TIndexOffU botb,
const Ebwt &ebwtFw,
const Ebwt &ebwtBw,
const Scoring &sc,
TAlScore minsc,
TAlScore maxpen,
DescentRedundancyChecker &re,
EFactory<Descent> &df,
EFactory<DescentPos> &pf,
const EList<DescentRoot> &rs,
const EList<DescentConfig> &cs,
EHeap<TDescentPair> &heap,
DescentAlignmentSink &alsink,
DescentMetrics &met,
PerReadMetrics &prm);
void nextLocsBi(
const Ebwt &ebwtFw,
const Ebwt &ebwtBw,
SideLocus &tloc,
SideLocus &bloc,
TIndexOffU topf,
TIndexOffU botf,
TIndexOffU topb,
TIndexOffU botb);
bool followMatches(
const Read &q,
const Scoring &sc,
const Ebwt &ebwtFw,
const Ebwt &ebwtBw,
DescentRedundancyChecker &re,
EFactory<Descent> &df,
EFactory<DescentPos> &pf,
const EList<DescentRoot> &rs,
const EList<DescentConfig> &cs,
EHeap<TDescentPair> &heap,
DescentAlignmentSink &alsink,
DescentMetrics &met,
PerReadMetrics &prm,
bool &branches,
bool &hitEnd,
bool &done,
TReadOff &off5p_i,
TIndexOffU &topf_bounce,
TIndexOffU &botf_bounce,
TIndexOffU &topb_bounce,
TIndexOffU &botb_bounce);
size_t recalcOutgoing(