VinaLC: Parallel Molecular Docking Program

Biochemical and Biophysical Systems Group
VinaLC version: 1.1.2

atom_type.h
Go to the documentation of this file.
1 /*
2 
3  Copyright (c) 2006-2010, The Scripps Research Institute
4 
5  Licensed under the Apache License, Version 2.0 (the "License");
6  you may not use this file except in compliance with the License.
7  You may obtain a copy of the License at
8 
9  http://www.apache.org/licenses/LICENSE-2.0
10 
11  Unless required by applicable law or agreed to in writing, software
12  distributed under the License is distributed on an "AS IS" BASIS,
13  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  See the License for the specific language governing permissions and
15  limitations under the License.
16 
17  Author: Dr. Oleg Trott <ot14@columbia.edu>,
18  The Olson Lab,
19  The Scripps Research Institute
20 
21 */
22 
23 #ifndef VINA_ATOM_TYPE_H
24 #define VINA_ATOM_TYPE_H
25 
26 #include "atom_constants.h"
28 
29 struct atom_type {
30  enum t {EL, AD, XS, SY};
31  sz el, ad, xs, sy;
33  sz get(t atom_typing_used) const {
34  switch(atom_typing_used) {
35  case EL: return el;
36  case AD: return ad;
37  case XS: return xs;
38  case SY: return sy;
39  default: assert(false); return max_sz;
40  }
41  }
42  bool is_hydrogen() const {
43  return ad_is_hydrogen(ad);
44  }
45  bool is_heteroatom() const {
46  return ad_is_heteroatom(ad) || xs == XS_TYPE_Met_D;
47  }
48  bool acceptable_type() const {
49  return ad < AD_TYPE_SIZE || xs == XS_TYPE_Met_D;
50  }
51  void assign_el() {
53  if(ad == AD_TYPE_SIZE && xs == XS_TYPE_Met_D)
54  el = EL_TYPE_Met;
55  }
56  bool same_element(const atom_type& a) const { // does not distinguish metals or unassigned types
57  return el == a.el;
58  }
59  fl covalent_radius() const {
61  else if(xs == XS_TYPE_Met_D) return metal_covalent_radius;
62  VINA_CHECK(false); return 0; // never happens - placating the compiler
63  }
65  return covalent_radius() + x.covalent_radius();
66  }
67 private:
69  template<class Archive>
70  void serialize(Archive& ar, const unsigned version) {
71  ar & el;
72  ar & ad;
73  ar & xs;
74  ar & sy;
75  }
76 };
77 
78 inline sz num_atom_types(atom_type::t atom_typing_used) {
79  switch(atom_typing_used) {
80  case atom_type::EL: return EL_TYPE_SIZE;
81  case atom_type::AD: return AD_TYPE_SIZE;
82  case atom_type::XS: return XS_TYPE_SIZE;
83  case atom_type::SY: return SY_TYPE_SIZE;
84  default: assert(false); return max_sz;
85  }
86 }
87 
88 inline sz get_type_pair_index(atom_type::t atom_typing_used, const atom_type& a, const atom_type& b) { // throws error if any arg is unassigned in the given typing scheme
89  sz n = num_atom_types(atom_typing_used);
90 
91  sz i = a.get(atom_typing_used); VINA_CHECK(i < n);
92  sz j = b.get(atom_typing_used); VINA_CHECK(j < n);
93 
94  if(i <= j) return triangular_matrix_index(n, i, j);
95  else return triangular_matrix_index(n, j, i);
96 }
97 
98 #endif