Quick dist
From PyMOLWiki
quick_dist will quickly find and write out the pairwise distances between two selections in PyMOL. On my machine this will write about 80,000 distance measures/second.
# # quick_dist.py # def quick_dist(s1, s2, inFile=None): import math m1 = cmd.get_model(s1) m2 = cmd.get_model(s2) if inFile!=None: f = open(inFile, 'w') f.write("ATOM1\tATOM2\tDIST\n") s="" for c1 in range(len(m1.atom)): for c2 in range(len(m2.atom)): s+="%s/%d\t%s/%d\t%3.2f\n" % (m1.atom[c1].name, m1.atom[c1].index,\ m2.atom[c2].name, m2.atom[c2].index,\ math.sqrt(sum(map(lambda f: (f[0]-f[1])**2, zip(a1.coord,a2.coord))))) if inFile!=None: f.write(s) f.close() else: print s cmd.extend("quick_dist", quick_dist)