00001
00002
00003
00004
00005 #ifndef BALL_KERNEL_NUCLEOTIDE_H
00006 #define BALL_KERNEL_NUCLEOTIDE_H
00007
00008 #ifndef BALL_KERNEL_FRAGMENT_H
00009 # include <BALL/KERNEL/fragment.h>
00010 #endif
00011
00012 #ifndef BALL_KERNEL_RESIDUE_H
00013 # include <BALL/KERNEL/residue.h>
00014 #endif
00015
00016 #ifndef BALL_KERNEL_NUCLEOTIDEITERATOR_H
00017 # include <BALL/KERNEL/nucleotideIterator.h>
00018 #endif
00019
00020
00021 #define BALL_NUCLEOTIDE_DEFAULT_ID ""
00022 #define BALL_NUCLEOTIDE_DEFAULT_INSERTION_CODE ' '
00023
00024 namespace BALL
00025 {
00026 class NucleicAcid;
00027
00035 class BALL_EXPORT Nucleotide
00036 : public Fragment
00037 {
00038 public:
00039
00040 BALL_CREATE_DEEP(Nucleotide)
00041
00042
00045
00047 enum Property
00048 {
00050 PROPERTY__5_PRIME = Residue::NUMBER_OF_PROPERTIES + 1,
00052 PROPERTY__3_PRIME,
00054 PROPERTY__NUCLEOTIDE,
00055
00057 NUMBER_OF_PROPERTIES
00058 };
00059
00061
00064
00066 Nucleotide();
00067
00069 Nucleotide(const Nucleotide& nucleotide, bool deep = true);
00070
00072 Nucleotide
00073 (const String& name,
00074 const String& id = BALL_NUCLEOTIDE_DEFAULT_ID,
00075 char insertion_code = BALL_NUCLEOTIDE_DEFAULT_INSERTION_CODE);
00076
00078 virtual ~Nucleotide();
00079
00081 virtual void clear();
00082
00084 virtual void destroy();
00085
00087
00090
00094 void persistentWrite(PersistenceManager& pm, const char* name = 0) const;
00095
00099 void persistentRead(PersistenceManager& pm);
00100
00102
00105
00111 void set(const Nucleotide& nucleotide, bool deep = true);
00112
00119 Nucleotide& operator = (const Nucleotide& nucleotide);
00120
00126 void get(Nucleotide& nucleotide, bool deep = true) const;
00127
00131 void swap(Nucleotide& nucleotide);
00132
00134
00139 bool operator == (const Nucleotide& nucleotide) const;
00140
00144 bool operator != (const Nucleotide& nucleotide) const;
00145
00148
00153 NucleicAcid* getNucleicAcid();
00154
00159 const NucleicAcid* getNucleicAcid() const;
00160
00164 void setID(const String& id);
00165
00169 const String& getID() const;
00170
00174 void setInsertionCode(char insertion_code);
00175
00179 char getInsertionCode() const;
00180
00184 void prepend(Atom& atom);
00185
00189 void append(Atom& atom);
00190
00194 void insert(Atom& atom);
00195
00200 void insertBefore(Atom& atom, Composite& before);
00201
00206 void insertAfter(Atom& atom, Composite& after);
00207
00211 bool remove(Atom& atom);
00212
00216 void spliceBefore(Nucleotide& nucleotide);
00217
00221 void spliceAfter(Nucleotide& nucleotide);
00222
00226 void splice(Nucleotide& nucleotide);
00227
00229
00232
00238 bool isTerminal() const;
00239
00244 bool is3Prime() const;
00245
00250 bool is5Prime() const;
00251
00253
00256
00261 virtual bool isValid() const;
00262
00269 virtual void dump(std::ostream& s = std::cout, Size depth = 0) const;
00270
00272
00273 private:
00274
00275 AtomContainer* getAtomContainer(Position position);
00276
00277 const AtomContainer* getAtomContainer(Position position) const;
00278
00279 Size countAtomContainers() const;
00280
00281 void prepend(AtomContainer& atom_container);
00282
00283 void append(AtomContainer& atom_container);
00284
00285 void insert(AtomContainer& atom_container);
00286
00287 void insertBefore(AtomContainer& atom_container, Composite& composite);
00288
00289 void insertAfter(AtomContainer& atom_container, Composite& composite);
00290
00291 void spliceBefore(AtomContainer& atom_container);
00292
00293 void spliceAfter(AtomContainer& base_ragment);
00294
00295 void splice(AtomContainer& AtomContainer);
00296
00297 bool remove(AtomContainer& AtomContainer);
00298
00299 bool isSuperAtomContainerOf(const AtomContainer& atom_container) const;
00300
00301 BALL_KERNEL_DEFINE_ITERATOR_CREATORS(AtomContainer)
00302
00303
00304
00305 String id_;
00306
00307 char insertion_code_;
00308 };
00309
00310
00311 template <class NucleotideContainerType>
00312 const Nucleotide* get5Prime(const NucleotideContainerType& nucleotide_container)
00313 {
00314 NucleotideConstIterator res_it;
00315 for ( res_it = nucleotide_container.beginNucleotide(); !res_it.isEnd(); ++res_it)
00316 {
00317 return &(*res_it);
00318 }
00319
00320 return 0;
00321 }
00322
00323 template <class NucleotideContainerType>
00324 const Nucleotide* get3Prime(const NucleotideContainerType& nucleotide_container)
00325 {
00326 for (NucleotideConstIterator res_it = nucleotide_container.rbeginNucleotide(); !res_it.isREnd(); ++res_it)
00327 {
00328 return &(*res_it);
00329 }
00330
00331 return 0;
00332 }
00333
00334 }
00335
00336 #endif // BALL_KERNEL_NUCLEOTIDE_H