LCOV - code coverage report
Current view: top level - reference - IntermolecularDRMSD.cpp (source / functions) Hit Total Coverage
Test: plumed test coverage Lines: 19 19 100.0 %
Date: 2024-10-11 08:09:47 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       10421 : 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           3 :   blocks[0]=0; for(unsigned i=0; i<nblocks; ++i) blocks[i+1]=pdb.getAtomBlockEnds()[i];
      50           1 :   readBounds( pdb ); 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           2 :   for(unsigned i=1; i<nblocks; ++i) {
      57           2 :     for(unsigned j=0; j<i; ++j) {
      58           4 :       for(unsigned iatom=blocks[i]; iatom<blocks[i+1]; ++iatom) {
      59          15 :         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             : }

Generated by: LCOV version 1.15