LCOV - code coverage report
Current view: top level - multicolvar - Torsions.cpp (source / functions) Hit Total Coverage
Test: plumed test coverage Lines: 16 16 100.0 %
Date: 2025-12-04 11:19:34 Functions: 2 3 66.7 %

          Line data    Source code
       1             : /* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
       2             :    Copyright (c) 2014-2020 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/ActionShortcut.h"
      23             : #include "core/ActionRegister.h"
      24             : #include "MultiColvarShortcuts.h"
      25             : 
      26             : //+PLUMEDOC MCOLVAR TORSIONS
      27             : /*
      28             : Calculate whether or not a set of torsional angles are within a particular range.
      29             : 
      30             : __This shortcut action allows you to calculate function of a distribution of torsions and reproduces the syntax in older PLUMED versions.
      31             : If you look at the example inputs below you can
      32             : see how the new syntax operates. We would strongly encourage you to use the newer syntax as it offers greater flexibility.__
      33             : 
      34             : The following provides an example of the input for the TORSIONS command
      35             : 
      36             : ```plumed
      37             : ab: TORSIONS ...
      38             :   ATOMS1=168,170,172,188
      39             :   ATOMS2=170,172,188,190
      40             :   ATOMS3=188,190,192,230
      41             :   BETWEEN={GAUSSIAN LOWER=0 UPPER=pi SMEAR=0.1}
      42             : ...
      43             : PRINT ARG=ab.* FILE=colvar STRIDE=10
      44             : ```
      45             : 
      46             : The input above calculates how many of torsion angles for the three groups of atoms that have been specified are between 0 and $\pi$.
      47             : 
      48             : Writing out the atoms involved in all the torsion angles in this way can be rather tedious. Thankfully if you are working with protein you
      49             : can avoid this by using the [MOLINFO](MOLINFO.md) command.  PLUMED uses the pdb file that you provide to this command to learn
      50             : about the topology of the protein molecule.  This means that you can specify torsion angles using the following syntax:
      51             : 
      52             : ```plumed
      53             : #SETTINGS MOLFILE=regtest/basic/rt32/helix.pdb
      54             : MOLINFO MOLTYPE=protein STRUCTURE=regtest/basic/rt32/helix.pdb
      55             : TORSIONS ...
      56             : ATOMS1=@phi-3
      57             : ATOMS2=@psi-3
      58             : ATOMS3=@phi-4
      59             : BETWEEN={GAUSSIAN LOWER=0 UPPER=pi SMEAR=0.1}
      60             : LABEL=ab
      61             : ... TORSIONS
      62             : PRINT ARG=ab.* FILE=colvar STRIDE=10
      63             : ```
      64             : 
      65             : Here, `@phi-3` tells plumed that you would like to calculate the $\phi$ angle in the third residue of the protein.
      66             : Similarly `@psi-4` tells plumed that you want to calculate the $\psi$ angle of the fourth residue of the protein.
      67             : 
      68             : 
      69             : */
      70             : //+ENDPLUMEDOC
      71             : 
      72             : namespace PLMD {
      73             : namespace multicolvar {
      74             : 
      75             : class Torsions : public ActionShortcut {
      76             : public:
      77             :   static void registerKeywords(Keywords& keys);
      78             :   explicit Torsions(const ActionOptions&);
      79             : };
      80             : 
      81             : PLUMED_REGISTER_ACTION(Torsions,"TORSIONS")
      82             : 
      83           8 : void Torsions::registerKeywords(Keywords& keys) {
      84           8 :   ActionShortcut::registerKeywords( keys );
      85           8 :   MultiColvarShortcuts::shortcutKeywords( keys );
      86          16 :   keys.needsAction("TORSION");
      87           8 :   keys.add("atoms","ATOMS","the four atoms involved in the torsional angle");
      88          16 :   keys.setValueDescription("vector","the TORSION for each set of three atoms that were specified");
      89           8 :   keys.setDeprecated("TORSION");
      90           8 : }
      91             : 
      92           6 : Torsions::Torsions(const ActionOptions& ao):
      93             :   Action(ao),
      94           6 :   ActionShortcut(ao) {
      95           6 :   log.printf("Action TORSION\n");
      96           6 :   log.printf("  with label %s \n", getShortcutLabel().c_str() );
      97             :   std::map<std::string,std::string> keymap;
      98           6 :   MultiColvarShortcuts::readShortcutKeywords( keymap, this );
      99          12 :   readInputLine( getShortcutLabel() + ": TORSION " + convertInputLineToString() );
     100             :   // Add shortcuts to label
     101          12 :   MultiColvarShortcuts::expandFunctions( getShortcutLabel(), getShortcutLabel(), "", keymap, this );
     102           6 : }
     103             : 
     104             : }
     105             : }

Generated by: LCOV version 1.16