Debian Codegraph @

auxil/vectors/diff-vec.cc

raw
1
2 #include <iostream>
3
4 #include <mmdb2/mmdb_manager.h>
5
6 int main(int argc, char **argv) {
7
8 if (argc > 1) {
9 char *filename = argv[1];
10 mmdb::Manager *mol = new mmdb::Manager;
11 mol->ReadCoorFile(filename);
12
13 std::cout << "(define obj (new-generic-object-number \"EJD's vectors\"))"
14 << std::endl;
15
16 if (mol) {
17 int imod = 1;
18 int ncount = 11;
19
20 mmdb::Model *model_p = mol->GetModel(imod);
21 mmdb::Chain *chain_p;
22 // run over chains of the existing mol
23 int nchains = model_p->GetNumberOfChains();
24 for (int ichain=0; ichain<nchains; ichain++) {
25 chain_p = model_p->GetChain(ichain);
26 int nres = chain_p->GetNumberOfResidues();
27 mmdb::PResidue residue_p;
28 mmdb::Atom *at;
29 for (int ires=0; ires<nres; ires++) {
30 residue_p = chain_p->GetResidue(ires);
31 int n_atoms = residue_p->GetNumberOfAtoms();
32
33 for (int iat=0; iat<n_atoms; iat++) {
34 at = residue_p->GetAtom(iat);
35
36 // inner atom loop
37 for (int jchain=0; jchain<nchains; jchain++) {
38 mmdb::Chain *chain2_p = model_p->GetChain(jchain);
39 int nres2 = chain2_p->GetNumberOfResidues();
40 mmdb::PResidue residue2_p;
41 mmdb::Atom *at2;
42 for (int jres=0; jres<nres2; jres++) {
43 residue2_p = chain2_p->GetResidue(jres);
44 int n_atoms2 = residue2_p->GetNumberOfAtoms();
45
46 for (int jat=0; jat<n_atoms2; jat++) {
47 at2 = residue2_p->GetAtom(jat);
48
49 if (at != at2) {
50 ncount++;
51
52 if (ncount > 10) {
53 ncount = 0;
54 float diff_x = at->x - at2->x;
55 float diff_y = at->y - at2->y;
56 float diff_z = at->z - at2->z;
57
58 std::string colour = "grey";
59 int width = 2;
60 float m = at->occupancy * at2->occupancy;
61 if (std::string(at->element) != " C")
62 colour = "green";
63 if (std::string(at2->element) != " C")
64 colour = "green";
65 if (std::string(at->element) == " S") {
66 colour = "yellow";
67 width = 4;
68 }
69 if (std::string(at2->element) == " S") {
70 colour = "yellow";
71 width = 4;
72 }
73 if (std::string(at->element) == " N")
74 colour = "blue";
75 if (std::string(at2->element) == " N")
76 colour = "blue";
77 if (std::string(at->element) == " O")
78 colour = "red";
79 if (std::string(at2->element) == " O")
80 colour = "red";
81
82 // std::cout << "(to-generic-object-add-line obj "
83 // << "\"" << colour << "\" "
84 // << width << " "
85 // << 0.0 << " " << 0.0 << " " << 0.0 << " "
86 // << diff_x << " " << diff_y << " " << diff_z
87 // << ")" << std::endl;
88 std::cout << "(to-generic-object-add-point obj "
89 << "\"" << colour << "\" "
90 << width << " "
91 << diff_x << " " << diff_y << " " << diff_z
92 << ")" << std::endl;
93 }
94 }
95 }
96 }
97 }
98 }
99 }
100 }
101 }
102 std::cout << "(set-display-generic-object obj 1)" << std::endl;
103 }
104 }
105