| 1 | // -*- Mode: C++; tab-width: 2; -*- |
| 2 | // vi: set ts=2: |
| 3 | // |
| 4 | |
| 5 | // Molecular Mechanics Parameter: class describing the ResidueTorsions section of a parameter file |
| 6 | |
| 7 | #ifndef BALL_MOLMEC_PARAMETER_RESIDUETORSIONS_H |
| 8 | #define BALL_MOLMEC_PARAMETER_RESIDUETORSIONS_H |
| 9 | |
| 10 | #ifndef BALL_FORMAT_PARAMETERSECTION_H |
| 11 | # include <BALL/FORMAT/parameterSection.h> |
| 12 | #endif |
| 13 | |
| 14 | #ifndef BALL_MOLMEC_PARAMETER_ATOMTYPES_H |
| 15 | # include <BALL/MOLMEC/PARAMETER/atomTypes.h> |
| 16 | #endif |
| 17 | |
| 18 | namespace BALL |
| 19 | { |
| 20 | /** Parameter class containing all proper torsions occuring in a residue. |
| 21 | Several force fields (e.g. CHARMM) do not necessarily consider or |
| 22 | parametrize all occurring torsions but explicitly list the torsions |
| 23 | for each residue. This parameter section is used to represent this list. |
| 24 | The class AMBER and CHARMM torsions components check for the presence of |
| 25 | the parameter section [ResidueTorsions] and then decide whether they have |
| 26 | to generate the torsions by itself (creating all torsions and |
| 27 | complaining about missing parameters) or whether they have to read them |
| 28 | from this section. \par |
| 29 | |
| 30 | \ingroup MolmecParameters |
| 31 | */ |
| 32 | class BALL_EXPORT ResidueTorsions |
| 33 | : public ParameterSection |
| 34 | { |
| 35 | public: |
| 36 | |
| 37 | /** @name Type definitions |
| 38 | */ |
| 39 | //@{ |
| 40 | |
| 41 | /** Strcuture containing the names of the residue and the atoms for a torsion. |
| 42 | */ |
| 43 | struct BALL_EXPORT Data |
| 44 | { |
| 45 | String residue_name; |
| 46 | String atom_name_A; |
| 47 | String atom_name_B; |
| 48 | String atom_name_C; |
| 49 | String atom_name_D; |
| 50 | |
| 51 | Data(const String& name, const String& A, const String& B, const String& C, const String& D) |
| 52 | : residue_name(name), |
| 53 | atom_name_A(A), |
| 54 | atom_name_B(B), |
| 55 | atom_name_C(C), |
| 56 | atom_name_D(D) |
| 57 | { |
| 58 | } |
| 59 | |
| 60 | Data() |
| 61 | : residue_name(""), |
| 62 | atom_name_A(""), |
| 63 | atom_name_B(""), |
| 64 | atom_name_C(""), |
| 65 | atom_name_D("") |
| 66 | { |
| 67 | } |
| 68 | |
| 69 | bool operator == (const Data& data) const; |
| 70 | bool operator != (const Data& data) const; |
| 71 | }; |
| 72 | |
| 73 | //@} |
| 74 | /** @name Constructors and Destructors |
| 75 | */ |
| 76 | //@{ |
| 77 | |
| 78 | /** Default constructor. |
| 79 | */ |
| 80 | ResidueTorsions(); |
| 81 | |
| 82 | /** Destructor. |
| 83 | */ |
| 84 | virtual ~ResidueTorsions() ; |
| 85 | |
| 86 | /** Clear method. |
| 87 | */ |
| 88 | virtual void clear() ; |
| 89 | |
| 90 | //@} |
| 91 | /** @name Accessors |
| 92 | */ |
| 93 | //@{ |
| 94 | |
| 95 | /** Reads a parameter section from an INI file. |
| 96 | This method reads the section given in section_name from ini_file, |
| 97 | interprets (if given) a format line, reads the data from this section according to |
| 98 | the format, and builds some datastructures for fast and easy acces this data. |
| 99 | */ |
| 100 | virtual bool extractSection(ForceFieldParameters& parameters, const String& section_name); |
| 101 | |
| 102 | /// |
| 103 | virtual bool extractSection(Parameters& parameters, const String& section_name); |
| 104 | |
| 105 | /** Return the number of torsions for this residue. |
| 106 | */ |
| 107 | Size getNumberOfResidueTorsions(const String& residue_name) const; |
| 108 | |
| 109 | /** Assign the <i> i </i>th torsion for a residue. |
| 110 | @param name the residue name (including modifiers like -S or -N); |
| 111 | @param i the index. 0 $<$ <tt>i</tt> $<$ \link getNumberOfResidueTorsions getNumberOfResidueTorsions \endlink |
| 112 | @param ResidueTorsion the torsion to be assigned to |
| 113 | @return bool - <b>true</b> if the torsion was found, <b>false</b> otherwise |
| 114 | */ |
| 115 | bool assignTorsion(const String& name, Position i, Data& torsion) const; |
| 116 | |
| 117 | /** Return true if the torsion has to be considered for the residue. |
| 118 | */ |
| 119 | bool hasTorsion |
| 120 | (const String& residue, const String& atom_A, const String& atom_B, |
| 121 | const String& atom_C, const String& atom_D) const; |
| 122 | |
| 123 | //@} |
| 124 | |
| 125 | protected: |
| 126 | |
| 127 | /*_ Contains arrays of ResidueTorsions. |
| 128 | All torsions for a given residue name are collected in |
| 129 | a vector and accessed via the residue name through a StringHashMap. |
| 130 | */ |
| 131 | StringHashMap<vector<Data> > torsions_; |
| 132 | |
| 133 | /*_ Hash set of all torsion identifiers. |
| 134 | This hash set contains all entries in the form of strings. |
| 135 | It is used by \Ref{hasTorsion}. |
| 136 | */ |
| 137 | HashSet<String> all_torsions_; |
| 138 | }; |
| 139 | } // namespace BALL |
| 140 | |
| 141 | #endif // BALL_MOLMEC_PARAMETER_RESIDUETORSIONS_H |