"user-doc/Installation.md" did not exist on "40a7b1799fa271ce0dd6a81498e9fbaeb2d744e0"
Newer
Older
/**
\page lugano-1 Lugano tutorial: Introduction to PLUMED syntax and analyzing CVs
\section lugano-1-aims Aims
The aim of this tutorial is to introduce you to the PLUMED syntax. We will go through the writing of input files to calculate
and print simple collective variables on a pre-calculated trajectory.
\section lugano-1-lo Learning Outcomes
Once this tutorial is completed, students will be able to:
- Write a simple PLUMED input file and use it with the PLUMED \ref driver to analyze a trajectory.
- Print collective variables such as distances.
(\ref DISTANCE), torsional angles (\ref TORSION), gyration radius (\ref GYRATION), and RMSD (\ref RMSD) using the \ref PRINT action.
- Use \ref MOLINFO shortcuts.
- Define and use virtual atoms, such as \ref CENTER.
- Take care of periodic boundary conditions within PLUMED using \ref WHOLEMOLECULES and be able to verify the result with \ref DUMPATOMS.
- Write their own CVs directly in the input file using the \ref COMBINE action.
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
\section lugano-1-resources Resources
The reference trajectories and other files needed for the exercises proposed in this tutorial
can be downloaded from `github` using the following command:
\verbatim
wget https://github.com/plumed/lugano2019/raw/master/handson_1/handson_1.tgz
\endverbatim
The zip archive contains the following files:
- GB1_native.pdb : A PDB file with the native structure of the GB1 protein.
- traj-whole.xtc: A trajectory in xtc format. To make the exercise easier, GB1 has been made whole already.
- traj-broken.xtc: The same trajectory as it was originally produced by GROMACS. Here GB1 is broken by periodic boundary conditions and should be fixed.
This tutorial has been tested on a pre-release version of PLUMED 2.6. However, it should also work with PLUMED version 2.5.
\section lugano-1-instructions Instructions
PLUMED is a library that can be incorporated into many MD codes by adding a relatively simple and well documented interface.
Once it is incorporated you can use PLUMED to perform a variety of different analyzes on the fly and to bias
the sampling in the molecular dynamics engine. PLUMED can also, however, be used as a standalone code for analyzing trajectories.
If you are using the code in this way you can, once PLUMED is compiled, run the plumed executable by issuing the command:
\verbatim
plumed <instructions>
\endverbatim
Let's start by getting a feel for the range of calculations that we can use PLUMED to perform. Issue the following command now:
\verbatim
plumed --help
\endverbatim
What is output when this command is run is a list of the tasks you can use PLUMED to perform. There are commands that allow you
to patch an MD code, commands that allow you to run molecular dynamics and commands that allow you to build the manual. In this
tutorial we will mostly be using PLUMED to analyze trajectories, however. As such most of the calculations we will perform will be performed
using the driver tool. Let's look at the options we can issue to plumed driver by issuing the following command:
\verbatim
plumed driver --help
\endverbatim
As you can see we can do a number of things with plumed driver. For all of these options, however, we are going to need to write
a PLUMED input file. The syntax of the PLUMED input file is the same that we will use later to run enhanced sampling simulations,
so all the things that you will learn now will be useful later when you will run PLUMED coupled to an MD code.
In the following we are going to see how to write an input file for PLUMED.
\subsection lugano-1-units PLUMED's internal units
By default the PLUMED inputs and outputs quantities in the following units:
- Energy - kJ/mol
- Length - nanometers
- Time - picoseconds
If you want to change these units you can do this using the \ref UNITS keyword.
\section lugano-1-structure The syntax of the PLUMED input file
The main goal of PLUMED is to compute collective variables, which are complex descriptors than can be used
to analyze a conformational change or a chemical reaction. This can be done either on-the-fly during
molecular dynamics or a posteriori, using PLUMED as a post-processing tool.
In both cases one, should create an input file with a specific PLUMED syntax. A sample input file is below:
\plumedfile
# Compute distance between atoms 1 and 10.
# Atoms are ordered as in the trajectory files and their numbering starts from 1.
# The distance is called "d" for future reference.
d: DISTANCE ATOMS=1,10
# Create a virtual atom in the center between atoms 20 and 30.
# The virtual atom only exists within PLUMED and is called "center" for future reference.
center: CENTER ATOMS=20,30
# Compute the torsional angle between atoms 1, 10, 20, and center.
# Notice that virtual atoms can be used as real atoms here.
# The angle is called "phi" for future reference.
phi1: TORSION ATOMS=1,10,20,center
# the same CV defined before can be split into multiple line
TORSION ...
LABEL=phi2
ATOMS=1,10,20,center
...
# Print d every 10 step on a file named "COLVAR1".
PRINT ARG=d STRIDE=10 FILE=COLVAR1
# Print phi1 and phi2 on another file names "COLVAR2" every 100 steps.
PRINT ARG=phi1,phi2 STRIDE=100 FILE=COLVAR2
\endplumedfile
In the input file above, each line defines a so-called action. An action could either compute a distance,
or the center between two or more atoms, or print some value on a file. Each action supports a number of keywords,
whose value is specified. Action names are highlighted in green and, clicking on them, you can go to the
corresponding page in the manual that contains a detailed description for each keyword.
Actions that support the keyword `STRIDE` are those that determine how frequently things are to be done.
Notice that the default value for `STRIDE` is always 1. In the example above, omitting `STRIDE` keywords
the corresponding COLVAR files would have been written for every frame of the analyzed trajectory.
All the other actions in the example above do not
support the `STRIDE` keyword and are only calculated when requested. That is, `d` will be computed
every 10 frames, and `phi1` and `phi2` every 100 frames.
In short, you can think that for every snapshot in the trajectory that you are analyzing PLUMED
is going to execute all the listed actions, though some of them are optimized out when `STRIDE` is different from 1.
Variables should be given a name (in the example above, `d`, `phi1`, and `phi2`), which is
then used to refer to these variables.
Lists of atoms should be provided as
comma separated numbers, with no space. Virtual atoms can be created and assigned a name for later use.
You can find more information on the PLUMED syntax
at \ref Syntax page of the manual. The complete documentation for all the supported
collective variables can be found at the \ref colvarintro page.
\section lugano-1-ex Exercises
\subsection lugano-1-ex-1 Exercise 1: Computing and printing simple collective variables
In this exercise, we will make practice with computing and printing collective variables.
To analyze the trajectories provided here, you should:
- Create a PLUMED input file with a text editor (let us call it `plumed.dat`) similar to the one above.
- Run the command `plumed driver` command (see below)
Notice that you can also visualize trajectories with VMD directly.
For example, the trajectory `traj-whole.xtc` can be visualized with
the command `vmd GB1_native.pdb traj-whole.xtc`.
Let's prepare a PLUMED input file that calculates
- The gyration radius of all CA protein atoms (\ref GYRATION). Look in the `GB1_native.pdb` file
to retrieve the list of indexes of the CA atoms.
- The total number of contacts (\ref COORDINATION) between all protein CA atoms.
For \ref COORDINATION, set reference distance `R_0` to 8.0 A (be careful with units!!).
Here you can find a sample `plumed.dat` file that you can use as a template.
Whenever you see an highlighted \highlight{FILL} string, this is a string that you should replace.
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
\plumedfile
# Compute gyration radius on CA atoms:
r: GYRATION ATOMS=__FILL__
# Compute number of contacts between CA atoms
co: COORDINATION GROUPA=__FILL__ R_0=__FILL__
# Print the collective variables on COLVAR file every step
PRINT ARG=r,co FILE=COLVAR STRIDE=__FILL__
\endplumedfile
Once your `plumed.dat` file is complete, you can use it with the following command
\verbatim
> plumed driver --plumed plumed.dat --mf_xtc traj-broken.xtc
\endverbatim
Scroll in your terminal to read the PLUMED log. As you can see,
PLUMED gives a lot of feedback about the input that he is reading. There's the
place where you can check if PLUMED understood correctly your input.
The command above will create a `COLVAR` file like this one:
\verbatim
#! FIELDS time r co
0.000000 2.458704 165.184127
1.000000 2.341932 164.546604
2.000000 2.404708 162.606975
3.000000 2.454297 143.850122
4.000000 2.569342 147.110408
5.000000 2.304027 163.608703
\endverbatim
Notice that the first line informs you about the content of each column.
__In case you obtain different numbers, check your input, you might have made some mistake!__
This file can then be visualized using `gnuplot`
\verbatim
gnuplot> p "COLVAR" u 1:2, "" u 1:3
\endverbatim
Now, look at what happens if you run the exercise twice. The second time, PLUMED
will *back up* the previously produced file so as not to overwrite it.
You can also *concatenate* your files by using the action \ref RESTART at the beginning
of your input file.
Finally, let's try to use the same input file with `traj-whole.xtc` and examine the results.
Did you find the same results as with the previous trajectory? Why?
\subsection lugano-1-ex-2 Exercise 2: MOLINFO shortcuts
PLUMED provides some shortcuts to select atoms with specific properties.
To use this feature, you should specify the \ref MOLINFO action along with a reference
pdb file.
Let's try to use this functionality to calculate the backbone dihedral angle phi of residue 2
of GB1. This CV is defined by the action \ref TORSION and a set of 4 atoms. For residue `i`,
the dihedral phi is defined by these atoms: C(i-1),N(i),CA(i),C(i).
After consulting the manual and inspecting GB1_native.pdb, let's define the dihedral angle
in question in two different ways: using the \ref MOLINFO shortcut to define psi of residue 2
and with an explicit list of 4 atoms.
\plumedfile
MOLINFO STRUCTURE=__FILL__
t1: TORSION ATOMS=__FILL__
t2: TORSION ATOMS=__FILL__
PRINT ARG=__FILL__ FILE=COLVAR STRIDE=10
\endplumedfile
After completing the PLUMED input file above, let's use it to analyze the trajectory `traj-whole.xtc` that you downloaded at the start of this exercise. Now, let's plot the trajectory of the two CVs above.
If you executed this exercise correctly, these two trajectories should be identical.
\subsection lugano-1-ex-3 Exercise 3: Virtual atoms
Sometimes, when calculating a CV, you may not want to use the positions of a number of atoms directly.
Instead you may want to define a virtual atom whose position is generated based on the positions
of a collection of other atoms. For example you might want to use the center of mass (\ref COM) or
the geometric center (\ref CENTER) of a group of atoms.
In this exercise, you will learn how to specify virtual atoms and later use them to define a CV.
Let's start by having a look at the PLUMED input file below.
# geometric center of mass of first residue
first: CENTER ATOMS=1,2,3,4,5,6,7,8
# geometric center of last residue
last: CENTER ATOMS=427-436
d1: DISTANCE ATOMS=first,last
d2: DISTANCE ATOMS=first,last NOPBC
PRINT ARG=d1,d2 STRIDE=1 FILE=COLVAR
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
Make a PLUMED input containing the above input and execute it on the trajectory `traj-broken.xtc` by making use of the following command:
\verbatim
plumed driver --mf_xtc traj-broken.xtc --plumed plumed.dat
\endverbatim
Before we turn to analyzing what is output from this calculation there are a few things to note about this input file. Firstly, I should describe what this file
instructs PLUMED to do. It tells PLUMED to:
1. calculate the position of the Virtual Atom 'first' as the \ref CENTER of atoms from 1 to 8;
2. calculate the position of the Virtual Atom 'last' as the \ref CENTER of atoms from 427 to 436;
3. calculate the distance between the two atoms 'first' and 'last' and saves it in 'd1';
4. calculate the distance (ignoring periodic boundary conditions) between the two atoms 'first' and 'last' and saves it in 'd2';
5. print the content of 'd1' and 'd2' in the file COLVAR for every frame of the trajectory
Notice that in the input above we have used two different ways of writing the atoms used in the \ref CENTER calculation:
1. ATOMS=1,2,3,4,5,6,7,8 is the explicit list of the atoms we need
2. ATOMS=427-436 is the range of atoms needed
Notice also that ranges of atoms can be defined with a stride which can also be negative as shown by the commands below, which are both equivalent:
3. ATOMS=from,to:by (i.e.: 427-436:2)
4. ATOMS=to,from:-by (i.e.: 436-427:-2)
Let's now analyze the output of the calculation by plotting the time series of the two CVs.
Are they identical? What do you think is happening in those frames in which the two CVs are different?
You can repeat the same analysis on `traj-whole.xtc` and compare with the previous trajectory.
Are the results identical?
\subsection lugano-1-ex-4 Exercise 4: Taking care of periodic boundary conditions
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
As you should have noticed, in this tutorial we are working with two different trajectories of
the GB1 protein:
- traj-broken.xtc: the original GROMACS trajectory in which GB1 is broken by periodic boundary conditions
- traj-whole.xtc: the trajectory processed by the `gmx trjconv` utility to fix PBCs discontinuities
In many PLUMED CVs, PBCs are automatically taken into account unless a special option (\ref NOPBC) is used.
In this way, the user can work directly with the raw trajectory `traj-broken.xtc`.
Alternatively, PLUMED can reconstruct internally the coordinates of the system and thus fix discontinuities due to PBCs.
In order to do so, the \ref WHOLEMOLECULES action should be used.
In this exercise, we will learn how to use the \ref WHOLEMOLECULES action.
Let's ask PLUMED to internally make the structure of GB1 whole and print the new atoms positions
on a new file, called `dump.gro`, every 10 steps.
\plumedfile
# let's use the range syntax to specify all GB1 atoms
WHOLEMOLECULES ENTITY0=__FILL__
DUMPATOMS FILE=dump.gro STRIDE=__FILL__
\endplumedfile
Once your `plumed.dat` file is complete, you can use it with the following command
\verbatim
> plumed driver --plumed plumed.dat --mf_xtc traj-broken.xtc
\endverbatim
and look at the output file with vmd. Have PBCs been fixed?
At this point, we can repeat \ref lugano-1-ex-3 after adding the \ref WHOLEMOLECULES action
at the beginning of the PLUMED input file:
\plumedfile
# make protein whole
WHOLEMOLECULES ENTITY0=__FILL__
# geometric center of mass of first residue
first: CENTER ATOMS=1,2,3,4,5,6,7,8
# geometric center of last residue
last: CENTER ATOMS=427-436
d1: DISTANCE ATOMS=first,last
d2: DISTANCE ATOMS=first,last NOPBC
PRINT ARG=d1,d2 STRIDE=1 FILE=COLVAR
\endplumedfile
We can now visualize the timeline of the two CVs and compare it with the results of
\ref lugano-1-ex-3. Which CVs are identical and which are not? Why?
\subsection lugano-1-ex-5 Exercise 5: Using CVs that measure the distance from a reference conformation
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
In many cases, it is useful to define a CV that quantifies the distance of the system from a reference conformation. In PLUMED, this can be achieved using a variety of different CVs.
Please, have a look <a href="../../user-doc/html/dists.html"> here </a>
for more info.
In this exercise, we will learn how to use the \ref RMSD and \ref DRMSD CVs.
In order to do so, we need to edit a reference pdb file and identify:
- for \ref RMSD, the atoms that you want to use for alignment and RMSD calculation
- for \ref DRMSD, the atoms that you want to use for the DRMSD calculation
Please refer to the manual to understand how to specify the atoms needed to calculate
the CA-RMSD and CA-DRMSD with respect to the native GB1 structure.
After editing the reference pdb file, please complete the following input file:
\plumedfile
# RMSD on CA atoms
rmsd: RMSD REFERENCE=__FILL__
# DRMSD on CA atoms
drmsd: DRMSD REFERENCE=__FILL__
# print both CVs to file
PRINT ARG=__FILL__ STRIDE=1 FILE=COLVAR
\endplumedfile
Once your `plumed.dat` file is complete, you can use it with the following command
\verbatim
> plumed driver --plumed plumed.dat --mf_xtc traj-broken.xtc
\endverbatim
and also on the trajectory file in which PBCs have been fixed:
\verbatim
> plumed driver --plumed plumed.dat --mf_xtc traj-whole.xtc
\endverbatim
Can you comment the results obtained and the differences - if any - between the two trajectories?
What is happening to the protein during the course of the simulation? Are the two metrics,
\ref RMSD and \ref DRMSD, equivalent?
\subsection lugano-1-ex-6 Exercise 6: Creating your own CV directly in the PLUMED input file
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
In PLUMED, you can define your own CV directly in the input file by writing it as a function
of existing CVs using the \ref CUSTOM action. PLUMED will then automatically calculate the derivatives with the respect to the atoms positions.
Let's look at the following example.
\plumedfile
dAB: DISTANCE ATOMS=10,12
dAC: DISTANCE ATOMS=10,15
diff: CUSTOM ARG=dAB,dAC FUNC=y-x PERIODIC=NO
\endplumedfile
In this example, a custom CV is defined as the difference of two distances between pairs of atoms.
Please complete the following input file to calculate two new CVs from those defined in \ref lugano-1-ex-5:
- the average between \ref RMSD and \ref DRMSD, calculated on all the CA atoms of GB1 (easy)
- the minimum value between \ref RMSD and \ref DRMSD (a bit more difficult).
To define this function, you can creatively take inspiration from the path CV `s` (see \ref PATH).
\plumedfile
# RMSD on CA atoms
rmsd: RMSD REFERENCE=__FILL__
# DRMSD on CA atoms
drmsd: DRMSD REFERENCE=__FILL__
# average between RMSD and DRMSD
ave: CUSTOM ARG=rmsd,drmsd FUNC=__FILL__ PERIODIC=NO
# minimum value between RMSD and DRMSD
min: CUSTOM ARG=rmsd,drmsd FUNC=__FILL__ PERIODIC=NO
# print all 4 CVs to file
PRINT ARG=__FILL__ STRIDE=1 FILE=COLVAR
\endplumedfile
Once your `plumed.dat` file is complete, you can use it with the following command
\verbatim
> plumed driver --plumed plumed.dat --mf_xtc traj-broken.xtc
\endverbatim
and then check that the calculation of the new CVs is correct by plotting the resulting `COLVAR` file with `gnuplot`.