rotamer.SetRotamer Edit

void rotamer.SetRotamer(integer segmentIndex, integer position)
Snap the sidechain at the given segment to a rotamer. (Range 1 to rotamer.GetCount()).
V1 Function Name
More Information

rotamer.SetRotamer moves the sidechain of a given segment to a different rotamer position.

The related function rotamer.GetCount reports the number of rotamer positions available.

The number of rotamers available varies depending on the shape of the protein's backbone and perhaps other factors. wiggling the protein may change the rotamer count of some segments, reducing the number of rotamers available.

Passing an invalid rotamer to rotamer.SetRotamer terminates the recipe with an error. The Lua function pcall can be used to trap the error, see Using pcall to trap Lua errors for details.

Sample Edit

The code below moves all sidechains to their best position according to the "sidechain" score part. This code is likely to hurt the overall score by creating clashes as the the sidechains move.

This code doesn't wiggle the backbone, but there's still a chance the rotamer count could decrease as sidechains move, terminating the recipe.

for seg = 1, structure.GetCount() do
    save.Quicksave ( 4 )
    local scr = current.GetSegmentEnergySubscore ( seg, "sidechain" )
    for rot = 1, rotamer.GetCount ( seg ) do
        rotamer.SetRotamer ( seg, rot )
        if current.GetSegmentEnergySubscore ( seg, "sidechain" ) > scr then
            save.Quicksave ( 4 )
    save.Quickload ( 4 )