Foldit Wiki
Advertisement

structure.GetDistance

Function
number structure.GetDistance(integer segmentIndex1, integer segmentIndex2)
Description
Return distance between two segments.
V1 Function Name
get_segment_distance

structure.GetDistance returns the distance in Angstroms between two segments of the protein.

The distance reported is normally very close to the length of a band added between the same segments by band.AddBetweenSegments.

The values of both segmentIndex1 and segmentIndex2 must be in the range 1 to structure.GetCount, or the function generates an error, terminating the recipe. segmentIndex1 and segmentIndex2 may be the same value, in which case the distance is zero.

The code below compares the two techniques for measuring distances when the two segments are different.


local seg1 = 45
local seg2 = 60
local dist1 = structure.GetDistance ( seg1, seg2 )
print ( "distance from " .. seg1 .. " to " .. seg2 .. " = " .. dist1 )

local bndx = band.AddBetweenSegments ( seg1, seg2 )
if bndx ~= nil and bndx ~= 0 then
    local dist2 = band.GetLength ( bndx )
    print ( "band length from " .. seg1 .. " to " .. seg2 .. " = " .. dist2 )
end

The output might be:

distance from 45 to 60 = 4.5700070572249
band length from 45 to 60 = 4.5700070572249

A segment can't be banded to itself, so the band technique won't work if seg1 == seg2.

Advertisement