Victor
 All Data Structures Functions Variables Friends Pages
SideChain.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 _SIDECHAIN_H_
19 #define _SIDECHAIN_H_
20 #include <vector>
21 #include <Group.h>
22 #include <AminoAcidCode.h>
23 #include <IntCoordConverter.h>
24 #include <Visitor.h>
25 
26 namespace Victor { namespace Biopool {
27 
32  class SideChain : public Group {
33  public:
34  // CONSTRUCTORS/DESTRUCTOR:
35  SideChain();
36  SideChain(const SideChain& orig);
37  virtual ~SideChain();
38 
39  // PREDICATES:
40 
41  virtual string getClassName() const {
42  return "SideChain";
43  }
44  virtual unsigned int getCode() const;
45  virtual string getType() const; // returns AA 3-L-code
46  virtual string getExtendedType() const; // returns full code
47 
48  double getChi(unsigned int n);
49  vector<double> getChi();
50  unsigned int getMaxChi();
51 
52  AminoAcid* getBackboneRef();
53 
54  bool isMember(const AtomCode& ac) const;
55 
56  void save(Saver& s); // data saver
57 
58  // MODIFIERS:
59  void setChi(unsigned int n, double c);
60  void setChi(vector<double> cv);
61  void setBackboneRef(AminoAcid* br);
62 
63  void copy(const SideChain& orig);
64  void load(Loader& l); // data loader
65 
66  void patchAminoAcidCode(); // determines the 3-letter code from the sidechain
67  bool setBondsFromPdbCode(bool connect, bool permissive = false);
68  // returns false if failed to connect
69 
70  virtual const SideChain& getInBond(unsigned int n) const;
71  virtual SideChain& getInBond(unsigned int n);
72  virtual const SideChain& getOutBond(unsigned int n) const;
73  virtual SideChain& getOutBond(unsigned int n);
74 
75  virtual void acceptCalculator(EnergyVisitor* v);
76  virtual void acceptOptimizer(OptimizationVisitor* v);
77 
78  // OPERATORS:
79  SideChain& operator=(const SideChain& orig);
80  Atom& operator[](unsigned int n);
81  const Atom& operator[](unsigned int n) const;
82  Atom& operator[](const AtomCode& ac);
83  const Atom& operator[](const AtomCode& ac) const;
84 
85  protected:
86 
87  private:
88  // HELPERS:
89  bool findCode(char c, unsigned int& pos, unsigned int& pos2);
90  void findHCode(char c, char c2, Atom& at, bool connect);
91  void setMaxChiFromCode();
92  void setMaxChi(unsigned int _maxChi);
93  double calculateChi(unsigned int n);
94  void convertChi(unsigned int n, double a);
95 
96  bool hasB();
97  bool hasG();
98  bool hasD();
99  bool hasE();
100  bool hasZ();
101  bool hasH();
102 
103  Atom& firstG();
104  Atom& firstD();
105  Atom& firstE();
106  Atom& firstZ();
107  Atom& firstH();
108 
109  // ATTRIBUTES:
110  unsigned int maxChi; // number of chi torsion angles
111  vector<double> chi; // torsion angles
112  AminoAcid* backboneRef; // reference to backbone (aminoacid) of this
113 
114  friend class AminoAcid;
115  };
116 
117  // ---------------------------------------------------------------------------
118  // Group
119  // -----------------x-------------------x-------------------x-----------------
120 
121  // PREDICATES:
122 
123  inline unsigned int SideChain::getCode() const {
124  return aminoAcidThreeLetterTranslator(getType());
125  }
126 
127  inline string SideChain::getType() const {
128  string tmp = id;
129  return tmp.substr(0, 3);
130  }
131 
132  inline string SideChain::getExtendedType() const {
133  return id;
134  }
135 
136  inline double SideChain::getChi(unsigned int n) {
137  PRECOND(n < chi.size(), exception);
138  if (chi[n] > 990)
139  chi[n] = RAD2DEG * calculateChi(n);
140  return chi[n];
141  }
142 
143  inline unsigned int SideChain::getMaxChi() {
144  return chi.size();
145  }
146 
147  inline AminoAcid* SideChain::getBackboneRef() {
148  if (backboneRef == NULL)
149  DEBUG_MSG("Sidechain has no assigned backbone.");
150  return backboneRef;
151  }
152 
153  inline bool SideChain::isMember(const AtomCode& ac) const {
154  return (pGetAtom(ac) != NULL);
155  }
156 
157  inline void SideChain::save(Saver& s) {
158  s.saveGroup(*this);
159  }
160 
161  inline void SideChain::acceptCalculator(EnergyVisitor* v) {
162  v->PrepareSideChain(*this);
163  }
164 
165  inline void SideChain::acceptOptimizer(OptimizationVisitor* v) {
166  v->PrepareSideChain(*this);
167  }
168 
169 
170  // MODIFIERS:
171 
172  inline void SideChain::setChi(unsigned int n, double c) {
173  PRECOND((n < chi.size()) && (c >= -180) && (c <= 180), exception);
174  convertChi(n, DEG2RAD * c);
175  chi[n] = c;
176  }
177 
178  inline void SideChain::load(Loader& l) {
179  l.loadSideChain(*this);
180  resetBoundaries();
181  }
182 
183  inline const SideChain& SideChain::getInBond(unsigned int n) const {
184  return dynamic_cast<const SideChain&> (Bond::getInBond(n));
185  }
186 
187  inline SideChain& SideChain::getInBond(unsigned int n) {
188  return dynamic_cast<SideChain&> (Bond::getInBond(n));
189  }
190 
191  inline const SideChain& SideChain::getOutBond(unsigned int n) const {
192  return dynamic_cast<const SideChain&> (Bond::getOutBond(n));
193  }
194 
195  inline SideChain& SideChain::getOutBond(unsigned int n) {
196  return dynamic_cast<SideChain&> (Bond::getOutBond(n));
197  }
198 
199  // OPERATORS:
200  inline Atom& SideChain::operator[](unsigned int n) {
201  return (Group::getAtom(n));
202  }
203 
204  inline const Atom& SideChain::operator[](unsigned int n) const {
205  return (Group::getAtom(n));
206  }
207 
208  inline Atom& SideChain::operator[](const AtomCode& ac) {
209  Atom* a = pGetAtom(ac);
210  INVARIANT(a != NULL, exception);
211  return *a;
212  }
213 
214  inline const Atom& SideChain::operator[](const AtomCode& ac) const {
215  Atom* a = pGetAtom(ac);
216  INVARIANT(a != NULL, exception);
217  return *a;
218  }
219 
220  // HELPERS:
221 
222 }} //namespace
223 #endif //_SIDECHAIN_H_
224 
void setBackboneRef(AminoAcid *br)
Definition: SideChain.cc:82
Base class for saving components (Atoms, Groups, etc.).
Definition: Saver.h:39
This class implements a side chain.
Definition: SideChain.h:32
vector< double > getChi()
Definition: SideChain.cc:47
virtual const SimpleBond & getInBond(unsigned int n) const
Definition: SimpleBond.h:176
virtual const SimpleBond & getOutBond(unsigned int n) const
Definition: SimpleBond.h:184
This class implements a simple chemical group.
Definition: Group.h:35
void resetBoundaries()
Definition: Group.cc:50
void patchAminoAcidCode()
Definition: SideChain.cc:96
virtual const SideChain & getInBond(unsigned int n) const
Definition: SideChain.h:183
Base class for loading components (Atoms, Groups, etc.).
Definition: Loader.h:39
Base class implementing the visitor pattern.
Definition: Visitor.h:38
bool setBondsFromPdbCode(bool connect, bool permissive=false)
Definition: SideChain.cc:171
virtual const SideChain & getOutBond(unsigned int n) const
Definition: SideChain.h:191
Atom * pGetAtom(const AtomCode &ac) const
Definition: Group.cc:200
Base class Optimizacion Patter.
Definition: Visitor.h:66
Implements a simple atom type.
Definition: Atom.h:39
It mplements a simple amino acid.
Definition: AminoAcid.h:43
virtual string getType() const
Definition: SideChain.h:127