From: Vishal Kopardé (vishal.koparde_at_alumni.vanderbilt.edu)
Date: Fri Oct 19 2007 - 11:16:25 CDT

My complete code is attached.
I am running it with '-e' option.
Thank you,
Vishal

John Stone wrote:
> Hi,
> You haven't provided quite enough information to determine what is
> causing your problem. Can you send me the verbatim source code of your
> script and also the exact sequence of commands you're using to run it?
> Are you running the script interactively, or are you running it in batch
> mode by redirecting VMD's input/output, or with -e?
>
> Cheers,
> John Stone
> vmd_at_ks.uiuc.edu
>
> On Fri, Oct 19, 2007 at 10:03:24AM -0400, Vishal Kopardé wrote:
>
>> Hello,
>> I am having a very weird problem with bigdcd, that the number of
>> frames accessed is equal to the number of new line characters following
>> the bigdcd statement. How do I get over it? I have 5000 frames in my dcd
>> file and right now I am adding 5000 blank lines after the bigdcd
>> statement in the tcl file.
>> This problem was reported earlier but I could not find a
>> straightforward solution.
>>
>> tcl script
>> **********************
>> source bigdcd.tcl
>>
>> proc zeros {num} {
>> set list1 {}
>> for {set i 0} {$i<$num} {incr i} {
>> lappend list1 0
>> }
>> return $list1
>> }
>>
>> proc sumlists {list1 list2} {
>> if {[llength $list1] != [llength $list2] } {
>> echo " ERROR lists are unequal "
>> return
>> }
>> set list3 {}
>> foreach i $list1 j $list2 {
>> lappend list3 [expr $i + $j]
>> }
>> return $list3
>> }
>>
>> set psffile hex.psf
>> set dcdfile prod1.dcd
>> set hblength 3.50
>> set rshell 4.0
>> set hbangle 30
>>
>> set res {}
>> for {set k 1} {$k <=21} {incr k} {
>> lappend res $k
>> set f2 [open ${k}pmol1.dat w]
>> close $f2
>> unset f2
>> set f2 [open ${k}pmol2.dat w]
>> close $f2
>> unset f2
>> set f2 [open ${k}pmol1num.dat w]
>> close $f2
>> unset f2
>> set f2 [open ${k}pmol2num.dat w]
>> close $f2
>> unset f2
>> }
>> set res1 {}
>> for {set j 1} {$j <=30} {incr j} {
>> set k [expr $j+21]
>> lappend res1 $j
>> set f2 [open ${k}pmol1.dat w]
>> close $f2
>> unset f2
>> set f2 [open ${k}pmol2.dat w]
>> close $f2
>> unset f2
>> set f2 [open ${k}pmol1num.dat w]
>> close $f2
>> unset f2
>> set f2 [open ${k}pmol2num.dat w]
>> close $f2
>> unset f2
>> }
>>
>> proc doit { i } {
>> global res res1 hblength hbangle rshell
>> **********
>> STATEMENTS
>> ************
>> }
>>
>>
>> mol delete all
>> mol load psf $psffile
>> bigdcd doit $dcdfile
>>
>> 5000 blank lines here
>> ************
>>
>>
>> Your help is greatly appreciated.
>> Thank you,
>> Vishal
>>
>> --
>> Vishal N Kopardé, Ph.D.
>> http://www.people.vcu.edu/~vnkoparde/
>>
>
>

-- 
Vishal N Kopardé, Ph.D.
http://www.people.vcu.edu/~vnkoparde/

source bigdcd.tcl

proc zeros {num} {
set list1 {}
for {set i 0} {$i<$num} {incr i} {
lappend list1 0
}
return $list1
}

proc sumlists {list1 list2} {
if {[llength $list1] != [llength $list2] } {
echo " ERROR lists are unequal "
return
}
set list3 {}
foreach i $list1 j $list2 {
lappend list3 [expr $i + $j]
}
return $list3
}

set psffile hex.psf
set dcdfile prod1.dcd
set hblength 3.50
set rshell 4.0
set hbangle 30

set res {}
for {set k 1} {$k <=21} {incr k} {
        lappend res $k
        set f2 [open ${k}pmol1.dat w]
        close $f2
        unset f2
        set f2 [open ${k}pmol2.dat w]
        close $f2
        unset f2
        set f2 [open ${k}pmol1num.dat w]
        close $f2
        unset f2
        set f2 [open ${k}pmol2num.dat w]
        close $f2
        unset f2
}
set res1 {}
for {set j 1} {$j <=30} {incr j} {
        set k [expr $j+21]
        lappend res1 $j
        set f2 [open ${k}pmol1.dat w]
        close $f2
        unset f2
        set f2 [open ${k}pmol2.dat w]
        close $f2
        unset f2
        set f2 [open ${k}pmol1num.dat w]
        close $f2
        unset f2
        set f2 [open ${k}pmol2num.dat w]
        close $f2
        unset f2
}
        
proc doit { i } {
        global res res1 hblength hbangle rshell
        foreach resid $res {
                set res_suffix {0 4 8}
                set temp1 {}
                foreach suff $res_suffix {
                        set chain "IA${suff}"
                        set t1 "resid $resid and segid $chain and not backbone and not carbon and noh"
                         set sel1 [atomselect top "$t1"]
                         set sel2 [atomselect top "water and noh"]
                        set hb1 [measure hbonds $hblength $hbangle $sel1 $sel2]
                        set hb2 [measure hbonds $hblength $hbangle $sel2 $sel1]
                        $sel1 delete
                        $sel2 delete
                        set hb10 [lindex $hb1 0]
                        set hb11 [lindex $hb1 1]
                        set hb20 [lindex $hb2 0]
                        set hb21 [lindex $hb2 1]
                        foreach j $hb10 k $hb11 {
                                if { $j < $k } {
                                        set t1 "$j$k"
                                        lappend temp1 $t1
                                }
                                if { $j > $k } {
                                        set t1 "$k$j"
                                        lappend temp1 $t1
                                }
                        }
                        foreach j $hb20 k $hb21 {
                                if { $j < $k } {
                                        set t1 "$j$k"
                                        lappend temp1 $t1
                                }
                                if { $j > $k } {
                                        set t1 "$k$j"
                                        lappend temp1 $t1
                                }
                        }
                        set nhbd1 [llength [lindex $hb1 0]]
                        set nhbd2 [llength [lindex $hb2 0]]
                        set f2 [open ${resid}pmol1num.dat a]
                        puts $f2 "$i $nhbd1 $nhbd2 [expr $nhbd1 + $nhbd2]"
                        close $f2
                        unset t1 hb1 hb2 hb10 hb11 hb21 hb20 nhbd1 nhbd2 f2
                }
                set f2 [open ${resid}pmol1.dat a]
                puts $f2 "$temp1"
                close $f2
                unset temp1 f2
                set res_suffix {2 6 10}
                set temp2 {}
                foreach suff $res_suffix {
                        set chain "IA${suff}"
                        set t1 "resid $resid and segid $chain and not backbone and not carbon and noh"
                         set sel1 [atomselect top "$t1"]
                         set sel2 [atomselect top "water and noh"]
                        set hb1 [measure hbonds $hblength $hbangle $sel1 $sel2]
                        set hb2 [measure hbonds $hblength $hbangle $sel2 $sel1]
                        $sel1 delete
                        $sel2 delete
                        set hb10 [lindex $hb1 0]
                        set hb11 [lindex $hb1 1]
                        set hb20 [lindex $hb2 0]
                        set hb21 [lindex $hb2 1]
                        foreach j $hb10 k $hb11 {
                                if { $j < $k } {
                                        set t1 "$j$k"
                                        lappend temp2 $t1
                                }
                                if { $j > $k } {
                                        set t1 "$k$j"
                                        lappend temp2 $t1
                                }
                        }
                        foreach j $hb20 k $hb21 {
                                if { $j < $k } {
                                        set t1 "$j$k"
                                        lappend temp2 $t1
                                }
                                if { $j > $k } {
                                        set t1 "$k$j"
                                        lappend temp2 $t1
                                }
                        }
                        set nhbd1 [llength [lindex $hb1 0]]
                        set nhbd2 [llength [lindex $hb2 0]]
                        set f2 [open ${resid}pmol2num.dat a]
                        puts $f2 "$i $nhbd1 $nhbd2 [expr $nhbd1 + $nhbd2]"
                        close $f2
                        unset t1 hb1 hb2 hb10 hb11 hb21 hb20 nhbd1 nhbd2 f2
                }
                set f2 [open ${resid}pmol2.dat a]
                puts $f2 "$temp2"
                close $f2
                unset temp2 f2
        }
        foreach resid $res1 {
                set m [expr $resid + 21]
                set res_suffix {1 5 9}
                set temp1 {}
                foreach suff $res_suffix {
                        set chain "IA${suff}"
                        set t1 "resid $resid and segid $chain and not backbone and not carbon and noh"
                         set sel1 [atomselect top "$t1"]
                         set sel2 [atomselect top "water and noh"]
                        set hb1 [measure hbonds $hblength $hbangle $sel1 $sel2]
                        set hb2 [measure hbonds $hblength $hbangle $sel2 $sel1]
                        $sel1 delete
                        $sel2 delete
                        set hb10 [lindex $hb1 0]
                        set hb11 [lindex $hb1 1]
                        set hb20 [lindex $hb2 0]
                        set hb21 [lindex $hb2 1]
                        foreach j $hb10 k $hb11 {
                                if { $j < $k } {
                                        set t1 "$j$k"
                                        lappend temp1 $t1
                                }
                                if { $j > $k } {
                                        set t1 "$k$j"
                                        lappend temp1 $t1
                                }
                        }
                        foreach j $hb20 k $hb21 {
                                if { $j < $k } {
                                        set t1 "$j$k"
                                        lappend temp1 $t1
                                }
                                if { $j > $k } {
                                        set t1 "$k$j"
                                        lappend temp1 $t1
                                }
                        }
                        set nhbd1 [llength [lindex $hb1 0]]
                        set nhbd2 [llength [lindex $hb2 0]]
                        set f2 [open ${m}pmol1num.dat a]
                        puts $f2 "$i $nhbd1 $nhbd2 [expr $nhbd1 + $nhbd2]"
                        close $f2
                        unset t1 hb1 hb2 hb10 hb11 hb21 hb20 nhbd1 nhbd2 f2
                }
                set f2 [open ${m}pmol1.dat a]
                puts $f2 "$temp1"
                close $f2
                unset temp1 f2
                set res_suffix {3 7 11}
                set temp2 {}
                foreach suff $res_suffix {
                        set chain "IA${suff}"
                        set t1 "resid $resid and segid $chain and not backbone and not carbon and noh"
                         set sel1 [atomselect top "$t1"]
                         set sel2 [atomselect top "water and noh"]
                        set hb1 [measure hbonds $hblength $hbangle $sel1 $sel2]
                        set hb2 [measure hbonds $hblength $hbangle $sel2 $sel1]
                        $sel1 delete
                        $sel2 delete
                        set hb10 [lindex $hb1 0]
                        set hb11 [lindex $hb1 1]
                        set hb20 [lindex $hb2 0]
                        set hb21 [lindex $hb2 1]
                        foreach j $hb10 k $hb11 {
                                if { $j < $k } {
                                        set t1 "$j$k"
                                        lappend temp2 $t1
                                }
                                if { $j > $k } {
                                        set t1 "$k$j"
                                        lappend temp2 $t1
                                }
                        }
                        foreach j $hb20 k $hb21 {
                                if { $j < $k } {
                                        set t1 "$j$k"
                                        lappend temp2 $t1
                                }
                                if { $j > $k } {
                                        set t1 "$k$j"
                                        lappend temp2 $t1
                                }
                        }
                        set nhbd1 [llength [lindex $hb1 0]]
                        set nhbd2 [llength [lindex $hb2 0]]
                        set f2 [open ${m}pmol2num.dat a]
                        puts $f2 "$i $nhbd1 $nhbd2 [expr $nhbd1 + $nhbd2]"
                        close $f2
                        unset t1 hb1 hb2 hb10 hb11 hb21 hb20 nhbd1 nhbd2 f2
                }
                set f2 [open ${m}pmol2.dat a]
                puts $f2 "$temp2"
                close $f2
                unset temp2 f2
        }
}

        mol delete all
        mol load psf $psffile
        bigdcd doit $dcdfile

exit