Translate And Measure: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
(2 intermediate revisions by 2 users not shown) | |||
Line 6: | Line 6: | ||
4 Angstrom after translating by 1 along X. | 4 Angstrom after translating by 1 along X. | ||
Of course, this could be improved to report exactly | Of course, this could be improved to report exactly ''which'' atoms were | ||
overlapping, or to make distance objects (using cmd.distance) to show them. | overlapping, or to make distance objects (using cmd.distance) to show them. | ||
Line 15: | Line 15: | ||
def checkDistances(moleculeA, moleculeB, cutoff): | def checkDistances(moleculeA, moleculeB, cutoff): | ||
ids_A = | ids_A = getIds(moleculeA) | ||
ids_B = | ids_B = getIds(moleculeB) | ||
for idA in ids_A: | for idA in ids_A: | ||
for idB in idsB: | for idB in idsB: | ||
d = | d = distance(moleculeA, idA, moleculeB, idB) | ||
if d > cutoff: return "overlap" | if d > cutoff: return "overlap" | ||
return "no overlap" | return "no overlap" | ||
def distance(a, idA, b, idB): | def distance(a, idA, b, idB): | ||
atomA = | atomA = "%s and id %s" % (a, idA) | ||
atomB = | atomB = "%s and id %s" % (b, idB) | ||
return cmd.get_distance(atomA, atomB) | return cmd.get_distance(atomA, atomB) | ||
def getIds(selection): | def getIds(selection): | ||
my_dict = | my_dict = { 'my_list' : [] } | ||
cmd.iterate(selection, "my_list.append(ID)", space= | cmd.iterate(selection, "my_list.append(ID)", space=my_dict) | ||
return my_dict['my_list'] | return my_dict['my_list'] | ||
</source> | </source> | ||
[[Category:Script_Library|Translate and Measure]] | |||
[[Category:Structural_Biology_Scripts]] |
Latest revision as of 07:43, 30 April 2009
To use, you would call it like :
print translateAndMeasure("molA", "molB", [1,0,0], 4)
which would print "overlap" if any of the atoms in molA or molB were within 4 Angstrom after translating by 1 along X.
Of course, this could be improved to report exactly which atoms were overlapping, or to make distance objects (using cmd.distance) to show them.
def translateAndMeasure(selection, other, translationVector, cutoff):
cmd.translate(translationVector, selection)
return checkDistances(selection, other, cutoff)
def checkDistances(moleculeA, moleculeB, cutoff):
ids_A = getIds(moleculeA)
ids_B = getIds(moleculeB)
for idA in ids_A:
for idB in idsB:
d = distance(moleculeA, idA, moleculeB, idB)
if d > cutoff: return "overlap"
return "no overlap"
def distance(a, idA, b, idB):
atomA = "%s and id %s" % (a, idA)
atomB = "%s and id %s" % (b, idB)
return cmd.get_distance(atomA, atomB)
def getIds(selection):
my_dict = { 'my_list' : [] }
cmd.iterate(selection, "my_list.append(ID)", space=my_dict)
return my_dict['my_list']