LCOV - code coverage report
Current view: top level - mapping - GeometricPathShortcut.cpp (source / functions) Hit Total Coverage
Test: plumed test coverage Lines: 22 22 100.0 %
Date: 2024-10-18 13:59:31 Functions: 2 3 66.7 %

          Line data    Source code
       1             : /* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
       2             :    Copyright (c) 2013-2018 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 "Path.h"
      23             : #include "tools/PDB.h"
      24             : #include "core/ActionRegister.h"
      25             : 
      26             : //+PLUMEDOC COLVAR GPATH
      27             : /*
      28             : Distance along and from a path calculated using geometric formulas
      29             : 
      30             : 
      31             : \par Examples
      32             : 
      33             : */
      34             : //+ENDPLUMEDOC
      35             : 
      36             : namespace PLMD {
      37             : namespace mapping {
      38             : 
      39             : class GeometricPathShortcut : public ActionShortcut {
      40             : public:
      41             :   static void registerKeywords(Keywords& keys);
      42             :   explicit GeometricPathShortcut(const ActionOptions&);
      43             : };
      44             : 
      45             : PLUMED_REGISTER_ACTION(GeometricPathShortcut,"GPATH")
      46             : 
      47           8 : void GeometricPathShortcut::registerKeywords( Keywords& keys ) {
      48           8 :   ActionShortcut::registerKeywords( keys ); Path::registerInputFileKeywords( keys );
      49          16 :   keys.add("optional","PROPERTY","read in path coordinates by finding option with this label in remark of pdb frames");
      50          16 :   keys.addOutputComponent("s","default","scalar","the position on the path");
      51          16 :   keys.addOutputComponent("z","default","scalar","the distance from the path");
      52          32 :   keys.needsAction("DISPLACEMENT"); keys.needsAction("GEOMETRIC_PATH"); keys.needsAction("PDB2CONSTANT"); keys.needsAction("CONSTANT");
      53           8 : }
      54             : 
      55           2 : GeometricPathShortcut::GeometricPathShortcut( const ActionOptions& ao ):
      56             :   Action(ao),
      57           2 :   ActionShortcut(ao)
      58             : {
      59           6 :   std::string mtype, reference_data; std::vector<std::string> argnames; parseVector("ARG",argnames); parse("TYPE", mtype);
      60             :   // Create list of reference configurations that PLUMED will use
      61           4 :   std::string reference; parse("REFERENCE",reference);
      62           2 :   FILE* fp=std::fopen(reference.c_str(),"r"); PDB mypdb; if(!fp) error("could not open reference file " + reference );
      63           2 :   bool do_read=mypdb.readFromFilepointer(fp,false,0.1); if( !do_read ) error("missing file " + reference );
      64           2 :   Path::readInputFrames( reference, mtype, argnames, true, this, reference_data );
      65             :   // Now get coordinates on spath
      66           4 :   std::vector<std::string> pnames; parseVector("PROPERTY",pnames); Path::readPropertyInformation( pnames, getShortcutLabel(), reference, this );
      67             :   // Create action that computes the geometric path variablesa
      68           2 :   std::string propstr = getShortcutLabel() + "_ind"; if( pnames.size()>0 ) propstr = pnames[0] + "_ref";
      69           3 :   if( argnames.size()>0 ) readInputLine( getShortcutLabel() + ": GEOMETRIC_PATH ARG=" + getShortcutLabel() + "_data " + " PROPERTY=" + propstr + " REFERENCE=" + reference_data + " METRIC={DIFFERENCE}");
      70             :   else {
      71           1 :     std::string num, align_str, displace_str; Tools::convert( mypdb.getOccupancy()[0], align_str ); Tools::convert( mypdb.getBeta()[0], displace_str );
      72          25 :     for(unsigned j=1; j<mypdb.getAtomNumbers().size(); ++j ) { Tools::convert( mypdb.getOccupancy()[j], num ); align_str += "," + num; Tools::convert( mypdb.getBeta()[0], num ); displace_str += "," + num; }
      73           2 :     std::string metric = "RMSD_VECTOR DISPLACEMENT TYPE=" + mtype + " ALIGN=" + align_str + " DISPLACE=" + displace_str;
      74           2 :     readInputLine( getShortcutLabel() + ": GEOMETRIC_PATH ARG=" + getShortcutLabel() + "_data.disp " + " PROPERTY=" +  propstr + " REFERENCE=" + reference_data + " METRIC={" + metric + "} METRIC_COMPONENT=disp");
      75             :   }
      76           6 : }
      77             : 
      78             : 
      79             : }
      80             : }
      81             : 
      82             : 

Generated by: LCOV version 1.16