forked from plumed/plumed2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Regex.txt
61 lines (45 loc) · 2.13 KB
/
Regex.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
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
/**
\page Regex Regular Expressions
When you use a collective variable that has many calculated components and you want to
refer to them as arguments you can use regular expressions.
Since version 2.1, plumed takes advantage of a configuration scripts that
detects libraries installed on your system. If regex library is found,
then you will be able to use regular expressions to refer to collective variables
or function names.
Regular expressions are enclosed in round braces and must not contain spaces (the components
names have no spaces indeed, so why use them?).
As an example then command
\verbatim
d1: DISTANCE ATOMS=1,2 COMPONENTS
PRINT ARG=(d1\.[xy]) STRIDE=100 FILE=colvar FMT=%8.4f
\endverbatim
will cause both the d1.x and d1.y components of the DISTANCE action to be printed out in the order that they are created by plumed.
The "." character must be escaped in order to interpret it as a literal ".". An unescaped dot is a wildcard which is matched by any character,
So as an example
\verbatim
d1: DISTANCE ATOMS=1,2 COMPONENTS
dxy: DISTANCE ATOMS=1,3
# this will match d1.x,d1.y,dxy
PRINT ARG=(d1.[xy]) STRIDE=100 FILE=colvar FMT=%8.4f
# while this will match d1.x,d1.y only
PRINT ARG=(d1\.[xy]) STRIDE=100 FILE=colvar FMT=%8.4f
\endverbatim
You can include more than one regular expression by using comma separated regular expressions
\verbatim
t1: TORSION ATOMS=5,7,9,15
t2: TORSION ATOMS=7,9,15,17
d1: DISTANCE ATOMS=7,17 COMPONENTS
PRINT ARG=(d1\.[xy]),(t[0-9]) STRIDE=100 FILE=colvar FMT=%8.4f
\endverbatim
(this selects t1,t2,d1.x and d2.x) Be aware that if you have overlapping selection they will be duplicated so it
a better alternative is to use the "or" operator "|".
\verbatim
t1: TORSION ATOMS=5,7,9,15
t2: TORSION ATOMS=7,9,15,17
d1: DISTANCE ATOMS=7,17 COMPONENTS
PRINT ARG=(d1\.[xy]|t[0-9]) STRIDE=100 FILE=colvar FMT=%8.4f
\endverbatim
this selects the same set of arguments as the previous example.
You can check the log to see whether or not your regular expression is picking the set of components you desire.
For more information on regular expressions visit http://www.regular-expressions.info/reference.html.
*/