#[cfg(feature = "rayon")]
use rayon::prelude::*;
pub fn get_index_for_symbol(symbol: impl AsRef<str>) -> Option<usize> {
let symbol = symbol.as_ref();
if let Some(index) = HERMANN_MAUGUIN_SYMBOL.iter().position(|i| *i == symbol) {
Some(index + 1)
} else {
HALL_SYMBOL.iter().position(|i| *i == symbol).map(|n| n + 1)
}
}
#[cfg(feature = "rayon")]
#[allow(dead_code)]
pub fn par_get_index_for_symbol(symbol: impl AsRef<str>) -> Option<usize> {
let symbol = symbol.as_ref();
if let Some(index) = HERMANN_MAUGUIN_SYMBOL
.par_iter()
.position_any(|i| *i == symbol)
{
Some(index + 1)
} else {
HALL_SYMBOL
.par_iter()
.position_any(|i| *i == symbol)
.map(|n| n + 1)
}
}
pub fn get_herman_mauguin_symbol_for_index(index: usize) -> Option<&'static str> {
HERMANN_MAUGUIN_SYMBOL.get(index - 1).copied()
}
pub fn get_hall_symbol_for_index(index: usize) -> Option<&'static str> {
HALL_SYMBOL.get(index - 1).copied()
}
pub fn get_transformation(index: usize) -> Option<&'static [[[f64; 4]; 3]]> {
SYMBOL_TRANSFORMATION.get(index - 1).copied()
}
pub fn is_amino_acid(aa: impl AsRef<str>) -> bool {
AMINO_ACIDS.contains(&aa.as_ref())
}
pub fn is_backbone(name: impl AsRef<str>) -> bool {
BACKBONE_NAMES.contains(&name.as_ref())
}
pub fn valid_remark_type_number(number: usize) -> bool {
REMARK_TYPES.contains(&number)
}
const REMARK_TYPES: [usize; 42] = [
0, 1, 2, 3, 4, 5, 100, 200, 205, 210, 215, 217, 230, 240, 245, 247, 250, 265, 280, 285, 290,
300, 350, 375, 400, 450, 465, 470, 475, 480, 500, 525, 600, 610, 615, 620, 630, 650, 700, 800,
900, 999,
];
const AMINO_ACIDS: &[&str] = &[
"ALA", "ARG", "ASH", "ASN", "ASP", "ASX", "CYS", "CYX", "GLH", "GLN", "GLU", "GLY", "HID",
"HIE", "HIM", "HIP", "HIS", "ILE", "LEU", "LYN", "LYS", "MET", "PHE", "PRO", "SER", "THR",
"TRP", "TYR", "VAL", "SEC", "PYL",
];
const BACKBONE_NAMES: &[&str] = &[
"N", "CA", "C", "O", "H", "H1", "H2", "H3", "HA", "HA2", "HA3",
];
const HERMANN_MAUGUIN_SYMBOL: &[&str] = include!("reference/hermann_mauguin_symbols.txt");
const HALL_SYMBOL: &[&str] = include!("reference/hall_symbols.txt");
const SYMBOL_TRANSFORMATION: &[&[[[f64; 4]; 3]]] =
include!("reference/crystal_transformations.txt");