Victor
 All Data Structures Functions Variables Friends Pages
AminoAcid.h
1 /* This file is part of Victor.
2 
3  Victor is free software: you can redistribute it and/or modify
4  it under the terms of the GNU General Public License as published by
5  the Free Software Foundation, either version 3 of the License, or
6  (at your option) any later version.
7 
8  Victor is distributed in the hope that it will be useful,
9  but WITHOUT ANY WARRANTY; without even the implied warranty of
10  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  GNU General Public License for more details.
12 
13  You should have received a copy of the GNU General Public License
14  along with Victor. If not, see <http://www.gnu.org/licenses/>.
15  */
16 
17 
18 #ifndef _AMINOACID_H_
19 #define _AMINOACID_H_
20 
21 
22 
23 // Includes:
24 #include <Group.h>
25 #include <SideChain.h>
26 #include <AminoAcidCode.h>
27 #include <IntCoordConverter.h>
28 #include <Visitor.h>
29 
30 
31 // Global constants, typedefs, etc. (to avoid):
32 
33 namespace Victor { namespace Biopool {
34 
43  class AminoAcid : public Group {
44  public:
45 
46  // CONSTRUCTORS/DESTRUCTOR:
47  AminoAcid();
48  AminoAcid(const AminoAcid& orig);
49  virtual ~AminoAcid();
50 
51  // PREDICATES:
52 
53  virtual string getClassName() const {
54  return "AminoAcid";
55  }
56  virtual unsigned int getCode() const;
57  char getType1L();
58  unsigned int size() const;
59  unsigned int sizeBackbone() const;
60 
61  double getPhi(bool override = false);
62  double getPsi(bool override = false);
63  double getOmega(bool override = false);
64  double getChi(unsigned int n);
65  vector<double> getChi();
66  unsigned int getMaxChi();
67 
68  StateCode getState(); // returns AA state (H, S, T, C)
69 
70  SideChain& getSideChain();
71  const SideChain& getSideChain() const;
72 
73  bool isMember(const AtomCode& ac) const;
74 
75  void save(Saver& s); // data saver
76 
77  // MODIFIERS:
78  virtual void connectIn(AminoAcid* c, unsigned int offset = 1);
79  virtual void connectOut(AminoAcid* c, unsigned int offset = 1);
80  virtual AminoAcid* unconnectIn();
81  virtual AminoAcid* unconnectOut();
82 
83  void copy(const AminoAcid& orig);
84  void setType1L(char _name);
85  void setType(string _name);
86 
87  void setPhi(double a);
88  void setPsi(double a);
89  void setOmega(double a);
90  void setChi(unsigned int n, double a);
91  void setChi(vector<double> cv);
92 
93  void setState(StateCode sc); // sets AA state (H, S, T, C)
94 
95  void setDefault();
96  void setBonds(double NToCaLen, double CaToCLen, double CToOLen, double atCaToCAng, double CaToOAng);
97 
98  void constructSideChain(SideChain& sc, vector<double> chi);
99  void constructSideChain(SideChain& sc, double chi1, double chi2,
100  double chi3, double chi4, double chi5);
101  void setSideChain(SideChain& sc);
102  void setStateFromTorsionAngles(); // sets states from its phi/psi angles
103  void adjustLeadingN(); // adjusts the translation of the N atom
104  void addTerminalOXT(); // adds an OXT atom to the C terminus
105  void addMissingO(); // adds an O atom where missing
106  void removeHAtomsfromLeadingNH3(); // removes H atoms in excess from NH3+
107  void removeSideChain();
108 
109  void patchBetaPosition(unsigned int n = 0);
110  // adds a CB atom to the sidechain, if necessary
111  void patchAminoAcidCode(); // determines the 3-letter code from the sidechain
112  bool setBondsFromPdbCode(bool connect, AminoAcid* prev = NULL,
113  bool permissive = false); // returns false if failed to connect
114  virtual void sync(); // synchronize coords with structure
115  virtual void setModified();
116 
117  void load(Loader& l); // data loader
118 
119  const AminoAcid& getInBond(unsigned int n) const;
120  AminoAcid& getInBond(unsigned int n);
121  const AminoAcid& getOutBond(unsigned int n) const;
122  AminoAcid& getOutBond(unsigned int n);
123 
124  virtual const Atom& getOpenInBondRef(unsigned int n = 0) const;
125  virtual Atom& getOpenInBondRef(unsigned int n = 0);
126  virtual const Atom& getOpenOutBondRef(unsigned int n = 0) const;
127  virtual Atom& getOpenOutBondRef(unsigned int n = 0);
128 
129  virtual Component* clone();
130 
131  virtual void acceptCalculator(EnergyVisitor* v);
132  virtual void acceptOptimizer(OptimizationVisitor* v);
133 
134  // OPERATORS:
135  //bool operator==(const AminoAcid& other) const;
136  //bool operator!=(const AminoAcid& other) const;
137  AminoAcid& operator=(const AminoAcid& orig);
138  Atom& operator[](unsigned int n);
139  const Atom& operator[](unsigned int n) const;
140  Atom& operator[](const AtomCode& ac);
141  const Atom& operator[](const AtomCode& ac) const;
142 
143  protected:
144 
145  // HELPERS:
146  virtual void resetBoundaries();
147 
148  private:
149 
150  // ATTRIBUTES:
151  static double BOND_ANGLE_N_TO_CB;
152  static double BOND_ANGLE_CB_TO_C;
153  static double BOND_LENGTH_CA_TO_CB;
154 
155  AminoAcidCode type; // AminoAcid type
156  StateCode state; // -- '' -- state (H, S, T, C)
157  double phi, psi, omega; // torsion angles
158  SideChain sideChain;
159  // vector atoms (inherited from Group) contains the backbone
160  IntCoordConverter icc;
161  };
162 
163  // ---------------------------------------------------------------------------
164  // AminoAcid
165  // -----------------x-------------------x-------------------x-----------------
166 
167  // PREDICATES:
168 
169  inline unsigned int
170  AminoAcid::getCode() const {
171  return aminoAcidThreeLetterTranslator(id);
172  }
173 
174  inline char
175  AminoAcid::getType1L() {
176  return threeLetter2OneLetter(id);
177  }
178 
179  inline unsigned int
180  AminoAcid::size() const {
181  return (Group::size() + sideChain.size());
182  }
183 
184  inline unsigned int
185  AminoAcid::sizeBackbone() const {
186  return Group::size();
187  }
188 
189  inline double
190  AminoAcid::getPhi(bool override) {
191  if ((phi > 990) || (override))
192  if (sizeInBonds())
193  phi = RAD2DEG * icc.getTorsionAngle(getInBond(0)[C], (*this)[N],
194  (*this)[CA], (*this)[C]);
195  return phi;
196  }
197 
198  inline double
199  AminoAcid::getPsi(bool override) {
200  if ((psi > 990) || (override))
201  if (sizeOutBonds())
202  psi = RAD2DEG * icc.getTorsionAngle((*this)[N], (*this)[CA],
203  (*this)[C], getOutBond(0)[N]);
204  return psi;
205  }
206 
207  inline double
208  AminoAcid::getOmega(bool override) {
209  if ((omega > 990) || (override))
210  if (sizeOutBonds())
211  omega = RAD2DEG * icc.getTorsionAngle((*this)[CA], (*this)[C],
212  getOutBond(0)[N], getOutBond(0)[CA]);
213  return omega;
214  }
215 
216  inline double
217  AminoAcid::getChi(unsigned int n) {
218  return sideChain.getChi(n);
219  }
220 
221  inline vector<double>
222  AminoAcid::getChi() {
223  return sideChain.getChi();
224  }
225 
226  inline unsigned int
227  AminoAcid::getMaxChi() {
228  return sideChain.getMaxChi();
229  }
230 
231  inline StateCode
232  AminoAcid::getState() {
233  return state;
234  }
235 
236  inline const SideChain&
237  AminoAcid::getSideChain() const {
238  return sideChain;
239  }
240 
241  inline SideChain&
242  AminoAcid::getSideChain() {
243  return sideChain;
244  }
245 
246  inline bool
247  AminoAcid::isMember(const AtomCode& ac) const {
248  return (pGetAtom(ac) != NULL);
249  }
250 
251  inline void
252  AminoAcid::save(Saver& s) {
253  s.saveAminoAcid(*this);
254  }
255 
256 
257  // MODIFIERS:
258 
259  inline void
260  AminoAcid::setType1L(char _name) {
261  type = aminoAcidOneLetterTranslator(_name);
262  id.setName(oneLetter2ThreeLetter(_name));
263  }
264 
265  inline void
266  AminoAcid::setType(string _name) {
267  type = aminoAcidThreeLetterTranslator(_name);
268  id.setName(_name);
269  }
270 
271  inline void
272  AminoAcid::setChi(unsigned int n, double a) {
273  sideChain.setChi(n, a);
274  }
275 
276  inline void
277  AminoAcid::setChi(vector<double> cv) {
278  sideChain.setChi(cv);
279  }
280 
281  inline void
282  AminoAcid::setState(StateCode sc) {
283  state = sc;
284  }
285 
286  inline void
287  AminoAcid::removeSideChain() {
288  SideChain sc;
289  sideChain = sc;
290  resetBoundaries();
291  }
292 
293  inline void
294  AminoAcid::load(Loader& l) {
295  l.loadAminoAcid(*this);
296  resetBoundaries();
297  }
298 
299  inline const AminoAcid&
300  AminoAcid::getInBond(unsigned int n) const {
301  return dynamic_cast<const AminoAcid&> (Bond::getInBond(n));
302  }
303 
304  inline AminoAcid&
305  AminoAcid::getInBond(unsigned int n) {
306  return dynamic_cast<AminoAcid&> (Bond::getInBond(n));
307  }
308 
309  inline const AminoAcid&
310  AminoAcid::getOutBond(unsigned int n) const {
311  return dynamic_cast<const AminoAcid&> (Bond::getOutBond(n));
312  }
313 
314  inline AminoAcid&
315  AminoAcid::getOutBond(unsigned int n) {
316  return dynamic_cast<AminoAcid&> (Bond::getOutBond(n));
317  }
318 
319  inline void
320  AminoAcid::patchAminoAcidCode() { // determines the 3-letter code from the sidechain
321  sideChain.patchAminoAcidCode();
322  setType(sideChain.getType());
323  }
324 
325  inline void
326  AminoAcid::setModified() {
327  Group::setModified();
328  sideChain.setModified();
329  }
330 
331  inline void
332  AminoAcid::acceptCalculator(EnergyVisitor* v) {
333  v->PrepareAminoAcid(*this);
334  }
335 
336  inline void
337  AminoAcid::acceptOptimizer(OptimizationVisitor* v) {
338  v->PrepareAminoAcid(*this);
339  }
340 
341 
342  // OPERATORS:
343 
344  /*inline bool
345  AminoAcid::operator==(const AminoAcid& other) const {
346  return (dynamic_cast<const Identity*> (this)) ==
347  dynamic_cast<const Identity*> (&other);
348  }
349 
350  inline bool
351  AminoAcid::operator!=(const AminoAcid& other) const {
352  return (dynamic_cast<const Identity*> (this)) !=
353  dynamic_cast<const Identity*> (&other);
354  }*/
355 
356 
357  inline Atom&
358  AminoAcid::operator[](unsigned int n) {
359  PRECOND(n < this->size(), exception);
360  return ((n < Group::size()) ? Group::getAtom(n) : sideChain[n - Group::size()]);
361  }
362 
363  inline const Atom&
364  AminoAcid::operator[](unsigned int n) const {
365  PRECOND(n < this->size(), exception);
366  return ((n < Group::size()) ? Group::getAtom(n) : sideChain[n - Group::size()]);
367  }
368 
369  inline Atom&
370  AminoAcid::operator[](const AtomCode& ac) {
371  Atom* a = pGetAtom(ac);
372  INVARIANT(a != NULL, exception);
373  return *a;
374  }
375 
376  inline const Atom&
377  AminoAcid::operator[](const AtomCode& ac) const {
378  Atom* a = pGetAtom(ac);
379  INVARIANT(a != NULL, exception);
380  return *a;
381  }
382 
383  // HELPERS:
384 
385 }} //namespace
386 #endif //_AMINOACID_H_
387 
const AminoAcid & getOutBond(unsigned int n) const
Definition: AminoAcid.h:310
virtual const Atom & getOpenInBondRef(unsigned int n=0) const
Definition: AminoAcid.cc:63
virtual void sync()
Definition: AminoAcid.cc:565
virtual void connectIn(AminoAcid *c, unsigned int offset=1)
Definition: AminoAcid.cc:112
bool setBondsFromPdbCode(bool connect, AminoAcid *prev=NULL, bool permissive=false)
Definition: AminoAcid.cc:666
Base class for saving components (Atoms, Groups, etc.).
Definition: Saver.h:39
static double getTorsionAngle(Atom &a1, Atom &a2, Atom &a3, Atom &a4)
Definition: IntCoordConverter.cc:127
void removeHAtomsfromLeadingNH3()
Definition: AminoAcid.cc:481
This class implements a side chain.
Definition: SideChain.h:32
void setBonds(double NToCaLen, double CaToCLen, double CToOLen, double atCaToCAng, double CaToOAng)
Definition: AminoAcid.cc:648
void setStateFromTorsionAngles()
Definition: AminoAcid.cc:383
virtual void connectOut(AminoAcid *c, unsigned int offset=1)
Definition: AminoAcid.cc:128
AminoAcid & operator=(const AminoAcid &orig)
Definition: AminoAcid.cc:589
virtual const SimpleBond & getInBond(unsigned int n) const
Definition: SimpleBond.h:176
virtual const SimpleBond & getOutBond(unsigned int n) const
Definition: SimpleBond.h:184
void adjustLeadingN()
Definition: AminoAcid.cc:403
This class implements a simple chemical group.
Definition: Group.h:35
void constructSideChain(SideChain &sc, vector< double > chi)
Definition: AminoAcid.cc:367
void patchAminoAcidCode()
Definition: SideChain.cc:96
Base class for composite structures.
Definition: Component.h:39
Base class for loading components (Atoms, Groups, etc.).
Definition: Loader.h:39
Base class implementing the visitor pattern.
Definition: Visitor.h:38
unsigned int sizeInBonds() const
Definition: SimpleBond.h:146
AminoAcid()
Definition: AminoAcid.cc:35
void setPhi(double a)
Definition: AminoAcid.cc:202
unsigned int sizeOutBonds() const
Definition: SimpleBond.h:153
void addTerminalOXT()
Definition: AminoAcid.cc:422
Atom * pGetAtom(const AtomCode &ac) const
Definition: Group.cc:200
void addMissingO()
Definition: AminoAcid.cc:451
void setDefault()
Definition: AminoAcid.cc:620
void patchBetaPosition(unsigned int n=0)
Definition: AminoAcid.cc:504
void setOmega(double a)
Definition: AminoAcid.cc:250
Base class Optimizacion Patter.
Definition: Visitor.h:66
virtual void resetBoundaries()
Definition: AminoAcid.cc:603
virtual AminoAcid * unconnectIn()
Definition: AminoAcid.cc:143
Implements a simple atom type.
Definition: Atom.h:39
void setSideChain(SideChain &sc)
Definition: AminoAcid.cc:275
virtual const Atom & getOpenOutBondRef(unsigned int n=0) const
Definition: AminoAcid.cc:85
virtual ~AminoAcid()
Definition: AminoAcid.cc:53
virtual AminoAcid * unconnectOut()
Definition: AminoAcid.cc:173
virtual Component * clone()
Definition: AminoAcid.cc:576
It mplements a simple amino acid.
Definition: AminoAcid.h:43
const AminoAcid & getInBond(unsigned int n) const
Definition: AminoAcid.h:300
void setPsi(double a)
Definition: AminoAcid.cc:226
void setType(string _name)
Definition: AminoAcid.h:266
void copy(const AminoAcid &orig)
Definition: AminoAcid.cc:531
virtual string getType() const
Definition: SideChain.h:127
Implements methods to manage translation vector and angles between vectors.
Definition: IntCoordConverter.h:46