Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
Plumed AlphaFold
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Martin Kurečka
Plumed AlphaFold
Commits
4bc18f57
There was an error fetching the commit references. Please try again later.
Commit
4bc18f57
authored
7 years ago
by
Giovanni Bussi
Browse files
Options
Downloads
Patches
Plain Diff
doc regex
parent
967a4f9b
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
user-doc/Regex.txt
+35
-10
35 additions, 10 deletions
user-doc/Regex.txt
with
35 additions
and
10 deletions
user-doc/Regex.txt
+
35
−
10
View file @
4bc18f57
...
@@ -2,8 +2,9 @@
...
@@ -2,8 +2,9 @@
\page Regex Regular Expressions
\page Regex Regular Expressions
When you use a collective variable that has many calculated components and you want to
When you use need to pass many arguments to a PLUMED action, being them
refer to them as arguments you can use regular expressions.
components of a few collective variables or also multiple collective variables,
you might find it convenient to use [regular expressions](https://en.wikipedia.org/wiki/Regular_expression).
Since version 2.1, plumed takes advantage of a configuration scripts that
Since version 2.1, plumed takes advantage of a configuration scripts that
detects libraries installed on your system. If regex library is found,
detects libraries installed on your system. If regex library is found,
...
@@ -13,13 +14,17 @@ or function names.
...
@@ -13,13 +14,17 @@ or function names.
Regular expressions are enclosed in round braces and must not contain spaces (the components
Regular expressions are enclosed in round braces and must not contain spaces (the components
names have no spaces indeed, so why use them?).
names have no spaces indeed, so why use them?).
As an example the
n
command
As an example the command
:
\plumedfile
\plumedfile
d1: DISTANCE ATOMS=1,2 COMPONENTS
d1: DISTANCE ATOMS=1,2 COMPONENTS
PRINT ARG=(d1\.[xy]) STRIDE=100 FILE=colvar FMT=%8.4f
PRINT ARG=(d1\.[xy]) STRIDE=100 FILE=colvar FMT=%8.4f
\endplumedfile
\endplumedfile
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.
will cause both the d1.x and d1.y components of the DISTANCE action to be printed.
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,
Notice that selection does not happen in alphabetic order, nor in the order in which `[xy]` are listed, but rather in the order in which
the two variables have been created by PLUMED.
Also notice that the
`.` character must be escaped as `\.` in order to interpret it as a literal `.`. An unescaped dot is a wildcard which is matched by any character,
So as an example
So as an example
\plumedfile
\plumedfile
d1: DISTANCE ATOMS=1,2 COMPONENTS
d1: DISTANCE ATOMS=1,2 COMPONENTS
...
@@ -32,27 +37,47 @@ PRINT ARG=(d1.[xy]) STRIDE=100 FILE=colvar FMT=%8.4f
...
@@ -32,27 +37,47 @@ PRINT ARG=(d1.[xy]) STRIDE=100 FILE=colvar FMT=%8.4f
PRINT ARG=(d1\.[xy]) STRIDE=100 FILE=colvar FMT=%8.4f
PRINT ARG=(d1\.[xy]) STRIDE=100 FILE=colvar FMT=%8.4f
\endplumedfile
\endplumedfile
You can
includ
e more than one regular expression by using comma separated regular expressions
You can
concatenat
e more than one regular expression by using comma separated regular expressions
.
The resulting matches will be concatenated:
\plumedfile
\plumedfile
t1: TORSION ATOMS=5,7,9,15
t1: TORSION ATOMS=5,7,9,15
t2: TORSION ATOMS=7,9,15,17
t2: TORSION ATOMS=7,9,15,17
d1: DISTANCE ATOMS=7,17 COMPONENTS
d1: DISTANCE ATOMS=7,17 COMPONENTS
# The first expression matches d1.x and d1.y
# The second expression matches t1 and t2
PRINT ARG=(d1\.[xy]),(t[0-9]) STRIDE=100 FILE=colvar FMT=%8.4f
PRINT ARG=(d1\.[xy]),(t[0-9]) STRIDE=100 FILE=colvar FMT=%8.4f
# Thus this is the same as ARG=d1.x,d1.y,t1,t2
\endplumedfile
\endplumedfile
(this selects t1,t2,d1.x and d2.x) Be aware that if you have overlapping selection they will be duplicated so it
Be aware that if you have overlapping selections they will be duplicated.
a better alternative is to use the "or" operator "|".
As an alternative you could use the "or" operator `|`:
\plumedfile
\plumedfile
t1: TORSION ATOMS=5,7,9,15
t1: TORSION ATOMS=5,7,9,15
t2: TORSION ATOMS=7,9,15,17
t2: TORSION ATOMS=7,9,15,17
d1: DISTANCE ATOMS=7,17 COMPONENTS
d1: DISTANCE ATOMS=7,17 COMPONENTS
# Here is a single regular expression
PRINT ARG=(d1\.[xy]|t[0-9]) STRIDE=100 FILE=colvar FMT=%8.4f
PRINT ARG=(d1\.[xy]|t[0-9]) STRIDE=100 FILE=colvar FMT=%8.4f
# Thus this is the same as ARG=t1,t2,d1.x,d1.y
\endplumedfile
\endplumedfile
this selects the same set of arguments as the previous example.
this selects the same set of arguments as the previous example.
\note
Be careful you do not confuse regular expressions, which are triggered by the parethesis `()` and only available when
PLUMED has been compiled with the regex library, with the capability of PLUMED to use `*` as a wildcard in arguments:
\plumedfile
d1: DISTANCE ATOMS=1,2 COMPONENTS
# this is a regular expression that selects all components of d1
# i.e. d1.x d1.y and d1.z
PRINT ARG=(d1\..*) STRIDE=100 FILE=colvar_reg FMT=%8.4f
# this is a wildcard that selects all the components of d1 as well
PRINT ARG=d1.* STRIDE=100 FILE=colvar_wild FMT=%8.4f
\endplumedfile
Regular expressions are way more flexible than wildcards!
You can check the log to see whether or not your regular expression is picking the set of components you desire.
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.
For more information on regular expressions visit http://www.regular-expressions.info/reference.html.
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment