1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
use crate::types::{AminoAcid, Element};
use serde::{Deserialize, Serialize};
use std::str::FromStr;
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Atom {
pub id: u32,
pub name: AminoAcidAtomName,
pub id1: char,
pub residue: AminoAcid,
pub chain: char,
pub sequence_number: u32,
pub insertion_code: char,
pub x: f32,
pub y: f32,
pub z: f32,
pub occupancy: f32,
pub temperature_factor: f32,
pub element: Element,
pub charge: i8,
pub hetatom: bool,
}
pub struct GenericAtomParser;
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum AminoAcidAtomName {
N,
CA,
C,
O,
Other(String),
}
impl FromStr for AminoAcidAtomName {
type Err = String;
fn from_str(inp: &str) -> std::result::Result<Self, <Self as std::str::FromStr>::Err> {
match inp {
"C" => Ok(AminoAcidAtomName::C),
"CA" => Ok(AminoAcidAtomName::CA),
"O" => Ok(AminoAcidAtomName::O),
"N" => Ok(AminoAcidAtomName::N),
_ => Ok(AminoAcidAtomName::Other(inp.to_owned())),
}
}
}