[gmx-users] Re: Trouble loading User data with a Tcl script (only half the data seems to load)

J. Nathan Scott scottjn at chemistry.montana.edu
Thu May 5 22:35:36 CEST 2011


Hello again, fellow gmx-users,

I finally found my coding error that only set the User data for the first
half of the frames loaded, it was a simple indexing error after all.
However, I would still *greatly* appreciate any assistance with speeding up
the following loop:

        for {set k 6} {$k <= 141} {incr k} {
        set prot [atomselect $mol_ID "resid $k" frame $j]
        set num [$prot num]
        $prot frame $j
        set user_list {}
        set u [lindex $efield [expr $k - 6]]
        for {set b 1} {$b <= $num} {incr b} {
           lappend user_list $u
        }
        $prot set user $user_list
        $prot delete
        }

Is there a simpler way to accomplish the task of assigning a single User
value to individual residues without first atomselecting each one, getting
its number of atoms, and then finally looping over the atoms to build a
user_list? I'm hoping that there is some better way to do this that I
haven't thought of yet. My script runs very wonderfully except for this
chunk.

Thanks in advance for any help you can provide,

-Nathan

On Wed, May 4, 2011 at 11:06 AM, J. Nathan Scott <
scottjn at chemistry.montana.edu> wrote:

> Hello all,
>
> I have written a script that does per-time-step coloring of the water
> molecules, residues, and ions in my protein based on electric field values I
> previously calculated. I received excellent help here a few months sorting
> out some problems with the script, but there is one big one remaining that I
> hope someone can help with.
>
> The problem is that only half the frames (the first half) in my simulation
> are getting colored, and I can't figure out why. This happens no matter how
> many frames I load, whether the full trajectory or just a few hundred
> frames. For what it's worth, the machine I'm running on has 12 GB of RAM, a
> very nice video card, and a new Xeon quad core processor, so I don't think
> this is an issue of system resources. At least I can see that there is still
> tons of free RAM when I am experiencing this issue.
>
> Also, I would sincerely appreciate any advice on speeding up one of my
> loops. To color the water molecules and ions I can simply atomselect them
> all, and then loop through the values from the electric field data file for
> that timestep and assign the color value to a user list either 3 or 1 times
> respectively to color each atom.
>
> However, for the residues in the protein I am having to atomselect them one
> at a time, get the number of atoms for that residue, and then do another
> loop to build a list of the correct length to assign the user values to each
> atom of the residue. Can anyone recommend a more efficient way of coloring
> the residues? When the residue coloring part of the script is stripped out
> it runs so much faster despite the fact that there are far fewer protein
> atoms than there are water or ion atoms, so I know this method of assignment
> is sluggish.
>
> Please see the script below my signature, and thank you in advance for any
> advice you can provide.
>
> --
> ----------
> J. Nathan Scott, Ph.D.
> Postdoctoral Fellow
> Department of Chemistry and Biochemistry
> Montana State University
>
>
>
>
> #######################################################################
> set first 0;
> set last 1000;
> set mut wt;
> set mut_ wt_;
> set i $first; #i will be timestep/filename indicator,
> set j 0;
>
> mol new /data/1stn/xtc/1stn_$mut.gro type gro waitfor all
> mol addfile /data/1stn/xtc/1stn_$mut.xtc type xtc waitfor all first $first
> last $l$
> set mol_ID top;
> set n [ molinfo $mol_ID get numframes ];
> animate goto 0
> animate delete  beg 0 end 0 skip 0 0
> mol delrep 0 $mol_ID
>
> while {$i <= $last} {
>         set fp [open "/data/1stn/$mut/pd5/pd5.stripped/1stn_$mut_$i.pd5" r]
>         set file_data [read $fp]
>         close $fp
>
>         set data [split $file_data "\n"]
>         foreach {one} $data {
>                 lappend efield [lindex $one 3]
>         }
>
> ### Looping through residues in the for loop,
> ### selecting one residue at a time, getting its number of atoms,
> ### and then building a user value list for each of those
> ### atoms in another for loop.
>
>         for {set k 6} {$k <= 141} {incr k} {
>         set prot [atomselect $mol_ID "resid $k" frame $j]
>         set num [$prot num]
>         $prot frame $j
>         set user_list {}
>         set u [lindex $efield [expr $k - 6]]
>         for {set b 1} {$b <= $num} {incr b} {
>            lappend user_list $u
>         }
>         $prot set user $user_list
>         $prot delete
>         }
>
> ### Water loop works well
>
>         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 $efield $a]
>                 lappend user_list $u $u $u
>         }
>         $wat set user $user_list
>         $wat delete
>
> ### Ion loop works well too
>
>         set ions [atomselect $mol_ID ions frame $j]
>         $ions frame $j
>         set user_list {}
>         for {set a 10233} {$a < 10243} {incr a} {
>                 set u [lindex $efield $a]
>                 lappend user_list $u
>         }
>         $ions set user $user_list
>         $ions delete
>
>         unset efield
>         incr j 1
>         incr i 2
> }
>
>
>
>


-- 
----------
J. Nathan Scott, Ph.D.
Postdoctoral Fellow
Department of Chemistry and Biochemistry
Montana State University
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://maillist.sys.kth.se/pipermail/gromacs.org_gmx-users/attachments/20110505/cf49e51d/attachment.html>


More information about the gromacs.org_gmx-users mailing list