LCOV - code coverage report
Current view: top level - secondarystructure - AntibetaRMSD.cpp (source / functions) Hit Total Coverage
Test: plumed test coverage Lines: 83 86 96.5 %
Date: 2018-12-19 07:49:13 Functions: 9 10 90.0 %

          Line data    Source code
       1             : /* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
       2             :    Copyright (c) 2012-2018 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 "SecondaryStructureRMSD.h"
      23             : #include "core/ActionRegister.h"
      24             : #include "core/PlumedMain.h"
      25             : #include "core/Atoms.h"
      26             : 
      27             : namespace PLMD {
      28             : namespace secondarystructure {
      29             : 
      30             : //+PLUMEDOC COLVAR ANTIBETARMSD
      31             : /*
      32             : Probe the antiparallel beta sheet content of your protein structure.
      33             : 
      34             : Two protein segments containing three continguous residues can form an antiparallel beta sheet.
      35             : Although if the two segments are part of the same protein chain they must be separated by
      36             : a minimum of 2 residues to make room for the turn. This colvar thus generates the set of
      37             : all possible six residue sections that could conceivably form an antiparallel beta sheet
      38             : and calculates the RMSD distance between the configuration in which the residues find themselves
      39             : and an idealized antiparallel beta sheet structure. These distances can be calculated by either
      40             : aligning the instantaneous structure with the reference structure and measuring each
      41             : atomic displacement or by calculating differences between the set of interatomic
      42             : distances in the reference and instantaneous structures.
      43             : 
      44             : This colvar is based on the following reference \cite pietrucci09jctc.  The authors of
      45             : this paper use the set of distances from the anti parallel beta sheet configurations to measure
      46             : the number of segments that have an configuration that resemebles an anti paralel beta sheet. This is done by calculating
      47             : the following sum of functions of the rmsd distances:
      48             : 
      49             : \f[
      50             : s = \sum_i \frac{ 1 - \left(\frac{r_i-d_0}{r_0}\right)^n } { 1 - \left(\frac{r_i-d_0}{r_0}\right)^m }
      51             : \f]
      52             : 
      53             : where the sum runs over all possible segments of antiparallel beta sheet.  By default the
      54             : NN, MM and D_0 parameters are set equal to those used in \cite pietrucci09jctc.  The R_0
      55             : parameter must be set by the user - the value used in \cite pietrucci09jctc was 0.08 nm.
      56             : 
      57             : If you change the function in the above sum you can calculate quantities such as the average
      58             : distance from a purely configuration composed of pure anti-parallel beta sheets or the distance between the set of
      59             : residues that is closest to an anti-parallel beta sheet and the reference configuration. To do these sorts of
      60             : calculations you can use the AVERAGE and MIN keywords. In addition you can use the LESS_THAN
      61             : keyword if you would like to change the form of the switching function. If you use any of these
      62             : options you no longer need to specify NN, R_0, MM and D_0.
      63             : 
      64             : Please be aware that for codes like gromacs you must ensure that plumed
      65             : reconstructs the chains involved in your CV when you calculate this CV using
      66             : anthing other than TYPE=DRMSD.  For more details as to how to do this see \ref WHOLEMOLECULES.
      67             : 
      68             : \par Examples
      69             : 
      70             : The following input calculates the number of six residue segments of
      71             : protein that are in an antiparallel beta sheet configuration.
      72             : 
      73             : \verbatim
      74             : MOLINFO STRUCTURE=helix.pdb
      75             : ANTIBETARMSD RESIDUES=all TYPE=DRMSD LESS_THAN={RATIONAL R_0=0.08 NN=8 MM=12} LABEL=a
      76             : \endverbatim
      77             : (see also \ref MOLINFO)
      78             : 
      79             : */
      80             : //+ENDPLUMEDOC
      81             : 
      82          24 : class AntibetaRMSD : public SecondaryStructureRMSD {
      83             : public:
      84             :   static void registerKeywords( Keywords& keys );
      85             :   explicit AntibetaRMSD(const ActionOptions&);
      86             : };
      87             : 
      88        2535 : PLUMED_REGISTER_ACTION(AntibetaRMSD,"ANTIBETARMSD")
      89             : 
      90          13 : void AntibetaRMSD::registerKeywords( Keywords& keys ) {
      91          13 :   SecondaryStructureRMSD::registerKeywords( keys );
      92             :   keys.add("compulsory","STYLE","all","Antiparallel beta sheets can either form in a single chain or from a pair of chains. If STYLE=all all "
      93             :            "chain configuration with the appropriate geometry are counted.  If STYLE=inter "
      94             :            "only sheet-like configurations involving two chains are counted, while if STYLE=intra "
      95          13 :            "only sheet-like configurations involving a single chain are counted");
      96          13 :   keys.use("STRANDS_CUTOFF");
      97          13 : }
      98             : 
      99          12 : AntibetaRMSD::AntibetaRMSD(const ActionOptions&ao):
     100             :   Action(ao),
     101          12 :   SecondaryStructureRMSD(ao)
     102             : {
     103             :   // read in the backbone atoms
     104          12 :   std::vector<unsigned> chains; readBackboneAtoms( "protein", chains );
     105             : 
     106          12 :   bool intra_chain(false), inter_chain(false);
     107          24 :   std::string style; parse("STYLE",style);
     108          12 :   if( style=="all" ) {
     109          10 :     intra_chain=true; inter_chain=true;
     110           2 :   } else if( style=="inter") {
     111           2 :     intra_chain=false; inter_chain=true;
     112           0 :   } else if( style=="intra") {
     113           0 :     intra_chain=true; inter_chain=false;
     114             :   } else {
     115           0 :     error( style + " is not a valid directive for the STYLE keyword");
     116             :   }
     117             : 
     118             :   // Align the atoms based on the positions of these two atoms
     119          12 :   setAtomsFromStrands( 6, 21 );
     120             : 
     121             :   // This constructs all conceivable sections of antibeta sheet in the backbone of the chains
     122          12 :   if( intra_chain ) {
     123          10 :     unsigned nres, nprevious=0; std::vector<unsigned> nlist(30);
     124         173 :     for(unsigned i=0; i<chains.size(); ++i) {
     125         163 :       if( chains[i]<40 ) error("segment of backbone is not long enough to form an antiparallel beta hairpin. Each backbone fragment must contain a minimum of 8 residues");
     126             :       // Loop over all possible triples in each 8 residue segment of protein
     127         163 :       nres=chains[i]/5;
     128         163 :       if( chains[i]%5!=0 ) error("backbone segment received does not contain a multiple of five residues");
     129         330 :       for(unsigned ires=0; ires<nres-7; ires++) {
     130         344 :         for(unsigned jres=ires+7; jres<nres; jres++) {
     131        2832 :           for(unsigned k=0; k<15; ++k) {
     132        2655 :             nlist[k]=nprevious + ires*5+k;
     133        2655 :             nlist[k+15]=nprevious + (jres-2)*5+k;
     134             :           }
     135         177 :           addColvar( nlist );
     136             :         }
     137             :       }
     138         163 :       nprevious+=chains[i];
     139          10 :     }
     140             :   }
     141          12 :   if( inter_chain ) {
     142          12 :     if( chains.size()==1 && style!="all" ) error("there is only one chain defined so cannot use inter_chain option");
     143          12 :     unsigned iprev,jprev,inres,jnres; std::vector<unsigned> nlist(30);
     144         167 :     for(unsigned ichain=1; ichain<chains.size(); ++ichain) {
     145         155 :       iprev=0; for(unsigned i=0; i<ichain; ++i) iprev+=chains[i];
     146         155 :       inres=chains[ichain]/5;
     147         155 :       if( chains[ichain]%5!=0 ) error("backbone segment received does not contain a multiple of five residues");
     148        1075 :       for(unsigned ires=0; ires<inres-2; ++ires) {
     149        9184 :         for(unsigned jchain=0; jchain<ichain; ++jchain) {
     150        8264 :           jprev=0; for(unsigned i=0; i<jchain; ++i) jprev+=chains[i];
     151        8264 :           jnres=chains[jchain]/5;
     152        8264 :           if( chains[jchain]%5!=0 ) error("backbone segment received does not contain a multiple of five residues");
     153       57838 :           for(unsigned jres=0; jres<jnres-2; ++jres) {
     154      793184 :             for(unsigned k=0; k<15; ++k) {
     155      743610 :               nlist[k]=iprev+ ires*5+k;
     156      743610 :               nlist[k+15]=jprev+ jres*5+k;
     157             :             }
     158       49574 :             addColvar( nlist );
     159             :           }
     160             :         }
     161             :       }
     162          12 :     }
     163             :   }
     164             : 
     165             :   // Build the reference structure ( in angstroms )
     166          24 :   std::vector<Vector> reference(30);
     167          12 :   reference[0]=Vector( 2.263, -3.795,  1.722); // N    i
     168          12 :   reference[1]=Vector( 2.493, -2.426,  2.263); // CA
     169          12 :   reference[2]=Vector( 3.847, -1.838,  1.761); // CB
     170          12 :   reference[3]=Vector( 1.301, -1.517,  1.921); // C
     171          12 :   reference[4]=Vector( 0.852, -1.504,  0.739); // O
     172          12 :   reference[5]=Vector( 0.818, -0.738,  2.917); // N    i+1
     173          12 :   reference[6]=Vector(-0.299,  0.243,  2.748); // CA
     174          12 :   reference[7]=Vector(-1.421, -0.076,  3.757); // CB
     175          12 :   reference[8]=Vector( 0.273,  1.680,  2.854); // C
     176          12 :   reference[9]=Vector( 0.902,  1.993,  3.888); // O
     177          12 :   reference[10]=Vector( 0.119,  2.532,  1.813); // N    i+2
     178          12 :   reference[11]=Vector( 0.683,  3.916,  1.680); // CA
     179          12 :   reference[12]=Vector( 1.580,  3.940,  0.395); // CB
     180          12 :   reference[13]=Vector(-0.394,  5.011,  1.630); // C
     181          12 :   reference[14]=Vector(-1.459,  4.814,  0.982); // O
     182          12 :   reference[15]=Vector(-2.962,  3.559, -1.359); // N    j-2
     183          12 :   reference[16]=Vector(-2.439,  2.526, -2.287); // CA
     184          12 :   reference[17]=Vector(-1.189,  3.006, -3.087); // CB
     185          12 :   reference[18]=Vector(-2.081,  1.231, -1.520); // C
     186          12 :   reference[19]=Vector(-1.524,  1.324, -0.409); // O
     187          12 :   reference[20]=Vector(-2.326,  0.037, -2.095); // N    j-1
     188          12 :   reference[21]=Vector(-1.858, -1.269, -1.554); // CA
     189          12 :   reference[22]=Vector(-3.053, -2.199, -1.291); // CB
     190          12 :   reference[23]=Vector(-0.869, -1.949, -2.512); // C
     191          12 :   reference[24]=Vector(-1.255, -2.070, -3.710); // O
     192          12 :   reference[25]=Vector( 0.326, -2.363, -2.072); // N    j
     193          12 :   reference[26]=Vector( 1.405, -2.992, -2.872); // CA
     194          12 :   reference[27]=Vector( 2.699, -2.129, -2.917); // CB
     195          12 :   reference[28]=Vector( 1.745, -4.399, -2.330); // C
     196          12 :   reference[29]=Vector( 1.899, -4.545, -1.102); // O
     197             : 
     198             :   // Store the secondary structure ( last number makes sure we convert to internal units nm )
     199          24 :   setSecondaryStructure( reference, 0.17/atoms.getUnits().getLength(), 0.1/atoms.getUnits().getLength() );
     200          12 : }
     201             : 
     202             : }
     203        2523 : }

Generated by: LCOV version 1.13