Foldit Wiki
Advertisement

structure.GetHBonds

Function
table structure.GetHBonds()
Description
Returns table of hydrogen bond information.
V1 Function Name
New to V2

structure.GetHBonds returns a table containing information about the hydrogen bonds in the current protein. The table also contains information about any disulfide bridges that are present.

The table returned has one entry per hydrogen bond. Each entry in turn is a table of keyword-value pairs. The keywords in this table are:

  • bond_type - 0 for hydrogen bond, 1 for disulfide bridge
  • res1 - the residue/segment for the first side of the bond
  • atom1 - the atom number for the first side of the bond
  • res2 - the residue/segment for the second side of the bond
  • atom2 - the atom number for the second side of the bond
  • width - "width" generally ranges between 0.25 Å (bad) and 0.75 Å (good)

For a symmetry puzzle, the segment number returned in "res2" may be higher than the number of segments indicated by structure.GetCount, indicating the hydrogen bond ends on one of the symmetric chains. See normalizing a segment number for a discussion of how to handle this case.

Example

The three examples below show demonstrate how to work with the table returned by structure.GetHBonds. The first two examples show different ways to access the data. The third example demonstrates adding bands to match the hydrogen bonds.

The use of keyword-value pairs for the inner table is alternative to storing values in numbered columns. One advantage is that the keyword identifies each item, where a column number does not.

In the first example, the Lua code demonstrates calling structure.GetHBonds and listing the contents of the table. This approach uses an inner for loop to list each keyword and its value. The inner for loop uses the "pairs" operator to extract a keyword and its value. This avoids needing to know what the keywords are in advance:

bonds = structure.GetHBonds ()
print ( #bonds .. " hydrogen bonds found" )
for ii = 1, #bonds do
   for kk, vv in pairs ( bonds [ ii ] ) do
      print ( "bond " .. ii .. ", key = " .. kk .. ", value = " .. vv )
   end
end

The output would look like this:

43 hydrogen bonds found
bond 1, key = bond_type, value = 0
bond 1, key = res1, value = 2
bond 1, key = atom1, value = 9
bond 1, key = atom2, value = 4
bond 1, key = res2, value = 3
bond 1, key = width, value = 0.3332012580951
bond 2, key = bond_type, value = 0
bond 2, key = res1, value = 7
bond 2, key = atom1, value = 4
bond 2, key = atom2, value = 1
bond 2, key = res2, value = 28
bond 2, key = width, value = 0.35813907692404
bond 3, key = bond_type, value = 0
bond 3, key = res1, value = 9
bond 3, key = atom1, value = 1
bond 3, key = atom2, value = 4
bond 3, key = res2, value = 26
bond 3, key = width, value = 0.620498880888
...and so on...

For structure.GetHBonds, we know the keywords for each entry. The keyword name can be used to address the values as a second dimension of the table, as the second example shows:

bonds = structure.GetHBonds ()
print ( #bonds .. " hydrogen bonds found" )

for ii = 1, #bonds do
   print ( "bond " .. ii .. 
       ", segment 1 = " .. bonds [ ii ] [ "res1" ] .. 
       ", atom 1 = " .. bonds [ ii ] [ "atom1" ] .. 
       ", segment 2 = " .. bonds [ ii ] [ "res2" ] ..
       ", atom 2 = " .. bonds [ ii ] [ "atom2" ] ..
       ", length = " .. bonds [ ii ] [ "width" ] )
end

The keyword names, such as "res1", "res2", and "width", must be enclosed in single or double quotes, as shown in the example.

The output from this example looks like this:

bond 1, segment 1 = 2, atom 1 = 9, segment 2 = 3, atom 2 = 4, length = 0.3332012580951
bond 2, segment 1 = 7, atom 1 = 4, segment 2 = 28, atom 2 = 1, length = 0.35813907692404
bond 3, segment 1 = 9, atom 1 = 1, segment 2 = 26, atom 2 = 4, length = 0.620498880888
...and so on...

As a third example, the output from structure.GetHBonds can be used to add bands with band.AddBetweenSegments, and then adjust the goal length of the band with band.SetGoalLength. The "width" element seems to be a relative "goodness" factor, and is not the actual length of the bond. In this example, however, width is simply used as the goal length of the band, in Angstroms, which produces incorrect band lengths.

bonds = structure.GetHBonds ()
print ( #bonds .. " hydrogen bonds found" )

for ii = 1, #bonds do
    bx = band.AddBetweenSegments ( bonds [ ii ] [ "res1" ], bonds [ ii ] [ "res2" ],
            bonds [ ii ] [ "atom1" ], bonds [ ii ] [ "atom2" ] )
    if bx ~= nil and bx ~= 0 then
        band.SetGoalLength ( bx, bonds [ ii ] [ "width" ] )
    end
end

This last example doesn't produce any output, except the bands.

Advertisement