Line data Source code
1 : /* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 : Copyright (c) 2012-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 "core/ActionRegister.h" 23 : #include "core/SetupMolInfo.h" 24 : 25 : namespace PLMD { 26 : namespace setup { 27 : 28 : //+PLUMEDOC TOPOLOGY MOLINFO 29 : /* 30 : This command is used to provide information on the molecules that are present in your system. 31 : 32 : The information on the molecules in your system can either be provided in the form of a pdb file 33 : or as a set of lists of atoms that describe the various chains in your system. If a pdb file 34 : is used plumed the MOLINFO command will endeavor to recognize the various chains and residues that 35 : make up the molecules in your system using the chainIDs and resnumbers from the pdb file. You can 36 : then use this information in later commands to specify atom lists in terms residues. For example 37 : using this command you can find the backbone atoms in your structure automatically. 38 : 39 : \warning 40 : Please be aware that the PDB parser in plumed is far from perfect. You should thus check the log file 41 : and examine what plumed is actually doing whenever you use the MOLINFO action. 42 : Also make sure that the atoms are listed in the pdb with the correct order. 43 : If you are using gromacs, the safest way is to use reference pdb file 44 : generated with `gmx editconf -f topol.tpr -o reference.pdb`. 45 : 46 : More information of the PDB parser implemented in PLUMED can be found \ref pdbreader "at this page". 47 : 48 : Providing `MOLTYPE=protein`, `MOLTYPE=rna`, or `MOLTYPE=dna` will instruct plumed to look 49 : for known residues from these three types of molecule. In other words, this is available for 50 : historical reasons and to allow future extensions where alternative lists will be provided. 51 : As of now, you can just ignore this keyword. 52 : 53 : Using \ref MOLINFO extends the possibility of atoms selection using the @ special 54 : symbol. The following shortcuts are available that do not refer to one specific residue: 55 : 56 : \verbatim 57 : @nucleic : all atoms that are part of a DNA or RNA molecule 58 : @protein : all atoms that are part of a protein 59 : @water : all water molecules 60 : @ions : all the ions 61 : @hydrogens : all hydrogen atoms (those for which the first non-number in the name is a H) 62 : @nonhydrogens : all non hydrogen atoms (those for which the first non-number in the name is not a H) 63 : \endverbatim 64 : 65 : \warning 66 : Be careful since these choices are based on common names used in PDB files. Always check if 67 : the selected atoms are correct. 68 : 69 : In addition, atoms from a specific residue can be selected with a symbol in this form: 70 : 71 : \verbatim 72 : @"definition"-chain_residuenum 73 : @"definition"-chainresiduenum 74 : @"definition"-residuenum 75 : \endverbatim 76 : 77 : So for example 78 : 79 : \verbatim 80 : @psi-1 will select the atoms defining the psi torsion of residue 1 81 : @psi-C1 or @psi-C_1 will define the same torsion for residue 1 of chain C. 82 : @psi-3_1 will define the same torsion for residue 1 of chain 3. 83 : \endverbatim 84 : 85 : Using the underscore to separate chain and residue is available as of PLUMED 2.5 and allows selecting chains 86 : with a numeric id. 87 : 88 : In the following are listed the current available definitions: 89 : 90 : For protein residues, the following groups are available: 91 : 92 : \verbatim 93 : @phi-# 94 : @psi-# 95 : @omega-# 96 : @chi1-# 97 : @chi2-# 98 : @chi3-# 99 : @chi4-# 100 : @chi5-# 101 : \endverbatim 102 : 103 : that select the appropriate atoms that define each dihedral angle for residue #. 104 : 105 : For DNA or RNA residues, the following groups are available: 106 : 107 : \verbatim 108 : # quadruplets for backbone dihedral angles 109 : @alpha-# 110 : @beta-# 111 : @gamma-# 112 : @delta-# 113 : @epsilon-# 114 : @zeta-# 115 : 116 : # quadruplets for sugar dihedral angles 117 : @v0-# 118 : @v1-# 119 : @v2-# 120 : @v3-# 121 : @v4-# 122 : 123 : # quadruplet corresponding to the chi torsional angle 124 : @chi-# 125 : 126 : # backbone, sugar, and base heavy atoms 127 : @back-# 128 : @sugar-# 129 : @base-# 130 : 131 : # ordered triplets of atoms on the 6-membered ring of nucleobases 132 : # namely: 133 : # C2/C4/C6 for pyrimidines 134 : # C2/C6/C4 for purines 135 : @lcs-# 136 : \endverbatim 137 : 138 : Notice that `zeta` and `epsilon` groups should not be used on 3' end residue and `alpha` and `beta` 139 : should not be used on 5' end residue. 140 : 141 : Furthermore it is also possible to pick single atoms using the syntax 142 : `atom-chain_residuenum`, `@atom-chainresiduenum` or `@atom-residuenum`. 143 : As of PLUMED 2.5, this also works when the residue is not a protein/rna/dna residue. 144 : For instance, `@OW-100` will select oxygen of water molecule with residue number 100. 145 : 146 : Finally, notice that other shortcuts are available even when not using the \ref MOLINFO command (see \ref atomSpecs). 147 : 148 : \warning If a residue-chain is repeated twice in the reference pdb only the first entry will be selected. 149 : 150 : \bug At the moment the HA1 atoms in a GLY residues are treated as if they are the CB atoms. This may or 151 : may not be true - GLY is problematic for secondary structure residues as it is achiral. 152 : 153 : \bug If you use WHOLEMOLECULES RESIDUES=1-10 for a 18 amino acid protein 154 : ( 18 amino acids + 2 terminal groups = 20 residues ) the code will fail as it will not be able to 155 : interpret terminal residue 1. 156 : 157 : \par Advanced atom selection with mdtraj or MDAnalysis 158 : 159 : Since PLUMED 2.6 it is possible to use the expressive selection syntax of [mdtraj](http://mdtraj.org/latest/atom_selection.html) and/or [MDAnalysis](https://www.mdanalysis.org/docs/documentation_pages/selections.html): 160 : 161 : \plumedfile 162 : MOLINFO STRUCTURE=helix.pdb PYTHON_BIN=python 163 : g1: GROUP ATOMS=@mda:backbone 164 : g2: GROUP ATOMS={@mda:{resnum 1 or resid 3:5}} 165 : g3: GROUP ATOMS={@mda:{resid 3:5} @mda:{resnum 1}} 166 : g4: GROUP ATOMS={@mdt:{protein and (backbone or resname ALA)}} 167 : g5: GROUP ATOMS={@mdt:{mass 5.5 to 20}} # masses guessed by mdtraj based on atom type! 168 : g6: GROUP ATOMS={@mda:{resid 3:5} @mda:{resnum 1} 1-10} 169 : \endplumedfile 170 : 171 : Here `@mda:` indicates that `MDAnalysis` language is used, whereas `@mdt:` indicates that `mdtraj` language is used. Notice that these languages typically select atoms in order. If you want to specify a different order, you can chain definitions as in `g3` above (compare with `g2`). Selections can be also chained with standard PLUMED selections (see `g6`). 172 : 173 : The double braces are required due to the way PLUMED parses atom lists. In particular: 174 : 175 : - The outer braces are needed to show PLUMED where the `ATOMS=...` option ends. 176 : - The inner braces are needed to show PLUMED where each selector ends. 177 : 178 : MDAnalysis also supports geometric selectors based on atomic coordinates. These selectors **are static** and return lists computed using the coordinates stored in the `MOLINFO` pdb file. 179 : 180 : In order to use this syntax you should check the following points at runtime: 181 : 182 : 1. `plumed --no-mpi config has subprocess` prints `subprocess on` (should be ok on most UNIX systems). 183 : 2. You have a python interpreter with mdtraj and/or MDAnalysis installed. You can check using: 184 : - `python -c "import mdtraj"` 185 : - `python -c "import MDAnalysis"` 186 : 187 : In order to install these packages refer to their documentation. Pip or conda install should be ok, provided you make sure the correct python interpreter is in the execution PATH at runtime. Notice that you will only need the package(s) related to the syntax that you want to use. 188 : 3. In case you installed these modules on a python with a different name (e.g. `python3.6`), the correct check is: 189 : - `python3.6 -c "import mdtraj"` 190 : - `python3.6 -c "import MDAnalysis"` 191 : 192 : If this is the case, you should set the environment variable `export PYTHON_BIN=python3.6` or `export PLUMED_PYTHON_BIN=python3.6` (higher priority). Alternatively, directly provide the interpreter in the PLUMED input file 193 : using `MOLINFO PYTHON_BIN=python3.6` (even higher priority). 194 : 4. The PDB file that you provide to `MOLINFO` should have consecutive atom numbers starting from 1. This is currently enforced since reading atom numbers out of order (as PLUMED does) is not supported by other packages. 195 : 196 : \par Advanced atom selection with VMD (experimental) 197 : 198 : Similarly to the `@mda:` and `@mdt:` selectors above, you can use the two following selectors in order to 199 : access to [VMD](https://www.ks.uiuc.edu/Research/vmd/) syntax for atoms selection: 200 : - `@vmdexec:`: This selector launches an instance of VMD, so `vmd` executable should be in your execution path. 201 : Might be very slow or even crash your simulation. Notice that even if `vmd` executable is used, 202 : the implementation is still python based and so a working python interpreter should be provided. 203 : - `@vmd:`: This selector tries to import the `vmd` python module. Notice that the best way to obtain this module 204 : is not within the standard VMD installer but rather by installing the python 205 : module that can be found at [this link](http://github.com/Eigenstate/vmd-python). 206 : The module is also available on [conda](https://anaconda.org/conda-forge/vmd-python). 207 : You should make sure the module is available in the python interpreter used by MOLINFO 208 : (check using the command `python -c "import vmd"`). 209 : 210 : These two selectors are experimental and might be removed at some point. 211 : 212 : \par Examples 213 : 214 : In the following example the MOLINFO command is used to provide the information on which atoms 215 : are in the backbone of a protein to the ALPHARMSD CV. 216 : 217 : \plumedfile 218 : #SETTINGS MOLFILE=regtest/basic/rt32/helix.pdb 219 : MOLINFO STRUCTURE=reference.pdb 220 : ALPHARMSD RESIDUES=all TYPE=DRMSD LESS_THAN={RATIONAL R_0=0.08 NN=8 MM=12} LABEL=a 221 : \endplumedfile 222 : 223 : The following example prints the distance corresponding to the hydrogen bonds 224 : in a GC Watson-Crick pair. 225 : 226 : \plumedfile 227 : #SETTINGS MOLFILE=regtest/basic/rt-ermsd/ref.pdb 228 : MOLINFO STRUCTURE=reference.pdb MOLTYPE=dna 229 : hb1: DISTANCE ATOMS=@N2-2,@O2-15 230 : hb2: DISTANCE ATOMS=@N1-2,@N3-15 231 : hb3: DISTANCE ATOMS=@O6-2,@N4-15 232 : PRINT ARG=hb1,hb2,hb3 233 : \endplumedfile 234 : 235 : This example use MOLINFO to calculate torsion angles 236 : 237 : \plumedfile 238 : #SETTINGS MOLFILE=regtest/basic/rt32/helix.pdb 239 : MOLINFO MOLTYPE=protein STRUCTURE=myprotein.pdb 240 : t1: TORSION ATOMS=@phi-3 241 : t2: TORSION ATOMS=@psi-4 242 : PRINT ARG=t1,t2 FILE=colvar STRIDE=10 243 : \endplumedfile 244 : 245 : */ 246 : //+ENDPLUMEDOC 247 : 248 : 249 : /* 250 : This action is defined in core/ as it is used by other actions. 251 : Anyway, it is registered here, so that excluding this module from 252 : compilation will exclude it from plumed. 253 : */ 254 : 255 : typedef PLMD::SetupMolInfo MolInfo; 256 : 257 7980 : PLUMED_REGISTER_ACTION(MolInfo,"MOLINFO") 258 : 259 : } 260 5874 : }