Subject: autocorrelation for dihedrals

From: [email-masked] (Frank Eisenmenger)
Date: Thu, 20 Apr 1995 16:28:37 +0200 (MET)

Dear CCL-ers,

recently, I posted the following question: 

> during conformational analysis of peptides the following question occurred:
> given a (time-)series of conformations of a linear four-atom molecule
> described by one dihedral angle (=tau, range 180 ... +180)
>
> How calculate the autocorrelation function for tau, taking into account the
> "cyclic" behaviour of dihedrals ?

A number of replies and our own efforts helped to produce the following
routine, which can serve as a first step in solving the above problem: 

--------------------------------------------------------------------------

      real*4 function avrang(n,angs,idx)

c ------------------------------------------
c PURPOSE: average of N angles given in
c          array ANGS ( all from [-pi,pi] )
c
c        ! array IDX must provide ASCENDING
c          order for angles (1...n) on INPUT
c
c          0 < EPS < 1 ensures that angles
c          EVENLY & DENSLY distributed in [-pi,pi]
c          have average close to 0.0
c
c K. Peters & F. Eisenmenger      April 1995
c Inst. of Biochemistry
c Med. Faculty of Humboldt Univ. Berlin
c ------------------------------------------

      implicit real*4 (a-h,o-z)
      implicit integer (i-n)

c      parameter (pi=3.141592653589793,
c     #           pi2=2.0*pi)

      parameter (pi=180.0,
     #           pi2=2.0*pi)

      parameter (eps=0.95)

      dimension angs(*),idx(*)

      ai=angs(idx(1))
      dm=angs(idx(n))-ai
      im=1
      av=ai

      ap=ai+pi2
      do i=2,n
        ai=angs(idx(i))
        d=ap-ai
        if (d.lt.eps*dm) then
          dm=d
          im=i
        endif
        av=av+ai
        ap=ai+pi2
      enddo

      av=(av+float(im-1)*pi2)/float(n)
      if (abs(av).gt.pi) av=av-sign(pi2,av)

      avrang=av

      return
      end

--------------------------------------------------------------------------

Feel free to test/apply this. I would be happy about any suggestions.

Good luck,

Frank Eisenmenger
 
+------------------------------------------------------------------------+
| Institute of Biochemistry                                              |
| Medical Faculty of the Humboldt University (Charite)                   |
|                                                                        |
| Hessische Str. 3-4                                                     |
| 10115 Berlin, Germany                                                  |
|                                                                        |
| Phone: +49-30-28468-612 or -239       FAX: +49-30-28468-600            |
| E-mail: [email-masked]                                 |
+------------------------------------------------------------------------+