From: Josh Vermaas (vermaas2_at_illinois.edu)
Date: Fri Dec 04 2015 - 09:04:34 CST

Hi Bryan,
Why not sort them so that you know that residA < residB, giving you an
upper-triangular table array? Another thing to consider is to have a
residlist that you reference, which saves you making atomselections
inside the innermost loop. This is what I would do instead:

set all [atomselect top "all"]
set residlist [$all get resid]

for {set i 0} {$i <= $numframes} {incr i} {
   $A frame $i
   $A update
   foreach {listA listB} [measure contacts $cutoff $A] break
   foreach indA $listA indB $listB {
        set residA [lindex $residlist $indA]
        set residB [lindex $residlist $indB]
        if { $residA > $residB } {
                set tmp $residA
                set residA $residB
                set residB $tmp
        }
        lappend contactTable($residA,$residB) $i
   }
}

-Josh Vermaas

On 12/03/2015 11:05 PM, Bryan Roessler wrote:
> Thanks Peter,
>
> I suppose then that the best way to iterate the over the list of contacts
> then is to simply combine both atom indices lists. I had been separating
> the atom pair lists using:
>
> for {set i 0} {$i <= $numframes} {incr i} {
> $A frame $i
> $A update
> foreach {listA listB} [measure contacts $cutoff $A] break
> foreach indA $listA indB $listB {
> set selA [atomselect top index $indA]
> set selB [atomselect top index $indB]
> set residA [$selA get resid]
> set residB [$selB get resid]
> $selA delete
> $selB delete
> lappend contactTable($residA,$residB) $i
> }
> }
>
> but obviously that's an issue when a single resid (residA or residB) is not
> tied to either listA or listB and is randomly distributed between the two,
> even when it is present in both *selection1* and *selection2*.
>
> Thus I would need to combine each list in my array by adding:
>
> lappend contactTable($residB,$residA) $i
>
> so that the contact pair is included regardless of the 'direction' of the
> measurement.
>
>
> Cheers,
> Bryan
>
> *Bryan Roessler | Graduate Research Assistant*
> UAB | The University of Alabama at Birmingham
> *uab.edu/cmdb <http://uab.edu/cmdb>*
> Knowledge that will change your world
>
> On Thu, Dec 3, 2015 at 9:14 PM, Peter Freddolino <petefred_at_umich.edu> wrote:
>
>> Hi Bryan,
>> It isn’t really an MWE if we don’t have the structure that you’re looking
>> at to try it out. But I’m pretty sure what you’re running into is that the
>> elementary object being enumerated by measure contacts is the *atom pair*