Profile
- Name
- Band Hbonds
- ID
- 109257
- Shared with
- Public
- Parent
- None
- Children
- None
- Created on
- November 22, 2025 at 12:24 PM UTC
- Updated on
- January 01, 2026 at 08:11 AM UTC
- Description
from wiki
Best for
Code
-- example 3 - add a band between the indicated atoms
-- get the current length of the band,
-- report in a compact format
--
function round ( ii )
return ii - ii % 0.001
end
--
-- normalSeg - convert possible symmetric segment number
-- to segment number and chain
--
-- arguments:
--
-- seg2 - segment number to convert
-- segcnt - length of chain
-- symnum - number of symmetric chains (0 to n)
--
-- returns:
--
-- seg - segment number, in the range 1 to segcnt
-- symchn - symmetric chain number (0 to n)
--
function normalSeg ( seg2, segcnt, symnum )
if seg2 <= segcnt or symnum == 0 then
return seg2, 0
end
local endz = {}
for sym = 1, symnum do
endz [ #endz + 1 ] = segcnt * sym + sym + 1
end
local adjseg = 0
local adjsym = 0
for rng = #endz, 1, -1 do
if seg2 >= endz [ rng ] then
adjseg = seg2 - endz [ rng ] + 1
adjsym = rng
break
end
end
return adjseg, adjsym
end
bonds = structure.GetHBonds ()
print ( #bonds .. " hydrogen bonds found" )
segcnt = structure.GetCount ()
symcnt = structure.GetSymCount ()
for ii = 1, #bonds do
local res2, chn = normalSeg ( bonds [ ii ] [ "res2" ], segcnt, symcnt )
bx = band.AddBetweenSegments ( bonds [ ii ] [ "res1" ], res2,
bonds [ ii ] [ "atom1" ], bonds [ ii ] [ "atom2" ], chn )
if bx ~= nil and bx ~= 0 then
blen = band.GetLength ( bx )
print ( "bond " .. ii ..
", " .. bonds [ ii ] [ "res1" ] ..
" ( " .. bonds [ ii ] [ "atom1" ] ..
" ) - " .. res2 ..
" ( " .. bonds [ ii ] [ "atom2" ] ..
" ), chain = " .. chn ..
", width = " .. round ( bonds [ ii ] [ "width" ] ) ..
", current length = " .. round ( blen ) )
end
end