Coot Scripting Interface  7000
probe-clash-score.hh
Go to the documentation of this file.
1 /* src/probe-clash-score.hh
2  *
3  * Copyright 2010 by the University of Oxford
4  * Copyright 2012 by Medical Research Council
5  * Author: Paul Emsley
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 3 of the License, or (at
10  * your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful, but
13  * WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
20  * 02110-1301, USA
21  */
22 
23 #ifndef PROBE_CLASH_SCORE_HH
24 #define PROBE_CLASH_SCORE_HH
25 
26 #include <algorithm> // for find
27 
28 #ifdef USE_GUILE
29 #include <libguile.h>
30 #endif // USE_GUILE
31 
32 #include "utils/coot-utils.hh"
33 #include "coot-utils/coot-coord-utils.hh"
34 
39 namespace coot {
40 
42  //
43  // " B 72 CYS HG A: B 53 HIS H "
44  //
45  class probe_atom_spec_t : public atom_spec_t {
46  public:
47  probe_atom_spec_t(const std::string &s) : atom_spec_t() {
48  if (s.length() > 14) {
49  std::string chain_local = s.substr(0,2);
50  std::string res_no_str = s.substr(2, 4);
51  std::string atom_name_local = s.substr(11, 4);
52  try {
53  int resno_local = util::string_to_int(res_no_str);
54  if (chain_local[0] == ' ') {
55  if (chain_local.length() > 1)
56  chain_id = std::string(chain_local.substr(1));
57  } else {
58  chain_id = chain_local;
59  }
60  res_no = resno_local;
61  atom_name = atom_name_local;
62  }
63  catch (const std::exception &e) {
64  std::cout << "WARNING:: " << e.what() << std::endl;
65  }
66  }
67  }
68  probe_atom_spec_t() : atom_spec_t() {}
69  };
70 
73  public:
74  probe_atom_spec_t from_atom;
75  std::vector<probe_atom_spec_t> to_atoms;
77  from_atom = spec;
78  }
79  unsigned int size() const { return to_atoms.size(); }
80  void add(const probe_atom_spec_t &spec) {
81  std::vector<probe_atom_spec_t>::const_iterator it;
82  it = std::find(to_atoms.begin(), to_atoms.end(), spec);
83  if (it == to_atoms.end()) {
84  to_atoms.push_back(spec);
85  }
86  }
87  };
88 
91  public:
92  std::vector<one_way_probe_contact_t> contacts;
93  void add(const probe_atom_spec_t &from_atom,
94  const probe_atom_spec_t &to_atom) {
95  bool found = false;
96  for (unsigned int i=0; i<contacts.size(); i++) {
97  if (contacts[i].from_atom == from_atom) {
98  contacts[i].add(to_atom);
99  found = true;
100  }
101  }
102  if (! found) {
103  one_way_probe_contact_t new_contact(from_atom);
104  new_contact.add(to_atom);
105  contacts.push_back(new_contact);
106  }
107  }
108  unsigned int size() const {
109  unsigned int s = 0;
110  for (unsigned int i=0; i<contacts.size(); i++)
111  s += contacts[i].size();
112  return s;
113  }
114  };
115 
118  public:
119  bool filled;
120  int n_bad_overlaps;
121  int n_hydrogen_bonds;
122  int n_small_overlaps;
123  int n_close_contacts;
124  int n_wide_contacts;
126  filled = false;
127  }
128  probe_clash_score_t(int n_bad_overlaps_in,
129  int n_hydrogen_bonds_in,
130  int n_small_overlaps_in,
131  int n_close_contacts_in,
132  int n_wide_contacts_in) {
133 
134  n_bad_overlaps = n_bad_overlaps_in;
135  n_hydrogen_bonds = n_hydrogen_bonds_in;
136  n_small_overlaps = n_small_overlaps_in;
137  n_close_contacts = n_close_contacts_in;
138  n_wide_contacts = n_wide_contacts_in;
139  filled = true;
140  }
141  probe_clash_score_t(const std::string &dots_file_name);
142  };
143 
144 
146  // couldn't get this to work - so I did by another method.
147  // deleteable cruft.
148  class spec_eraser {
149  public:
150  std::map<std::pair<probe_atom_spec_t, probe_atom_spec_t>, bool> ref_specs;
151  spec_eraser(const std::map<std::pair<probe_atom_spec_t, probe_atom_spec_t>, bool> &ref_specs_in) {
152  ref_specs = ref_specs_in;
153  }
154  // bool operator() (const std::pair<probe_atom_spec_t, probe_atom_spec_t> &s) const {
155  // return true;
156  // }
157  };
158 }
159 
160 
161 #ifdef USE_GUILE
162 // (n_bad_overlaps n_hydrogen_bonds n_small_overlaps n_close_contacts
164 // n_wide_contacts)
165 //
166 SCM probe_clash_score_scm(const std::string &dots_file_name);
167 SCM probe_clash_score_as_scm(const coot::probe_clash_score_t &p);
168 coot::probe_clash_score_t probe_clash_score_from_scm(SCM p);
169 #endif // USE_GUILE
170 
171 #ifdef USE_PYTHON
172 // (n_bad_overlaps n_hydrogen_bonds n_small_overlaps n_close_contacts
174 // n_wide_contacts)
175 //
176 PyObject *probe_clash_score_py(const std::string &dots_file_name);
177 PyObject *probe_clash_score_as_py(const coot::probe_clash_score_t &p);
178 coot::probe_clash_score_t probe_clash_score_from_py(PyObject *p);
179 #endif // USE_PYTHON
180 
181 
182 #endif // PROBE_CLASH_SCORE_HH
one way probe contacts container
Definition: probe-clash-score.hh:90
SCM probe_clash_score_scm(const std::string &dots_file_name)
return scheme false on failure or a scheme list
PyObject * probe_clash_score_py(const std::string &dots_file_name)
return scheme false on failure or a scheme list
probe atom type
Definition: probe-clash-score.hh:45
probe clash score
Definition: probe-clash-score.hh:117
This doesn&#39;t work.
Definition: probe-clash-score.hh:148
one way probe contact
Definition: probe-clash-score.hh:72