| 1 | # Find minimumum distance between two sets of atoms.
|
|---|
| 2 | def min_distance(spec1, spec2):
|
|---|
| 3 | from chimera.selection import OSLSelection
|
|---|
| 4 | s1 = OSLSelection(spec1)
|
|---|
| 5 | s2 = OSLSelection(spec2)
|
|---|
| 6 | dist = []
|
|---|
| 7 | for a1 in s1.atoms():
|
|---|
| 8 | for a2 in s2.atoms():
|
|---|
| 9 | d = a1.xformCoord().distance(a2.xformCoord())
|
|---|
| 10 | dist.append((d, a1, a2))
|
|---|
| 11 | dmin, a1, a2 = min(dist)
|
|---|
| 12 | return dmin, a1, a2
|
|---|
| 13 |
|
|---|
| 14 | d, a1, a2 = min_distance('#0:16.B@CA', '#0:.A')
|
|---|
| 15 | print 'Minimum distances', d, 'between', a1.oslIdent(), 'and', a2.oslIdent()
|
|---|
| 16 |
|
|---|