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 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 ) override; 34 : void setup_targets() override; 35 : }; 36 : 37 13787 : 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 1 : } 44 : 45 1 : void IntramolecularDRMSD::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 intramolecular 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 IntramolecularDRMSD::setup_targets() { 61 1 : plumed_massert( bounds_were_set, "I am missing a call to DRMSD::setBoundsOnDistances"); 62 : 63 3 : for(unsigned i=0; i<nblocks; ++i) { 64 7 : for(unsigned iatom=blocks[i]+1; iatom<blocks[i+1]; ++iatom) { 65 14 : for(unsigned jatom=blocks[i]; jatom<iatom; ++jatom) { 66 9 : double distance = delta( getReferencePosition(iatom), getReferencePosition(jatom) ).modulo(); 67 9 : if(distance < upper && distance > lower ) { 68 9 : targets[std::make_pair(iatom,jatom)] = distance; 69 : } 70 : } 71 : } 72 : } 73 1 : } 74 : 75 : }