Line data Source code
1 : /* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 : Copyright (c) 2013-2019 The plumed team
3 : (see the PEOPLE file at the root of the distribution for a list of names)
4 :
5 : See http://www.plumed.org for more information.
6 :
7 : This file is part of plumed, version 2.
8 :
9 : plumed is free software: you can redistribute it and/or modify
10 : it under the terms of the GNU Lesser General Public License as published by
11 : the Free Software Foundation, either version 3 of the License, or
12 : (at your option) any later version.
13 :
14 : plumed is distributed in the hope that it will be useful,
15 : but WITHOUT ANY WARRANTY; without even the implied warranty of
16 : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 : GNU Lesser General Public License for more details.
18 :
19 : You should have received a copy of the GNU Lesser General Public License
20 : along with plumed. If not, see <http://www.gnu.org/licenses/>.
21 : +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
22 : #include "Colvar.h"
23 : #include "core/PlumedMain.h"
24 : #include "ActionRegister.h"
25 : #include "tools/PDB.h"
26 : #include "reference/MultiDomainRMSD.h"
27 : #include "reference/MetricRegister.h"
28 : #include "core/Atoms.h"
29 :
30 :
31 : using namespace std;
32 :
33 : namespace PLMD {
34 : namespace colvar {
35 :
36 : class MultiRMSD : public Colvar {
37 :
38 : PLMD::MultiDomainRMSD* rmsd;
39 : bool squared;
40 : MultiValue myvals;
41 : ReferenceValuePack mypack;
42 :
43 : public:
44 : explicit MultiRMSD(const ActionOptions&);
45 : ~MultiRMSD();
46 : virtual void calculate();
47 : static void registerKeywords(Keywords& keys);
48 : };
49 :
50 :
51 : using namespace std;
52 :
53 : //+PLUMEDOC DCOLVAR MULTI-RMSD
54 : /*
55 : Calculate the RMSD distance moved by a number of separated domains from their positions in a reference structure.
56 :
57 :
58 : When you have large proteins the calculation of the root mean squared deviation between all the atoms in a reference
59 : structure and the instantaneous configuration becomes prohibitively expensive. You may thus instead want to calculate
60 : the RMSD between the atoms in a set of domains of your protein and your reference structure. That is to say:
61 :
62 : \f[
63 : d(X,X_r) = \sqrt{ \sum_{i} w_i\vert X_i - X_i' \vert^2 }
64 : \f]
65 :
66 : where here the sum is over the domains of the protein, \f$X_i\f$ represents the positions of the atoms in domain \f$i\f$
67 : in the instantaneous configuration and \f$X_i'\f$ is the positions of the atoms in domain \f$i\f$ in the reference
68 : configuration. \f$w_i\f$ is an optional weight.
69 :
70 : The distances for each of the domains in the above sum can be calculated using the \ref DRMSD or \ref RMSD measures or
71 : using a combination of these distance. The reference configuration is specified in a pdb file like the one below:
72 :
73 : \verbatim
74 : ATOM 2 O ALA 2 -0.926 -2.447 -0.497 1.00 1.00 DIA O
75 : ATOM 4 HNT ALA 2 0.533 -0.396 1.184 1.00 1.00 DIA H
76 : ATOM 6 HT1 ALA 2 -0.216 -2.590 1.371 1.00 1.00 DIA H
77 : ATOM 7 HT2 ALA 2 -0.309 -1.255 2.315 1.00 1.00 DIA H
78 : ATOM 8 HT3 ALA 2 -1.480 -1.560 1.212 1.00 1.00 DIA H
79 : ATOM 9 CAY ALA 2 -0.096 2.144 -0.669 1.00 1.00 DIA C
80 : ATOM 10 HY1 ALA 2 0.871 2.385 -0.588 1.00 1.00 DIA H
81 : TER
82 : ATOM 12 HY3 ALA 2 -0.520 2.679 -1.400 1.00 1.00 DIA H
83 : ATOM 14 OY ALA 2 -1.139 0.931 -0.973 1.00 1.00 DIA O
84 : ATOM 16 HN ALA 2 1.713 1.021 -0.873 1.00 1.00 DIA H
85 : ATOM 18 HA ALA 2 0.099 -0.774 -2.218 1.00 1.00 DIA H
86 : ATOM 19 CB ALA 2 2.063 -1.223 -1.276 1.00 1.00 DIA C
87 : ATOM 20 HB1 ALA 2 2.670 -0.716 -2.057 1.00 1.00 DIA H
88 : ATOM 21 HB2 ALA 2 2.556 -1.051 -0.295 1.00 1.00 DIA H
89 : ATOM 22 HB3 ALA 2 2.070 -2.314 -1.490 1.00 1.00 DIA H
90 : END
91 : \endverbatim
92 :
93 : with the TER keyword being used to separate the various domains in you protein.
94 :
95 :
96 : \par Examples
97 :
98 : The following tells plumed to calculate the RMSD distance between
99 : the positions of the atoms in the reference file and their instantaneous
100 : position. The Kearseley algorithm for each of the domains.
101 :
102 : \plumedfile
103 : MULTI-RMSD REFERENCE=file.pdb TYPE=MULTI-OPTIMAL
104 : \endplumedfile
105 :
106 : The following tells plumed to calculate the RMSD distance btween the positions of
107 : the atoms in the domains of reference the reference structure and their instantaneous
108 : positions. Here distances are calculated using the \ref DRMSD measure.
109 :
110 : \plumedfile
111 : MULTI-RMSD REFERENCE=file.pdb TYPE=MULTI-DRMSD
112 : \endplumedfile
113 :
114 : in this case it is possible to use the following DRMSD options in the pdb file using the REMARK syntax:
115 : \verbatim
116 : NOPBC to calculate distances without PBC
117 : LOWER_CUTOFF=# only pairs of atoms further than LOWER_CUTOFF are considered in the calculation
118 : UPPER_CUTOFF=# only pairs of atoms further than UPPER_CUTOFF are considered in the calculation
119 : \endverbatim
120 : as shown in the following example
121 :
122 : \verbatim
123 : REMARK NOPBC
124 : REMARK LOWER_CUTOFF=0.1
125 : REMARK UPPER_CUTOFF=0.8
126 : ATOM 2 O ALA 2 -0.926 -2.447 -0.497 1.00 1.00 DIA O
127 : ATOM 4 HNT ALA 2 0.533 -0.396 1.184 1.00 1.00 DIA H
128 : ATOM 6 HT1 ALA 2 -0.216 -2.590 1.371 1.00 1.00 DIA H
129 : ATOM 7 HT2 ALA 2 -0.309 -1.255 2.315 1.00 1.00 DIA H
130 : ATOM 8 HT3 ALA 2 -1.480 -1.560 1.212 1.00 1.00 DIA H
131 : ATOM 9 CAY ALA 2 -0.096 2.144 -0.669 1.00 1.00 DIA C
132 : ATOM 10 HY1 ALA 2 0.871 2.385 -0.588 1.00 1.00 DIA H
133 : TER
134 : ATOM 12 HY3 ALA 2 -0.520 2.679 -1.400 1.00 1.00 DIA H
135 : ATOM 14 OY ALA 2 -1.139 0.931 -0.973 1.00 1.00 DIA O
136 : ATOM 16 HN ALA 2 1.713 1.021 -0.873 1.00 1.00 DIA H
137 : ATOM 18 HA ALA 2 0.099 -0.774 -2.218 1.00 1.00 DIA H
138 : ATOM 19 CB ALA 2 2.063 -1.223 -1.276 1.00 1.00 DIA C
139 : ATOM 20 HB1 ALA 2 2.670 -0.716 -2.057 1.00 1.00 DIA H
140 : ATOM 21 HB2 ALA 2 2.556 -1.051 -0.295 1.00 1.00 DIA H
141 : ATOM 22 HB3 ALA 2 2.070 -2.314 -1.490 1.00 1.00 DIA H
142 : END
143 : \endverbatim
144 :
145 :
146 : */
147 : //+ENDPLUMEDOC
148 :
149 6454 : PLUMED_REGISTER_ACTION(MultiRMSD,"MULTI-RMSD")
150 :
151 : //+PLUMEDOC DCOLVAR MULTI_RMSD
152 : /*
153 : An alias to the \ref MULTI-RMSD function.
154 :
155 : \par Examples
156 :
157 : Just replace \ref MULTI-RMSD with \ref MULTI_RMSD
158 :
159 : \plumedfile
160 : MULTI_RMSD REFERENCE=file.pdb TYPE=MULTI-DRMSD
161 : \endplumedfile
162 :
163 : */
164 : //+ENDPLUMEDOC
165 :
166 : class Multi_RMSD :
167 : public MultiRMSD {
168 : };
169 :
170 6453 : PLUMED_REGISTER_ACTION(MultiRMSD,"MULTI_RMSD")
171 :
172 :
173 5 : void MultiRMSD::registerKeywords(Keywords& keys) {
174 5 : Colvar::registerKeywords(keys);
175 20 : keys.add("compulsory","REFERENCE","a file in pdb format containing the reference structure and the atoms involved in the CV.");
176 25 : keys.add("compulsory","TYPE","MULTI-SIMPLE","the manner in which RMSD alignment is performed. Should be MULTI-OPTIMAL, MULTI-OPTIMAL-FAST, MULTI-SIMPLE or MULTI-DRMSD.");
177 15 : keys.addFlag("SQUARED",false," This should be setted if you want MSD instead of RMSD ");
178 10 : keys.remove("NOPBC");
179 5 : }
180 :
181 3 : MultiRMSD::MultiRMSD(const ActionOptions&ao):
182 3 : PLUMED_COLVAR_INIT(ao),squared(false),myvals(1,0), mypack(0,0,myvals)
183 : {
184 : string reference;
185 6 : parse("REFERENCE",reference);
186 : string type;
187 3 : type.assign("SIMPLE");
188 6 : parse("TYPE",type);
189 6 : parseFlag("SQUARED",squared);
190 :
191 3 : checkRead();
192 :
193 :
194 3 : addValueWithDerivatives(); setNotPeriodic();
195 6 : PDB pdb;
196 :
197 : // read everything in ang and transform to nm if we are not in natural units
198 6 : if( !pdb.read(reference,plumed.getAtoms().usingNaturalUnits(),0.1/atoms.getUnits().getLength()) )
199 0 : error("missing input file " + reference );
200 :
201 3 : rmsd = metricRegister().create<MultiDomainRMSD>(type,pdb);
202 :
203 : std::vector<AtomNumber> atoms;
204 3 : rmsd->getAtomRequests( atoms );
205 3 : requestAtoms( atoms );
206 :
207 6 : myvals.resize( 1, 3*atoms.size()+9 ); mypack.resize( 0, atoms.size() );
208 141 : for(unsigned i=0; i<atoms.size(); ++i) mypack.setAtomIndex( i, i );
209 :
210 6 : log.printf(" reference from file %s\n",reference.c_str());
211 6 : log.printf(" which contains %d atoms\n",getNumberOfAtoms());
212 6 : log.printf(" method for alignment : %s \n",type.c_str() );
213 3 : if(squared)log.printf(" chosen to use SQUARED option for MSD instead of RMSD\n");
214 3 : }
215 :
216 9 : MultiRMSD::~MultiRMSD() {
217 3 : delete rmsd;
218 6 : }
219 :
220 :
221 : // calculator
222 15 : void MultiRMSD::calculate() {
223 30 : double r=rmsd->calculate( getPositions(), getPbc(), mypack, squared );
224 :
225 15 : setValue(r);
226 480 : for(unsigned i=0; i<getNumberOfAtoms(); i++) setAtomsDerivatives( i, mypack.getAtomDerivative(i) );
227 :
228 15 : if( !mypack.virialWasSet() ) setBoxDerivativesNoPbc();
229 10 : else setBoxDerivatives( mypack.getBoxDerivatives() );
230 15 : }
231 :
232 : }
233 4839 : }
234 :
235 :
236 :
|