use clap::ValueEnum;
use serde::{Deserialize, Serialize};
pub mod aahash_iterator;
mod aahash_tables;
pub mod bloom_filter;
pub mod nthash_iterator;
mod nthash_tables;
pub const SEQSEP: u8 = 5;
pub const DEFAULT_LEVEL: AaLevel = AaLevel::Level1;
#[derive(Clone, Debug, PartialEq, PartialOrd, Serialize, Deserialize, ValueEnum)]
pub enum AaLevel {
Level1,
Level2,
Level3,
}
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, PartialOrd, Default)]
pub enum HashType {
#[default]
DNA,
AA(AaLevel),
PDB,
}
impl clap::ValueEnum for HashType {
fn value_variants<'a>() -> &'a [Self] {
&[
HashType::DNA,
HashType::AA(DEFAULT_LEVEL),
HashType::PDB,
]
}
fn to_possible_value<'a>(&self) -> ::std::option::Option<clap::builder::PossibleValue> {
match self {
Self::DNA => Some(clap::builder::PossibleValue::new("dna")),
Self::AA(_) => Some(clap::builder::PossibleValue::new("aa")),
Self::PDB => Some(clap::builder::PossibleValue::new("pdb")),
}
}
}
#[inline(always)]
fn encode_base(base: u8) -> u8 {
(base >> 1) & 0x3
}
#[inline(always)]
fn rc_base(base: u8) -> u8 {
base ^ 2
}
#[inline(always)]
fn valid_base(mut base: u8) -> bool {
base |= 0x20; matches!(base, b'a' | b'c' | b'g' | b't' | b'u')
}
#[inline(always)]
fn swapbits033(v: u64) -> u64 {
let x = (v ^ (v >> 33)) & 1;
v ^ (x | (x << 33))
}
#[inline(always)]
fn swapbits3263(v: u64) -> u64 {
let x = ((v >> 32) ^ (v >> 63)) & 1;
v ^ ((x << 32) | (x << 63))
}
pub trait RollHash: Iterator<Item = u64> {
fn set_k(&mut self, k: usize);
fn curr_hash(&self) -> u64;
fn hash_type(&self) -> HashType;
fn seq_len(&self) -> usize;
fn seq(&self) -> &Vec<u8>;
fn sketch_data(&self) -> (bool, [usize; 4], usize);
fn iter(&mut self) -> Box<dyn Iterator<Item = u64> + '_> {
Box::new(self)
}
fn reads(&self) -> bool {
false
}
}