pdbtbx/
reference_tables.rs1#[cfg(feature = "rayon")]
2use rayon::prelude::*;
3
4pub fn get_index_for_symbol(symbol: impl AsRef<str>) -> Option<usize> {
8 let symbol = symbol.as_ref();
9 if let Some(index) = HERMANN_MAUGUIN_SYMBOL.iter().position(|i| *i == symbol) {
10 Some(index + 1)
11 } else {
12 HALL_SYMBOL.iter().position(|i| *i == symbol).map(|n| n + 1)
13 }
14}
15
16#[cfg(feature = "rayon")]
20#[allow(dead_code)]
21pub fn par_get_index_for_symbol(symbol: impl AsRef<str>) -> Option<usize> {
22 let symbol = symbol.as_ref();
23 if let Some(index) = HERMANN_MAUGUIN_SYMBOL
24 .par_iter()
25 .position_any(|i| *i == symbol)
26 {
27 Some(index + 1)
28 } else {
29 HALL_SYMBOL
30 .par_iter()
31 .position_any(|i| *i == symbol)
32 .map(|n| n + 1)
33 }
34}
35
36pub fn get_herman_mauguin_symbol_for_index(index: usize) -> Option<&'static str> {
38 HERMANN_MAUGUIN_SYMBOL.get(index - 1).copied()
39}
40
41pub fn get_hall_symbol_for_index(index: usize) -> Option<&'static str> {
43 HALL_SYMBOL.get(index - 1).copied()
44}
45
46pub fn get_transformation(index: usize) -> Option<&'static [[[f64; 4]; 3]]> {
48 SYMBOL_TRANSFORMATION.get(index - 1).copied()
49}
50
51pub fn is_amino_acid(aa: impl AsRef<str>) -> bool {
53 AMINO_ACIDS.contains(&aa.as_ref())
54}
55
56pub fn is_backbone(name: impl AsRef<str>) -> bool {
58 BACKBONE_NAMES.contains(&name.as_ref())
59}
60
61pub fn valid_remark_type_number(number: usize) -> bool {
63 REMARK_TYPES.contains(&number)
64}
65
66const REMARK_TYPES: [usize; 42] = [
68 0, 1, 2, 3, 4, 5, 100, 200, 205, 210, 215, 217, 230, 240, 245, 247, 250, 265, 280, 285, 290,
69 300, 350, 375, 400, 450, 465, 470, 475, 480, 500, 525, 600, 610, 615, 620, 630, 650, 700, 800,
70 900, 999,
71];
72
73const AMINO_ACIDS: &[&str] = &[
76 "ALA", "ARG", "ASH", "ASN", "ASP", "ASX", "CYS", "CYX", "GLH", "GLN", "GLU", "GLY", "HID",
77 "HIE", "HIM", "HIP", "HIS", "ILE", "LEU", "LYN", "LYS", "MET", "PHE", "PRO", "SER", "THR",
78 "TRP", "TYR", "VAL", "SEC", "PYL",
79];
80
81const BACKBONE_NAMES: &[&str] = &[
83 "N", "CA", "C", "O", "H", "H1", "H2", "H3", "HA", "HA2", "HA3",
84];
85
86const HERMANN_MAUGUIN_SYMBOL: &[&str] = include!("reference/hermann_mauguin_symbols.txt");
88
89const HALL_SYMBOL: &[&str] = include!("reference/hall_symbols.txt");
91
92const SYMBOL_TRANSFORMATION: &[&[[[f64; 4]; 3]]] =
94 include!("reference/crystal_transformations.txt");