LCOV - code coverage report
Current view: top level - reference - IntramolecularDRMSD.cpp (source / functions) Hit Total Coverage
Test: plumed test coverage Lines: 20 20 100.0 %
Date: 2020-11-18 11:20:57 Functions: 10 11 90.9 %

          Line data    Source code
       1             : /* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
       2             :    Copyright (c) 2016-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 "DRMSD.h"
      23             : #include "MetricRegister.h"
      24             : 
      25             : namespace PLMD {
      26             : 
      27           3 : class IntramolecularDRMSD : public DRMSD {
      28             : private:
      29             :   unsigned nblocks;
      30             :   std::vector<unsigned> blocks;
      31             : public:
      32             :   explicit IntramolecularDRMSD( const ReferenceConfigurationOptions& ro );
      33             :   void read( const PDB& pdb );
      34             :   void setup_targets();
      35             : };
      36             : 
      37        6453 : PLUMED_REGISTER_METRIC(IntramolecularDRMSD,"INTRA-DRMSD")
      38             : 
      39           1 : IntramolecularDRMSD::IntramolecularDRMSD( const ReferenceConfigurationOptions& ro ):
      40             :   ReferenceConfiguration( ro ),
      41             :   DRMSD( ro ),
      42           1 :   nblocks(0)
      43             : {
      44           1 : }
      45             : 
      46           1 : void IntramolecularDRMSD::read( const PDB& pdb ) {
      47           1 :   readAtomsFromPDB( pdb, true ); nblocks = pdb.getNumberOfAtomBlocks(); blocks.resize( nblocks+1 );
      48           1 :   if( nblocks==1 ) error("Trying to compute intramolecular rmsd but found no TERs in input PDB");
      49           5 :   blocks[0]=0; for(unsigned i=0; i<nblocks; ++i) blocks[i+1]=pdb.getAtomBlockEnds()[i];
      50           1 :   readBounds(); setup_targets();
      51           1 : }
      52             : 
      53           1 : void IntramolecularDRMSD::setup_targets() {
      54           1 :   plumed_massert( bounds_were_set, "I am missing a call to DRMSD::setBoundsOnDistances");
      55             : 
      56           3 :   for(unsigned i=0; i<nblocks; ++i) {
      57          16 :     for(unsigned iatom=blocks[i]+1; iatom<blocks[i+1]; ++iatom) {
      58          14 :       for(unsigned jatom=blocks[i]; jatom<iatom; ++jatom) {
      59           9 :         double distance = delta( getReferencePosition(iatom), getReferencePosition(jatom) ).modulo();
      60           9 :         if(distance < upper && distance > lower ) targets[std::make_pair(iatom,jatom)] = distance;
      61             :       }
      62             :     }
      63             :   }
      64           1 : }
      65             : 
      66        4839 : }

Generated by: LCOV version 1.13