LCOV - code coverage report
Current view: top level - reference - IntermolecularDRMSD.cpp (source / functions) Hit Total Coverage
Test: plumed test coverage Lines: 25 26 96.2 %
Date: 2026-03-30 13:16:06 Functions: 6 7 85.7 %

          Line data    Source code
       1             : /* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
       2             :    Copyright (c) 2016-2023 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             : 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 ) override;
      34             :   void setup_targets() override;
      35             : };
      36             : 
      37       13787 : 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           1 : }
      44             : 
      45           1 : void IntermolecularDRMSD::read( const PDB& pdb ) {
      46           1 :   readAtomsFromPDB( pdb, true );
      47           1 :   nblocks = pdb.getNumberOfAtomBlocks();
      48           1 :   blocks.resize( nblocks+1 );
      49           1 :   if( nblocks==1 ) {
      50           0 :     error("Trying to compute intermolecular rmsd but found no TERs in input PDB");
      51             :   }
      52           1 :   blocks[0]=0;
      53           3 :   for(unsigned i=0; i<nblocks; ++i) {
      54           2 :     blocks[i+1]=pdb.getAtomBlockEnds()[i];
      55             :   }
      56           1 :   readBounds( pdb );
      57           1 :   setup_targets();
      58           1 : }
      59             : 
      60           1 : void IntermolecularDRMSD::setup_targets() {
      61           1 :   plumed_massert( bounds_were_set, "I am missing a call to DRMSD::setBoundsOnDistances");
      62             : 
      63           2 :   for(unsigned i=1; i<nblocks; ++i) {
      64           2 :     for(unsigned j=0; j<i; ++j) {
      65           4 :       for(unsigned iatom=blocks[i]; iatom<blocks[i+1]; ++iatom) {
      66          15 :         for(unsigned jatom=blocks[j]; jatom<blocks[j+1]; ++jatom) {
      67          12 :           double distance = delta( getReferencePosition(iatom), getReferencePosition(jatom) ).modulo();
      68          12 :           if(distance < upper && distance > lower ) {
      69          12 :             targets[std::make_pair(iatom,jatom)] = distance;
      70             :           }
      71             :         }
      72             :       }
      73             :     }
      74             :   }
      75           1 : }
      76             : 
      77             : }

Generated by: LCOV version 1.16