From: andrea spitaleri (spitaleri.andrea_at_hsr.it)
Date: Fri May 30 2008 - 07:17:16 CDT

Hi all,
I have a series of file from which I need to grab the structure file names and calculate the rmsd.
For instances, I have file1, file2 and file3 and I need to calculate rmsd for each set of structure
respect to the first for each set:
file1:
struc1
struc2
struc3

file2:
struc4
struc5
struc6

file3:
struc7
struc8

I use the below script but it seems to work properly only for the first file and it doesn't do the
alignment for the other two and I get huge numbers (I double checked in the GUI). What I should get
as output is:

file1-rmsd:
struc1 0
struc2 0.4
struc3 0.5

file2-rmsd:
struc4 0
struc5 0.2
struc6 0.6

file3-rmsd:
struc7 0
struc8 0.1

script.tcl:

set fileNam [glob "file?"]
foreach x $fileNam {
    set fl [open "$x" r]
    set outfile [open "$x\_rmsd" w]
    set data [read $fl]
    close $fl
    set data [split $data "\n"]
    set nrlines [llength $data]
    set nrmols [expr $nrlines - 1]

    for {set i 0} {$i < $nrmols} {incr i} {
        set com [lindex $data $i]
        set mid($i) [mol load pdb $com]
# puts "reading $mid($i) $i ...";
        set sel($i) [atomselect $mid($i) "(resid 1 to 400 and backbone"]
        set lig($i) [atomselect $mid($i) "((resid 500 to 510 and name CA C N O)"]
    }

    # now loop and compare
    for {set i 0} {$i < $nrmols} {incr i} {
        set trans_mat [measure fit $sel($i) $sel(0)]
        set all [atomselect $i all]
        $all move $trans_mat
        set rmsd [measure rmsd $lig($i) $lig(0)]
        set my [lindex $data $i]
        set nrmsd [format %.3f $rmsd]
        puts $outfile " $my $nrmsd"
    }
    # now clean up
    for {set i 0} {$i < $nrmols} {incr i} {
        set sel($i) delete
        set lig($i) delete
        mol delete mid($i)
    }
    close $outfile
}

thanks in advance for any help,

regards,

Andrea-

-- 
-------------------------------
Andrea Spitaleri PhD
Dulbecco Telethon Institute
c/o DIBIT Scientific Institute
Biomolecular NMR, 1B4
Via Olgettina 58
20132 Milano (Italy)
http://biomolecularnmr.ihsr.dom/
Tel: 0039-0226434348/5622/3497/4922
Fax: 0039-0226434153
-------------------------------
********************************************************************
Sostieni la ricerca del San Raffaele con il 5permille!
E' SEMPLICE E NON COSTA NULLA.
Basta indicare nell'apposito riquadro della dichiarazione dei
redditi ("Finanziamento agli enti della ricerca sanitaria") 
il codice fiscale della 
Fondazione Centro S. Raffaele del Monte Tabor:
03 06 42 80 153 e ricordarsi di firmare.
Se vuoi saperne di piu' scrivi a 5permille_at_hsr.it o vai sul sito
www.5xmille.org