VMD-L Mailing List
From: John Stone (johns_at_ks.uiuc.edu)
Date: Fri Jan 23 2015 - 00:20:52 CST
- Next message: John Stone: "Re: VMD killed despite using $sel delete and unset sel"
- Previous message: MannyEful E: "VMD killed despite using $sel delete and unset sel"
- In reply to: MannyEful E: "VMD killed despite using $sel delete and unset sel"
- Next in thread: John Stone: "Re: VMD killed despite using $sel delete and unset sel"
- Maybe reply: John Stone: "Re: VMD killed despite using $sel delete and unset sel"
- Maybe reply: John Stone: "Re: VMD killed despite using $sel delete and unset sel"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
Hi,
Your return statement in the angle proc occurs before you
call the $sel delete commands, so they are not being executed at all.
Move the return statement so it is the last line of the proc and that
should cure your problem assuming there aren't other issues that I didn't see.
Cheers,
John Stone
vmd_at_ks.uiuc.edu
On Fri, Jan 23, 2015 at 05:18:10AM +0000, MannyEful E wrote:
> Hello Everyone,
>
> I wrote a script to calculate the tetrahedral orientation order parameter
> of liquid water over time. Could anyone advise me on what causes VMD to be
> killed despite the use of "$sel delete" / "unset sel" / "array unset sel"?
> I imagine that this is a memory leak problem, however I can't spot it.
>
> Thanks in advanced for your time and help!
>
> Script:
> ##################################################################################
> #: TitleA A A A A A : q4_calc.tclA A A A A A A A A A A A A A A
> A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A
> A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A
> A A A A A A A A A A A A A A A #
> #: Description : Get the tetrahedral orientation parameter for
> watersA A A A A A A A A A A A A A A A A A A A A A A A A A A A
> A A A A A A A A A A A A A #
> #: Usage:A A A A A A A A A A A vmd -dispdev text -gro test.gro -e
> q4_calc_bulk.tcl A A A A A A A A A A A A A A A A A A A A A A A A
> A A A A A A A A A A A A A A A A #
> ##################################################################################
>
> proc angle {Di Hi Ai} {
>
> # Calculates angles between three points
> # select atoms
> set selD [atomselect top "resid $Di and name OW"];A A A A A # select
> atom1
> set selH [atomselect top "index $Hi and name OW"];A A A A # select atom2
> set selA [atomselect top "resid $Ai and name OW"];A A A A A # select
> atom3
> A
> # obtain corresponding coordinates
> set D [lindex [$selD get {x y z}] 0];
> set H [lindex [$selH get {x y z}] 0];
> set A [lindex [$selA get {x y z}] 0];
>
> # obtain cosine of the angle between the 3 selected atoms
> A global M_PI;A A A A A A A A A A A A A A A A A A A A # get pi value
> A set hd [vecsub $D $H];A A A A # calculate hd vector
> A set ha [vecsub $A $H];A A A A # calculate ha vector
> A set cosine [expr [vecdot $hd $ha] / ( [veclength $hd] * [veclength
> $ha])];A A # calculate cosine
>
> # return [expr acos($cosine)*(180.0/$M_PI)]; A A # convert cosine to
> angle in degreesA A
> A return $cosine
> A
> # delete variables we do not need any moreA
> $Di delete;
> $Hi delete;
> $Ai delete;
> $selD delete;
> $selH delete;
> $selA delete;
> $D delete;
> $H delete;
> $A delete;
> $hd delete;
> $ha delete;
> A
> }
>
> proc nwat {n sel} {
> A # Calculates the n nearest neighbours
> A # reset the l3 variables to become an empty array
> A set l3 {};
>
> A # find the oxygens within 10 angstroms of the selection
> A set lists [measure contacts 10 [atomselect top "name OW"] $sel];
>
> A # obtains the list of oxygens indices
> A set wlist [lindex $lists 0];
>
> A # obtain the list of the selection atoms indices
> A set slist [lindex $lists 1];
>
> A # for every listed selection and its corresponding oxygen
> A # get the residue number for the oxygen
> A # get the distance between the twoA
> A # appends this distance and corresponding resids to a list called l1
> A foreach satom $slist watom $wlist {
> A A A set wresnum [[atomselect top "index $watom"] get resid];
> A A A set d [measure bond "$watom $satom"];
> A A A lappend l1 [list $wresnum $d];
> A }
>
> A # make a variable called l1 which sorts out the 4 closest distancesA
> A # appends the 4 atom resids to a list called l3
> A set l2 [lrange [lsort -index 1 [lsort -unique -index 0 [lsort -index 1
> -decreasing $l1]]] 0 [expr $n - 1]];
> A #puts " F ";A
> A foreach water $l2 {
> A A A lappend l3 "[lindex $water 0]";
> A }
>
> A # returns a list of resids for the 4 nearest
> A return $l3;
>
> # delete variables we do not need any moreA A
> array unset $selD;
> array unset $selA;
> array unset $selH;
> array unset $D;
> array unset $A;
> array unset $H;
> $Di delete; unset Di;
> $Hi delete; unset Hi;
> $Ai delete; unset Ai;
> $selD delete; array unset selD;
> $selH delete;array unset selH;
> $selA delete;array unset selA;
> $D delete;array unset D;
> $H delete;array unset A;
> $A delete; array unset A;
> $hd delete;array unset hd;
> $ha delete;array unset ha;
> A
> }
>
> # assign a filename
> ##A set q_file [open "q_19Jan2015_sla_260K_0-3_8.txt" w];
>
> # define the number of frames
> set end 3;
> A
> # make a selection for which q will be calculated
> set total_wat [atomselect top "name OW and (resname SLA) "];A
> A A
> # loop through all the framesA
> for { set i 0 } { $i < $end } { incr i} {A
> A
> A A A A A A # go to the specified frame
> A A A A A A animate goto $i;
> A A A A A
> A A A A A A # selection refreshed for the new frame
> A A A A A A $total_wat frame $i;
>
> A A A A A A # counts the number of atoms selected
> A A A A A A set num_Totalwat [$total_wat num];
> A A A A A
> A A A A A A # get the residue indices and atom indices for selection
> A A A A A A set wat_resid [$total_wat get resid];
> A A A A A A set wat_index [$total_wat get index];
>
> A A A A A A # sets a counter to zero
> A A A A A A set checkingNums 0;
>
> A A A A A A # for each water we do the following
> A A A A A A foreach waterID $wat_index waterRID $wat_resid {
>
> A A A A A A # add 1 to the counter and print out so we know how far into
> the loop we have gone
> A A A A A A incr checkingNums;
> A A A A A A puts " WATER $checkingNums OF $num_Totalwat ";A
> A A A A A A A A
> A A A A A A # make a temporary selection using the atom indices and
> residue indicesA A
> A A A A A A set wat_coord [atomselect top "name OW and index $waterID and
> resid $waterRID"];A
> A
> A A A A A A # find the 4 closest waters to this atom
> A A A A A A set close_wat [nwat 4 $wat_coord];
>
> A A A A A # Find all the possible 3 angle combinations which can be made
> with the 4 neighbour whilst wat_coord is at the centre
> A A A # set the sum to zero A A A A A A A A A A A A A A A A A A A A A
> A A A A A A set sum 0.0;
>
> A A A A A A # set counter to zero
> A A A A A A set countAngles 0;
> A A A A A A for { set k 0 } { $k < 4 } { incr k } {A
> A A A A A A A A A A for { set l [expr $k+1] } { $l < 4 } { incr l } {A
>
> A A A A A A A A A A A A A A # add 1 to angles which have been calculated.
> The final value should always be 6 for 4 neighbours.
> A A A A A A A A A A A A A A incr countAngles;
>
> A A A A A A A A A A A A A A # select the first atom index
> A A A A A A A A A A A A A A set hi1 "[lindex $close_wat $k]";
>
> A A A A A A A A A A A A A A # select the reference atom index
> A A A A A A A A A A A A A A set atom2 [[atomselect top "name OW and
> (index $waterID and resid $waterRID)"] get {index}];
>
> A A A A A A A A A A A A A A # select the third atom indexA
> A A A A A A A A A A A A A A set hi3 "[lindex $close_wat $l]";A
>
> A A A A A A A A A A A A A A # calculate the angle usin proc calcangle
> defined earlier
> A A A A A A A A A A A A A A set calcangle [angle $hi1 $atom2 $hi3];
> A
> A A A A A A A A A A A A A A # add up cosine results to those from
> previous angles
> A A A A A A A A A A A A A A set sum [expr
> {(($calcangle+1.0/3.0)*($calcangle+1.0/3.0))+$sum}];
> A
> A A A A A A A A A A }A
> A A A A A A }
> A
> A A A A A # define the q value
> A A A A A A set q [expr {1.0-((3.0/8.0)*$sum)}];
>
> A A A A A A # print theA A A A FrameA A A A A A A Loop
> numberA A A A A A A Atom index A A A A A A A Q valueA A A A details to
> file
> A A A A A A puts [format "Frame: $i\t ID: $checkingNums \t AtomIDX:
> $waterID \t Q: %.2f"A A $q];
> A
> ##A puts $q_file "ID: $checkingNumsA A A AtomIDX: $waterIDA A Q: $q";A
> # print details to file
> A
> A A A A }
>
> A A A A A # delete variables we do not need any moreA A A A A A
> A A A A A $wat_coord delete; array unset wat_coord;
> A A A A A $close_wat delete; array unset close_wat;
> A A A A A $k delete; array unset k;
> A A A A A $l delete; array unset l;
> A A A A A $hi1 delete; array unset hi1;
> A A A A A $atom2 delete; array unset atom2;
> A A A A A $hi3 delete; array unset hi3;
> A A A A A $calcangle delete; array unset calcangle;
> A A A A A $sum delete; array unset sum;
> A A A A A $q delete; array unset q;
> A A A A A A
>
> ##A A puts $q_file "END"; # add END line after every frame
>
> # delete variables we do not need any moreA A
> A $total_wat delete; array unset total_wat;
> A $num_Totalwat delete; array unset num_Totalwat;
> A $wat_resid $delete; array unset wat_resid;
> A $wat_index delete; array unset wat_index;
> A $waterID delete; array unset waterID;
> A $waterRID delete; array unset waterRID;
> A $checkingNums delete; array unset checkingNums;
> A $countAngles delete; array unset countAngles;
> A
> A A }A
>
> ##A A puts $q_file " "; # add empty newline to file
>
> ##A A close $q_file;A A A # close file
>
> # delete variables we do not need any moreA A
> $total_wat delete;
> A
> A
>
> END
-- NIH Center for Macromolecular Modeling and Bioinformatics Beckman Institute for Advanced Science and Technology University of Illinois, 405 N. Mathews Ave, Urbana, IL 61801 http://www.ks.uiuc.edu/~johns/ Phone: 217-244-3349 http://www.ks.uiuc.edu/Research/vmd/
- Next message: John Stone: "Re: VMD killed despite using $sel delete and unset sel"
- Previous message: MannyEful E: "VMD killed despite using $sel delete and unset sel"
- In reply to: MannyEful E: "VMD killed despite using $sel delete and unset sel"
- Next in thread: John Stone: "Re: VMD killed despite using $sel delete and unset sel"
- Maybe reply: John Stone: "Re: VMD killed despite using $sel delete and unset sel"
- Maybe reply: John Stone: "Re: VMD killed despite using $sel delete and unset sel"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]