MMFF94Parameters.h

Go to the documentation of this file.
00001 // -*- Mode: C++; tab-width: 2; -*-
00002 // vi: set ts=2:
00003 //
00004 // $Id: MMFF94Parameters.h,v 1.1.8.1 2007/03/25 21:25:17 oliver Exp $ 
00005 //
00006 
00007 // Molecular Mechanics: MMFF94 force field class
00008 
00009 #ifndef BALL_MOLMEC_MMFF94_MMFF94PARAMETERS_H
00010 #define BALL_MOLMEC_MMFF94_MMFF94PARAMETERS_H
00011 
00012 #ifndef BALL_COMMON_H
00013 # include <BALL/common.h>
00014 #endif
00015 
00016 #ifndef BALL_DATATYPE_HASHMAP_H
00017 # include <BALL/DATATYPE/hashMap.h>
00018 #endif 
00019 
00020 using namespace std;
00021 
00022 namespace BALL 
00023 {
00024 
00025   class Atom;
00026   class Parameters;
00027 
00028   Position getMMFF94Index(Position atom_type1, Position atom_type2);
00029 
00031   extern Size MMFF94_number_atom_types;
00032   
00033   class MMFF94AtomTypeEquivalences;
00034 
00035 #define MMFF94_INVALID_VALUE 99.0
00036 
00038 
00041   class BALL_EXPORT MMFF94ParametersBase
00042   {
00043     public:
00044 
00045     BALL_CREATE(MMFF94ParametersBase)
00046 
00047     
00048     MMFF94ParametersBase();
00049 
00051     virtual ~MMFF94ParametersBase() {};
00052 
00054     const MMFF94ParametersBase& operator = (const MMFF94ParametersBase&)
00055        {return *this;};
00056 
00058     virtual void clear()
00059       ;
00060 
00062     bool isInitialized() { return is_initialized_;}
00063 
00065     bool readParameters(Parameters& p, const String& section)
00066       throw(Exception::FileNotFound);
00067 
00069     void setEquivalences(const MMFF94AtomTypeEquivalences& equi) { equiv_ = &equi;}
00070     
00071     protected:
00072 
00073     virtual bool setup_(const vector<vector<String> >&) { return true;};
00074 
00075     bool is_initialized_;
00076 
00077     // nr of needed fields in parameter files
00078     Size number_expected_fields_;
00079     const MMFF94AtomTypeEquivalences* equiv_;
00080   };
00081 
00082 
00086   class BALL_EXPORT MMFF94AtomTypeEquivalences:
00087     public MMFF94ParametersBase
00088   {
00089     public: 
00090 
00092     MMFF94AtomTypeEquivalences();
00093 
00095     MMFF94AtomTypeEquivalences(const MMFF94AtomTypeEquivalences& to_copy);
00096 
00098     ~MMFF94AtomTypeEquivalences();
00099     
00101     void clear()
00102       ;
00103 
00108     Index getEquivalence(Position original, Position number) const;
00109 
00110     protected:
00111 
00112     virtual bool setup_(const vector<vector<String> >&);
00113     vector<vector<Position> > equivalences_;
00114     vector<String>   names_;
00115     vector<bool>     exists_;
00116   };
00117   
00118 
00120   struct BALL_EXPORT MMFF94AtomType
00121   {
00123     MMFF94AtomType();
00124 
00126     Position aspec;
00127 
00129     Position crd;
00130 
00132     Position val;
00133 
00135     bool pilp;
00136 
00140     Position mltb;
00141 
00143     bool arom;
00144 
00146     bool lin;
00147 
00149     bool sbmb;
00150 
00152     bool valid;
00153   };
00154 
00155 
00157 
00160   class BALL_EXPORT MMFF94AtomTypes:
00161     public MMFF94ParametersBase
00162   {
00163     public:
00164 
00166     MMFF94AtomTypes();
00167 
00169     MMFF94AtomTypes(const MMFF94AtomTypes& to_copy);
00170 
00172     ~MMFF94AtomTypes() {};
00173 
00175     const vector<MMFF94AtomType>& getAtomTypes() const { return data_;}
00176 
00177     protected:
00178 
00179     virtual bool setup_(const vector<vector<String> >&);
00180     vector<MMFF94AtomType> data_;
00181   };
00182 
00184   
00188   class BALL_EXPORT MMFF94StretchParameters:
00189     public MMFF94ParametersBase
00190   {
00191     public:
00192 
00194     struct BondData
00195     {
00196       BondData();
00197 
00198       double kb_normal;
00199       double r0_normal;
00200       bool  standard_bond_exists;
00201       
00203       double kb_sbmb;
00204       double r0_sbmb;
00205       bool  sbmb_exists;
00206       bool  empirical;
00207     };
00208 
00210     struct EmpiricalBondData
00211     {
00212       double kb;
00213       double r0;
00214     };
00215   
00217     typedef HashMap<Position, BondData> StretchMap;
00218     typedef HashMap<Position, EmpiricalBondData> EmpiricalStretchMap;
00219 
00220     BALL_CREATE(MMFF94StretchParameters)
00221 
00222     
00223     MMFF94StretchParameters();
00224 
00226     virtual ~MMFF94StretchParameters();
00227 
00229     const MMFF94StretchParameters& operator = (const MMFF94StretchParameters& param)
00230       ;
00231 
00233     virtual void clear()
00234       ;
00235 
00237     bool assignParameters(Position type1, Position type2, BondData& data) const;
00238 
00240     bool readEmpiricalParameters(Parameters& p, const String& section);
00241 
00243     const StretchMap& getBondParameters() const { return parameters_;}
00244     
00246     const EmpiricalStretchMap& getEmpiricalParameters() const { return empirical_parameters_;}
00247 
00248     static double radii[];
00249     static double electronegatives[];
00250 
00251     protected:
00252 
00253     virtual bool setup_(const vector<vector<String> >&);
00254 
00256     StretchMap parameters_;
00257     mutable StretchMap buffered_parameters_;
00258     EmpiricalStretchMap empirical_parameters_;
00259   };
00260 
00262 
00266   class BALL_EXPORT MMFF94BendParameters
00267     : public MMFF94ParametersBase
00268   {
00269     public:
00270 
00272     typedef HashMap<Position, pair<double, double> > BendMap;
00273 
00274     BALL_CREATE(MMFF94BendParameters)
00275 
00276     
00277     MMFF94BendParameters();
00278 
00280     virtual ~MMFF94BendParameters();
00281 
00283     const MMFF94BendParameters& operator = (const MMFF94BendParameters& param)
00284       ;
00285 
00287     virtual void clear()
00288       ;
00289 
00291     bool assignParameters(Position bend_type,
00292                        Position atom_type1, Position atom_type2, Position atom_type3, 
00293                        double& ka, double& angle) const;
00294 
00295     protected:
00296 
00297     virtual bool setup_(const vector<vector<String> >&);
00298 
00299     Position getIndex_(Position bend_type, Position atom_type1, Position atom_type2, Position atom_type3) const;
00300 
00302     BendMap parameters_;
00303     mutable BendMap buffered_parameters_;
00304   };
00305 
00306 
00309 
00313   class BALL_EXPORT MMFF94StretchBendParameters
00314     : public MMFF94ParametersBase
00315   {
00316     public:
00317 
00319     typedef HashMap<Position, pair<double, double> > StretchBendMap;
00320 
00321     BALL_CREATE(MMFF94StretchBendParameters)
00322 
00323     
00324     MMFF94StretchBendParameters();
00325 
00327     virtual ~MMFF94StretchBendParameters();
00328 
00330     const MMFF94StretchBendParameters& operator = (const MMFF94StretchBendParameters& param)
00331       ;
00332 
00334     virtual void clear()
00335       ;
00336 
00338     bool assignParameters(Position stretch_bend_type, const Atom& atom1, const Atom& atom2, const Atom& atom3, 
00339                        double& kba_ijk, double& kba_kji) const;
00340 
00342     bool readEmpiricalParameters(Parameters& p, const String& section)
00343       throw(Exception::FileNotFound);
00344     
00346 
00347     protected:
00348 
00349     virtual bool setup_(const vector<vector<String> >&);
00350 
00351     Position getIndex_(Position stretch_bend_type,
00352                        Position atom_type1, Position atom_type2, Position atom_type3) const; 
00353 
00354     Position getIndexByRow_(Position r1, Position r2, Position r3) const;
00355 
00357     StretchBendMap parameters_;
00358     mutable StretchBendMap buffered_parameters_;
00359     StretchBendMap parameters_by_row_;
00360   };
00361 
00364   
00368   class BALL_EXPORT MMFF94TorsionParameters
00369     : public MMFF94ParametersBase
00370   {
00371     public:
00372 
00374     typedef HashMap<String, vector<double> > TorsionsMap;
00375 
00376     BALL_CREATE(MMFF94TorsionParameters)
00377 
00378     
00379     MMFF94TorsionParameters();
00380 
00382     virtual ~MMFF94TorsionParameters();
00383 
00385     const MMFF94TorsionParameters& operator = (const MMFF94TorsionParameters& param)
00386       ;
00387 
00389     virtual void clear()
00390       ;
00391 
00393     bool assignParameters(Position type_index,
00394                        Index at1, Index at2, Index at3, Index at4,
00395                        double& v1, double& v2, double& v3) const;
00396 
00397     protected:
00398 
00399     virtual bool setup_(const vector<vector<String> >&);
00400 
00401     String getIndex_(Position type, Position atom_type1, Position atom_type2, Position atom_type3, Position atom_type4) const;
00402 
00404     TorsionsMap parameters_;
00405     mutable TorsionsMap buffered_parameters_;
00406     static Position ic_[5];
00407     static Position lc_[5];
00408   };
00409 
00412 
00416   class BALL_EXPORT MMFF94PlaneParameters
00417     : public MMFF94ParametersBase
00418   {
00419     public:
00420 
00422     typedef HashMap<String, double> PlaneMap;
00423 
00424     BALL_CREATE(MMFF94PlaneParameters)
00425 
00426     
00427     MMFF94PlaneParameters();
00428 
00430     virtual ~MMFF94PlaneParameters();
00431 
00433     const MMFF94PlaneParameters& operator = (const MMFF94PlaneParameters& param)
00434       ;
00435 
00437     virtual void clear()
00438       ;
00439 
00441     bool assignParameters(Index at1, Index at2, Index at3, Index at4, double& v) const;
00442 
00443     protected:
00444 
00445     virtual bool setup_(const vector<vector<String> >&);
00446 
00447     String getIndex_(Position atom_type1, Position atom_type2, Position atom_type3, Position atom_type4) const;
00448 
00450     PlaneMap parameters_;
00451     mutable PlaneMap buffered_parameters_;
00452   };
00453 
00456 
00460   class BALL_EXPORT MMFF94VDWParameters
00461     : public MMFF94ParametersBase
00462   {
00463     public:
00464 
00465     struct VDWEntry
00466     {
00467       double alpha_i;
00468       double ni;
00469       double ai;
00470       double gi;
00471       short  donor_acceptor;
00472       bool   valid;
00473     };
00474 
00475     BALL_CREATE(MMFF94VDWParameters)
00476 
00477     
00478     MMFF94VDWParameters();
00479 
00481     virtual ~MMFF94VDWParameters();
00482 
00484     const MMFF94VDWParameters& operator = (const MMFF94VDWParameters& param)
00485       ;
00486 
00488     virtual void clear()
00489       ;
00490 
00492     double getR(Position atom_type) const;
00493 
00495     const VDWEntry& getParameters(Index at) const;
00496 
00498     bool assignParameters(Position at1, Position at2, double& rij, double& rij_7_, double& eij) const;
00499 
00500     protected:
00501 
00502     virtual bool setup_(const vector<vector<String> >&);
00503 
00505     vector<VDWEntry> parameters_;
00506 
00507     // R star ii for all individual atom types
00508     mutable vector<double> rs_;
00509 
00510     // R star ij for pairs of atom types
00511     mutable vector<double> rij_;
00512     // R star ij ^ 7 for pairs of atom types
00513     mutable vector<double> rij_7_;
00514     // R star ij and for pairs of atom types
00515     mutable vector<double> eij_;
00516     // bools if indivual value was already calculated
00517     mutable vector<bool>   calculated_;
00518   };
00519 
00520 
00523 
00527   class BALL_EXPORT MMFF94ESParameters
00528     : public MMFF94ParametersBase
00529   {
00530     public:
00531 
00532     BALL_CREATE(MMFF94ESParameters)
00533 
00534     
00535     MMFF94ESParameters();
00536 
00538     virtual ~MMFF94ESParameters();
00539 
00541     const MMFF94ESParameters& operator = (const MMFF94ESParameters& param)
00542       ;
00543 
00545     virtual void clear()
00546       ;
00547 
00552     double getPartialCharge(Position at1, Position at2, Position bt) const;
00553     
00555     bool readEmpiricalParameters(Parameters& p, const String& section)
00556       throw(Exception::FileNotFound);
00557 
00559     double getPhi(Index atom_type) const;
00560 
00562     double getPBCI(Index atom_type) const;
00563 
00564     protected:
00565 
00566     virtual bool setup_(const vector<vector<String> >&);
00567     Position getIndex_(Position at1, Position at2, Position bt) const;
00568 
00570     vector<double> parameters_, phis_, pbcis_;
00571   };
00572 
00573 
00574 } // namespace BALL
00575 
00576 #endif // BALL_MOLMEC_MMFF94_MMFF94PARAMETERS_H