Victor
 All Data Structures Functions Variables Friends Pages
Nucleotide.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 _NUCLEOTIDE_H_
19 #define _NUCLEOTIDE_H_
20 
21 //unuseful comment
22 // Includes:
23 #include <Group.h>
24 #include <IntCoordConverter.h>
25 #include <Visitor.h>
26 #include <NucleotideCode.h>
27 
28 
29 // Global constants, typedefs, etc. (to avoid):
30 
31 namespace Victor { namespace Biopool {
32 
37  class Nucleotide : public Group {
38  public:
39 
40  // CONSTRUCTORS/DESTRUCTOR:
41  Nucleotide();
42  Nucleotide(const Nucleotide& orig);
43  virtual ~Nucleotide();
44 
45  // PREDICATES:
46 
47  virtual string getClassName() const {
48  return "Nucleotide";
49  }
50  virtual unsigned int getCode() const;
51  unsigned int size() const;
52 
53  unsigned int sizeNucleotide() const;
54 
55 
56  bool isMember(const AtomCode& ac) const;
57 
58  void save(Saver& s); // data saver
59 
60  // MODIFIERS:
61 
62 
63  void copy(const Nucleotide& orig);
64  void setType(string _name);
65 
66  void setBonds(double NToCaLen, double CaToCLen, double CToOLen, double atCaToCAng, double CaToOAng);
67  bool setBondsFromPdbCode(bool connect, Nucleotide* prev, bool permissive);
68 
69  virtual void sync(); // synchronize coords with structure
70  virtual void setModified();
71 
72  void load(Loader& l); // data loader
73 
74  virtual Component* clone();
75 
76  // OPERATORS:
77  bool operator==(const Nucleotide& other) const;
78  bool operator!=(const Nucleotide& other) const;
79  Nucleotide& operator=(const Nucleotide& 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 
89  // ATTRIBUTES:
90 
91  NucleotideCode type; // Nucleotide type
92  // vector atoms (inherited from Group) contains the backbone
93  IntCoordConverter icc; // should be static, but compiler won't accept it?
94  };
95 
96  // ---------------------------------------------------------------------------
97  // Nucleotide
98  // -----------------x-------------------x-------------------x-----------------
99 
100  // PREDICATES:
101 
102  inline unsigned int
103  Nucleotide::getCode() const {
104  return nucleotideThreeLetterTranslator(id);
105  }
106 
107  inline unsigned int
108  Nucleotide::size() const {
109  return Group::size();
110  }
111 
112  inline unsigned int
113  Nucleotide::sizeNucleotide() const {
114  return Group::size();
115  }
116 
117  inline bool
118  Nucleotide::isMember(const AtomCode& ac) const {
119  return (pGetAtom(ac) != NULL);
120  }
121 
122  inline void
123  Nucleotide::save(Saver& s) {
124  s.saveNucleotide(*this);
125  }
126 
127 
128  // MODIFIERS:
129 
130  inline void
131  Nucleotide::setType(string _name) {
132  type = nucleotideThreeLetterTranslator(_name);
133  id.setName(_name);
134  }
135 
136  inline void
137  Nucleotide::load(Loader& l) {
138  l.loadNucleotide(*this);
139  resetBoundaries();
140  }
141 
142  inline void
143  Nucleotide::setModified() {
144  Group::setModified();
145  }
146 
147 
148 
149 
150  // OPERATORS:
151 
152  inline bool
153  Nucleotide::operator==(const Nucleotide& other) const {
154  return (dynamic_cast<const Identity*> (this)) ==
155  dynamic_cast<const Identity*> (&other);
156  }
157 
158  inline bool
159  Nucleotide::operator!=(const Nucleotide& other) const {
160  return (dynamic_cast<const Identity*> (this)) !=
161  dynamic_cast<const Identity*> (&other);
162  }
163 
164 
165  inline Atom&
166  Nucleotide::operator[](unsigned int n) {
167  PRECOND(n < this->size(), exception);
168  return Group::getAtom(n);
169  }
170 
171  inline const Atom&
172  Nucleotide::operator[](unsigned int n) const {
173  PRECOND(n < this->size(), exception);
174  return Group::getAtom(n);
175  }
176 
177  inline Atom&
178  Nucleotide::operator[](const AtomCode& ac) {
179  Atom* a = pGetAtom(ac);
180  INVARIANT(a != NULL, exception);
181  return *a;
182  }
183 
184  inline const Atom&
185  Nucleotide::operator[](const AtomCode& ac) const {
186  Atom* a = pGetAtom(ac);
187  INVARIANT(a != NULL, exception);
188  return *a;
189  }
190 }}
191 #endif //_NUCLEOTIDE_H_
Base class for saving components (Atoms, Groups, etc.).
Definition: Saver.h:39
Implements a simple nucleotide.
Definition: Nucleotide.h:37
void copy(const Nucleotide &orig)
Definition: Nucleotide.cc:67
void setType(string _name)
Definition: Nucleotide.h:131
This class implements a simple chemical group.
Definition: Group.h:35
void resetBoundaries()
Definition: Group.cc:50
Base class for composite structures.
Definition: Component.h:39
Nucleotide()
Definition: Nucleotide.cc:33
Base class for loading components (Atoms, Groups, etc.).
Definition: Loader.h:39
virtual ~Nucleotide()
Definition: Nucleotide.cc:49
Nucleotide & operator=(const Nucleotide &orig)
Definition: Nucleotide.cc:97
Atom * pGetAtom(const AtomCode &ac) const
Definition: Group.cc:200
Implements a simple atom type.
Definition: Atom.h:39
virtual Component * clone()
Definition: Nucleotide.cc:84
Implements methods to manage translation vector and angles between vectors.
Definition: IntCoordConverter.h:46