Hi there all,
I have the below code, which is to be interpreted in the software package VMD, and I am having some basic Tcl problems with it. Basically what I want to do is to open a file, discard the first line of that file, and then store the numerical value of the 4th column of the file in a variable called trpshift, which I will use in VMD to color individual molecules.
I know that the coloring part of the script works, because I was able to use a similar script successfully, but now my input files are a bit different and I need to discard the first line (this wasn't an issue before, because I had specially formatted files to access). I found an example of how to discard a line in Tcl on a webpage somewhere, but I keep getting the error "can not find channel number <file contents>" when the script reaches the first nested while loop, the one that is supposed to process the file data. It appears that the entire contents of $file_data are being expanded within the while evaluation, but I can't get this behavior to stop.
Can anyone offer any help with this issue? This is probably a very basic Tcl screw up on my part, but I can't seem to figure it out and would sincerely appreciate any help you can offer!
I have the below code, which is to be interpreted in the software package VMD, and I am having some basic Tcl problems with it. Basically what I want to do is to open a file, discard the first line of that file, and then store the numerical value of the 4th column of the file in a variable called trpshift, which I will use in VMD to color individual molecules.
I know that the coloring part of the script works, because I was able to use a similar script successfully, but now my input files are a bit different and I need to discard the first line (this wasn't an issue before, because I had specially formatted files to access). I found an example of how to discard a line in Tcl on a webpage somewhere, but I keep getting the error "can not find channel number <file contents>" when the script reaches the first nested while loop, the one that is supposed to process the file data. It appears that the entire contents of $file_data are being expanded within the while evaluation, but I can't get this behavior to stop.
Can anyone offer any help with this issue? This is probably a very basic Tcl screw up on my part, but I can't seem to figure it out and would sincerely appreciate any help you can offer!
Code:
while {$i >= $first && $i <= $last} {
set fp [open "/data/1stn/$mut/pd5/1stn_$mut_$i.pd5" r]
set file_data [read $fp]
close $fp
while {[gets $file_data line] >= -1 } {
set data [split $file_data "\n"]
foreach {one} $data {
lappend trpshift [lindex $one 3]
}
}
set prot [atomselect $mol_ID protein frame $j]
$prot frame $j
set user_list {}
for {set a 0} {$a < 136} {incr a} {
set u [lindex $trpshift $a]
lappend user_list $u $u $u
}
$prot set user $user_list
$prot delete
set wat [atomselect $mol_ID waters frame $j]
$wat frame $j
set user_list {}
for {set a 136} {$a < 10233} {incr a} {
set u [lindex $trpshift $a]
lappend user_list $u $u $u
}
$wat set user $user_list
$wat delete
set ions [atomselect $mol_ID ions frame $j]
$ions frame $j
set user_list {}
for {set a 10233} {$a < 10244} {incr a} {
set u [lindex $trpshift $a]
lappend user_list $u $u $u
}
$ions set user $user_list
$ions delete
unset trpshift
incr j 1
incr i 2
}