LOOS  v2.3.2
Selectors.cpp
1 /*
2  This file is part of LOOS.
3 
4  LOOS (Lightweight Object-Oriented Structure library)
5  Copyright (c) 2008, Tod D. Romo, Alan Grossfield
6  Department of Biochemistry and Biophysics
7  School of Medicine & Dentistry, University of Rochester
8 
9  This package (LOOS) is free software: you can redistribute it and/or modify
10  it under the terms of the GNU General Public License as published by
11  the Free Software Foundation under version 3 of the License.
12 
13  This package is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  GNU General Public License for more details.
17 
18  You should have received a copy of the GNU General Public License
19  along with this program. If not, see <http://www.gnu.org/licenses/>.
20 */
21 
22 #include <Selectors.hpp>
23 
24 namespace loos {
25 
26 
27  bool IndexSelector::operator()(const pAtom& pa) const {
28  return(pa->index() == _index);
29  }
30 
31 
32  bool CAlphaSelector::operator()(const pAtom& pa) const {
33  return(pa->name() == "CA");
34  }
35 
36 
37  std::string BackboneSelector::residue_names[BackboneSelector::nresnames] = {
38  "A",
39  "ALA",
40  "ARG",
41  "ASN",
42  "ASP",
43  "C",
44  "CYS",
45  "CYX",
46  "DA",
47  "DC",
48  "DG",
49  "DT",
50  "G",
51  "GLN",
52  "GLU",
53  "GLY",
54  "HID",
55  "HIE",
56  "HIP",
57  "HIS",
58  "HSD",
59  "HSE",
60  "HSP",
61  "ILE",
62  "LEU",
63  "LYS",
64  "MET",
65  "MSE",
66  "PHE",
67  "PRO",
68  "PTR",
69  "SER",
70  "T",
71  "THR",
72  "TRP",
73  "TYR",
74  "U",
75  "VAL"
76  };
77 
78  std::string BackboneSelector::atom_names[BackboneSelector::natomnames] = {
79  "C",
80  "C1'",
81  "C2'",
82  "C3'",
83  "C4'",
84  "C5'",
85  "CA",
86  "H",
87  "H1'",
88  "H12'",
89  "H15'",
90  "H2'",
91  "H2''",
92  "H22'",
93  "H25'",
94  "H3'",
95  "H4'",
96  "H5'",
97  "H5''",
98  "HO2'",
99  "HO3'",
100  "HO5'",
101  "N",
102  "O",
103  "O2'",
104  "O3'",
105  "O4'",
106  "O5'",
107  "OP1",
108  "OP2",
109  "OP3",
110  "OXT",
111  "P"
112  };
113 
114 
115 
116  bool BackboneSelector::operator()(const pAtom& pa) const {
117  if (std::binary_search(residue_names, residue_names + nresnames, pa->resname()))
118  if (std::binary_search(atom_names, atom_names + natomnames, pa->name()))
119  return(true);
120 
121  return(false);
122  }
123 
124  bool SegidSelector::operator()(const pAtom& pa) const {
125  return(pa->segid() == str);
126  }
127 
128  bool AtomNameSelector::operator()(const pAtom& pa) const {
129  return(pa->name() == str);
130  }
131 
132  bool ResidRangeSelector::operator()(const pAtom& pa) const {
133  return(pa->resid() >= _low && pa->resid() <= _high);
134  }
135 
136 
137  bool ZSliceSelector::operator()(const pAtom& pa) const {
138  greal z = (pa->coords()).z();
139  return ( (z>=_min) && (z<_max) );
140  }
141 
142  bool NotSelector::operator()(const pAtom& pa) const {
143  return(!(sel(pa)));
144  }
145 
146  bool HydrogenSelector::operator()(const pAtom& pa) const {
147  bool masscheck = true;
148 
149  if (pa->checkProperty(Atom::massbit))
150  masscheck = (pa->mass() < 1.1);
151 
152  std::string n = pa->name();
153  return( (n[0] == 'H') && masscheck );
154  }
155 
156  bool HeavyAtomSelector::operator()(const pAtom& pa) const {
157  return (not_heavy(pa));
158  }
159 
160 
161  bool AndSelector::operator()(const pAtom& pa) const {
162  return(lhs(pa) && rhs(pa));
163  }
164 
165  bool OrSelector::operator()(const pAtom& pa) const {
166  return(lhs(pa) || rhs(pa));
167  }
168 
169 
170  bool SolventSelector::operator()(const pAtom& pa) const {
171  return(osel(pa));
172  }
173 
174 
175  bool HeavySolventSelector::operator()(const pAtom& pa) const {
176  return(sel(pa));
177  }
178 
179  bool KernelSelector::operator()(const pAtom& pa) const {
180  krnl.execute(pa);
181  if (krnl.stack().size() != 1) {
182  throw(LOOSError("Execution error - unexpected values on stack"));
183  }
184 
185  internal::Value results = krnl.stack().pop();
186  if (results.type != internal::Value::INT)
187  throw(LOOSError("Execution error - unexpected value on top of stack"));
188 
189  return(results.itg);
190  }
191 
192 }
bool operator()(const pAtom &pa) const
Definition: Selectors.cpp:170
bool operator()(const pAtom &pa) const
Definition: Selectors.cpp:156
bool operator()(const pAtom &pa) const
Definition: Selectors.cpp:137
bool operator()(const pAtom &) const
Definition: Selectors.cpp:128
bool operator()(const pAtom &) const
Definition: Selectors.cpp:32
bool operator()(const pAtom &) const
Definition: Selectors.cpp:132
bool operator()(const pAtom &pa) const
Definition: Selectors.cpp:175
bool operator()(const pAtom &pa) const
Definition: Selectors.cpp:27
bool operator()(const pAtom &pa) const
Definition: Selectors.cpp:161
bool operator()(const pAtom &) const
Definition: Selectors.cpp:116
Generic LOOS exception.
Definition: exceptions.hpp:40
bool operator()(const pAtom &) const
Definition: Selectors.cpp:124
void execute(pAtom pa=pAtom())
Execute the stored commands for a specific atom.
Definition: Kernel.cpp:47
bool operator()(const pAtom &) const
Definition: Selectors.cpp:142
bool operator()(const pAtom &) const
Definition: Selectors.cpp:146
Namespace for most things not already encapsulated within a class.
Value class for the LOOS Kernel (virtual machine)
Definition: KernelValue.hpp:51
bool operator()(const pAtom &pa) const
Definition: Selectors.cpp:165
bool operator()(const pAtom &pa) const
Definition: Selectors.cpp:179