Icon representing a recipe

Recipe: Blue Fuse 2020b

created by marsfan

Profile


Name
Blue Fuse 2020b
ID
103547
Shared with
Public
Parent
Blue Fuse 2020
Children
Created on
June 16, 2020 at 03:53 AM UTC
Updated on
June 16, 2020 at 03:53 AM UTC
Description

Updated version of Blue Fuse v1.1 by Vertex, January 2010 - see https://fold.it/portal/recipe/2052

Changes in May 27, 2020 version: Added support for disabling filters before wiggling and shaking, script now repeats untill there is no more gain, now does 25 iterations of wiggle and 2 iterations of shake.

June 15, 2020 Changes:
Added ability to scale CI values so CI never exceeds user set CI.
Added a menu that allows the user to control the number of wiggle iterations, shake iterations, wheter or not to scale CI values, whether or not to repeat untill no score change, whether or not to disable filters when wiggling/shaking, and display a help menu.
Added a cleanup routine to reset the CI, restore recent best, and re-enable filters if the user presses cancel

Best for


Code


-- -- Blue Fuse 2020a - 21 March 2020 - see notes at end -- -- Global settings values. changed by user setting the GUI wiggleIterations = 25 shakeIterations = 2 scaleCI = true repeatFuse = true filterOnRun = true ciScaleFactor = 1 -- New dialog function to add a gap in a dialog dialog.AddNewline = function() return dialog.AddLabel("") end function enableFilters(state) if filterOnRun then behavior.SetFiltersDisabled(not state) end end function fuse() enableFilters(true) startScore = current.GetEnergyScore () -- Get the current energy score. print ( "starting score = " .. startScore ) -- print the starting score enableFilters(false) behavior.SetClashImportance ( 0.05 * ciScaleFactor) -- Set the clashing importance. structure.ShakeSidechainsAll ( shakeIterations) -- Shake all sidechains. behavior.SetClashImportance ( 1.00 * ciScaleFactor ) -- Reset the clashing importance. structure.WiggleAll ( wiggleIterations ) -- Global wiggle all segments. enableFilters(true) print ( "after first shake/wiggle, score = " .. current.GetEnergyScore () ) enableFilters(false) behavior.SetClashImportance ( 0.07 * ciScaleFactor) -- Set the clashing importance. structure.ShakeSidechainsAll ( shakeIterations ) -- Shake all sidechains. behavior.SetClashImportance ( 1.00 * ciScaleFactor) -- Reset the clashing importance. structure.WiggleAll ( wiggleIterations ) -- Global wiggle all segments. enableFilters(true) print ( "after second shake/wiggle, score = " .. current.GetEnergyScore () ) recentbest.Restore () -- Load the recent best pose. print ( "after restoring recent best, score = " .. current.GetEnergyScore () ) enableFilters(false) behavior.SetClashImportance ( 0.3 * ciScaleFactor) -- Set the clashing importance. structure.WiggleAll (shakeIterations) -- Global wiggle all segments. behavior.SetClashImportance ( 1.00 * ciScaleFactor ) -- Reset the clashing importance. structure.WiggleAll ( wiggleIterations ) -- Global wiggle all segments. enableFilters(true) print ( "after final wiggle, score = " .. current.GetEnergyScore () ) recentbest.Restore () -- Load the recent best pose. finalScore = current.GetEnergyScore () -- Get the current energy score. print ( "final score = " .. finalScore ) -- print the final score gain = finalScore - startScore -- calculate the gain print ( "gain = " .. gain ) -- print the gain print ( "Blue Fuze 2020b complete" ) return gain end function makeGUI() local options = dialog.CreateDialog("Blue Fuse 2020b") options.wiggleIterations = dialog.AddTextbox("Wiggle Iterations", tostring(wiggleIterations)) options.shakeIterations = dialog.AddTextbox("Shake Iterations", tostring(shakeIterations)) options.scaleCI = dialog.AddCheckbox("Scale CI To Current Value", scaleCI) options.repeatFuse = dialog.AddCheckbox("Repeat Until Gain = 0", repeatFuse) options.filterOnRun = dialog.AddCheckbox("Disable filters",filterOnRun) options.OK = dialog.AddButton("OK", 1) options.help = dialog.AddButton("Help", 2) options.cancel = dialog.AddButton("Cancel", 0) return options end function textToValidNumber(text) -- Try to convert text to a number converted = tonumber(text) -- Check that number converted properly, is not nan, is an integer, and is greater than 1 -- If any of the tests fail, return a boolean false if converted and (converted == converted) and (converted%1 == 0) and (converted >=0) then return converted else return false end end function showBadNumber(invalidSetting) local badNumberDialog = dialog.CreateDialog("Invalid Value") badNumberDialog.label = dialog.AddLabel("The value for "..invalidSetting.." is invalid") badNumberDialog.label2 = dialog.AddLabel("Please set it to a positive integer.") badNumberDialog.button = dialog.AddButton("OK", 1) dialog.Show(badNumberDialog) end function updateSettingsVars(optionMenu) valuesAreGood = true wiggleIterationsCheck = textToValidNumber(optionMenu.wiggleIterations.value) shakeIterationsCheck = textToValidNumber(optionMenu.shakeIterations.value) scaleCI = optionMenu.scaleCI.value repeatFuse = optionMenu.repeatFuse.value filterOnRun = optionMenu.filterOnRun.value if not wiggleIterationsCheck then valuesAreGood=false showBadNumber("Wiggle Iteraions") else wiggleIterations = wiggleIterationsCheck end if not shakeIterationsCheck then valuesAreGood = false showBadNumber("Shake Iterations") else shakeIterations = shakeIterationsCheck end return valuesAreGood end function showHelp() local helpMenu = dialog.CreateDialog("Blue Fuse 2020b Help") helpMenu.wiggleHelp = dialog.AddLabel("Wiggle Iterations: How many cycles of wiggle to run") helpMenu.WiggleHelp2 = dialog.AddLabel("each time script starts wiggling protein.") helpMenu.space1 = dialog.AddNewline() helpMenu.shakeHelp = dialog.AddLabel("Shake Iterations: How many cycles of shake to run") helpMenu.shakeHelp2 = dialog.AddLabel("each time script starts shaking protein.") helpMenu.space2 = dialog.AddNewline() helpMenu.scaleHelp = dialog.AddLabel("Scale CI to Current Value: Scale defualt CI values") helpMenu.scaleHelp2 = dialog.AddLabel("so that max CI is never greater than currently set") helpMenu.scaleHelp3 = dialog.AddLabel("CI value. Useful if you want to fuse, but keep CI") helpMenu.scaleHelp4 = dialog.AddLabel("below a specific value. ") helpMenu.space3 = dialog.AddNewline() helpMenu.repeatHelp = dialog.AddLabel("Repeat Until Gain = 0: Repeat Blue Fuse 2020b until") helpMenu.repeatHelp2 = dialog.AddLabel("no more score gain.") helpMenu.space4 = dialog.AddNewline() helpMenu.filterHelp = dialog.AddLabel("Disable Filters: Disable filters when wiggling and") helpMenu.filterHelp2 = dialog.AddLabel("shaking to speed up script.") helpMenu.OK = dialog.AddButton("OK", 0) dialog.Show(helpMenu) end function main() recentbest.Save () -- Save the current pose as the recent best pose. existingCI = behavior.GetClashImportance() print ( "Blue Fuze 2020b" ) -- Keep looping so that we can re-draw GUI if user makes a mistake, or presses help while true do options = makeGUI() selection = dialog.Show(options) -- Check if user pressed cancel, if not, update the settings to what the user input. if (selection == 0) then break else if updateSettingsVars(options) then if (selection == 1) then if scaleCI then ciScaleFactor = existingCI else ciScaleFactor = 1 end if repeatFuse then repeat fuse() until(gain <= 0) else fuse() end break elseif (selection == 2) then showHelp() end end end end end function cleanup(err) if string.find(err, "Cancelled") then print("User Cancelled") else print(err) end recentbest.Restore() behavior.SetFiltersDisabled(false) behavior.SetClashImportance(existingCI) end -- -- original: Blue Fuse v1.1 by Vertex 3 January 2010 - https://fold.it/portal/recipe/2052 -- -- BlueFuse 2020a - LociOiling - 21 March 2020 -- + converted to Foldit Lua interface V1 to V2 -- + added printing scores and gain -- + dropped "select_all", not needed with ShakeSidechainsAll and WiggleAll -- -- BlueFuse 2020b - marsfan - 27 May 2020 -- + Added ability to disable filters to improve performance -- + Script now repeats untill no more gain -- + Wiggle Iterations changed to 25 -- + Shake Iterations changed to 2 -- -- BlueFuse 2020b2 - marsfan - 16 June 2020 -- + Added ability to scale clash importance settings -- + Added quicksaving so that pressing cancel reverts to recent best score. -- + Added GUI to enable/disable repeat, enable/disable scaling of CI, and set iteration counts. -- + Add built in help for options -- -- Some potential improvements: -- -- TODO: round the score to three decimals -- TODO: repeat the process if there's a gain -- TODO: try different values for clashing importance -- TODO: try a different number of iterations for -- TODO: add a dialog to control settings -- xpcall(main, cleanup)

Comments


Formula350 Lv 1

You sure that you want 25 Iters of SHAKE and only 2 of Wiggle?

That seems opposite of what most people would want.

:)
-Form