VMD-L Mailing List
From: Barry Isralewitz (barryi_at_ks.uiuc.edu)
Date: Wed Aug 01 2001 - 17:40:06 CDT
- Next message: John Stone: "Announce: VMD 1.7 Released!!"
- Previous message: Jeff Taylor: "Re: fixing a molecule"
- In reply to: Mauricio Carrillo-Tripp: "fixing a molecule"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
Hi Maruicio,
On Mon, Jul 30, 2001 at 03:08:39PM -0700, Mauricio Carrillo-Tripp wrote:
> Hi, i would like to know if it is possible to do the following:
> I'm displaying a MD run from a dcd charmm file. The problem
> is that as the run pass by, the molecule rotates randomly.
> I would like to fix a certain atom on the origin, another on the
> x axis, and a third one on the x-y plane, in such a way that
> those three atoms are always on a fixed plane so when I play
> de MD the molecule wont rotate.
> Or, is there another way for fixing it?
> thank you.
>
> ______________________________________________________________________
>
> Mauricio Carrillo Tripp
> PhD Biophysics
> CCF-UNAM
>
>
> _________________________________________________________________
> Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp
Here's a script that does this. Thanks for the request, the
result looks really nice when a molecule gets particularly 'tortured',
such as during some of the applied-forced simulations we do around
here.
The instructions on usage are in the comments at the beginning
of the file. Just copy out the text and save it to a file called
'follow.tcl'. We'll probably put this into the VMD script library,
http://www.ks.uiuc.edu/Research/vmd/script_library/
in a couple of days. The script follows...
Enjoy,
Barry
===cut-here=====
# follow.tcl (alignFrames)
# Barry Isralewitz July 31, 2001
#
# VMD script, removes a molecule's translations and rotations
# from trajectory ("follows" a specified set of three atoms)
#
# Usage:
# 1. Put 3 atoms into a vmd selection.
# Note: When you call alignFrames,
# the first atom in the selection will be translated to
# the origin. The second atom will be somewhere on the x axis,
# the third atom will be somewhere on the x-y plane.
# 2. Put what you want to move (usually
# an entire molecule) into another vmd selection.
# 3. Align frames firstFrame to lastFrame with:
# alignFrames threeSel molSel firstFrame lastFrame
#
# Example (will align frames 0 to 80):
# source follow2.tcl
# set three [atomselect top "index 0 6 10"]
# set all [atomselect top "all"]
# alignFrames $three $all 0 80
#
proc align {threeSel molSel} {
set Pi 3.14159265
#threeSel contains three atoms to define plane
#molSel contains what you want to move (usually a whole molecule)
lassign [$threeSel get {x y z}] v1 v2 v3
#find normal to the plane made by the three points
#set normal [ veccross [vecsub $v2 $v1] [vecsub $v3 $v1] ]
set vec [vecsub $v2 $v1]
#we bring the v1 to the origin
set theTrans [transoffset [vecinvert $v1]]
#and rotate
set theRot [ transvecinv $vec]
#apply the transformation
set mat [transmult $theRot $theTrans]
$molSel move $mat
# now rotate v3 into the plane
lassign [$threeSel get {x y z}] v1 v2 v3
set v3_y [lindex $v3 1]
set v3_z [lindex $v3 2]
#find the angle around the x axis
set theta [expr atan ($v3_z / $v3_y) ]
if { $v3_y < 0 } {
set theta [expr $theta + $Pi]
}
#find the rotation for ( -theta) around the x axis
set mat [transaxis x -$theta rad]
#apply the transformation
$molSel move $mat
}
proc alignFrames {threeSel molSel first last} {
if {$first > $last } {
$first = $last
}
for {set i $first} {$i <= $last} {incr i} {
animate goto $i
display update
align $threeSel $molSel
}
}
===cut-here=====
-- Barry Isralewitz Beckman 3121 Theoretical Biophysics Group, UIUC Office Phone: (217) 244-1612 Home Phone: (217) 337-6364 email: barryi_at_ks.uiuc.edu http://www.ks.uiuc.edu/~barryi
- Next message: John Stone: "Announce: VMD 1.7 Released!!"
- Previous message: Jeff Taylor: "Re: fixing a molecule"
- In reply to: Mauricio Carrillo-Tripp: "fixing a molecule"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]