From: Nuno Loureiro Ferreira (nunolf_at_ci.uc.pt)
Date: Tue Aug 21 2007 - 16:34:25 CDT

J T wrote:
>> > Instead of
>> > set nwatlist [lsort $wlist]
>> >
>> > try,
>> > set nwatlist [lsort -unique $wlist]
>
>
> Tried it. Since the list elements are double valued (distance and
> residue number) the -unique does not work. Is a different way to set
> the list up so the -unique option would filter out all double residue
> numbers.

Right ;-)
Try instead
set nwatlist [lsort -unique -index 1 $wlist]

This way you will sort by uniqueness on the second element, in your
case, the residue number.

> Right now the ith list element is created with the command:
>
> lset wlist $i "$d $wres"
>
> where $d is the distance and $wres is the water residue number,
>
>
>
>
>
>
>
>
>
>
>
>
>
> On Aug 21, 2007, at 4:55 PM, Nuno Loureiro Ferreira wrote:
>
>> Hi JT
>>
>> Instead of
>> set nwatlist [lsort $wlist]
>>
>> try,
>> set nwatlist [lsort -unique $wlist]
>> N.
>>
>> J T wrote:
>>> Dear VMD Community,
>>>
>>> I've been working on a script that will select the N-closest waters
>>> to a specified atom selection by following the algorithm suggested
>>> by John Stone in an earlier post. It successfully returns a sorted
>>> list of increasing distances, but there are duplicate water
>>> residues. The script generates a list of all water indices within a
>>> max cutoff distance. Then each water index in that list is replaced
>>> with a double valued element containing the distance and the water
>>> residue. Is there a way I can use the -unique option somehow to fix
>>> this?
>>>
>>> Thank-you for reading,
>>> Jeff Tibbitt
>>> jtibbitt_at_odu.edu <mailto:jtibbitt_at_odu.edu>
>>>
>>>
>>> John Stone's algorithm:
>>> / 1) select all waters within the max cutoff distance M /
>>> / 2) calculate the distance D of each water molecule and add the
>>> index and //distance to a list or lists /
>>> / 3) sort the list(s) by the distance (keeping the water index and
>>> distance //assocation intact, if they are in separate lists..) /
>>> / 4) select the closest N waters from the sorted list// /
>>> /
>>> /
>>> /
>>> /
>>> /My Script:/
>>> proc nwat {n sel} {
>>> set lists [measure contacts 6 [atomselect top water] $sel]
>>> set wlist [lindex $lists 0]
>>> set slist [lindex $lists 1]
>>> set n [llength $wlist]
>>> for {set i 0} {$i < $n} {incr i} {
>>> set satom [lindex $slist $i]
>>> set watom [lindex $wlist $i]
>>> set wres [[atomselect top "index $watom"] get resid]
>>> set d [measure bond "$watom $satom"]
>>> lset wlist $i "$d $wres"
>>> } set nwatlist [lsort $wlist]
>>> }
>>> ------------------------------------------------------------------------
>>>
>>>
>>> No virus found in this incoming message.
>>> Checked by AVG Free Edition. Version: 7.5.484 / Virus Database:
>>> 269.12.0/961 - Release Date: 19-08-2007 7:27
>>>
>>
>
>
>