BALL  1.4.1
HBondProcessor.h
Go to the documentation of this file.
00001 // -*- Mode: C++; tab-width: 2; -*-
00002 // vi: set ts=2:
00003 //
00004 
00005 #ifndef BALL_STRUCTURE_HBONDPROCESSOR_H
00006 #define BALL_STRUCTURE_HBONDPROCESSOR_H
00007 
00008 #ifndef BALL_CONCEPT_PROCESSOR_H
00009 #include <BALL/CONCEPT/processor.h>
00010 #endif
00011 
00012 #ifndef BALL_KERNEL_RESIDUE_H
00013 #include <BALL/KERNEL/residue.h>
00014 #endif
00015 
00016 #ifndef BALL_MATHS_VECTOR3_H
00017 #include <BALL/MATHS/vector3.h> 
00018 #endif
00019 
00020 #ifndef BALL_DATATYPE_OPTIONS_H
00021   #include <BALL/DATATYPE/options.h>
00022 #endif
00023 
00024 #include <vector>
00025 #include <map>
00026 
00027 namespace BALL
00028 {
00098   class BALL_EXPORT HBondProcessor 
00099     : public UnaryProcessor<Composite>
00100   {
00101  
00102     public: 
00103       
00107        
00110       class BALL_EXPORT HBond
00111       {
00112         public: 
00113           HBond();
00114           HBond(Atom const* acceptor, Atom const* donor, bool donor_is_hydrogen=false) 
00115                 {acceptor_ = acceptor; donor_ = donor; donor_is_hydrogen_ = donor_is_hydrogen;}
00116           Atom const* getAcceptor() { return acceptor_; }
00117           Atom const* getDonor()    { return donor_; }
00118 
00120           bool donorIsHydrogen()    { return donor_is_hydrogen_; }
00121 
00123           float getLength() { return acceptor_->getDistance(*donor_); }
00124 
00125           // TODO: getAngle()? This is tricky as the DSSP works with implicit hydrogen positions
00126 
00127         protected:
00128           Atom const* acceptor_;
00129           Atom const* donor_;
00130           bool        donor_is_hydrogen_;
00131       };
00133 
00137 
00138       struct BALL_EXPORT Option
00139       {
00142         static const String PREDICTION_METHOD;
00143         
00146         static const String ADD_HBONDS; 
00147         
00150         static const String KABSCH_SANDER_ENERGY_CUTOFF;
00151       };  
00152       
00154       struct BALL_EXPORT Default
00155       {
00156         static const String PREDICTION_METHOD;   
00157         static const bool ADD_HBONDS; 
00158         static const float KABSCH_SANDER_ENERGY_CUTOFF;
00159       };
00160       
00162       struct BALL_EXPORT PredictionMethod
00163       {
00164         static const String KABSCH_SANDER;
00165         static const String WISHART_ET_AL;  
00166       };
00167         
00168       // constants for Kabsch Sander
00169       // 5.2 Angstrom is the maximum distance between N and O in a hydrogen bond.
00170       // 4.2 Angstrom is an upper bound for the distance between N and O in the same
00171       // residue. Therefore, if two residues are farther apart than MAX_LENGTH, N and O
00172       // are farther apart than 5.2 Angstroms and there will be no hydrogen bond.
00173       static float MAX_LENGTH;
00174       static float BOND_LENGTH_N_H;
00175       static float BOND_LENGTH_C_O;
00176 
00177       // constants for Wishard et al
00178       static float AMIDE_PROTON_OXYGEN_SEPARATION_DISTANCE; // = 3.5;
00179       static float ALPHA_PROTON_OXYGEN_SEPARATION_DISTANCE; // = 2.77208;
00180 
00181       
00183       struct BALL_EXPORT ResidueData
00184       {
00185         Vector3 pos_C;
00186         Vector3 pos_N;
00187         Vector3 pos_H;
00188         Vector3 pos_O;
00189         Size    number;
00190         Residue*  res; 
00192         bool is_complete; 
00193       };
00194 
00195       BALL_CREATE(HBondProcessor);
00196 
00199       
00201       HBondProcessor();
00202 
00204       HBondProcessor(Options& new_options);
00205       
00207       virtual ~HBondProcessor();
00208       
00210 
00211 
00214       
00217       virtual void init();
00218 
00221       virtual bool start();
00222 
00224       //                            computes the theoretical position of H
00225       //                            and stores the residue information in residue_data_
00226       //                            
00228       virtual Processor::Result operator() (Composite &composite);
00229       
00231       // to the chosen method <tt> PredictionMethod</tt>.
00232       virtual bool finish();
00233 
00235   
00239       
00241       const std::vector< HBond>& getHBonds() const {return h_bonds_;}
00242       
00244       std::vector< HBond> getHBonds() {return h_bonds_;}
00245 
00247       BALL_DEPRECATED const std::vector< std::vector<Position> >& getBackboneHBondPairs() const;
00248       
00250       const std::vector< std::vector<Position> >& getBackboneHBondPattern() const;
00251 
00253       const std::vector<ResidueData>& getResidueData() const;
00254       
00256 
00260 
00261       Options options;
00262 
00265       void setDefaultOptions();
00267 
00268     protected:  
00269 
00270       void preComputeBonds_(ResidueIterator& data);
00271       bool finishKabschSander_();
00272       bool finishWishartEtAl_();
00273       
00274 
00278 
00279       //_ lower point of the grid
00280       Vector3         upper_;
00281       //_ upper point of the grid
00282       Vector3         lower_;
00283       
00284       //_ the atom positions and an accending number per residue 
00285       std::vector<ResidueData>            residue_data_;
00286 
00287       //_ the backbone hydrogen bonds for the secondary structure processor
00288       std::vector<std::vector<Position> > backbone_h_bond_pairs_;
00290 
00291 
00292 
00296       
00297       /*_ list of __ShiftX__ HBond donors collected by <tt>operator ()</tt>
00298        */
00299       std::vector<Atom*>             donors_;
00300 
00301       /*_ list of HBond acceptors collected by <tt>operator ()</tt>
00302        */
00303       std::vector<Atom*>             acceptors_;
00304 
00305       std::map< Residue*, Position>  residue_ptr_to_position_;    
00307     
00311         
00313       std::vector<HBond>             h_bonds_; 
00315 
00316   }; //class HBondProcessor
00317 } //namesspace BALL
00318 
00319 
00320 #endif // BALL_STRUCTURE_HBONDPROCESSOR_H
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines