LCOV - code coverage report
Current view: top level - reference - IntermolecularDRMSD.cpp (source / functions) Hit Total Coverage
Test: plumed test coverage Lines: 21 21 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 IntermolecularDRMSD : public DRMSD {
      28             : private:
      29             :   unsigned nblocks;
      30             :   std::vector<unsigned> blocks;
      31             : public:
      32             :   explicit IntermolecularDRMSD( const ReferenceConfigurationOptions& ro );
      33             :   void read( const PDB& pdb );
      34             :   void setup_targets();
      35             : };
      36             : 
      37        6453 : PLUMED_REGISTER_METRIC(IntermolecularDRMSD,"INTER-DRMSD")
      38             : 
      39           1 : IntermolecularDRMSD::IntermolecularDRMSD( const ReferenceConfigurationOptions& ro ):
      40             :   ReferenceConfiguration( ro ),
      41             :   DRMSD( ro ),
      42           1 :   nblocks(0)
      43             : {
      44           1 : }
      45             : 
      46           1 : void IntermolecularDRMSD::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 intermolecular 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 IntermolecularDRMSD::setup_targets() {
      54           1 :   plumed_massert( bounds_were_set, "I am missing a call to DRMSD::setBoundsOnDistances");
      55             : 
      56           3 :   for(unsigned i=1; i<nblocks; ++i) {
      57           3 :     for(unsigned j=0; j<i; ++j) {
      58           9 :       for(unsigned iatom=blocks[i]; iatom<blocks[i+1]; ++iatom) {
      59          33 :         for(unsigned jatom=blocks[j]; jatom<blocks[j+1]; ++jatom) {
      60          12 :           double distance = delta( getReferencePosition(iatom), getReferencePosition(jatom) ).modulo();
      61          12 :           if(distance < upper && distance > lower ) targets[std::make_pair(iatom,jatom)] = distance;
      62             :         }
      63             :       }
      64             :     }
      65             :   }
      66           1 : }
      67             : 
      68        4839 : }

Generated by: LCOV version 1.13