VMD-L Mailing List
From: Ludovic (ludomer_at_gmail.com)
Date: Tue Jun 18 2013 - 09:31:14 CDT
- Next message: Robert Johnson: "AutoIMD with Periodic Boundary Conditions"
- Previous message: Olaf Lenz: "Re: variable particle size"
- In reply to: John Stone: "Re: error: too many open files"
- Next in thread: Axel Kohlmeyer: "Re: error: too many open files"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
Hi John and Alex,
Thanks for your help!
So I tried adding a close at the end of the "readBF" part, but I still
have the same error message.
I used the "file channels" command to see the list of open channels and
all I have is "file13 stdin stdout stderr" when I use it just before the
close call and "stdin stdout stderr" when I use it after I call the
"readBF" process in the main part.
I also tried adding a "unset" but it doesn't seem to change anything.
I don't understand. Sorry, it's probably a silly mistake.
Cheers,
Ludovic
Here is how it looks at the moment:
proc readBF { fname } {
set all [atomselect top all]
set in [open $fname r]
set beta {}
set numat 0
while { [gets $in line] != -1 } {
switch -- [string range $line 0 3] {
ATOM -
HETA {
incr numat
lappend beta [expr [string range $line 61 66]]
}
}
}
#set z [file channels]
#puts $z
close $in
return $beta
}
proc makeanimallpdbwBF {start end fileformat thresh threshmax} {
set filename [format $fileformat [expr $start]]
mol new $filename type pdb waitfor all
mol modselect 0 top user < $thresh and not protein
mol modcolor 0 top ColorID 2
mol modstyle 0 top CPK 1.800000 0.300000 10.000000 2.000000
mol modmaterial 0 top AOEdgy
for {set i $start} {$i <= $end} {incr i 1} {
set filename [format $fileformat [expr $i]]
animate read pdb $filename
set all [atomselect top all]
set beta [readBF $filename]
#set x [file channels]
#puts $x
$all set user $beta
#unset beta
scale by 1.7
set filename $filename.rgb
render snapshot $filename
$all delete
animate delete all
}
}
On 13/06/2013 04:03, John Stone wrote:
> Hi,
> I don't see any "close" call in your script.
> For every file that you "open", there should be a matching "close"
> when you read the end of the file...
>
> Cheers,
> John
>
>
> On Thu, Jun 13, 2013 at 02:14:35AM +0200, Ludovic wrote:
>> Hi everyone!
>>
>> I'm trying to visualize the movement of atoms using a system with 8000
>> frames.
>> I'm using a Tcl script to load each frame (each in a single PDB file)
>> and make a screenshot with VMD.
>> The problem is that it stops at the 1000-ish frame giving me the error:
>> "couldn't read file XXX: too many open files"
>> (it works well if I use less than a 1000 frames)
>> (I'm using Ubuntu 10.4 64-bit and VMD 1.9.1)
>>
>> You can find the script I was using at the end of this post (version 1).
>>
>> I guess it's a memory problem so I tried modifying the script (version
>> 2) so it is creating a molecule, adding to it the first 1000 frames,
>> make the screenshots then delete the molecule, creating a second
>> molecule, adding to it the next 1000 frames...
>> But it gives me the same error.
>>
>> I also tried using the command "animate delete" at the end end of each
>> loop, but still the same error.
>> I really have no idea what to do. Maybe the problem is in the "readBF" part?
>>
>> I'd be really glad if someone could help me on this...
>>
>> I also have another question while I'm at it.
>> For the time being I'm using the user-field to save data for each atom,
>> so that, each frame, VMD checks if this value is higher than a value
>> "$thresh" for each atom and modify the color using a color scale.
>> What I would like (and couldn't manage) to do is, when an atom get a
>> higher value of $thresh, modify its color but keep this color for all
>> subsequent frames (and still modify its position).
>> I tried using "mol colupdate 1 top off" but it doesn't work, and the
>> colors go weird.
>> I can't use "mol drawframes" either since the position of the atoms will
>> not be updated.
>>
>> If you have an idea of some kind...
>>
>> Thank you very much!
>>
>> Regards,
>> Ludovic Mercier
>>
>>
>> ##########################################################
>> ##########################################################
>> ###
>> ### VERSION 1
>> ###
>>
>> ## Name:
>> ## makeanimallpdbwBF.tcl
>> ##
>>
>> proc readBF { fname } {
>> set all [atomselect top all]
>> set in [open $fname r]
>> set beta {}
>> set numat 0
>> while { [gets $in line] != -1 } {
>> switch -- [string range $line 0 3] {
>> ATOM -
>> HETA {
>> incr numat
>> lappend beta [expr [string range $line 61 66]]
>> }
>> }
>> }
>> return $beta
>> }
>>
>> #start is 1
>> #end is the total number of frames
>> proc makeanimallpdbwBF {start end fileformat thresh threshmax} {
>>
>> for {set i [expr $start]} {$i <= $end} {incr i 1} {
>> set filename [format $fileformat [expr $i]]
>> mol addfile $filename type pdb waitfor all
>> }
>>
>> for {set i $start} {$i <= $end} {incr i 1} {
>> set filename [format $fileformat [expr $i]]
>> set all [atomselect top all frame [expr $i-1]]
>> set beta [readBF $filename]
>> $all set user $beta
>> $all delete
>> }
>>
>> mol modselect 0 top user < $thresh and not protein
>> mol modcolor 0 top ColorID 2
>> mol modstyle 0 top CPK 1.800000 0.300000 10.000000 2.000000
>> mol modmaterial 0 top AOEdgy
>> #mol showperiodic top 0 xyXY
>> #mol numperiodic top 0 1
>> mol addrep top
>>
>> mol modselect 1 top user >= $thresh
>> mol modcolor 1 top user
>> mol modstyle 1 top CPK 2.600000 0.300000 10.000000 2.000000
>> mol modmaterial 1 top Opaque
>> #mol showperiodic top 1 xyXY
>> #mol numperiodic top 1 1
>> mol addrep top
>>
>> mol modselect 2 top protein
>> mol modcolor 2 top Name
>> mol modstyle 2 top CPK 1.500000 1.2000000 10.000000 2.000000
>> mol modmaterial 2 top BrushedMetal
>> #mol showperiodic top 2 xyXY
>> #mol numperiodic top 2 1
>> mol addrep top
>>
>> mol selupdate 0 top on
>> mol selupdate 1 top on
>> mol selupdate 2 top on
>> mol colupdate 0 top on
>> mol colupdate 1 top on
>> mol colupdate 2 top on
>>
>> #pbc set {41.259 41.259 41.259 90.0 90.0 90.0} -molid top -all
>> #pbc box -centersel protein -center com -color magenta
>>
>> color scale method BGR
>> color scale midpoint 0.2
>> mol scaleminmax top 1 $thresh $threshmax
>>
>> scale by 1.6
>>
>> for {set i [expr $start]} {$i <= $end} {incr i 1} {
>>
>> animate goto [expr $i-1]
>> set filename [format $fileformat [expr $i]]
>> set filename $filename.rgb
>> render snapshot $filename
>> }
>> #atomselect list
>> }
>>
>> ############################################
>> ############################################
>> ###
>> ### VERSION 2
>> ###
>>
>> ## Name:
>> ## makeanimallpdbwBF.tcl
>> ##
>>
>> proc readBF { fname } {
>> set all [atomselect top all]
>> set in [open $fname r]
>> set beta {}
>> set numat 0
>> while { [gets $in line] != -1 } {
>> switch -- [string range $line 0 3] {
>> ATOM -
>> HETA {
>> incr numat
>> lappend beta [expr [string range $line 61 66]]
>> }
>> }
>> }
>> return $beta
>> }
>>
>> proc makeanimallpdbwBF {start end fileformat thresh threshmax} {
>>
>> set filename [format $fileformat [expr $start]]
>> mol new $filename type pdb waitfor all
>>
>> mol modselect 0 top user < $thresh and not protein
>> mol modcolor 0 top ColorID 2
>> mol modstyle 0 top CPK 1.800000 0.300000 10.000000 2.000000
>> mol modmaterial 0 top AOEdgy
>>
>> mol addrep top
>> mol modselect 1 top user >= $thresh
>> mol modcolor 1 top user
>> mol modstyle 1 top CPK 2.600000 0.300000 10.000000 2.000000
>> mol modmaterial 1 top Opaque
>>
>> mol addrep top
>> mol modselect 2 top protein
>> mol modcolor 2 top Name
>> mol modstyle 2 top CPK 1.500000 1.2000000 10.000000 2.000000
>> mol modmaterial 2 top BrushedMetal
>>
>> color scale method BGR
>> color scale midpoint 0.2
>> mol scaleminmax top 1 $thresh $threshmax
>>
>> scale by 1.7
>>
>> for {set i $start} {$i <= 1000} {incr i 1} {
>>
>> set filename [format $fileformat [expr $i]]
>> animate read pdb $filename
>> set all [atomselect top all]
>> set beta [readBF $filename]
>> $all set user $beta
>>
>> set filename $filename.rgb
>> render snapshot $filename
>>
>> $all delete
>> }
>> animate delete all top
>>
>> mol delete top
>>
>> set filename [format $fileformat 1001]
>> mol new $filename type pdb waitfor all
>>
>> mol modselect 0 top user < $thresh and not protein
>> mol modcolor 0 top ColorID 2
>> mol modstyle 0 top CPK 1.800000 0.300000 10.000000 2.000000
>> mol modmaterial 0 top AOEdgy
>>
>> mol addrep top
>> mol modselect 1 top user >= $thresh
>> mol modcolor 1 top user
>> mol modstyle 1 top CPK 2.600000 0.300000 10.000000 2.000000
>> mol modmaterial 1 top Opaque
>>
>> mol addrep top
>> mol modselect 2 top protein
>> mol modcolor 2 top Name
>> mol modstyle 2 top CPK 1.500000 1.2000000 10.000000 2.000000
>> mol modmaterial 2 top BrushedMetal
>>
>> color scale method BGR
>> color scale midpoint 0.2
>> mol scaleminmax top 1 $thresh $threshmax
>>
>> scale by 1.7
>>
>> for {set i 1001} {$i <= 2000} {incr i 1} {
>>
>> set filename [format $fileformat [expr $i]]
>> animate read pdb $filename
>> set all [atomselect top all]
>> set beta [readBF $filename]
>> $all set user $beta
>>
>> set filename $filename.rgb
>> render snapshot $filename
>>
>> $all delete
>> }
>> animate delete all top
>>
>> #atomselect list
>> #mol list
>> }
- Next message: Robert Johnson: "AutoIMD with Periodic Boundary Conditions"
- Previous message: Olaf Lenz: "Re: variable particle size"
- In reply to: John Stone: "Re: error: too many open files"
- Next in thread: Axel Kohlmeyer: "Re: error: too many open files"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]