1use num_traits::FromPrimitive;
37use num_traits::PrimInt;
38use serde_derive::{Deserialize, Serialize};
39use std;
40use std::fmt;
41use std::hash::Hash;
42use std::marker::PhantomData;
43
44use crate::bits_to_base;
45use crate::Kmer;
46use crate::Mer;
47
48pub type Kmer64 = IntKmer<u128>;
52pub type Kmer63 = VarIntKmer<u128, K63>;
54pub type Kmer62 = VarIntKmer<u128, K62>;
56pub type Kmer61 = VarIntKmer<u128, K61>;
58pub type Kmer60 = VarIntKmer<u128, K60>;
60pub type Kmer59 = VarIntKmer<u128, K59>;
62pub type Kmer58 = VarIntKmer<u128, K58>;
64pub type Kmer57 = VarIntKmer<u128, K57>;
66pub type Kmer56 = VarIntKmer<u128, K56>;
68pub type Kmer55 = VarIntKmer<u128, K55>;
70pub type Kmer54 = VarIntKmer<u128, K54>;
72pub type Kmer53 = VarIntKmer<u128, K53>;
74pub type Kmer52 = VarIntKmer<u128, K52>;
76pub type Kmer51 = VarIntKmer<u128, K51>;
78pub type Kmer50 = VarIntKmer<u128, K50>;
80pub type Kmer49 = VarIntKmer<u128, K49>;
82pub type Kmer48 = VarIntKmer<u128, K48>;
84pub type Kmer47 = VarIntKmer<u128, K47>;
86pub type Kmer46 = VarIntKmer<u128, K46>;
88pub type Kmer45 = VarIntKmer<u128, K45>;
90pub type Kmer44 = VarIntKmer<u128, K44>;
92pub type Kmer43 = VarIntKmer<u128, K43>;
94pub type Kmer42 = VarIntKmer<u128, K42>;
96pub type Kmer41 = VarIntKmer<u128, K41>;
98pub type Kmer40 = VarIntKmer<u128, K40>;
100pub type Kmer39 = VarIntKmer<u128, K39>;
102pub type Kmer38 = VarIntKmer<u128, K38>;
104pub type Kmer37 = VarIntKmer<u128, K37>;
106pub type Kmer36 = VarIntKmer<u128, K36>;
108pub type Kmer35 = VarIntKmer<u128, K35>;
110pub type Kmer34 = VarIntKmer<u128, K34>;
112pub type Kmer33 = VarIntKmer<u128, K33>;
114pub type Kmer32 = IntKmer<u64>;
116pub type Kmer31 = VarIntKmer<u64, K31>;
118pub type Kmer30 = VarIntKmer<u64, K30>;
120pub type Kmer29 = VarIntKmer<u64, K29>;
122pub type Kmer28 = VarIntKmer<u64, K28>;
124pub type Kmer27 = VarIntKmer<u64, K27>;
126pub type Kmer26 = VarIntKmer<u64, K26>;
128pub type Kmer25 = VarIntKmer<u64, K25>;
130pub type Kmer24 = VarIntKmer<u64, K24>;
132pub type Kmer23 = VarIntKmer<u64, K23>;
134pub type Kmer22 = VarIntKmer<u64, K22>;
136pub type Kmer21 = VarIntKmer<u64, K21>;
138pub type Kmer20 = VarIntKmer<u64, K20>;
140pub type Kmer19 = VarIntKmer<u64, K19>;
142pub type Kmer18 = VarIntKmer<u64, K18>;
144pub type Kmer17 = VarIntKmer<u64, K17>;
146pub type Kmer16 = IntKmer<u32>;
148pub type Kmer15 = VarIntKmer<u32, K15>;
150pub type Kmer14 = VarIntKmer<u32, K14>;
152pub type Kmer13 = VarIntKmer<u32, K13>;
154pub type Kmer12 = VarIntKmer<u32, K12>;
156pub type Kmer11 = VarIntKmer<u32, K11>;
158pub type Kmer10 = VarIntKmer<u32, K10>;
160pub type Kmer9 = VarIntKmer<u32, K9>;
162pub type Kmer8 = IntKmer<u16>;
164pub type Kmer7 = VarIntKmer<u16, K7>;
166pub type Kmer6 = VarIntKmer<u16, K6>;
168pub type Kmer5 = VarIntKmer<u16, K5>;
170pub type Kmer4 = IntKmer<u8>;
172pub type Kmer3 = VarIntKmer<u8, K3>;
174pub type Kmer2 = VarIntKmer<u8, K2>;
176
177
178pub trait IntHelp: PrimInt + FromPrimitive {
180 fn reverse_by_twos(&self) -> Self;
182
183 fn lower_of_two() -> Self;
184}
185
186impl IntHelp for u128 {
187 #[inline]
188 fn reverse_by_twos(&self) -> u128 {
189 let mut r = ((self & 0x33333333333333333333333333333333u128) << 2)
191 | ((self >> 2) & 0x33333333333333333333333333333333u128);
192
193 r = ((r & 0x0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0Fu128) << 4)
195 | ((r >> 4) & 0x0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0Fu128);
196
197 r = ((r & 0x00FF00FF00FF00FF00FF00FF00FF00FFu128) << 8)
199 | ((r >> 8) & 0x00FF00FF00FF00FF00FF00FF00FF00FFu128);
200
201 r = ((r & 0x0000FFFF0000FFFF0000FFFF0000FFFFu128) << 16)
203 | ((r >> 16) & 0x0000FFFF0000FFFF0000FFFF0000FFFFu128);
204
205 r = ((r & 0x00000000FFFFFFFF00000000FFFFFFFFu128) << 32)
207 | ((r >> 32) & 0x00000000FFFFFFFF00000000FFFFFFFFu128);
208
209 r = ((r & 0x0000000000000000FFFFFFFFFFFFFFFFu128) << 64)
211 | ((r >> 64) & 0x0000000000000000FFFFFFFFFFFFFFFFu128);
212
213 r
214 }
215
216 #[inline]
217 fn lower_of_two() -> u128 {
218 0x55555555555555555555555555555555u128
219 }
220}
221
222impl IntHelp for u64 {
223 #[inline]
224 fn reverse_by_twos(&self) -> u64 {
225 let mut r = ((self & 0x3333333333333333u64) << 2) | ((self >> 2) & 0x3333333333333333u64);
227
228 r = ((r & 0x0F0F0F0F0F0F0F0Fu64) << 4) | ((r >> 4) & 0x0F0F0F0F0F0F0F0Fu64);
230
231 r = ((r & 0x00FF00FF00FF00FFu64) << 8) | ((r >> 8) & 0x00FF00FF00FF00FFu64);
233
234 r = ((r & 0x0000FFFF0000FFFFu64) << 16) | ((r >> 16) & 0x0000FFFF0000FFFFu64);
236
237 r = ((r & 0x00000000FFFFFFFFu64) << 32) | ((r >> 32) & 0x00000000FFFFFFFFu64);
239
240 r
241 }
242
243 #[inline]
244 fn lower_of_two() -> u64 {
245 0x5555555555555555u64
246 }
247}
248
249impl IntHelp for u32 {
250 #[inline]
251 fn reverse_by_twos(&self) -> u32 {
252 let mut r = ((self & 0x33333333u32) << 2) | ((self >> 2) & 0x33333333u32);
254
255 r = ((r & 0x0F0F0F0Fu32) << 4) | ((r >> 4) & 0x0F0F0F0Fu32);
257
258 r = ((r & 0x00FF00FFu32) << 8) | ((r >> 8) & 0x00FF00FFu32);
260
261 r = ((r & 0x0000FFFFu32) << 16) | ((r >> 16) & 0x0000FFFFu32);
263
264 r
265 }
266
267 #[inline]
268 fn lower_of_two() -> u32 {
269 0x55555555u32
270 }
271}
272
273impl IntHelp for u16 {
274 #[inline]
275 fn reverse_by_twos(&self) -> u16 {
276 let mut r = ((self & 0x3333u16) << 2) | ((self >> 2) & 0x3333u16);
278
279 r = ((r & 0x0F0Fu16) << 4) | ((r >> 4) & 0x0F0Fu16);
281
282 r = ((r & 0x00FFu16) << 8) | ((r >> 8) & 0x00FFu16);
284
285 r
286 }
287
288 #[inline]
289 fn lower_of_two() -> u16 {
290 0x5555u16
291 }
292}
293
294impl IntHelp for u8 {
295 #[inline]
296 fn reverse_by_twos(&self) -> u8 {
297 let mut r = ((self & 0x33u8) << 2) | ((self >> 2) & 0x33u8);
299
300 r = ((r & 0x0Fu8) << 4) | ((r >> 4) & 0x0Fu8);
302
303 r
304 }
305
306 #[inline]
307 fn lower_of_two() -> u8 {
308 0x55u8
309 }
310}
311
312#[derive(Copy, Clone, PartialEq, PartialOrd, Eq, Ord, Hash, Serialize, Deserialize)]
314pub struct IntKmer<T: PrimInt + FromPrimitive + IntHelp + Sized> {
315 pub storage: T,
316}
317
318impl<T: PrimInt + FromPrimitive + Hash + IntHelp + Sized> IntKmer<T> {
319 fn msk() -> T {
320 T::one() << 1 | T::one()
321 }
322
323 fn to_byte(v: T) -> u8 {
324 T::to_u8(&v).unwrap()
325 }
326
327 fn t_from_byte(v: u8) -> T {
328 T::from_u8(v).unwrap()
329 }
330
331 fn t_from_u64(v: u64) -> T {
332 T::from_u64(v).unwrap()
333 }
334
335 #[inline]
336 fn addr(&self, pos: usize) -> usize {
337 let top_base = Self::k() - 1;
338 (top_base - pos) * 2
339 }
340
341 #[inline(always)]
342 fn _k() -> usize {
343 std::mem::size_of::<T>() * 4
345 }
346
347 #[inline(always)]
348 fn _bits() -> usize {
349 std::mem::size_of::<T>() * 8
350 }
351
352 #[inline(always)]
353 pub fn top_mask(n_bases: usize) -> T {
354 if n_bases > 0 {
355 let one = T::one();
357 ((one << (n_bases * 2)) - one) << (Self::_bits() - n_bases * 2)
358 } else {
359 T::zero()
360 }
361 }
362
363 #[inline(always)]
364 pub fn bottom_mask(n_bases: usize) -> T {
365 if n_bases > 0 {
366 let one = T::one();
368 (one << (n_bases * 2)) - one
369 } else {
370 T::zero()
371 }
372 }
373}
374
375impl<T: PrimInt + FromPrimitive + Hash + IntHelp> Mer for IntKmer<T> {
376 #[inline(always)]
377 fn len(&self) -> usize {
378 Self::_k()
379 }
380
381 #[inline(always)]
382 fn is_empty(&self) -> bool {
383 false
384 }
385
386 fn get(&self, pos: usize) -> u8 {
388 let bit = self.addr(pos);
389 Self::to_byte(self.storage >> bit & Self::msk())
390 }
391
392 fn set_mut(&mut self, pos: usize, v: u8) {
393 let bit = self.addr(pos);
394 let mask = !(Self::msk() << bit);
395
396 self.storage = (self.storage & mask) | (Self::t_from_byte(v) << bit);
397 }
398
399 #[inline(always)]
403 fn set_slice_mut(&mut self, pos: usize, n_bases: usize, value: u64) {
404 debug_assert!(pos + n_bases <= Self::k());
405
406 let v_shift = if Self::_bits() < 64 {
407 value >> (64 - Self::_bits())
408 } else {
409 value
410 };
411
412 let v = if Self::_bits() > 64 {
413 Self::t_from_u64(v_shift) << (Self::_bits() - 64)
414 } else {
415 Self::t_from_u64(v_shift)
416 };
417
418 let top_mask = Self::top_mask(pos);
419 let bottom_mask = Self::bottom_mask(Self::k() - (pos + n_bases));
420 let mask = top_mask | bottom_mask;
421
422 let value_slide = v >> (2 * pos);
423
424 self.storage = (self.storage & mask) | (value_slide & !mask);
425 }
426
427 fn rc(&self) -> Self {
429 let new = !self.storage.reverse_by_twos();
431
432 IntKmer { storage: new }
434 }
435
436 fn at_count(&self) -> u32 {
437 let mix_base_bits = !((self.storage >> 1) ^ self.storage);
440 let mask_lower = mix_base_bits & IntHelp::lower_of_two();
441 mask_lower.count_ones()
442 }
443
444 fn gc_count(&self) -> u32 {
445 let mix_base_bits = (self.storage >> 1) ^ self.storage;
448 let mask_lower = mix_base_bits & IntHelp::lower_of_two();
449 mask_lower.count_ones()
450 }
451}
452
453impl<T: PrimInt + FromPrimitive + Hash + IntHelp> Kmer for IntKmer<T> {
454 fn empty() -> Self {
455 IntKmer { storage: T::zero() }
456 }
457
458 #[inline(always)]
459 fn k() -> usize {
460 Self::_k()
461 }
462
463 fn from_u64(v: u64) -> IntKmer<T> {
464 IntKmer {
465 storage: Self::t_from_u64(v),
466 }
467 }
468
469 fn to_u64(&self) -> u64 {
470 T::to_u64(&self.storage).unwrap()
471 }
472
473 fn extend_left(&self, v: u8) -> Self {
475 let new = self.storage >> 2 | (Self::t_from_byte(v) << ((Self::k() - 1) * 2));
476 IntKmer { storage: new }
477 }
478
479 fn extend_right(&self, v: u8) -> Self {
480 let new = self.storage << 2;
481 let mut kmer = IntKmer { storage: new };
482 kmer.set_mut(Self::k() - 1, v);
483 kmer
484 }
485
486 fn hamming_dist(&self, other: Self) -> u32 {
488 let bit_diffs = self.storage ^ other.storage;
489 let two_bit_diffs = (bit_diffs | bit_diffs >> 1) & IntHelp::lower_of_two();
490 two_bit_diffs.count_ones()
491 }
492}
493
494impl<T: PrimInt + FromPrimitive + Hash + IntHelp> fmt::Debug for IntKmer<T> {
495 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
496 let mut s = String::new();
497 for pos in 0..Self::k() {
498 s.push(bits_to_base(self.get(pos)))
499 }
500
501 write!(f, "{}", s)
502 }
503}
504
505pub trait KmerSize: Ord + Hash + Copy + fmt::Debug {
507 #[allow(non_snake_case)]
508 fn K() -> usize;
509}
510
511#[derive(Copy, Clone, PartialEq, PartialOrd, Eq, Ord, Hash, Serialize, Deserialize)]
521pub struct VarIntKmer<T: PrimInt + FromPrimitive + IntHelp, KS: KmerSize> {
522 pub storage: T,
523 pub phantom: PhantomData<KS>,
524}
525
526impl<T: PrimInt + FromPrimitive + Hash + IntHelp, KS: KmerSize> Kmer for VarIntKmer<T, KS> {
527 fn empty() -> Self {
528 VarIntKmer {
529 storage: T::zero(),
530 phantom: PhantomData,
531 }
532 }
533
534 #[inline]
535 fn k() -> usize {
536 Self::_k()
537 }
538
539 fn to_u64(&self) -> u64 {
540 T::to_u64(&self.storage).unwrap()
541 }
542
543 fn from_u64(v: u64) -> Self {
544 VarIntKmer {
545 storage: Self::t_from_u64(v),
546 phantom: PhantomData,
547 }
548 }
549
550 fn extend_left(&self, v: u8) -> Self {
552 let new = self.storage >> 2;
553 let mut kmer = VarIntKmer {
554 storage: new,
555 phantom: PhantomData,
556 };
557 kmer.set_mut(0, v);
558 kmer
559 }
560
561 fn extend_right(&self, v: u8) -> Self {
562 let new = self.storage << 2 & !Self::top_mask(0);
563 let mut kmer = VarIntKmer {
564 storage: new,
565 phantom: PhantomData,
566 };
567 kmer.set_mut(Self::k() - 1, v);
568 kmer
569 }
570
571 fn hamming_dist(&self, other: Self) -> u32 {
572 let bit_diffs = self.storage ^ other.storage;
573 let two_bit_diffs = (bit_diffs | bit_diffs >> 1) & IntHelp::lower_of_two();
574 two_bit_diffs.count_ones()
575 }
576}
577
578impl<T: PrimInt + FromPrimitive + Hash + IntHelp, KS: KmerSize> VarIntKmer<T, KS> {
579 #[inline(always)]
580 fn msk() -> T {
581 T::one() << 1 | T::one()
582 }
583
584 fn to_byte(v: T) -> u8 {
585 T::to_u8(&v).unwrap()
586 }
587
588 fn t_from_byte(v: u8) -> T {
589 T::from_u8(v).unwrap()
590 }
591
592 fn t_from_u64(v: u64) -> T {
593 T::from_u64(v).unwrap()
594 }
595
596 #[inline(always)]
597 fn addr(&self, pos: usize) -> usize {
598 let top_base = Self::k() - 1;
599 (top_base - pos) * 2
600 }
601
602 #[inline(always)]
604 fn _k() -> usize {
605 KS::K()
606 }
607
608 #[inline(always)]
610 fn _bits() -> usize {
611 Self::_k() * 2
612 }
613
614 #[inline(always)]
615 fn _total_bits() -> usize {
616 std::mem::size_of::<T>() * 8
617 }
618
619 #[inline(always)]
621 pub fn top_mask(n_bases: usize) -> T {
622 let unused_bits = Self::_total_bits() - Self::_bits();
623 let mask_bits = n_bases * 2 + unused_bits;
624
625 if mask_bits > 0 {
626 let one = T::one();
627 ((one << mask_bits) - one) << (Self::_total_bits() - mask_bits)
628 } else {
629 T::zero()
630 }
631 }
632
633 #[inline(always)]
634 pub fn bottom_mask(n_bases: usize) -> T {
635 if n_bases > 0 {
636 let one = T::one();
638 (one << (n_bases * 2)) - one
639 } else {
640 T::zero()
641 }
642 }
643}
644
645impl<T: PrimInt + FromPrimitive + Hash + IntHelp, KS: KmerSize> Mer for VarIntKmer<T, KS> {
646 #[inline(always)]
647 fn len(&self) -> usize {
648 Self::_k()
649 }
650
651 fn is_empty(&self) -> bool {
652 Self::_k() == 0
653 }
654
655 fn get(&self, pos: usize) -> u8 {
657 let bit = self.addr(pos);
658 Self::to_byte(self.storage >> bit & Self::msk())
659 }
660
661 fn set_mut(&mut self, pos: usize, v: u8) {
662 let bit = self.addr(pos);
663 let mask = !(Self::msk() << bit);
664
665 self.storage = (self.storage & mask) | (Self::t_from_byte(v) << bit);
666 }
667
668 #[inline(always)]
672 fn set_slice_mut(&mut self, pos: usize, n_bases: usize, value: u64) {
673 debug_assert!(pos + n_bases <= Self::k());
674
675 let v_shift = if Self::_total_bits() < 64 {
677 value >> (64 - Self::_total_bits())
678 } else {
679 value
680 };
681
682 let v = if Self::_total_bits() > 64 {
684 Self::t_from_u64(v_shift) << (Self::_total_bits() - 64)
685 } else {
686 Self::t_from_u64(v_shift)
687 };
688
689 let top_mask = Self::top_mask(pos);
691 let bottom_mask = Self::bottom_mask(Self::k() - (pos + n_bases));
692 let mask = top_mask | bottom_mask;
693
694 let shift = (2 * pos) + (Self::_total_bits() - Self::_bits());
696 let value_slide = v >> shift;
697
698 self.storage = (self.storage & mask) | (value_slide & !mask);
699 }
700
701 fn rc(&self) -> Self {
703 let mut new = !self.storage.reverse_by_twos();
705
706 if Self::k() < std::mem::size_of::<T>() * 4 {
708 let up_shift = 2 * (std::mem::size_of::<T>() * 4 - Self::k());
709 new = new >> up_shift;
710 }
711
712 VarIntKmer {
713 storage: new,
714 phantom: PhantomData,
715 }
716 }
717
718 fn at_count(&self) -> u32 {
719 let mix_base_bits = !((self.storage >> 1) ^ self.storage);
722 let mask_lower = mix_base_bits & !Self::top_mask(0) & IntHelp::lower_of_two();
723 mask_lower.count_ones()
724 }
725
726 fn gc_count(&self) -> u32 {
727 let mix_base_bits = (self.storage >> 1) ^ self.storage;
730 let mask_lower = mix_base_bits & !Self::top_mask(0) & IntHelp::lower_of_two();
731 mask_lower.count_ones()
732 }
733}
734
735impl<T: PrimInt + FromPrimitive + Hash + IntHelp, KS: KmerSize> fmt::Debug for VarIntKmer<T, KS> {
736 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
737 let mut s = String::new();
738 for pos in 0..Self::k() {
739 s.push(bits_to_base(self.get(pos)))
740 }
741
742 write!(f, "{}", s)
743 }
744}
745
746#[derive(Debug, Hash, Copy, Clone, Ord, PartialOrd, Eq, PartialEq)]
748pub struct K63;
749
750impl KmerSize for K63 {
751 #[inline(always)]
752 fn K() -> usize {
753 63
754 }
755}
756
757#[derive(Debug, Hash, Copy, Clone, Ord, PartialOrd, Eq, PartialEq)]
759pub struct K62;
760
761impl KmerSize for K62 {
762 #[inline(always)]
763 fn K() -> usize {
764 62
765 }
766}
767
768#[derive(Debug, Hash, Copy, Clone, Ord, PartialOrd, Eq, PartialEq)]
770pub struct K61;
771
772impl KmerSize for K61 {
773 #[inline(always)]
774 fn K() -> usize {
775 61
776 }
777}
778
779#[derive(Debug, Hash, Copy, Clone, Ord, PartialOrd, Eq, PartialEq)]
781pub struct K60;
782
783impl KmerSize for K60 {
784 #[inline(always)]
785 fn K() -> usize {
786 60
787 }
788}
789
790
791#[derive(Debug, Hash, Copy, Clone, Ord, PartialOrd, Eq, PartialEq)]
793pub struct K59;
794
795impl KmerSize for K59 {
796 #[inline(always)]
797 fn K() -> usize {
798 59
799 }
800}
801
802#[derive(Debug, Hash, Copy, Clone, Ord, PartialOrd, Eq, PartialEq)]
804pub struct K58;
805
806impl KmerSize for K58 {
807 #[inline(always)]
808 fn K() -> usize {
809 58
810 }
811}
812
813#[derive(Debug, Hash, Copy, Clone, Ord, PartialOrd, Eq, PartialEq)]
815pub struct K57;
816
817impl KmerSize for K57 {
818 #[inline(always)]
819 fn K() -> usize {
820 57
821 }
822}
823
824#[derive(Debug, Hash, Copy, Clone, Ord, PartialOrd, Eq, PartialEq)]
826pub struct K56;
827
828impl KmerSize for K56 {
829 #[inline(always)]
830 fn K() -> usize {
831 56
832 }
833}
834
835#[derive(Debug, Hash, Copy, Clone, Ord, PartialOrd, Eq, PartialEq)]
837pub struct K55;
838
839impl KmerSize for K55 {
840 #[inline(always)]
841 fn K() -> usize {
842 55
843 }
844}
845
846#[derive(Debug, Hash, Copy, Clone, Ord, PartialOrd, Eq, PartialEq)]
848pub struct K54;
849
850impl KmerSize for K54 {
851 #[inline(always)]
852 fn K() -> usize {
853 54
854 }
855}
856
857#[derive(Debug, Hash, Copy, Clone, Ord, PartialOrd, Eq, PartialEq)]
859pub struct K53;
860
861impl KmerSize for K53 {
862 #[inline(always)]
863 fn K() -> usize {
864 53
865 }
866}
867
868#[derive(Debug, Hash, Copy, Clone, Ord, PartialOrd, Eq, PartialEq)]
870pub struct K52;
871
872impl KmerSize for K52 {
873 #[inline(always)]
874 fn K() -> usize {
875 52
876 }
877}
878
879#[derive(Debug, Hash, Copy, Clone, Ord, PartialOrd, Eq, PartialEq)]
881pub struct K51;
882
883impl KmerSize for K51 {
884 #[inline(always)]
885 fn K() -> usize {
886 51
887 }
888}
889
890#[derive(Debug, Hash, Copy, Clone, Ord, PartialOrd, Eq, PartialEq)]
892pub struct K50;
893
894impl KmerSize for K50 {
895 #[inline(always)]
896 fn K() -> usize {
897 50
898 }
899}
900
901#[derive(Debug, Hash, Copy, Clone, Ord, PartialOrd, Eq, PartialEq)]
903pub struct K49;
904
905impl KmerSize for K49 {
906 #[inline(always)]
907 fn K() -> usize {
908 49
909 }
910}
911
912#[derive(Debug, Hash, Copy, Clone, Ord, PartialOrd, Eq, PartialEq)]
914pub struct K48;
915
916impl KmerSize for K48 {
917 #[inline(always)]
918 fn K() -> usize {
919 48
920 }
921}
922
923#[derive(Debug, Hash, Copy, Clone, Ord, PartialOrd, Eq, PartialEq)]
925pub struct K47;
926
927impl KmerSize for K47 {
928 #[inline(always)]
929 fn K() -> usize {
930 47
931 }
932}
933
934#[derive(Debug, Hash, Copy, Clone, Ord, PartialOrd, Eq, PartialEq)]
936pub struct K46;
937
938impl KmerSize for K46 {
939 #[inline(always)]
940 fn K() -> usize {
941 46
942 }
943}
944
945#[derive(Debug, Hash, Copy, Clone, Ord, PartialOrd, Eq, PartialEq)]
947pub struct K45;
948
949impl KmerSize for K45 {
950 #[inline(always)]
951 fn K() -> usize {
952 45
953 }
954}
955
956#[derive(Debug, Hash, Copy, Clone, Ord, PartialOrd, Eq, PartialEq)]
958pub struct K44;
959
960impl KmerSize for K44 {
961 #[inline(always)]
962 fn K() -> usize {
963 44
964 }
965}
966
967#[derive(Debug, Hash, Copy, Clone, Ord, PartialOrd, Eq, PartialEq)]
969pub struct K43;
970
971impl KmerSize for K43 {
972 #[inline(always)]
973 fn K() -> usize {
974 43
975 }
976}
977
978#[derive(Debug, Hash, Copy, Clone, Ord, PartialOrd, Eq, PartialEq)]
980pub struct K42;
981
982impl KmerSize for K42 {
983 #[inline(always)]
984 fn K() -> usize {
985 42
986 }
987}
988
989#[derive(Debug, Hash, Copy, Clone, Ord, PartialOrd, Eq, PartialEq)]
991pub struct K41;
992
993impl KmerSize for K41 {
994 #[inline(always)]
995 fn K() -> usize {
996 41
997 }
998}
999
1000#[derive(Debug, Hash, Copy, Clone, Ord, PartialOrd, Eq, PartialEq)]
1002pub struct K40;
1003
1004impl KmerSize for K40 {
1005 #[inline(always)]
1006 fn K() -> usize {
1007 40
1008 }
1009}
1010
1011#[derive(Debug, Hash, Copy, Clone, Ord, PartialOrd, Eq, PartialEq)]
1013pub struct K39;
1014
1015impl KmerSize for K39 {
1016 #[inline(always)]
1017 fn K() -> usize {
1018 39
1019 }
1020}
1021
1022#[derive(Debug, Hash, Copy, Clone, Ord, PartialOrd, Eq, PartialEq)]
1024pub struct K38;
1025
1026impl KmerSize for K38 {
1027 #[inline(always)]
1028 fn K() -> usize {
1029 38
1030 }
1031}
1032
1033#[derive(Debug, Hash, Copy, Clone, Ord, PartialOrd, Eq, PartialEq)]
1035pub struct K37;
1036
1037impl KmerSize for K37 {
1038 #[inline(always)]
1039 fn K() -> usize {
1040 37
1041 }
1042}
1043
1044#[derive(Debug, Hash, Copy, Clone, Ord, PartialOrd, Eq, PartialEq)]
1046pub struct K36;
1047
1048impl KmerSize for K36 {
1049 #[inline(always)]
1050 fn K() -> usize {
1051 36
1052 }
1053}
1054
1055#[derive(Debug, Hash, Copy, Clone, Ord, PartialOrd, Eq, PartialEq)]
1057pub struct K35;
1058
1059impl KmerSize for K35 {
1060 #[inline(always)]
1061 fn K() -> usize {
1062 35
1063 }
1064}
1065
1066#[derive(Debug, Hash, Copy, Clone, Ord, PartialOrd, Eq, PartialEq)]
1068pub struct K34;
1069
1070impl KmerSize for K34 {
1071 #[inline(always)]
1072 fn K() -> usize {
1073 34
1074 }
1075}
1076
1077#[derive(Debug, Hash, Copy, Clone, Ord, PartialOrd, Eq, PartialEq)]
1079pub struct K33;
1080
1081impl KmerSize for K33 {
1082 #[inline(always)]
1083 fn K() -> usize {
1084 33
1085 }
1086}
1087
1088#[derive(Debug, Hash, Copy, Clone, Ord, PartialOrd, Eq, PartialEq)]
1090pub struct K31;
1091
1092impl KmerSize for K31 {
1093 #[inline(always)]
1094 fn K() -> usize {
1095 31
1096 }
1097}
1098
1099#[derive(Debug, Hash, Copy, Clone, Ord, PartialOrd, Eq, PartialEq)]
1101pub struct K30;
1102
1103impl KmerSize for K30 {
1104 #[inline(always)]
1105 fn K() -> usize {
1106 30
1107 }
1108}
1109
1110#[derive(Debug, Hash, Copy, Clone, Ord, PartialOrd, Eq, PartialEq)]
1112pub struct K29;
1113
1114impl KmerSize for K29 {
1115 #[inline(always)]
1116 fn K() -> usize {
1117 29
1118 }
1119}
1120
1121#[derive(Debug, Hash, Copy, Clone, Ord, PartialOrd, Eq, PartialEq)]
1123pub struct K28;
1124
1125impl KmerSize for K28 {
1126 #[inline(always)]
1127 fn K() -> usize {
1128 28
1129 }
1130}
1131
1132#[derive(Debug, Hash, Copy, Clone, Ord, PartialOrd, Eq, PartialEq)]
1134pub struct K27;
1135
1136impl KmerSize for K27 {
1137 #[inline(always)]
1138 fn K() -> usize {
1139 27
1140 }
1141}
1142
1143#[derive(Debug, Hash, Copy, Clone, Ord, PartialOrd, Eq, PartialEq)]
1145pub struct K26;
1146
1147impl KmerSize for K26 {
1148 #[inline(always)]
1149 fn K() -> usize {
1150 26
1151 }
1152}
1153
1154#[derive(Debug, Hash, Copy, Clone, Ord, PartialOrd, Eq, PartialEq)]
1156pub struct K25;
1157
1158impl KmerSize for K25 {
1159 #[inline(always)]
1160 fn K() -> usize {
1161 25
1162 }
1163}
1164
1165#[derive(Debug, Hash, Copy, Clone, Ord, PartialOrd, Eq, PartialEq)]
1167pub struct K24;
1168
1169impl KmerSize for K24 {
1170 #[inline(always)]
1171 fn K() -> usize {
1172 24
1173 }
1174}
1175
1176#[derive(Debug, Hash, Copy, Clone, Ord, PartialOrd, Eq, PartialEq)]
1178pub struct K23;
1179
1180impl KmerSize for K23 {
1181 #[inline(always)]
1182 fn K() -> usize {
1183 23
1184 }
1185}
1186
1187
1188#[derive(Debug, Hash, Copy, Clone, Ord, PartialOrd, Eq, PartialEq)]
1190pub struct K22;
1191
1192impl KmerSize for K22 {
1193 #[inline(always)]
1194 fn K() -> usize {
1195 22
1196 }
1197}
1198
1199#[derive(Debug, Hash, Copy, Clone, Ord, PartialOrd, Eq, PartialEq)]
1201pub struct K21;
1202
1203impl KmerSize for K21 {
1204 #[inline(always)]
1205 fn K() -> usize {
1206 21
1207 }
1208}
1209
1210#[derive(Debug, Hash, Copy, Clone, Ord, PartialOrd, Eq, PartialEq)]
1212pub struct K20;
1213
1214impl KmerSize for K20 {
1215 #[inline(always)]
1216 fn K() -> usize {
1217 20
1218 }
1219}
1220
1221#[derive(Debug, Hash, Copy, Clone, Ord, PartialOrd, Eq, PartialEq)]
1223pub struct K19;
1224
1225impl KmerSize for K19 {
1226 #[inline(always)]
1227 fn K() -> usize {
1228 19
1229 }
1230}
1231
1232#[derive(Debug, Hash, Copy, Clone, Ord, PartialOrd, Eq, PartialEq)]
1234pub struct K18;
1235
1236impl KmerSize for K18 {
1237 #[inline(always)]
1238 fn K() -> usize {
1239 18
1240 }
1241}
1242
1243#[derive(Debug, Hash, Copy, Clone, Ord, PartialOrd, Eq, PartialEq)]
1245pub struct K17;
1246
1247impl KmerSize for K17 {
1248 #[inline(always)]
1249 fn K() -> usize {
1250 17
1251 }
1252}
1253
1254#[derive(Debug, Hash, Copy, Clone, Ord, PartialOrd, Eq, PartialEq)]
1256pub struct K15;
1257
1258impl KmerSize for K15 {
1259 #[inline(always)]
1260 fn K() -> usize {
1261 15
1262 }
1263}
1264
1265#[derive(Debug, Hash, Copy, Clone, Ord, PartialOrd, Eq, PartialEq)]
1267pub struct K14;
1268
1269impl KmerSize for K14 {
1270 #[inline(always)]
1271 fn K() -> usize {
1272 14
1273 }
1274}
1275
1276#[derive(Debug, Hash, Copy, Clone, Ord, PartialOrd, Eq, PartialEq)]
1278pub struct K13;
1279
1280impl KmerSize for K13 {
1281 #[inline]
1282 fn K() -> usize {
1283 13
1284 }
1285}
1286
1287#[derive(Debug, Hash, Copy, Clone, Ord, PartialOrd, Eq, PartialEq)]
1289pub struct K12;
1290
1291impl KmerSize for K12 {
1292 #[inline]
1293 fn K() -> usize {
1294 12
1295 }
1296}
1297
1298#[derive(Debug, Hash, Copy, Clone, Ord, PartialOrd, Eq, PartialEq)]
1300pub struct K11;
1301
1302impl KmerSize for K11 {
1303 #[inline]
1304 fn K() -> usize {
1305 11
1306 }
1307}
1308
1309#[derive(Debug, Hash, Copy, Clone, Ord, PartialOrd, Eq, PartialEq)]
1311pub struct K10;
1312
1313impl KmerSize for K10 {
1314 #[inline]
1315 fn K() -> usize {
1316 10
1317 }
1318}
1319
1320#[derive(Debug, Hash, Copy, Clone, Ord, PartialOrd, Eq, PartialEq)]
1322pub struct K9;
1323
1324impl KmerSize for K9 {
1325 #[inline(always)]
1326 fn K() -> usize {
1327 9
1328 }
1329}
1330
1331#[derive(Debug, Hash, Copy, Clone, Ord, PartialOrd, Eq, PartialEq)]
1333pub struct K7;
1334
1335impl KmerSize for K7 {
1336 #[inline(always)]
1337 fn K() -> usize {
1338 7
1339 }
1340}
1341
1342#[derive(Debug, Hash, Copy, Clone, Ord, PartialOrd, Eq, PartialEq)]
1344pub struct K6;
1345
1346impl KmerSize for K6 {
1347 #[inline(always)]
1348 fn K() -> usize {
1349 6
1350 }
1351}
1352
1353#[derive(Debug, Hash, Copy, Clone, Ord, PartialOrd, Eq, PartialEq)]
1355pub struct K5;
1356
1357impl KmerSize for K5 {
1358 #[inline(always)]
1359 fn K() -> usize {
1360 5
1361 }
1362}
1363#[derive(Debug, Hash, Copy, Clone, Ord, PartialOrd, Eq, PartialEq)]
1365pub struct K4;
1366
1367impl KmerSize for K4 {
1368 #[inline(always)]
1369 fn K() -> usize {
1370 4
1371 }
1372}
1373#[derive(Debug, Hash, Copy, Clone, Ord, PartialOrd, Eq, PartialEq)]
1375pub struct K3;
1376
1377impl KmerSize for K3 {
1378 #[inline(always)]
1379 fn K() -> usize {
1380 3
1381 }
1382}
1383#[derive(Debug, Hash, Copy, Clone, Ord, PartialOrd, Eq, PartialEq)]
1385pub struct K2;
1386
1387impl KmerSize for K2 {
1388 #[inline(always)]
1389 fn K() -> usize {
1390 2
1391 }
1392}
1393
1394#[cfg(test)]
1395mod tests {
1396 use super::*;
1397 use crate::vmer::Lmer;
1398 use rand::{self, Rng, RngCore};
1399
1400 use crate::MerImmut;
1401 use crate::Vmer;
1402
1403 fn check_hd<T: Kmer>(k1: T, k2: T) {
1404 let mut n = 0;
1405 for i in 0..T::k() {
1406 if k1.get(i) != k2.get(i) {
1407 n += 1;
1408 }
1409 }
1410
1411 assert_eq!(k1.hamming_dist(k2), n);
1412 assert_eq!(k2.hamming_dist(k1), n);
1413 }
1414
1415 fn check_kmer<T: Kmer>() {
1417 #[allow(non_snake_case)]
1418 let K = T::k();
1419
1420 let km = random_kmer::<T>();
1422
1423 let km2 = random_kmer::<T>();
1425 check_hd(km, km2);
1426
1427 let rc = km.rc();
1429 let double_rc = rc.rc();
1430 assert!(km == double_rc);
1431
1432 for i in 0..K {
1433 assert!(km.get(i) == (3 - rc.get(K - 1 - i)))
1434 }
1435
1436 for i in 0..K {
1438 let km2 = km.set(i, 0);
1439 assert!(km2.get(i) == 0);
1440 }
1441 let mut copy_kmer = T::empty();
1442 for i in 0..K {
1443 copy_kmer = copy_kmer.set(i, km.get(i));
1444 }
1445 assert!(km == copy_kmer);
1446
1447 let nb = random_base();
1449 let ext_r = km.extend_right(nb);
1450 assert!(ext_r.get(K - 1) == nb);
1451 assert!(km.get(1) == ext_r.get(0));
1452
1453 let nb = random_base();
1455 let ext_l = km.extend_left(nb);
1456 assert!(ext_l.get(0) == nb);
1457 assert!(ext_l.get(1) == km.get(0));
1458
1459 let lt = km.extend_left(0);
1461 assert!(lt <= km);
1462
1463 let gt = km.extend_left(3);
1465 assert!(gt >= km);
1466
1467 let l_base = random_base();
1469 let r_base = random_base();
1470 let ts = km.set(0, l_base).set(K - 1, r_base);
1471
1472 let double_shift = ts.extend_left(0).extend_right(r_base);
1473 assert!(ts == double_shift);
1474
1475 if T::k() <= 32 {
1476 let u64_1 = km.to_u64();
1478 let km2 = T::from_u64(u64_1);
1479 let u64_2 = km2.to_u64();
1480 assert_eq!(km, km2);
1481 assert_eq!(u64_1, u64_2);
1482 }
1483
1484 let mut at_count = 0;
1486 let mut gc_count = 0;
1487 for i in 0..km.len() {
1488 let base = km.get(i);
1489 if base == 0 || base == 3 {
1490 at_count += 1;
1491 } else {
1492 gc_count += 1;
1493 }
1494 }
1495
1496 assert_eq!(km.at_count(), at_count);
1497 assert_eq!(km.gc_count(), gc_count);
1498 }
1499
1500 fn check_vmer<V: Vmer + MerImmut, T: Kmer>() {
1501 let vm = random_vmer::<V, T>();
1502 let l = vm.len();
1503
1504 let rc = vm.rc();
1505
1506 for i in 0..l {
1507 if vm.get(i) != (3 - rc.get(l - 1 - i)) {
1508 println!("km: {:?}, rc: {:?}", vm, rc);
1509 }
1510
1511 assert!(vm.get(i) == (3 - rc.get(l - 1 - i)))
1512 }
1513
1514 let double_rc = rc.rc();
1515 assert!(vm == double_rc);
1516
1517 for i in 0..l {
1518 let vm2 = vm.set(i, 0);
1520 assert!(vm2.get(i) == 0);
1521 }
1522
1523 let mut copy_vmer = V::new(l);
1524 for i in 0..l {
1525 copy_vmer = copy_vmer.set(i, vm.get(i));
1526 }
1527 assert!(vm == copy_vmer);
1528
1529 let kmers: Vec<T> = vm.iter_kmers().collect();
1530 assert_eq!(kmers.len(), vm.len() - T::k() + 1);
1531
1532 for (pos, kmer) in kmers.iter().enumerate() {
1533 for i in 0..T::k() {
1534 assert_eq!(kmer.get(i), vm.get(i + pos))
1535 }
1536
1537 if vm.get_kmer::<T>(pos) != *kmer {
1538 println!(
1539 "didn't get same kmer: i:{}, vm: {:?} kmer_iter: {:?}, kmer_get: {:?}",
1540 pos,
1541 vm,
1542 kmer,
1543 vm.get_kmer::<T>(pos)
1544 )
1545 }
1546 assert_eq!(*kmer, vm.get_kmer(pos));
1547 }
1548
1549 assert!(kmers[0] == vm.first_kmer());
1550 assert!(kmers[kmers.len() - 1] == vm.last_kmer());
1551 }
1552
1553 pub fn random_vmer<V: Vmer + MerImmut, T: Kmer>() -> V {
1554 let mut r = rand::thread_rng();
1555 let len = r.gen_range(T::k(), V::max_len());
1556
1557 let mut vmer = V::new(len);
1558 for pos in 0..len {
1559 let b = (r.next_u64() % 4) as u8;
1560 vmer = vmer.set(pos, b);
1561 }
1562 vmer
1563 }
1564
1565 pub fn random_kmer<T: Kmer>() -> T {
1566 let mut r = rand::thread_rng();
1567 let mut kmer = T::empty();
1568 for pos in 0..T::k() {
1569 let b = (r.next_u64() % 4) as u8;
1570 kmer = kmer.set(pos, b);
1571 }
1572 kmer
1573 }
1574
1575 pub fn random_base() -> u8 {
1576 let mut r = rand::thread_rng();
1577 (r.next_u64() % 4) as u8
1578 }
1579
1580 #[test]
1581 fn test_lmer_3_kmer_64() {
1582 for _ in 0..10000 {
1583 check_vmer::<Lmer<[u64; 3]>, IntKmer<u128>>();
1584 }
1585 }
1586
1587 #[test]
1588 fn test_lmer_3_kmer_48() {
1589 for _ in 0..10000 {
1590 check_vmer::<Lmer<[u64; 3]>, VarIntKmer<u128, K48>>();
1591 }
1592 }
1593
1594 #[test]
1595 fn test_lmer_3_kmer_32() {
1596 for _ in 0..10000 {
1597 check_vmer::<Lmer<[u64; 3]>, IntKmer<u64>>();
1598 }
1599 }
1600
1601 #[test]
1602 fn test_lmer_2_kmer_32() {
1603 for _ in 0..10000 {
1604 check_vmer::<Lmer<[u64; 3]>, IntKmer<u64>>();
1605 }
1606 }
1607
1608 #[test]
1609 fn test_lmer_1_kmer_24() {
1610 for _ in 0..10000 {
1611 check_vmer::<Lmer<[u64; 1]>, VarIntKmer<u64, K24>>();
1612 }
1613 }
1614
1615 #[test]
1616 fn test_lmer_1_kmer_20() {
1617 for _ in 0..10000 {
1618 check_vmer::<Lmer<[u64; 1]>, VarIntKmer<u64, K20>>();
1619 }
1620 }
1621
1622 #[test]
1623 fn test_lmer_1_kmer_16() {
1624 for _ in 0..10000 {
1625 check_vmer::<Lmer<[u64; 1]>, IntKmer<u32>>();
1626 }
1627 }
1628
1629 #[test]
1630 fn test_kmer_64() {
1631 for _ in 0..10000 {
1632 check_kmer::<IntKmer<u128>>();
1633 }
1634 }
1635
1636 #[test]
1637 fn test_kmer_63() {
1638 for _ in 0..10000 {
1639 check_kmer::<VarIntKmer<u128, K63>>();
1640 }
1641 }
1642
1643 #[test]
1644 fn test_kmer_62() {
1645 for _ in 0..10000 {
1646 check_kmer::<VarIntKmer<u128, K62>>();
1647 }
1648 }
1649
1650 #[test]
1651 fn test_kmer_61() {
1652 for _ in 0..10000 {
1653 check_kmer::<VarIntKmer<u128, K61>>();
1654 }
1655 }
1656
1657 #[test]
1658 fn test_kmer_60() {
1659 for _ in 0..10000 {
1660 check_kmer::<VarIntKmer<u128, K60>>();
1661 }
1662 }
1663
1664 #[test]
1665 fn test_kmer_59() {
1666 for _ in 0..10000 {
1667 check_kmer::<VarIntKmer<u128, K59>>();
1668 }
1669 }
1670
1671 #[test]
1672 fn test_kmer_58() {
1673 for _ in 0..10000 {
1674 check_kmer::<VarIntKmer<u128, K58>>();
1675 }
1676 }
1677
1678
1679 #[test]
1680 fn test_kmer_57() {
1681 for _ in 0..10000 {
1682 check_kmer::<VarIntKmer<u128, K57>>();
1683 }
1684 }
1685
1686 #[test]
1687 fn test_kmer_56() {
1688 for _ in 0..10000 {
1689 check_kmer::<VarIntKmer<u128, K56>>();
1690 }
1691 }
1692
1693
1694 #[test]
1695 fn test_kmer_55() {
1696 for _ in 0..10000 {
1697 check_kmer::<VarIntKmer<u128, K55>>();
1698 }
1699 }
1700
1701 #[test]
1702 fn test_kmer_54() {
1703 for _ in 0..10000 {
1704 check_kmer::<VarIntKmer<u128, K54>>();
1705 }
1706 }
1707
1708 #[test]
1709 fn test_kmer_53() {
1710 for _ in 0..10000 {
1711 check_kmer::<VarIntKmer<u128, K53>>();
1712 }
1713 }
1714
1715 #[test]
1716 fn test_kmer_52() {
1717 for _ in 0..10000 {
1718 check_kmer::<VarIntKmer<u128, K52>>();
1719 }
1720 }
1721
1722 #[test]
1723 fn test_kmer_51() {
1724 for _ in 0..10000 {
1725 check_kmer::<VarIntKmer<u128, K51>>();
1726 }
1727 }
1728
1729 #[test]
1730 fn test_kmer_50() {
1731 for _ in 0..10000 {
1732 check_kmer::<VarIntKmer<u128, K50>>();
1733 }
1734 }
1735
1736 #[test]
1737 fn test_kmer_49() {
1738 for _ in 0..10000 {
1739 check_kmer::<VarIntKmer<u128, K49>>();
1740 }
1741 }
1742
1743
1744 #[test]
1745 fn test_kmer_48() {
1746 for _ in 0..10000 {
1747 check_kmer::<VarIntKmer<u128, K48>>();
1748 }
1749 }
1750
1751 #[test]
1752 fn test_kmer_47() {
1753 for _ in 0..10000 {
1754 check_kmer::<VarIntKmer<u128, K47>>();
1755 }
1756 }
1757
1758 #[test]
1759 fn test_kmer_46() {
1760 for _ in 0..10000 {
1761 check_kmer::<VarIntKmer<u128, K46>>();
1762 }
1763 }
1764
1765 #[test]
1766 fn test_kmer_45() {
1767 for _ in 0..10000 {
1768 check_kmer::<VarIntKmer<u128, K45>>();
1769 }
1770 }
1771
1772 #[test]
1773 fn test_kmer_44() {
1774 for _ in 0..10000 {
1775 check_kmer::<VarIntKmer<u128, K44>>();
1776 }
1777 }
1778
1779 #[test]
1780 fn test_kmer_43() {
1781 for _ in 0..10000 {
1782 check_kmer::<VarIntKmer<u128, K43>>();
1783 }
1784 }
1785
1786 #[test]
1787 fn test_kmer_42() {
1788 for _ in 0..10000 {
1789 check_kmer::<VarIntKmer<u128, K42>>();
1790 }
1791 }
1792
1793 #[test]
1794 fn test_kmer_41() {
1795 for _ in 0..10000 {
1796 check_kmer::<VarIntKmer<u128, K41>>();
1797 }
1798 }
1799
1800 #[test]
1801 fn test_kmer_40() {
1802 for _ in 0..10000 {
1803 check_kmer::<VarIntKmer<u128, K40>>();
1804 }
1805 }
1806
1807 #[test]
1808 fn test_kmer_39() {
1809 for _ in 0..10000 {
1810 check_kmer::<VarIntKmer<u128, K39>>();
1811 }
1812 }
1813
1814 #[test]
1815 fn test_kmer_38() {
1816 for _ in 0..10000 {
1817 check_kmer::<VarIntKmer<u128, K38>>();
1818 }
1819 }
1820
1821 #[test]
1822 fn test_kmer_37() {
1823 for _ in 0..10000 {
1824 check_kmer::<VarIntKmer<u128, K37>>();
1825 }
1826 }
1827
1828 #[test]
1829 fn test_kmer_36() {
1830 for _ in 0..10000 {
1831 check_kmer::<VarIntKmer<u128, K36>>();
1832 }
1833 }
1834
1835 #[test]
1836 fn test_kmer_35() {
1837 for _ in 0..10000 {
1838 check_kmer::<VarIntKmer<u128, K35>>();
1839 }
1840 }
1841
1842 #[test]
1843 fn test_kmer_34() {
1844 for _ in 0..10000 {
1845 check_kmer::<VarIntKmer<u128, K34>>();
1846 }
1847 }
1848
1849 #[test]
1850 fn test_kmer_33() {
1851 for _ in 0..10000 {
1852 check_kmer::<VarIntKmer<u128, K33>>();
1853 }
1854 }
1855
1856 #[test]
1857 fn test_kmer_32() {
1858 for _ in 0..10000 {
1859 check_kmer::<IntKmer<u64>>();
1860 }
1861 }
1862
1863 #[test]
1864 fn test_kmer_31() {
1865 for _ in 0..10000 {
1866 check_kmer::<VarIntKmer<u64, K31>>();
1867 }
1868 }
1869
1870 #[test]
1871 fn test_kmer_30() {
1872 for _ in 0..10000 {
1873 check_kmer::<VarIntKmer<u64, K30>>();
1874 }
1875 }
1876
1877 #[test]
1878 fn test_kmer_29() {
1879 for _ in 0..10000 {
1880 check_kmer::<VarIntKmer<u64, K29>>();
1881 }
1882 }
1883
1884 #[test]
1885 fn test_kmer_28() {
1886 for _ in 0..10000 {
1887 check_kmer::<VarIntKmer<u64, K28>>();
1888 }
1889 }
1890
1891 #[test]
1892 fn test_kmer_27() {
1893 for _ in 0..10000 {
1894 check_kmer::<VarIntKmer<u64, K27>>();
1895 }
1896 }
1897
1898 #[test]
1899 fn test_kmer_26() {
1900 for _ in 0..10000 {
1901 check_kmer::<VarIntKmer<u64, K26>>();
1902 }
1903 }
1904
1905 #[test]
1906 fn test_kmer_25() {
1907 for _ in 0..10000 {
1908 check_kmer::<VarIntKmer<u64, K25>>();
1909 }
1910 }
1911
1912 #[test]
1913 fn test_kmer_24() {
1914 for _ in 0..10000 {
1915 check_kmer::<VarIntKmer<u64, K24>>();
1916 }
1917 }
1918
1919 #[test]
1920 fn test_kmer_23() {
1921 for _ in 0..10000 {
1922 check_kmer::<VarIntKmer<u64, K23>>();
1923 }
1924 }
1925
1926 #[test]
1927 fn test_kmer_22() {
1928 for _ in 0..10000 {
1929 check_kmer::<VarIntKmer<u64, K22>>();
1930 }
1931 }
1932
1933 #[test]
1934 fn test_kmer_21() {
1935 for _ in 0..10000 {
1936 check_kmer::<VarIntKmer<u64, K21>>();
1937 }
1938 }
1939
1940 #[test]
1941 fn test_kmer_20() {
1942 for _ in 0..10000 {
1943 check_kmer::<VarIntKmer<u64, K20>>();
1944 }
1945 }
1946
1947 #[test]
1948 fn test_kmer_19() {
1949 for _ in 0..10000 {
1950 check_kmer::<VarIntKmer<u64, K19>>();
1951 }
1952 }
1953
1954 #[test]
1955 fn test_kmer_18() {
1956 for _ in 0..10000 {
1957 check_kmer::<VarIntKmer<u64, K18>>();
1958 }
1959 }
1960
1961 #[test]
1962 fn test_kmer_17() {
1963 for _ in 0..10000 {
1964 check_kmer::<VarIntKmer<u64, K17>>();
1965 }
1966 }
1967
1968 #[test]
1969 fn test_kmer_16() {
1970 for _ in 0..10000 {
1971 check_kmer::<IntKmer<u32>>();
1972 }
1973 }
1974
1975 #[test]
1976 fn test_kmer_15() {
1977 for _ in 0..10000 {
1978 check_kmer::<VarIntKmer<u32, K15>>();
1979 }
1980 }
1981
1982 #[test]
1983 fn test_kmer_14() {
1984 for _ in 0..10000 {
1985 check_kmer::<VarIntKmer<u32, K14>>();
1986 }
1987 }
1988
1989 #[test]
1990 fn test_kmer_13() {
1991 for _ in 0..10000 {
1992 check_kmer::<VarIntKmer<u32, K13>>();
1993 }
1994 }
1995
1996 #[test]
1997 fn test_kmer_12() {
1998 for _ in 0..10000 {
1999 check_kmer::<VarIntKmer<u32, K12>>();
2000 }
2001 }
2002
2003 #[test]
2004 fn test_kmer_11() {
2005 for _ in 0..10000 {
2006 check_kmer::<VarIntKmer<u32, K11>>();
2007 }
2008 }
2009
2010 #[test]
2011 fn test_kmer_10() {
2012 for _ in 0..10000 {
2013 check_kmer::<VarIntKmer<u32, K10>>();
2014 }
2015 }
2016
2017 #[test]
2018 fn test_kmer_9() {
2019 for _ in 0..10000 {
2020 check_kmer::<VarIntKmer<u32, K9>>();
2021 }
2022 }
2023
2024 #[test]
2025 fn test_kmer_8() {
2026 for _ in 0..10000 {
2027 check_kmer::<IntKmer<u16>>();
2028 }
2029 }
2030
2031 #[test]
2032 fn test_kmer_7() {
2033 for _ in 0..10000 {
2034 check_kmer::<Kmer7>();
2035 }
2036 }
2037
2038 #[test]
2039 fn test_kmer_6() {
2040 for _ in 0..10000 {
2041 check_kmer::<Kmer6>();
2042 }
2043 }
2044
2045 #[test]
2046 fn test_kmer_5() {
2047 for _ in 0..10000 {
2048 check_kmer::<Kmer5>();
2049 }
2050 }
2051
2052 #[test]
2053 fn test_kmer_4() {
2054 for _ in 0..10000 {
2055 check_kmer::<Kmer4>();
2056 }
2057 }
2058
2059 #[test]
2060 fn test_kmer_3() {
2061 for _ in 0..10000 {
2062 check_kmer::<Kmer3>();
2063 }
2064 }
2065
2066 #[test]
2067 fn test_kmer_2() {
2068 for _ in 0..10000 {
2069 check_kmer::<Kmer2>();
2070 }
2071 }
2072}