-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpdbatom.cpp
83 lines (66 loc) · 1.93 KB
/
pdbatom.cpp
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
#include "pdbatom.h"
#include "math.h"
PDBAtom::PDBAtom(double x, double y, double z) {
this->index = -1;
this->x = x;
this->y = y;
this->z = z;
}
PDBAtom::PDBAtom(int index, double x, double y, double z) {
this->index = index;
this->x = x;
this->y = y;
this->z = z;
}
PDBAtom::PDBAtom(std::string atomic_symbol, double x, double y, double z) {
this->atomic_symbol = atomic_symbol;
this->index = -1;
this->x = x;
this->y = y;
this->z = z;
}
PDBAtom::PDBAtom(std::string atomic_symbol, int index, double x, double y, double z) {
this->atomic_symbol = atomic_symbol;
this->index = index;
this->x = x;
this->y = y;
this->z = z;
}
int PDBAtom::getAtomicNumber() {
for (int i = 0; i < this->periodic_table_size; ++i) {
if (strcmp(this->periodic_table[i], this->atomic_symbol.c_str()) == 0) {
return (i+1);
}
}
return -1;
}
int PDBAtom::getIndex() {
return this->index;
}
double PDBAtom::distance(PDBAtom atom) {
return sqrt(pow(atom.x - this->x, 2) + pow(atom.y - this->y, 2) + pow(atom.z - this->z, 2));
}
std::string PDBAtom::atomicNumberToSymbol(int atomic_number) {
return PDBAtom::periodic_table[atomic_number-1];
}
int PDBAtom::atomicSymbolToNumber(std::string atomic_symbol) {
for (int i = 0; i < PDBAtom::periodic_table_size; ++i) {
if (strcmp(PDBAtom::periodic_table[i], atomic_symbol.c_str()) == 0) {
return (i+1);
}
}
return -1;
}
const char* PDBAtom::periodic_table[] = {
"H", "He","Li","Be","B", "C", "N", "O", "F", "Ne",
"Na","Mg","Al","Si","P", "S", "Cl","Ar","K", "Ca",
"Sc","Ti","V", "Cr","Mn","Fe","Co","Ni","Cu","Zn",
"Ga","Ge","As","Se","Br","Kr","Rb","Sr","Y", "Zr",
"Nb","Mo","Tc","Ru","Rh","Pd","Ag","Cd","In","Sn",
"Sb","Te","I", "Xe","Cs","Ba","La","Ce","Pr","Nd",
"Pm","Sm","Eu","Gd","Tb","Dy","Ho","Er","Tm","Yb",
"Lu","Hf","Ta","W", "Re","Os","Ir","Pt","Au","Hg",
"Tl","Pb","Bi","Po","At","Rn","Fr","Ra","Ac","Th",
"Pa","U", "Np","Pu","Am","Cm","Bk","Cf","Es","Fm",
"Md","No","Lr"
};