Profile


Name
clean 1.0
ID
103719
Shared with
Public
Parent
None
Children
None
Created on
July 19, 2020 at 20:11 PM UTC
Updated on
July 19, 2020 at 20:11 PM UTC
Description

Cleans up the pose after a recipe or a crash, by recentering, unfreezing, deleting band, and applying automatic secondary structures. Doesn't attempt to restore the best score.

Best for


Code


--[[ clean - clean the pose after a recipe or a crash For recovering from a crash or getting ready for sharing, clean does the following: * recenters the viewport * unfreezes all segments * deletes all bands * applys automatic structures The recipe doesn't attempt to restore the best score. Especially after a crash, the user may have to select the correct track and find the correct pose. version 1.0 - 2020/07/19 - LociOiling ]]-- Recipe = "clean" Version = "1.0" ReVersion = Recipe .. " " .. Version function main () print ( ReVersion ) print ( "Puzzle: " .. puzzle.GetName () .. " (" .. puzzle.GetPuzzleID () .. ")" ) print ( "Track: " .. ui.GetTrackName () ) print ( "--" ) -- -- disable filters -- filter.DisableAll () -- -- turn off undo -- undo.SetUndo ( false ) -- -- attempt to center the protein in the window -- (similar to the 'q' hotkey, doesn't reset the -- zoom level, and doesn't guarantee visibility) -- ui.CenterViewport () -- -- unfreeze the protein -- frz = freeze.GetCount () if frz > 0 then freeze.UnfreezeAll () print ( "unfroze " .. frz .. " segments" ) else print ( "no frozen segments found" ) end -- -- delete all bands -- bnd = band.GetCount () if bnd > 0 then band.DeleteAll () print ( "deleted " .. bnd .. " bands" ) else print ( "no bands found" ) end -- -- apply automatic secondary structures -- -- some design puzzles have segments with locked backbone, -- but moveable sidechains -- -- it's possible to change the secondary structure of -- these segments -- -- for example, many recipes set all segments to loop -- which affects these locked backbone, moveable sidechain -- segments -- -- the automatic structures option does not restore the -- original secondary structure in this case -- -- it's possible to do automatic structures segment-by-segment, -- but that's slower, and the effect is the same -- selection.SelectAll () structure.SetSecondaryStructureSelected ( "a" ) print ( "automatic secondary structures applied" ) -- -- enable filters -- filter.EnableAll () print ( "filters enabled" ) -- -- exit via cleanup -- cleanup () end function cleanup ( errmsg ) if CLEANUPENTRY ~= nil then return end CLEANUPENTRY = true print ( "---" ) local reason local start, stop, line, msg if errmsg == nil then reason = "complete" else -- -- civilized error reporting, thanks to Bruno K. and Jean-Bob -- start, stop, line, msg = errmsg:find ( ":(%d+):%s()" ) if msg ~= nil then errmsg = errmsg:sub ( msg, #errmsg ) end if errmsg:find ( "Cancelled" ) ~= nil then reason = "cancelled" else reason = "error" end end -- -- print recipe name, puzzle, track, time, score, and gain -- print ( ReVersion .. " " .. reason ) if reason == "error" then print ( "Unexpected error detected" ) print ( "Error line: " .. line ) print ( "Error: \"" .. errmsg .. "\"" ) end end xpcall ( main, cleanup )

Comments


LociOiling Lv 1

Recipes can leave frozen segments or hard-to-see bands that get in the way of further progress. Some recipes set all segments to loop and then leave them that way. And it's common for players to move the protein off the screen while a recipe is running in an attempt to speed things up a little.

"clean 1.0" attempts to recenter the protein in the Foldit window, then unfreezes everything and removes all bands. It also applies automatic secondary structures.

"clean 1.0" doesn't attempt to find the best score. Especially after a Foldit crash, players may need to select the correct track, then attempt to restore the best score. A recipe can't change the current track.

There are some limitations to the cleaning.

Re-centering the protein actually means centering the "camera" or "viewport" on the protein. The effect is similar to the 'q' hotkey. It centers and resets some of the visibility options, notably far cutoff, near cutoff, and fog. It doesn't reset the zoom level, so the protein may be almost invisible in the distance, or zoomed in too close for comfort.

Also this q-type recenter doesn't change the orientation of the protein. So if you dragged the protein off the screen, you'll still be looking at the same side when it's re-centered.

The Home key on Windows is similar, but resets the zoom level and the camera position. You may end up looking at a different side of the protein. Recipes can't do this type of re-centering.

Automatic secondary structures also has a slight glitch. Some puzzles, especially binder or docking puzzles, have segments with locked backbone, but moveable sidechains. It's possible to change the secondary structure assignment of these segments, either manually or using a recipe. The automatic secondary structures function won't change these segments, however. So a locked segment with a moveable sidechain may get changed from sheet or helix to loop by a recipe, but "clean 1.0" won't change it back. The same limitation applies to using the "Auto Structures" tool manually.

LociOiling Lv 1

The various methods for re-centering the protein and other puzzle parts have a common limitation. If a puzzle has multiple pieces – multiple protein chains or a mix of proteins and other molecules – the pieces may be far apart.

The hotkeys 'q' and 'Home' and the script function ui.CenterViewport all have some center point. We can't see the x, y, and z coordinates in Foldit, so it's not clear if the center point is 0, 0, 0 or some other point determined by the current pose.

In the extreme case of separate chains or other pieces being far apart, none of the centering options guarantees you'll be able to see anything. You may need to rotate the camera around by dragging on the background, and zoom out by shift-dragging upward on the background to see where things are.