Hi,

And if you want a simple and trivial awk script (based on that
google'ing that Charlie described): save attached file in your path,
make it executable and run it e.g. as

 % vecang  1.23 3.45 6.78  9.87 7.65 5.43

Cheers

Clemens

PS: sorry it isn't in python/scheme or something similarly modern ;-)

On Thu, Apr 16, 2009 at 07:21:45PM +0800, Charlie Bond wrote:
> I've previously done it by using the centroids of the Calphas from the  
> first 4 residues and last 4 residues of the helix to define the vector  
> (7 residues might be better if the helix is long enough). It seemed to  
> work well enough by eye.
> From then on it is simple vector algebra (google 'dot product' or  
> something similar).
> Cheers,
> Charlie
> -- 
> Charlie Bond
> Professorial Fellow
> University of Western Australia
> School of Biomedical, Biomolecular and Chemical Sciences
> M310,  35 Stirling Highway
> Crawley WA 6009, Australia

-- 

***************************************************************
* Clemens Vonrhein, Ph.D.     vonrhein AT GlobalPhasing DOT com
*
*  Global Phasing Ltd.
*  Sheraton House, Castle Park 
*  Cambridge CB3 0AX, UK
*--------------------------------------------------------------
* BUSTER Development Group      (http://www.globalphasing.com)
***************************************************************
#!/bin/sh
version="Time-stamp: <2009-04-16 12:47:59 vonrhein>"
#
# Copyright  2008 by Global Phasing Limited
#
#           All rights reserved.
#
# Author    (2008) Clemens Vonrhein <[email protected]>
#
# Contact   [email protected]
#
#----------------------------------------------------------------------
#              BEGIN OF USER INPUT
#----------------------------------------------------------------------

#----------------------------------------------------------------------
#               END OF USER INPUT
#----------------------------------------------------------------------
echo " " >&2
echo " 
============================================================================ " 
>&2
echo " " >&2
echo " Copyright (C) 2008 by Global Phasing Limited" >&2
echo " " >&2
echo "           All rights reserved." >&2
echo " " >&2
echo " 
---------------------------------------------------------------------------- " 
>&2
echo " " >&2
echo " Contact:  [email protected]" >&2
echo " " >&2
ShortVersion=`echo $version | cut -f2- -d':' | sed "s/ 
[a-z0-9][a-z0-9][a-z0-9]*>/>/g"`
echo " Program:  `basename $0`   version ${ShortVersion} " >&2
echo " " >&2
echo " 
============================================================================ " 
>&2
echo " " >&2
#----------------------------------------------------------------------
#               BEGIN OF SCRIPT
#----------------------------------------------------------------------

usage () {
  echo " "
  echo " USAGE: $0  <Ax> <Ay> <Az>  <Bx> <By> <Bz>"
  echo " "
  echo "        <Ax> <Ay> <Az>   : XYZ coordinates of vector A"
  echo " "
  echo "        <Bx> <By> <Bz>   : XYZ coordinates of vector B"
  echo " "
}

[ $# -ne 6 ] && usage && exit 1

echo $@ | awk 'BEGIN{
  PI = 4*atan2(1,1)
  DTOR = PI/180
  RTOD = 180/PI
}
function Sin(x)    { return sin(x*DTOR) }
function Cos(x)    { return cos(x*DTOR) }
function Tan(x)    { return Sin(x)/Cos(x) }
function ASin(x)   { return atan2(x,sqrt(1 - x * x))*RTOD }
function ACos(x)   { return atan2(sqrt(1 - x * x),x)*RTOD }
function ATan2(y,x){ return atan2(y,x)*RTOD }
{
  ax=$1;ay=$2;az=$3
  l=sqrt(ax*ax+ay*ay+az*az)
  x1=ax/l;y1=ay/l;z1=az/l
  bx=$4;by=$5;bz=$6
  l=sqrt(bx*bx+by*by+bz*bz)
  x2=bx/l;y2=by/l;z2=bz/l
  dot=x1*x2+y1*y2+z1*z2
  ang=ACos(dot)
  printf("                 %15.5f        %15.5f\n",ax,bx)
  printf(" angle between   %15.5f  and   %15.5f  =  %15.5f degree\n",ay,by,ang)
  printf("                 %15.5f        %15.5f\n",az,bz)
  printf("\n")
}'
#----------------------------------------------------------------------
#               END OF SCRIPT
#----------------------------------------------------------------------

Reply via email to