From: Mustafa Tekpinar (tekpinar_at_buffalo.edu)
Date: Wed Feb 01 2012 - 13:38:34 CST

Hi,
After correcting my mistakes, I am posting my rmsd calculation over a
trajectory script with the hope it might be useful for other people.
//-------------------------------------------------------------
 #Purpose: This script calculates rmsd (of only CA atoms) between a
specified pdb file and each frame of a trajectory!

# It assumes that there is not any other structure loaded before!

#Author : Mustafa Tekpinar

#Email : tekpinar_at_buffalo.edu

#Date : February 1, 2012

if { $argc != 5 } {
    puts "Usage: vmd -dispdev text -e rmsd_traj.tcl -args trgt.pdb trj.psf
trj.dcd results.dat"
    exit -1
} else {
    set target_pdb [lindex $argv 0]
    puts "pdb file: [lindex $argv 0]"
    set traj_psf [lindex $argv 1]
    puts "psf file: [lindex $argv 1]"
    set traj_dcd [lindex $argv 2]
    puts "dcd file: [lindex $argv 2]"
    set results_file [lindex $argv 3]
    puts "Results file: [lindex $argv 3]"
}

# load reference pdb file

mol new ${target_pdb}
set reference [atomselect 0 "name CA"]

# load psf-dcd

mol new ${traj_psf} waitfor all
mol addfile ${traj_dcd} waitfor all

# the frame being compared

set compare [atomselect 1 "name CA"]

# open results file

set file [open "${results_file}" w ]

# determine number of frames in trajectory

set num_steps [molinfo 1 get numframes]

for {set frame 0} {$frame < $num_steps} {incr frame} {

    # get the correct frame

    $compare frame $frame

    # compute the transformation

    set trans_mat [measure fit $compare $reference]

    # do the alignment

    $compare move $trans_mat

    # compute the RMSD

    set rmsd [measure rmsd $compare $reference]

    # print rmsd (ca) to the results file

    puts $file "$frame \t$rmsd"
}
close $file
$compare delete
$reference delete
mol delete all
exit

//-------------------------------------------------------------
Regards,
Mustafa Tekpinar

On Tue, Jan 31, 2012 at 5:09 PM, Axel Kohlmeyer <akohlmey_at_gmail.com> wrote:

> oh, and please always send a copy of your
> responses to the mailing list, so that people
> see how problems get resolved.
>
> thanks,
> axel.
>
> On Tue, Jan 31, 2012 at 5:06 PM, Mustafa Tekpinar <tekpinar_at_buffalo.edu>
> wrote:
> > I think it doesnt make any significant difference if both arent doing the
> > job :)
> >
> //------------------------------------------------------------------------------
> >
> > Usage: vmd -dispdev text -e rmsd_traj.tcl -args pdb_name(W/out extension)
> > trj.psf trj.dcd
> > can't read "pdb_name": no such variable
> > can't read "target_pdb": no such variable
> > Cannot find molecule 0 in atomselect's 'molId'
> > can't read "pdb_name": no such variable
> > can't read "data_file_name": no such variable
> > can't read "traj_psf": no such variable
> > can't read "traj_dcd": no such variable
> > Cannot find molecule 1 in atomselect's 'molId'
> > molinfo: get: no molecule exists with id 1
> > can't read "num_steps": no such variable
> > can't read "file": no such variable
> > can't read "compare": no such variable
> > can't read "reference": no such variable
> > ERROR) No molecules loaded.
> > Info) VMD for LINUXAMD64, version 1.9 (October 12, 2011)
> > Info) Exiting normally.
> >
> //------------------------------------------------------------------------------
> > Mustafa
> >
> >
> > On Tue, Jan 31, 2012 at 4:55 PM, Axel Kohlmeyer <akohlmey_at_gmail.com>
> wrote:
> >>
> >> On Tue, Jan 31, 2012 at 2:48 PM, Mustafa Tekpinar <tekpinar_at_buffalo.edu
> >
> >> wrote:
> >> > Hi,
> >> > I am trying to calculate rmsd of a pdb file vs each frame of a
> >> > trajectory
> >> > and write results to a file. However, it doesn't work with arguments
> >> > properly. The error and the script is below:
> >> >
> >> > can't read "pdb_name": no such variable
> >> > can't read "target_pdb": no such variable
> >> > Cannot find molecule 0 in atomselect's 'molId'
> >> > can't read "pdb_name": no such variable
> >> > can't read "data_file_name": no such variable
> >> > can't read "traj_psf": no such variable
> >> > can't read "traj_dcd": no such variable
> >> > Cannot find molecule 1 in atomselect's 'molId'
> >> > molinfo: get: no molecule exists with id 1
> >> > can't read "num_steps": no such variable
> >> > can't read "file": no such variable
> >> > can't read "compare": no such variable
> >> > can't read "reference": no such variable
> >> > ERROR) No molecules loaded.
> >> > Info) VMD for LINUXAMD64, version 1.8.6 (April 6, 2007)
> >>
> >> don't you think it is time to upgrade to a more recent
> >> version of VMD after almost five years?
> >>
> >> axel.
> >>
> >>
> >>
> >> > Info) Exiting normally.
> >> >
> >> >
> >> >
> >> >
> //===========================================================================================================
> >> > if { $argc != 3 }
> >> > puts "Usage: vmd -dispdev text -e rmsd_traj.tcl -args
> >> > pdb_name(W/out
> >> > extension) trj.psf trj.dcd"
> >> > } else {
> >> > set pdb_name [lindex $argv 0]
> >> > puts "[lindex $argv 0]"
> >> > set traj_psf [lindex $argv 1]
> >> > puts "[lindex $argv 1]"
> >> > set traj_dcd [lindex $argv 2]
> >> > puts "[lindex $argv 2]"
> >> > }
> >> >
> >> > #set pdb_name
> >> > 1yzi
> >> > set target_pdb ${pdb_name}.pdb
> >> >
> >> > mol new ${target_pdb}
> >> > set reference [atomselect 0 "name CA"]
> >> >
> >> > set data_file_name rmsd_${pdb_name}_to_trj_test.dat
> >> > set file [open "$data_file_name" w]
> >> >
> >> > mol new ${traj_psf} waitfor all
> >> > mol addfile ${traj_dcd} waitfor all
> >> >
> >> > # the frame being
> >> > compared
> >> > set compare [atomselect 1 "name CA"]
> >> >
> >> > set num_steps [molinfo 1 get numframes]
> >> > for {set frame 0} {$frame < $num_steps} {incr frame} {
> >> >
> >> > # get the correct
> >> > frame
> >> > $compare frame $frame
> >> >
> >> > # compute the
> >> > transformation
> >> >
> >> > set trans_mat [measure fit $compare $reference]
> >> >
> >> > # do the
> >> > alignment
> >> > $compare move $trans_mat
> >> >
> >> > # compute the
> >> > RMSD
> >> > set rmsd [measure rmsd $compare $reference]
> >> >
> >> > # print the
> >> > RMSD
> >> > puts $file "$frame \t$rmsd"
> >> > }
> >> > close $file
> >> > $compare delete
> >> > $reference delete
> >> > mol delete all
> >> > exit
> >> >
> >> >
> //===========================================================================================================
> >> > Mustafa Tekpinar
> >> >
> >> > Department of Physics
> >> > SUNY at Buffalo,
> >> > Buffalo, NY
> >> >
> >>
> >>
> >>
> >> --
> >> Dr. Axel Kohlmeyer
> >> akohlmey_at_gmail.com http://goo.gl/1wk0
> >>
> >> College of Science and Technology
> >> Temple University, Philadelphia PA, USA.
> >
> >
>
>
>
> --
> Dr. Axel Kohlmeyer
> akohlmey_at_gmail.com http://goo.gl/1wk0
>
> College of Science and Technology
> Temple University, Philadelphia PA, USA.
>