Profile


Name
AddMax 1.0
ID
102636
Shared with
Public
Parent
None
Children
Created on
March 05, 2018 at 22:00 PM UTC
Updated on
March 05, 2018 at 22:00 PM UTC
Description

Adds the maximum number of segments (residues) allowed. Useful for design puzzles with a variable number of segments.

Best for


Code


-- -- AddMax -- -- adds as many segments as possible -- -- 1.0 - LociOiling - 2018/03/02 -- Recipe = "AddMax" Version = "1.0" ReVersion = Recipe .. " " .. Version print ( ReVersion ) undo.SetUndo ( false ) behavior.SetFiltersDisabled ( true ) local segcnti = structure.GetCount () local segcnt = segcnti print ( "initial segment count = " .. segcnti ) local ok = true repeat local ss1 = structure.GetSecondaryStructure ( segcnt - 1 ) structure.SetSecondaryStructure ( segcnt - 1, "E" ) local ss2 = structure.GetSecondaryStructure ( segcnt ) structure.SetSecondaryStructure ( segcnt, "E" ) local aa2 = structure.GetAminoAcid ( segcnt ) -- -- add segment before the last segment -- ok = structure.InsertResidue ( segcnt - 1 ) structure.SetSecondaryStructure ( segcnt - 1, ss1 ) structure.SetSecondaryStructure ( segcnt, ss2 ) segcnt = structure.GetCount () if ok then -- -- set secondary structure of last segment -- structure.SetSecondaryStructure ( segcnt, ss2 ) -- -- set amino acid of added segment -- structure.SetAminoAcid ( segcnt - 1, aa2 ) end until not ok local segcnt = structure.GetCount () if segcnti == segcnt then print ( "no segments added" ) else print ( segcnt - segcnti .. " segments added" ) end print ( "final segment count = " .. segcnt ) print ( ReVersion .. " complete" ) undo.SetUndo ( true ) behavior.SetFiltersDisabled ( false )

Comments


LociOiling Lv 1

Recent design puzzles have a variable number of segments. Players can add segments up to a specified maximum. Each added segment carries a penalty.

AddMax adds segments (residues) until the maximum number is reached.

Segments are added one at a time, before the last segment. To keep things straight, the last and next to last segments are changed to sheet before the new segment is added. This forces the new segment to be part of the sheet. This feature is useful for preserving the straight "extended chain" found at the beginning of a design puzzle.

The inserted segment is mutated to the same amino acid as the last segment in the puzzle. The inserted segment is also set to the same secondary structure as the last segment had initially.

The last and the old-next-to-last segment are reset to their initial secondary structure.