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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
use io::Record;
#[derive(Debug)]
pub struct XYZ {
pub x: f64,
pub y: f64,
pub z: f64,
}
impl XYZ {
pub fn new(x: f64, y: f64, z: f64) -> XYZ {
XYZ { x, y, z }
}
pub fn clone(&self) -> XYZ {
let x = self.x.clone();
let y = self.y.clone();
let z = self.z.clone();
XYZ { x, y, z }
}
}
pub struct Pose {
pub atoms: Vec<Atom>,
}
impl Pose {
pub fn from_atoms(atoms: Vec<Atom>) -> Pose {
Pose { atoms }
}
}
pub struct Residue {
atoms: Vec<Atom>,
residue_name: String,
residue_index: i32,
}
pub struct Atom {
pub charge: f64,
pub xyz: XYZ,
pub element: String,
}
impl Atom {
pub fn new(record: &Record) -> Atom {
let xyz = record.xyz.clone();
let charge = record.charge.clone();
let element = record.element.clone();
Atom { xyz, charge, element }
}
pub fn dist(&self, other: &Atom) -> f64 {
((self.xyz.x - other.xyz.x).powi(2) +
(self.xyz.y - other.xyz.y).powi(2) +
(self.xyz.z - other.xyz.z).powi(2)).sqrt()
}
}