BALL  1.4.79
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
nucleotide.h
Go to the documentation of this file.
1 // -*- Mode: C++; tab-width: 2; -*-
2 // vi: set ts=2:
3 //
4 
5 #ifndef BALL_KERNEL_NUCLEOTIDE_H
6 #define BALL_KERNEL_NUCLEOTIDE_H
7 
8 #ifndef BALL_KERNEL_FRAGMENT_H
9 # include <BALL/KERNEL/fragment.h>
10 #endif
11 
12 #ifndef BALL_KERNEL_RESIDUE_H
13 # include <BALL/KERNEL/residue.h>
14 #endif
15 
16 #ifndef BALL_KERNEL_NUCLEOTIDEITERATOR_H
18 #endif
19 
20 
21 #define BALL_NUCLEOTIDE_DEFAULT_ID ""
22 #define BALL_NUCLEOTIDE_DEFAULT_INSERTION_CODE ' '
23 
24 namespace BALL
25 {
26  class NucleicAcid;
27 
36  : public Fragment
37  {
38  public:
39 
41 
42 
45 
47  enum Property
48  {
50  PROPERTY__5_PRIME = Residue::NUMBER_OF_PROPERTIES + 1,
55 
57  NUMBER_OF_PROPERTIES
58  };
59 
61 
64 
66  Nucleotide();
67 
69  Nucleotide(const Nucleotide& nucleotide, bool deep = true);
70 
73  (const String& name,
75  char insertion_code = BALL_NUCLEOTIDE_DEFAULT_INSERTION_CODE);
76 
78  virtual ~Nucleotide();
79 
81  virtual void clear();
82 
84  virtual void destroy();
85 
87 
90 
94  void persistentWrite(PersistenceManager& pm, const char* name = 0) const;
95 
99  void persistentRead(PersistenceManager& pm);
100 
102 
105 
111  void set(const Nucleotide& nucleotide, bool deep = true);
112 
119  Nucleotide& operator = (const Nucleotide& nucleotide);
120 
126  void get(Nucleotide& nucleotide, bool deep = true) const;
127 
131  void swap(Nucleotide& nucleotide);
132 
134 
139  bool operator == (const Nucleotide& nucleotide) const;
140 
144  bool operator != (const Nucleotide& nucleotide) const;
145 
148 
153  NucleicAcid* getNucleicAcid();
154 
159  const NucleicAcid* getNucleicAcid() const;
160 
164  void setID(const String& id);
165 
169  const String& getID() const;
170 
174  void setInsertionCode(char insertion_code);
175 
179  char getInsertionCode() const;
180 
184  void prepend(Atom& atom);
185 
189  void append(Atom& atom);
190 
194  void insert(Atom& atom);
195 
200  void insertBefore(Atom& atom, Composite& before);
201 
206  void insertAfter(Atom& atom, Composite& after);
207 
211  bool remove(Atom& atom);
212 
216  void spliceBefore(Nucleotide& nucleotide);
217 
221  void spliceAfter(Nucleotide& nucleotide);
222 
226  void splice(Nucleotide& nucleotide);
227 
229 
232 
238  bool isTerminal() const;
239 
244  bool is3Prime() const;
245 
250  bool is5Prime() const;
251 
253 
256 
261  virtual bool isValid() const;
262 
269  virtual void dump(std::ostream& s = std::cout, Size depth = 0) const;
270 
272 
273  private:
274 
275  AtomContainer* getAtomContainer(Position position);
276 
277  const AtomContainer* getAtomContainer(Position position) const;
278 
279  Size countAtomContainers() const;
280 
281  void prepend(AtomContainer& atom_container);
282 
283  void append(AtomContainer& atom_container);
284 
285  void insert(AtomContainer& atom_container);
286 
287  void insertBefore(AtomContainer& atom_container, Composite& composite);
288 
289  void insertAfter(AtomContainer& atom_container, Composite& composite);
290 
291  void spliceBefore(AtomContainer& atom_container);
292 
293  void spliceAfter(AtomContainer& base_ragment);
294 
295  void splice(AtomContainer& AtomContainer);
296 
297  bool remove(AtomContainer& AtomContainer);
298 
299  bool isSuperAtomContainerOf(const AtomContainer& atom_container) const;
300 
303 
304  // --- ATTRIBUTES
305 
306  String id_;
307 
308  char insertion_code_;
309  };
310 
311 
312  template <class NucleotideContainerType>
313  const Nucleotide* get5Prime(const NucleotideContainerType& nucleotide_container)
314  {
316  for ( res_it = nucleotide_container.beginNucleotide(); !res_it.isEnd(); ++res_it)
317  {
318  return &(*res_it);
319  }
320 
321  return 0;
322  }
323 
324  template <class NucleotideContainerType>
325  const Nucleotide* get3Prime(const NucleotideContainerType& nucleotide_container)
326  {
327  for (NucleotideConstIterator res_it = nucleotide_container.rbeginNucleotide(); !res_it.isREnd(); ++res_it)
328  {
329  return &(*res_it);
330  }
331 
332  return 0;
333  }
334 
335 } // namespace BALL
336 
337 #endif // BALL_KERNEL_NUCLEOTIDE_H
BALL_INLINE bool isEnd() const
Check whether the iterator points to the position after the last item of the container.
#define BALL_KERNEL_DEFINE_ITERATOR_CREATORS(Type)
Definition: iterator.h:25
const Nucleotide * get5Prime(const NucleotideContainerType &nucleotide_container)
Definition: nucleotide.h:313
const Nucleotide * get3Prime(const NucleotideContainerType &nucleotide_container)
Definition: nucleotide.h:325
Property
The number of predefined properties for AtomContainer.
Definition: atomContainer.h:42
BALL_EXPORT bool operator!=(const String &s1, const String &s2)
#define BALL_CREATE_DEEP(name)
Definition: create.h:26
#define BALL_DECLARE_STD_ITERATOR_WRAPPER(container, type, method_name)
#define BALL_NUCLEOTIDE_DEFAULT_INSERTION_CODE
Definition: nucleotide.h:22
BALL_EXPORT bool operator==(const String &s1, const String &s2)
BALL_EXPORT AtomContainerList atomContainers(const AtomContainer &fragment, bool selected_only=false)
#define BALL_NUCLEOTIDE_DEFAULT_ID
Definition: nucleotide.h:21
BALL_INLINE bool isREnd() const
Test wheter the iterator points to the position before the first element.
#define BALL_EXPORT
Definition: COMMON/global.h:50