Icon representing a recipe

Recipe: simple wiggle by ones v2

created by LociOiling

Profile


Name
simple wiggle by ones v2
ID
102608
Shared with
Public
Parent
None
Children
Created on
January 30, 2018 at 05:37 AM UTC
Updated on
January 30, 2018 at 05:37 AM UTC
Description

Local wiggle each segment in the protein. Adapted from the original v1 version by themarquis.

Best for


Code


-- -- simple wiggle by ones v2 -- -- adapted from "simple wiggle by ones" by themarquis -- -- Converted to Foldit Lua interface v2 -- -- LociOiling - 2018/01/29 -- -- -- round numbers to three decimal places -- function round ( x ) return x - x % 0.001 end -- -- get and print the number of segments in the protein -- numSegs = structure.GetCount () print ( "segment count = " .. numSegs ) -- -- get and print the initial score -- startscore = current.GetEnergyScore () print ( "starting score = " .. round ( startscore ) ) -- -- This basic loop we be can used in many different scripts. -- It goes through each residue the protein and does something to it. for seg = 1, numSegs do -- -- make sure nothing is selected -- selection.DeselectAll () -- -- pick the segments to work on by selecting them -- for this recipe, we'll select just one segment -- selection.Select ( seg ) -- -- get the segment's score -- segscore = current.GetSegmentEnergyScore ( seg ) -- -- print the segment number and score -- print ( "segment " .. seg .. ", score = " .. round ( segscore ) ) -- -- apply the local wiggle tool -- structure.LocalWiggleSelected ( 5 ) -- -- get the segment's score -- afterscore = current.GetSegmentEnergyScore ( seg ) if afterscore > segscore then gain = round ( afterscore - segscore ) if gain > 0 then print ( "segment " .. seg .. " gained " .. gain ) else print ( "segment " .. seg .. " tiny gain" ) end end end -- -- print the final score -- endscore = current.GetEnergyScore () print ( "ending score = " .. round ( endscore ) .. ", gain = " .. round ( endscore - startscore ) )

Comments


LociOiling Lv 1

Simple wiggle by ones does a local wiggle of each segment in the protein.

This version has been converted to v2 of the Foldit Lua interface. The messages have been slightly expanded.

This recipe is discussed in Lua Scripting Tutorial (Intermediate) on the Foldit wiki. The tutorial is being updated to use the new version of the recipe.

Thanks to themarquis for the original recipe and tutorial.

WBarme1234 Lv 1

Loosing points instead winning - I prefer to gain only more points
(I tried it with puzzle 1496: -12 points)

robgee Lv 1

Nice, Thnx LociOiling.
Used it and the Tutorial to learn, then used it as a base to make my own version.