LCOV - code coverage report
Current view: top level - secondarystructure - AntibetaRMSD.cpp (source / functions) Hit Total Coverage
Test: plumed test coverage Lines: 96 98 98.0 %
Date: 2024-10-18 13:59:31 Functions: 2 3 66.7 %

          Line data    Source code
       1             : /* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
       2             :    Copyright (c) 2012-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 "SecondaryStructureRMSD.h"
      23             : #include "core/ActionShortcut.h"
      24             : #include "core/ActionRegister.h"
      25             : 
      26             : namespace PLMD {
      27             : namespace secondarystructure {
      28             : 
      29             : //+PLUMEDOC COLVAR ANTIBETARMSD
      30             : /*
      31             : Probe the antiparallel beta sheet content of your protein structure.
      32             : 
      33             : Two protein segments containing three contiguous residues can form an antiparallel beta sheet.
      34             : Although if the two segments are part of the same protein chain they must be separated by
      35             : a minimum of 2 residues to make room for the turn. This colvar thus generates the set of
      36             : all possible six residue sections that could conceivably form an antiparallel beta sheet
      37             : and calculates the RMSD distance between the configuration in which the residues find themselves
      38             : and an idealized antiparallel beta sheet structure. These distances can be calculated by either
      39             : aligning the instantaneous structure with the reference structure and measuring each
      40             : atomic displacement or by calculating differences between the set of inter-atomic
      41             : distances in the reference and instantaneous structures.
      42             : 
      43             : This colvar is based on the following reference \cite pietrucci09jctc.  The authors of
      44             : this paper use the set of distances from the anti parallel beta sheet configurations to measure
      45             : the number of segments that have an configuration that resembles an anti parallel beta sheet. This is done by calculating
      46             : the following sum of functions of the rmsd distances:
      47             : 
      48             : \f[
      49             : 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 }
      50             : \f]
      51             : 
      52             : where the sum runs over all possible segments of antiparallel beta sheet.  By default the
      53             : NN, MM and D_0 parameters are set equal to those used in \cite pietrucci09jctc.  The R_0
      54             : parameter must be set by the user - the value used in \cite pietrucci09jctc was 0.08 nm.
      55             : 
      56             : If you change the function in the above sum you can calculate quantities such as the average
      57             : distance from a purely configuration composed of pure anti-parallel beta sheets or the distance between the set of
      58             : residues that is closest to an anti-parallel beta sheet and the reference configuration. To do these sorts of
      59             : calculations you can use the AVERAGE and MIN keywords. In addition you can use the LESS_THAN
      60             : keyword if you would like to change the form of the switching function. If you use any of these
      61             : options you no longer need to specify NN, R_0, MM and D_0.
      62             : 
      63             : Please be aware that for codes like gromacs you must ensure that plumed
      64             : reconstructs the chains involved in your CV when you calculate this CV using
      65             : anything other than TYPE=DRMSD.  For more details as to how to do this see \ref WHOLEMOLECULES.
      66             : 
      67             : \par Examples
      68             : 
      69             : The following input calculates the number of six residue segments of
      70             : protein that are in an antiparallel beta sheet configuration.
      71             : 
      72             : \plumedfile
      73             : #SETTINGS MOLFILE=regtest/basic/rt32/helix.pdb
      74             : MOLINFO STRUCTURE=beta.pdb
      75             : ab: ANTIBETARMSD RESIDUES=all STRANDS_CUTOFF=1
      76             : \endplumedfile
      77             : 
      78             : Here the same is done use RMSD instead of DRMSD
      79             : 
      80             : \plumedfile
      81             : #SETTINGS MOLFILE=regtest/basic/rt32/helix.pdb
      82             : MOLINFO STRUCTURE=helix.pdb
      83             : WHOLEMOLECULES ENTITY0=1-100
      84             : hh: ANTIBETARMSD RESIDUES=all TYPE=OPTIMAL R_0=0.1  STRANDS_CUTOFF=1
      85             : \endplumedfile
      86             : */
      87             : //+ENDPLUMEDOC
      88             : 
      89             : class AntibetaRMSD : public ActionShortcut {
      90             : public:
      91             :   static void registerKeywords( Keywords& keys );
      92             :   explicit AntibetaRMSD(const ActionOptions&);
      93             : };
      94             : 
      95             : PLUMED_REGISTER_ACTION(AntibetaRMSD,"ANTIBETARMSD")
      96             : 
      97          84 : void AntibetaRMSD::registerKeywords( Keywords& keys ) {
      98          84 :   SecondaryStructureRMSD::registerKeywords( keys );
      99         168 :   keys.setValueDescription("scalar/vector","if LESS_THAN is present the RMSD distance between each residue and the ideal antiparallel beta sheet.  If LESS_THAN is not present the number of residue segments where the structure is similar to an anti parallel beta sheet");
     100         252 :   keys.remove("ATOMS"); keys.remove("SEGMENT"); keys.remove("BONDLENGTH");
     101         252 :   keys.remove("NO_ACTION_LOG"); keys.remove("CUTOFF_ATOMS"); keys.remove("STRUCTURE");
     102         168 :   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 "
     103             :            "chain configuration with the appropriate geometry are counted.  If STYLE=inter "
     104             :            "only sheet-like configurations involving two chains are counted, while if STYLE=intra "
     105             :            "only sheet-like configurations involving a single chain are counted");
     106          84 : }
     107             : 
     108          14 : AntibetaRMSD::AntibetaRMSD(const ActionOptions&ao):
     109             :   Action(ao),
     110          14 :   ActionShortcut(ao)
     111             : {
     112             :   // Read in the input and create a string that describes how to compute the less than
     113          14 :   std::string ltmap; bool uselessthan=SecondaryStructureRMSD::readShortcutWords( ltmap, this );
     114             :   // read in the backbone atoms
     115          28 :   std::vector<unsigned> chains; std::string atoms; SecondaryStructureRMSD::readBackboneAtoms( this, plumed, "protein", chains, atoms );
     116             : 
     117             :   bool intra_chain(false), inter_chain(false);
     118          14 :   std::string style; parse("STYLE",style);
     119          28 :   if( Tools::caseInSensStringCompare(style, "all") ) {
     120             :     intra_chain=true; inter_chain=true;
     121           2 :   } else if( Tools::caseInSensStringCompare(style, "inter") ) {
     122             :     intra_chain=false; inter_chain=true;
     123           0 :   } else if( Tools::caseInSensStringCompare(style, "intra") ) {
     124             :     intra_chain=true; inter_chain=false;
     125             :   } else {
     126           0 :     error( style + " is not a valid directive for the STYLE keyword");
     127             :   }
     128             : 
     129             :   // This constructs all conceivable sections of antibeta sheet in the backbone of the chains
     130          14 :   std::string seglist; unsigned k=1;
     131          14 :   if( intra_chain ) {
     132          13 :     unsigned nprevious=0; std::vector<unsigned> nlist(30);
     133         230 :     for(unsigned i=0; i<chains.size(); ++i) {
     134         217 :       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");
     135             :       // Loop over all possible triples in each 8 residue segment of protein
     136         217 :       unsigned nres=chains[i]/5;
     137         217 :       if( chains[i]%5!=0 ) error("backbone segment received does not contain a multiple of five residues");
     138         438 :       for(unsigned ires=0; ires<nres-7; ires++) {
     139         452 :         for(unsigned jres=ires+7; jres<nres; jres++) {
     140        3696 :           for(unsigned k=0; k<15; ++k) {
     141        3465 :             nlist[k]=nprevious + ires*5+k;
     142        3465 :             nlist[k+15]=nprevious + (jres-2)*5+k;
     143             :           }
     144             :           std::string nlstr, num;
     145         231 :           Tools::convert( nlist[0], nlstr );
     146         231 :           Tools::convert(k, num); k++;
     147         462 :           seglist += " SEGMENT" + num + "=" + nlstr;
     148        6930 :           for(unsigned kk=1; kk<nlist.size(); ++kk ) { Tools::convert( nlist[kk], nlstr ); seglist += "," + nlstr; }
     149             :         }
     150             :       }
     151         217 :       nprevious+=chains[i];
     152             :     }
     153             :   }
     154          14 :   if( inter_chain ) {
     155          15 :     if( chains.size()==1 && style!="all" ) error("there is only one chain defined so cannot use inter_chain option");
     156          14 :     std::vector<unsigned> nlist(30);
     157         219 :     for(unsigned ichain=1; ichain<chains.size(); ++ichain) {
     158        2042 :       unsigned iprev=0; for(unsigned i=0; i<ichain; ++i) iprev+=chains[i];
     159         205 :       unsigned inres=chains[ichain]/5;
     160         205 :       if( chains[ichain]%5!=0 ) error("backbone segment received does not contain a multiple of five residues");
     161        1430 :       for(unsigned ires=0; ires<inres-2; ++ires) {
     162       12242 :         for(unsigned jchain=0; jchain<ichain; ++jchain) {
     163       69769 :           unsigned jprev=0; for(unsigned i=0; i<jchain; ++i) jprev+=chains[i];
     164       11017 :           unsigned jnres=chains[jchain]/5;
     165       11017 :           if( chains[jchain]%5!=0 ) error("backbone segment received does not contain a multiple of five residues");
     166       77114 :           for(unsigned jres=0; jres<jnres-2; ++jres) {
     167     1057552 :             for(unsigned k=0; k<15; ++k) {
     168      991455 :               nlist[k]=iprev+ ires*5+k;
     169      991455 :               nlist[k+15]=jprev+ jres*5+k;
     170             :             }
     171             :             std::string nlstr, num;
     172       66097 :             Tools::convert( nlist[0], nlstr );
     173       66097 :             Tools::convert(k, num); k++;
     174      132194 :             seglist += " SEGMENT" + num + "=" + nlstr;
     175     1982910 :             for(unsigned kk=1; kk<nlist.size(); ++kk ) { Tools::convert( nlist[kk], nlstr ); seglist += "," + nlstr; }
     176             :           }
     177             :         }
     178             :       }
     179             :     }
     180             :   }
     181             : 
     182             :   // Build the reference structure ( in angstroms )
     183          14 :   std::vector<Vector> reference(30);
     184          14 :   reference[0]=Vector( 2.263, -3.795,  1.722); // N    i
     185          14 :   reference[1]=Vector( 2.493, -2.426,  2.263); // CA
     186          14 :   reference[2]=Vector( 3.847, -1.838,  1.761); // CB
     187          14 :   reference[3]=Vector( 1.301, -1.517,  1.921); // C
     188          14 :   reference[4]=Vector( 0.852, -1.504,  0.739); // O
     189          14 :   reference[5]=Vector( 0.818, -0.738,  2.917); // N    i+1
     190          14 :   reference[6]=Vector(-0.299,  0.243,  2.748); // CA
     191          14 :   reference[7]=Vector(-1.421, -0.076,  3.757); // CB
     192          14 :   reference[8]=Vector( 0.273,  1.680,  2.854); // C
     193          14 :   reference[9]=Vector( 0.902,  1.993,  3.888); // O
     194          14 :   reference[10]=Vector( 0.119,  2.532,  1.813); // N    i+2
     195          14 :   reference[11]=Vector( 0.683,  3.916,  1.680); // CA
     196          14 :   reference[12]=Vector( 1.580,  3.940,  0.395); // CB
     197          14 :   reference[13]=Vector(-0.394,  5.011,  1.630); // C
     198          14 :   reference[14]=Vector(-1.459,  4.814,  0.982); // O
     199          14 :   reference[15]=Vector(-2.962,  3.559, -1.359); // N    j-2
     200          14 :   reference[16]=Vector(-2.439,  2.526, -2.287); // CA
     201          14 :   reference[17]=Vector(-1.189,  3.006, -3.087); // CB
     202          14 :   reference[18]=Vector(-2.081,  1.231, -1.520); // C
     203          14 :   reference[19]=Vector(-1.524,  1.324, -0.409); // O
     204          14 :   reference[20]=Vector(-2.326,  0.037, -2.095); // N    j-1
     205          14 :   reference[21]=Vector(-1.858, -1.269, -1.554); // CA
     206          14 :   reference[22]=Vector(-3.053, -2.199, -1.291); // CB
     207          14 :   reference[23]=Vector(-0.869, -1.949, -2.512); // C
     208          14 :   reference[24]=Vector(-1.255, -2.070, -3.710); // O
     209          14 :   reference[25]=Vector( 0.326, -2.363, -2.072); // N    j
     210          14 :   reference[26]=Vector( 1.405, -2.992, -2.872); // CA
     211          14 :   reference[27]=Vector( 2.699, -2.129, -2.917); // CB
     212          14 :   reference[28]=Vector( 1.745, -4.399, -2.330); // C
     213          14 :   reference[29]=Vector( 1.899, -4.545, -1.102); // O
     214             :   std::string ref0, ref1, ref2;
     215          14 :   Tools::convert(  reference[0][0], ref0 );
     216          14 :   Tools::convert(  reference[0][1], ref1 );
     217          14 :   Tools::convert(  reference[0][2], ref2 );
     218          28 :   std::string structure=" STRUCTURE1=" + ref0 + "," + ref1 + "," + ref2;
     219         420 :   for(unsigned i=1; i<30; ++i) {
     220        1624 :     for(unsigned k=0; k<3; ++k) { Tools::convert( reference[i][k], ref0 ); structure += "," + ref0; }
     221             :   }
     222             : 
     223          28 :   std::string strands_cutoff; parse("STRANDS_CUTOFF",strands_cutoff);
     224          27 :   if( strands_cutoff.length()>0 ) strands_cutoff=" CUTOFF_ATOMS=6,21 STRANDS_CUTOFF="+strands_cutoff;
     225          28 :   std::string type; parse("TYPE",type); std::string lab = getShortcutLabel() + "_rmsd"; if( uselessthan ) lab = getShortcutLabel();
     226          28 :   std::string nopbcstr=""; bool nopbc; parseFlag("NOPBC",nopbc); if( nopbc ) nopbcstr = " NOPBC";
     227          14 :   if( seglist.length()==0 ) error("no segments to investigate");
     228          28 :   readInputLine( lab + ": SECONDARY_STRUCTURE_RMSD BONDLENGTH=0.17" + seglist + structure + " " + atoms + " TYPE=" + type + strands_cutoff + nopbcstr );
     229             :   // Create the less than object
     230          14 :   if( ltmap.length()>0 ) SecondaryStructureRMSD::expandShortcut( uselessthan, getShortcutLabel(), lab, ltmap, this );
     231          14 : }
     232             : 
     233             : }
     234             : }

Generated by: LCOV version 1.16