Andreas,
In PyMOL:
print cmd.get_extent(selection)
where selection is the name of the molecule you'd loaded.
Note that the set of coordinates which define an XYZ extent do not necessarily correspond to only to atoms.
To find the two atoms most distant from one another, you could iterate over all pairs of coordinates. This is possible in PyMOL as shown below, but is impractically slow for large structures due to the N^2 dependence.
# PyMOL Script: longest_diagonal.pml
# takes 5-10 seconds with a 1,600 atom structure
# (1) extract all coordinates into a temporary array "xrd"
xrd = []
iterate_state 1, all, xrd.append( ((x,y,z), model+"`"+str(index)) )
python
from chempy import cpv
xrd_len = len(xrd)
# (2) measure all diagonals and keep the longest
diag = (-1.0,"none","none")
for i in range(xrd_len):
for j in range(i+1,xrd_len):
dst = cpv.distance(xrd[i][0], xrd[j][0])
if dst > diag [0]:
diag = (dst, xrd[i][1], xrd[j][1])
# (3) draw the longest diagonal
cmd.distance("diag", diag[1], diag[2])
python end
Cheers,
Warren
> -----Original Message-----
> From: CCP4 bulletin board [mailto:[log in to unmask]] On Behalf Of
> Andreas Förster
> Sent: Monday, April 20, 2009 10:25 AM
> To: [log in to unmask]
> Subject: [ccp4bb] largest distance between atoms
>
> Hey all,
>
> is there a script out there that computes the longest extent of a
> molecule and determines which atoms define the 'space diagonal'. In
> other words, I'm looking for the two atoms in a molecule that are most
> distant from each other.
>
> Thanks.
>
>
> Andreas
>
>
> --
> Andreas Förster, Research Associate
> Paul Freemont & Xiaodong Zhang Labs
> Department of Biochemistry, Imperial College London
> http://www.msf.bio.ic.ac.uk
>
>
>
|