From: Brian Radak (brian.radak_at_gmail.com)
Date: Fri Apr 27 2018 - 08:59:34 CDT

+1 to Giacomo.

For the record (although you should really read the documentation!) the
syntax for deleting a selection freeing up memory is:

<selection value> delete

as in this pseudocode:

set compare [atomselect top "residue 1"]
for # iterate frames {
  $compare frame $frame
  <measure>
}
$compare delete

I would hazard a guess that VMD attempts to clean up all such objects
whenever it exits, but it will almost always be much better to delete them
explicitly.

On Fri, Apr 27, 2018 at 8:01 AM, Giacomo Fiorin <giacomo.fiorin_at_gmail.com>
wrote:

> Any atom selection created in VMD will take up memory. I'm not sure if
> that's the cause in your case (how many POPC molecules are there?), but you
> should remove the selections that you don't use any more. The
> documentation of the atomselect command contains the syntax for that.
>
> Also, the "get" method for an atomselection returns the requested property
> for each atom in the selection. Try printing the result of "get residue".
>
> Giacomo
>
> On Fri, Apr 27, 2018 at 12:30 AM, Sadegh Faramarzi Ganjabad <
> safaramarziganjabad_at_mix.wvu.edu> wrote:
>
>> Hello all,
>>
>> I am trying to calculate RMSD of individual lipids in a protein-lipid
>> system. I found this code that aligns a single residue and gets the RMSD of
>> the entire trajectory.
>>
>> # Prints the RMSD of the protein atoms between each timestep
>> # and the first timestep for the given molecule id (default: top)
>> proc print_rmsd_through_time {{mol top}} {
>> # use frame 0 for the reference
>> set reference [atomselect $mol "residue X" frame 0]
>> # the frame being compared
>> set compare [atomselect $mol "residue X"]
>>
>> set num_steps [molinfo $mol get numframes]
>> for {set frame 0} {$frame < $num_steps} {incr frame} {
>> # get the correct frame
>> $compare frame $frame
>>
>> # compute the transformation
>> set trans_mat [measure fit $compare $reference]
>> # do the alignment
>> $compare move $trans_mat
>> # compute the RMSD
>> set rmsd [measure rmsd $compare $reference]
>> # print the RMSD
>> puts "RMSD of $frame is $rmsd"
>> }
>> }
>>
>>
>> but when I iterate this code for all lipid residues it takes a lot of memory and my computer freezes. I'm not sure why. Here is the code I'm using
>>
>>
>>
>> set selmode [[atomselect top "resname POPC"] get residue]
>> #gets stdin selmode
>> foreach r $selmode {
>>
>> # selection
>> set reference [atomselect top "residue $r" frame 0]
>> set compare [atomselect top "residue $r"]
>> set num_steps [molinfo top get numframes]
>> set output [open "rmsd_$r.dat" w]
>> # rmsd calculation loop
>> for {set frame 0} {$frame < $num_steps} {incr frame} {
>> # get the correct frame
>> $compare frame $frame
>>
>> # compute the transformation
>> set trans_mat [measure fit $compare $reference]
>> # do the alignment
>> $compare move $trans_mat
>> # compute the RMSD
>> set rmsd [measure rmsd $compare $reference]
>> # print the RMSD
>> #puts "$r"
>> puts $output "$rmsd"
>> }
>>
>> close $output
>>
>> }
>>
>>
>>
>> Does anybody know a better way of doing this?
>>
>> Thanks,
>> Sadegh Faramarzi,
>>
>> Research Assistant
>> West Virginia University, Department of Chemistry
>> Email:safaramarziganjabad_at_mix.wvu.edu
>>
>
>
>
> --
> Giacomo Fiorin
> Associate Professor of Research, Temple University, Philadelphia, PA
> Contractor, National Institutes of Health, Bethesda, MD
> http://goo.gl/Q3TBQU
> https://github.com/giacomofiorin
>