Debian Codegraph @

auxil/sec-str/sec-str-dist-check.cc

raw
1
2 #include <unistd.h>
3 #include <iostream>
4 #include "sec-str-dist-check.hh"
5 #include "clipper/core/coords.h"
6
7 int main(int argc, char **argv) {
8
9 if (argc > 1) {
10 std::string filename = argv[1];
11 mmdb::Manager *mol = get_mol(filename);
12 if (mol) {
13 mmdb::Model *model_p = mol->GetModel(1);
14 int status = model_p->CalcSecStructure(1);
15 if (status == SSERC_Ok) {
16 std::cout << "INFO:: SSE status was OK\n";
17 CSSContainer helices;
18
19 distance_checks(model_p);
20 } else {
21 std::cout << "INFO:: SSE status was bad\n" << status << "\n";
22 }
23 }
24 } else {
25 std::cout << "Usage: " << argv[0] << " <pdb-file-name>"
26 << std::endl;
27 }
28 return 0;
29 }
30
31 // Running over all of Top500:
32 // oxygen distance
33 // Strand stats: 4.5171 +/- 0.356533
34 // Helix stats: 3.56436 +/- 0.333756
35 //
36 void
37 distance_checks(mmdb::Model *model_p) {
38
39 int imod = 1;
40
41 mmdb::Chain *chain_p;
42 int nchains = model_p->GetNumberOfChains();
43 for (int ichain=0; ichain<nchains; ichain++) {
44 chain_p = model_p->GetChain(ichain);
45 int nres = chain_p->GetNumberOfResidues();
46 mmdb::PResidue residue_p_1;
47 mmdb::PResidue residue_p_2;
48 for (int ires=0; ires<(nres-1); ires++) {
49 residue_p_1 = chain_p->GetResidue(ires);
50 residue_p_2 = chain_p->GetResidue(ires+1);
51 int n_atoms_1 = residue_p_1->GetNumberOfAtoms();
52 int n_atoms_2 = residue_p_2->GetNumberOfAtoms();
53 if (n_atoms_1 && n_atoms_2) {
54 if (residue_p_1->GetSeqNum() == (residue_p_2->GetSeqNum()-1)) {
55 int sse_1 = SSE(residue_p_1);
56 int sse_2 = SSE(residue_p_2);
57 if (((sse_1 == SSE_Strand) && (sse_2 == SSE_Strand)) ||
58 ((sse_1 == SSE_Helix) && (sse_2 == SSE_Helix))) {
59 float d = oxygen_check(residue_p_1, residue_p_2);
60 if (d > 0) {
61 std::string ss("Helix ");
62 if (sse_1 == SSE_Strand)
63 ss = "Strand";
64 std::cout << ss << " " << d << " "
65 << residue_p_1->GetChainID()
66 << " "
67 << residue_p_1->GetSeqNum()
68 << std::endl;
69 }
70 }
71 }
72 }
73 }
74 }
75 }
76
77 int SSE(mmdb::Residue *res) {
78 return res->SSE;
79 }
80
81 mmdb::Manager *get_mol(const std::string &filename) {
82
83 mmdb::Manager *MMDBManager = new mmdb::Manager();
84 int err = MMDBManager->ReadCoorFile((char *)filename.c_str());
85 if (err) {
86 std::cout << "Error reading " << filename << std::endl;
87 delete MMDBManager;
88 MMDBManager = 0;
89 }
90 return MMDBManager;
91 }
92
93
94
95 // return -1 on failure
96 //
97 float oxygen_check(mmdb::Residue *residue_p_1, mmdb::Residue *residue_p_2) {
98
99 int n_atoms_1 = residue_p_1->GetNumberOfAtoms();
100 int n_atoms_2 = residue_p_2->GetNumberOfAtoms();
101 mmdb::Atom *at, *at2;
102 float d = -1;
103 short int done_it = 0;
104
105 for (int iat=0; iat<n_atoms_1; iat++) {
106 at = residue_p_1->GetAtom(iat);
107 std::string atom_name (at->name);
108 if (atom_name == " O ") {
109 for (int iat2=0; iat2<n_atoms_2; iat2++) {
110 at2 = residue_p_2->GetAtom(iat2);
111 std::string atom_name_2 (at2->name);
112 if (atom_name_2 == " O ") {
113 std::string altconf1 = at->altLoc;
114 std::string altconf2 = at2->altLoc;
115 if ((altconf1 == "") && (altconf2 == "")) {
116 clipper::Coord_orth c1(at->x, at->y, at->z);
117 clipper::Coord_orth c2(at2->x, at2->y, at2->z);
118 d = clipper::Coord_orth::length(c1, c2);
119 done_it = 1;
120 break;
121 }
122 }
123 }
124 }
125 if (done_it)
126 break;
127 }
128 return d;
129 }