nucleotide.h

Go to the documentation of this file.
00001 // -*- Mode: C++; tab-width: 2; -*-
00002 // vi: set ts=2:
00003 //
00004 // $Id: nucleotide.h,v 1.37 2005/10/23 12:02:19 oliver Exp $
00005 //
00006 
00007 #ifndef BALL_KERNEL_NUCLEOTIDE_H
00008 #define BALL_KERNEL_NUCLEOTIDE_H
00009 
00010 #ifndef BALL_KERNEL_FRAGMENT_H
00011 # include <BALL/KERNEL/fragment.h>
00012 #endif
00013 
00014 #ifndef BALL_KERNEL_RESIDUE_H
00015 # include <BALL/KERNEL/residue.h>
00016 #endif
00017 
00018 #ifndef BALL_KERNEL_NUCLEOTIDEITERATOR_H
00019 # include <BALL/KERNEL/nucleotideIterator.h>
00020 #endif
00021 
00022  
00023 #define BALL_NUCLEOTIDE_DEFAULT_ID               ""
00024 #define BALL_NUCLEOTIDE_DEFAULT_INSERTION_CODE   ' '
00025 
00026 namespace BALL 
00027 {
00028   class NucleicAcid;
00029 
00037   class BALL_EXPORT Nucleotide
00038     : public Fragment
00039   {
00040     public:
00041 
00042     BALL_CREATE_DEEP(Nucleotide)
00043   
00044     
00047 
00049     enum Property
00050     {
00052       PROPERTY__5_PRIME = Residue::NUMBER_OF_PROPERTIES + 1,
00054       PROPERTY__3_PRIME,
00056       PROPERTY__NUCLEOTIDE,
00057 
00059       NUMBER_OF_PROPERTIES
00060     };
00061 
00063 
00066   
00068     Nucleotide();
00069   
00071     Nucleotide(const Nucleotide& nucleotide, bool deep = true);
00072   
00074     Nucleotide
00075       (const String& name,
00076        const String& id = BALL_NUCLEOTIDE_DEFAULT_ID,
00077        char insertion_code = BALL_NUCLEOTIDE_DEFAULT_INSERTION_CODE);
00078 
00080     virtual ~Nucleotide();
00081 
00083     virtual void clear();
00084   
00086     virtual void destroy();
00087   
00089 
00092 
00096     void persistentWrite(PersistenceManager& pm, const char* name = 0) const
00097       throw(Exception::GeneralException);
00098 
00102     void persistentRead(PersistenceManager& pm)
00103       throw(Exception::GeneralException);
00104 
00106 
00109 
00115     void set(const Nucleotide& nucleotide, bool deep = true);
00116 
00123     Nucleotide& operator = (const Nucleotide& nucleotide);
00124 
00130     void get(Nucleotide& nucleotide, bool deep = true) const;
00131 
00135     void swap(Nucleotide& nucleotide);
00136   
00138 
00143     bool operator == (const Nucleotide& nucleotide) const;
00144 
00148     bool operator != (const Nucleotide& nucleotide) const;
00149 
00152 
00157     NucleicAcid* getNucleicAcid();
00158     
00163     const NucleicAcid* getNucleicAcid() const;
00164 
00168     void setID(const String& id);
00169 
00173     const String& getID() const;
00174 
00178     void setInsertionCode(char insertion_code);
00179 
00183     char getInsertionCode() const;
00184 
00188     void prepend(Atom& atom);
00189 
00193     void append(Atom& atom);
00194 
00198     void insert(Atom& atom);
00199 
00204     void insertBefore(Atom& atom, Composite& before);
00205 
00210     void insertAfter(Atom& atom, Composite& after);
00211 
00215     bool remove(Atom& atom);
00216 
00220     void spliceBefore(Nucleotide& nucleotide);
00221 
00225     void spliceAfter(Nucleotide& nucleotide);
00226 
00230     void splice(Nucleotide& nucleotide);
00231 
00233 
00236 
00242     bool isTerminal() const;
00243   
00248     bool is3Prime() const;
00249 
00254     bool is5Prime() const;
00255 
00257 
00260 
00265     virtual bool isValid() const;
00266 
00273     virtual void dump(std::ostream& s = std::cout, Size depth = 0) const;
00274 
00276  
00277     private:
00278 
00279     AtomContainer* getAtomContainer(Position position);
00280   
00281     const AtomContainer* getAtomContainer(Position position) const;
00282   
00283     Size countAtomContainers() const;
00284 
00285     void prepend(AtomContainer& atom_container);
00286 
00287     void append(AtomContainer& atom_container);
00288 
00289     void insert(AtomContainer& atom_container);
00290 
00291     void insertBefore(AtomContainer& atom_container, Composite& composite);
00292 
00293     void insertAfter(AtomContainer& atom_container, Composite& composite);
00294 
00295     void spliceBefore(AtomContainer& atom_container);
00296 
00297     void spliceAfter(AtomContainer& base_ragment);
00298 
00299     void splice(AtomContainer& AtomContainer);
00300 
00301     bool remove(AtomContainer& AtomContainer);
00302 
00303     bool isSuperAtomContainerOf(const AtomContainer& atom_container) const;
00304 
00305     BALL_KERNEL_DEFINE_ITERATOR_CREATORS(AtomContainer)
00306 
00307     // --- ATTRIBUTES
00308 
00309     String  id_;
00310 
00311     char    insertion_code_;
00312   };
00313 
00314 
00315   template <class NucleotideContainerType>
00316   const Nucleotide* get5Prime(const NucleotideContainerType& nucleotide_container)
00317   {
00318     NucleotideConstIterator res_it;
00319     for ( res_it = nucleotide_container.beginNucleotide(); !res_it.isEnd(); ++res_it)
00320     {
00321       return &(*res_it);
00322     }
00323 
00324     return 0;
00325   }
00326 
00327   template <class NucleotideContainerType>
00328   const Nucleotide* get3Prime(const NucleotideContainerType& nucleotide_container)
00329   {
00330     for (NucleotideConstIterator res_it = nucleotide_container.rbeginNucleotide(); !res_it.isREnd(); ++res_it)
00331     {
00332       return &(*res_it);
00333     }
00334 
00335     return 0;
00336   }
00337  
00338 } // namespace BALL
00339 
00340 #endif // BALL_KERNEL_NUCLEOTIDE_H