Icon representing a recipe

Recipe: SS Edit 1.0

created by LociOiling

Profile


Name
SS Edit 1.0
ID
49164
Shared with
Public
Parent
None
Children
Created on
May 20, 2014 at 03:20 AM UTC
Updated on
May 20, 2014 at 03:20 AM UTC
Description

Displays the current secondary structure. The displayed value can be cut or copied and a new value pasted in. Clicking the "Change" button applies the displayed value to the protein. Click "Exit" when any changes are complete.

Best for


Code


--[[ SS Edit Get and set secondary structure SS Edit displays the current secondary structure. The displayed value can be selected and cut or copied. A new value can be pasted in. When the "Change" button is clicked, the currently displayed secondary structure will be applied to the protein. SS Edit doesn't validate or edit the secondary structure codes. Only the foldit codes "H" for helix, "E" for sheet, and "L" for loop should be used. Other values may produce unpredictable results. If the structure list is longer than the protein, SS Edit discards the extra entries at the end of the list. If the structure list is shorter than the protein, SS Edit applies the list to the first *n* segments of the protein, where *n* is the length of the list. Any remaining segments are unchanged. All changes are written to the scriptlog. See "AA Copy Paste Compare v 1.1.1 -- Brow42" for a full-function recipe that works with primary and secondary structures. ]]-- -- -- Globals -- Recipe = "SS Edit" Version = "1.00" ReVersion = Recipe .. " v." .. Version -- -- end of globals section -- function getSS ( ) ssList = {} for ii = 1, structure.GetCount () do ssList [ #ssList + 1 ] = structure.GetSecondaryStructure ( ii ) end ssList = table.concat ( ssList, '' ) return ssList end function setSS ( tab ) for ii = 1, math.min ( #tab, structure.GetCount () ) do structure.SetSecondaryStructure ( ii, string.sub ( tab, ii, ii ) ) end end function GetParameters ( tab ) local dlog = dialog.CreateDialog ( ReVersion ) dlog.tab0 = dialog.AddLabel ( "Secondary structure" ) dlog.tab = dialog.AddTextbox ( "SStruct", tab ) dlog.u0 = dialog.AddLabel ( "" ) dlog.u1 = dialog.AddLabel ( "Usage: use select all and copy, cut, or paste" ) dlog.u2 = dialog.AddLabel ( "to save or change secondary structure" ) dlog.w0 = dialog.AddLabel ( "" ) dlog.w1 = dialog.AddLabel ( "Windows: ctrl + a = select all" ) dlog.w2 = dialog.AddLabel ( "Windows: ctrl + x = cut" ) dlog.w3 = dialog.AddLabel ( "Windows: ctrl + c = copy" ) dlog.w4 = dialog.AddLabel ( "Windows: ctrl + v = paste" ) dlog.z0 = dialog.AddLabel ( "" ) dlog.ok = dialog.AddButton ( "Change" , 1 ) dlog.exit = dialog.AddButton ( "Exit" , 0 ) if ( dialog.Show ( dlog ) > 0 ) then tab = dlog.tab.value return tab else return {} end end function main () print ( ReVersion ) print ( "Puzzle: " .. puzzle.GetName () ) print ( "Track: " .. ui.GetTrackName () ) local changeNum = 0 local ssList = {} repeat ssList = getSS () print ( "secondary structure, change # " .. changeNum ) print ( ssList ) ssList = GetParameters ( ssList ) if #ssList > 0 then changeNum = changeNum + 1 setSS ( ssList ) end until #ssList == 0 print ( ReVersion .. " complete" ) end function cleanup ( error ) print ( error ) end --main () xpcall ( main, cleanup )

Comments


LociOiling Lv 1

It's easy to lose changes to secondary structure, especially on design puzzles.

Some recipes change everything to loops, and either don't restore the original values or crash before they can.

You can save the structures via ctrl-shift-9 and restore them using ctrl-9 (on Windows), but this information is lost if the client crashes.

SS Edit displays the current secondary structure. You can cut or copy the displayed value (the "SStruct" field) and paste it into the editor or spreadsheet of your choice, or even save it in a segment note on the protein.

You can also paste in a new value. When you click the "Change" button, the value in the "SStruct" field is applied to the protein.

All the changes are logged to the scriptlog.

Make sure to use only the foldit codes "H" for helix, "E" for sheet, and "L" for loop. Any other values may produce Unpredictable Results.

See "AA Copy Paste Compare v 1.1.1 – Brow42" for a full-function recipe that works with both primary and secondary structure. https://fold.it/portal/recipe/38147