residueRotamerSet.h

Go to the documentation of this file.
00001 // -*- Mode: C++; tab-width: 2; -*-
00002 // vi: set ts=2:
00003 //
00004 // $Id: residueRotamerSet.h,v 1.1.2.5 2007/08/07 07:27:37 toussaint Exp $
00005 //
00006 
00007 #ifndef BALL_STRUCTURE_RESIDUEROTAMERSET_H
00008 #define BALL_STRUCTURE_RESIDUEROTAMERSET_H
00009 
00010 #ifndef BALL_COMMON_H
00011   #include <BALL/common.h>
00012 #endif
00013 
00014 #ifndef BALL_MATHS_ANGLE_H
00015   #include <BALL/MATHS/angle.h>
00016 #endif
00017 
00018 #ifndef BALL_DATATYPE_STRING_H
00019   #include <BALL/DATATYPE/string.h>
00020 #endif
00021 
00022 #ifndef BALL_MATHS_VECTOR3_H
00023   #include <BALL/MATHS/vector3.h>
00024 #endif
00025 
00026 namespace BALL
00027 {
00029   class Residue;
00030   template <typename Key> class HashSet;
00031   template <typename Key> class StringHashMap;
00032   class Atom;
00033 
00043   class BALL_EXPORT Rotamer
00044   {
00045     public:
00046 
00050 
00051     Rotamer();
00052 
00054     Rotamer(const Rotamer& rotamer);
00055 
00057     Rotamer(float new_P, float new_chi1, float new_chi2 = 0.0, 
00058             float new_chi3 = 0.0, float new_chi4 = 0.0);
00060 
00061 
00065 
00066     float P;
00067     
00069     float chi1;
00070 
00072     float chi2;
00073     
00075     float chi3;
00076     
00078     float chi4;
00080   };
00081 
00082 
00093   class BALL_EXPORT ResidueRotamerSet
00094   {
00095     public:
00096 
00100 
00101     typedef std::vector<Rotamer>::const_iterator  ConstIterator;
00102     typedef std::vector<Rotamer>::const_iterator  const_iterator;
00104     typedef std::vector<Rotamer>::iterator        Iterator;
00105     typedef std::vector<Rotamer>::iterator        iterator;
00107 
00108 
00112     BALL_CREATE(ResidueRotamerSet)
00113 
00114     
00116     ResidueRotamerSet();
00117 
00120     ResidueRotamerSet(const ResidueRotamerSet& rotamer_set);
00121 
00124     ResidueRotamerSet(const Residue& residue, Size number_of_torsions);
00125 
00128     virtual ~ResidueRotamerSet();
00130 
00131 
00135 
00138     Iterator begin()
00139     {
00140       return rotamers_.begin();
00141     }
00142 
00145     Iterator end()
00146     {
00147       return rotamers_.end();
00148     }
00149     
00152     ConstIterator begin() const
00153     {
00154       return rotamers_.begin();
00155     }
00156 
00159     ConstIterator end() const
00160     {
00161       return rotamers_.end();
00162     }
00164 
00168 
00169     const ResidueRotamerSet& operator = (const ResidueRotamerSet& residue_rotamer_set);
00171 
00175 
00176     const String& getName() const; 
00177 
00179     bool isValid() const; 
00180 
00182     Size getNumberOfRotamers() const;
00183 
00187     Size getNumberOfTorsions() const;
00188 
00192     void setNumberOfTorsions(Size number_of_torsions) throw(Exception::IndexOverflow);
00193 
00195     const Rotamer& operator [] (Position index) const throw(Exception::IndexOverflow);
00196 
00198     bool hasTorsionPhi() const;
00199 
00201     Angle getTorsionPhi() const;
00202 
00204     void setTorsionPhi(const Angle& phi);
00205 
00207     bool hasTorsionPsi() const;
00208 
00210     Angle getTorsionPsi() const;
00211 
00213     void setTorsionPsi(const Angle& psi);
00215 
00219 
00220     bool setTemplateResidue(const Residue& residue, Size number_of_torsions);
00221 
00225     bool setRotamer(Residue& residue, const Rotamer& rotamer);
00226 
00230     Rotamer getRotamer(const Residue& residue) const;
00231 
00237     const Rotamer& getRotamer(Position index) const;
00238 
00240     void setName(const String& name); 
00241 
00243     void addRotamer(const Rotamer& rotamer);
00244 
00246     void deleteRotamer(Iterator loc);
00247     
00249     void deleteRotamers(Iterator begin, Iterator end);
00250 
00252     void sort();
00254   
00255     
00256 
00257     protected:
00258 
00259     
00260     struct RotamerProbabilityGreaterThan_
00261       : std::binary_function<Rotamer, Rotamer, bool>
00262     {
00263       bool operator () (const Rotamer& r1, const Rotamer& r2)
00264       {
00265         return r1.P > r2.P;
00266       }
00267     };
00268 
00274     void addMovable_(std::vector<String>& movable, const Atom& a, const HashSet<String>& assigned_atoms); 
00275 
00277     void setTorsionAngle_(Residue& residue, const std::vector<String>& movable, float torsion); 
00278 
00280     bool valid_; 
00281 
00283     String name_;
00284     
00286     std::vector<Rotamer> rotamers_;
00287 
00289     std::vector<String> movable_atoms_chi1_;
00290     std::vector<String> movable_atoms_chi2_;
00291     std::vector<String> movable_atoms_chi3_;
00292     std::vector<String> movable_atoms_chi4_;
00293 
00295     Size number_of_torsions_;
00296 
00298     StringHashMap<Vector3> original_coordinates_;
00299 
00301     bool has_torsion_phi_;
00302 
00304     bool has_torsion_psi_;
00305 
00307     Angle phi_;
00308 
00310     Angle psi_;
00311   };
00312 
00313 } // namespace BALL
00314 
00315 #endif // BALL_STRUCTURE_RESIDUEROTAMERSET_H