use crate::{ChunkIt, PaddedIt};
use super::u32x8;
use mem_dbg::{MemDbg, MemSize};
use std::ops::Range;
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct Delay(pub usize);
pub trait Seq<'s>: Copy + Eq + Ord {
const BITS_PER_CHAR: usize;
const BASES_PER_BYTE: usize;
type SeqVec: SeqVec;
fn bits_per_char(&self) -> usize {
Self::BITS_PER_CHAR
}
fn len(&self) -> usize;
fn is_empty(&self) -> bool;
fn get(&self, _index: usize) -> u8;
fn get_ascii(&self, _index: usize) -> u8;
fn as_u64(&self) -> u64;
fn revcomp_as_u64(&self) -> u64;
fn as_u128(&self) -> u128;
fn revcomp_as_u128(&self) -> u128;
#[deprecated = "Prefer `to_u64`."]
#[inline(always)]
fn to_word(&self) -> usize {
self.as_u64() as usize
}
#[deprecated = "Prefer `revcomp_to_u64`."]
#[inline(always)]
fn to_word_revcomp(&self) -> usize {
self.revcomp_as_u64() as usize
}
fn to_vec(&self) -> Self::SeqVec;
fn to_revcomp(&self) -> Self::SeqVec;
fn slice(&self, range: Range<usize>) -> Self;
#[inline(always)]
fn read_kmer(&self, k: usize, pos: usize) -> u64 {
self.slice(pos..pos + k).as_u64()
}
#[inline(always)]
fn read_revcomp_kmer(&self, k: usize, pos: usize) -> u64 {
self.slice(pos..pos + k).revcomp_as_u64()
}
#[inline(always)]
fn read_kmer_u128(&self, k: usize, pos: usize) -> u128 {
self.slice(pos..pos + k).as_u128()
}
#[inline(always)]
fn read_revcomp_kmer_u128(&self, k: usize, pos: usize) -> u128 {
self.slice(pos..pos + k).revcomp_as_u128()
}
fn iter_bp(self) -> impl ExactSizeIterator<Item = u8>;
fn par_iter_bp(self, context: usize) -> PaddedIt<impl ChunkIt<u32x8>>;
fn par_iter_bp_delayed(
self,
context: usize,
delay: Delay,
) -> PaddedIt<impl ChunkIt<(u32x8, u32x8)>>;
fn par_iter_bp_delayed_2(
self,
context: usize,
delay1: Delay,
delay2: Delay,
) -> PaddedIt<impl ChunkIt<(u32x8, u32x8, u32x8)>>;
fn cmp_lcp(&self, other: &Self) -> (std::cmp::Ordering, usize);
}
cfg_if::cfg_if! {
if #[cfg(feature = "epserde")] {
pub use epserde::{deser::DeserializeInner, ser::SerializeInner};
} else {
pub trait SerializeInner {}
pub trait DeserializeInner {}
use crate::packed_seq::{Bits, SupportedBits, PackedSeqVecBase};
impl SerializeInner for Vec<u8> {}
impl DeserializeInner for Vec<u8> {}
impl SerializeInner for crate::AsciiSeqVec {}
impl DeserializeInner for crate::AsciiSeqVec {}
impl<const B: usize> SerializeInner for PackedSeqVecBase<B> where Bits<B>:SupportedBits {}
impl<const B: usize> DeserializeInner for PackedSeqVecBase<B> where Bits<B>:SupportedBits {}
}
}
pub trait SeqVec:
Default + Sync + SerializeInner + DeserializeInner + MemSize + MemDbg + Clone + 'static
{
type Seq<'s>: Seq<'s>;
fn as_slice(&self) -> Self::Seq<'_>;
#[inline(always)]
fn slice(&self, range: Range<usize>) -> Self::Seq<'_> {
self.as_slice().slice(range)
}
#[inline(always)]
fn read_kmer(&self, k: usize, pos: usize) -> u64 {
self.as_slice().read_kmer(k, pos)
}
#[inline(always)]
fn read_revcomp_kmer(&self, k: usize, pos: usize) -> u64 {
self.as_slice().read_revcomp_kmer(k, pos)
}
#[inline(always)]
fn read_kmer_u128(&self, k: usize, pos: usize) -> u128 {
self.as_slice().read_kmer_u128(k, pos)
}
#[inline(always)]
fn read_revcomp_kmer_u128(&self, k: usize, pos: usize) -> u128 {
self.as_slice().read_revcomp_kmer_u128(k, pos)
}
fn len(&self) -> usize;
fn is_empty(&self) -> bool;
fn clear(&mut self);
fn into_raw(self) -> Vec<u8>;
#[cfg(feature = "rand")]
fn random(n: usize) -> Self;
#[inline(always)]
fn from_ascii(seq: &[u8]) -> Self {
let mut packed_vec = Self::default();
packed_vec.push_ascii(seq);
packed_vec
}
fn push_seq(&mut self, seq: Self::Seq<'_>) -> Range<usize>;
fn push_ascii(&mut self, seq: &[u8]) -> Range<usize>;
}