Icon representing a recipe

Recipe: Mutate Tweak Worst v0.1 BETA - Brow 42

created by brow42

Profile


Name
Mutate Tweak Worst v0.1 BETA - Brow 42
ID
40448
Shared with
Public
Parent
None
Children
Created on
July 18, 2012 at 16:40 PM UTC
Updated on
July 18, 2012 at 16:40 PM UTC
Description

Like Tlaloc mutate all, but sorted by score. and quicker fuzing. Frozen segs are skipped. Early release, untested.

Best for


Code


--[[ * Mutate Worst * Original Author: Brow42 Apr 8 2012 * This script combines the functions of Mutate Combo * Mutate All Acid Tweak Sidechain Tweak, but does so * start from the worst scoring segment. It also is * less rigorous about stabilizing after tweak/mutation. * Version 0.1 Quick release for end of puzzle 537 2102/4/8 * For each AA (optionally, only mutable AAs): * Perform a sidechain tweak (optional fuze after each tweak) * Perform a mutation (optional fuze or tweak after each mutation) * Starts with lowest scoring AA --]] title = 'Simple Mutate-Tweak Worst 0.1 BETA' beta_date = os.time({year=2012, month=9, day=31}) _,has_mutables = pcall(function() for i = 1,structure.GetCount() do if structure.IsMutable(i) then return true end end return false end) do_mutate = true and has_mutables do_sidechain = false or not has_mutables do_fuze = true aa_list = { 'a', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'k', 'l', 'm', 'n', 'p', 'q', 'r', 's', 't', 'v', 'w', 'y' } score_type = '' shake_radius = 15 mutable_only = true and has_mutables n_shakes = 10 n_wiggles = 10 print(title) print(puzzle.GetName(),current.GetScore()) if beta_date and beta_date < os.time() then local d = dialog.CreateDialog('Beta Expired') d.msg = dialog.AddLabel('This beta software has expired.') d.msg2 = dialog.AddLabel('Please download a new copy today!') d.ok = dialog.AddButton('Ok!',1) dialog.Show(d) end function MakeDialog() local d = dialog.CreateDialog(title) if beta_date then d.beta = dialog.AddLabel(string.format( ' * This is a BETA recipe that expires %s.',os.date('%b. %d %Y',beta_date))) end d.label1 = dialog.AddLabel('Peforms Mutate and/or Tweak on Worst') d.label2 = dialog.AddLabel('Fuze or Tweak will be performed after each mutation') d.mutate = dialog.AddCheckbox('Do Mutation',do_mutate) d.sidechain = dialog.AddCheckbox('Do Sidechain Tweak',do_sidechain) d.fuze = dialog.AddCheckbox('Do Simple Fuze: LCI S CI1 W LCI W CI1 W',do_fuze) d.onlymute = dialog.AddCheckbox('Only Do Mutable',mutable_only) d.ok = dialog.AddButton('Go',1) d.cancel = dialog.AddButton('Cancel',0) local rc = dialog.Show(d) if rc == 0 then return 0 end do_mutate = d.mutate.value do_sidechain = d.sidechain.value do_fuze = d.fuze.value mutable_only = d.onlymute.value return 1 end if MakeDialog() == 0 then print('Canceled') return end function GetSegmentScore(iSeg) if score_type == '' then return current.GetSegmentEnergyScore(iSeg) end return current.GetSegmentEnergySubscore(iSeg,score_type) end _BestScore = -math.huge function ResetBest() _BestScore = current.GetEnergyScore() save.Quicksave(100) end function SaveBest() if current.GetEnergyScore() > _BestScore then ResetBest() end end function RestoreBest() save.Quickload(100) end if structure.IsLocked == nil then structure.IsLocked = function() return false end end function Select(iSeg) selection.SelectRange(iSeg,shake_radius) end function DoWiggle() structure.WiggleSelected(n_wiggles) end function DoShake() structure.ShakeSidechainsSelected(n_shakes) end function DoFuze() behavior.SetClashImportance(0.3) DoShake() behavior.SetClashImportance(1.0) DoWiggle() behavior.SetClashImportance(0.5) DoWiggle() behavior.SetClashImportance(1.0) DoWiggle() SaveBest() end function DoSidechain(iSeg) local n_rot = rotamer.GetCount(iSeg) if n_rot < 2 then return end print(' Optimizing',iSeg,n_rot,'rotamers') for r = 1,n_rot do rotamer.SetRotamer(iSeg,r) Select(iSeg) -- redundant? DoShake() -- need to freeze here if do_fuze then DoFuze() else DoShake() DoWiggle() end SaveBest() end end targets = {} for i = 1,structure.GetCount() do if structure.GetSecondaryStructure(i) ~= 'M' then if (structure.IsMutable(i) or not mutable_only) and not (structure.IsLocked(i) or freeze.IsFrozen(i)) then targets[#targets+1] = {i, GetSegmentScore(i) } end end end function SortFunc(a,b) return a[2] < b[2] end table.sort(targets,SortFunc) print('Found',#targets,'segments to mutate/tweak.') selection.DeselectAll() for iSeg = 1, #targets do save.Quicksave(3) ResetBest() Select(targets[iSeg][1]) local s = current.GetScore() print(iSeg,'Seg',targets[iSeg][1],targets[iSeg][2]) if do_mutate then for iaa = 1, #aa_list do structure.SetAminoAcid(targets[iSeg][1],aa_list[iaa]) DoShake() DoWiggle() SaveBest() if do_fuze and not do_sidechain then DoFuze() end if do_sidechain then DoSidechain(targets[iSeg][1]) end end else if do_fuze then DoFuze() else DoWiggle() SaveBest() end if do_sidechain then DoSidechain(targets[iSeg][1]) end end selection.DeselectAll() RestoreBest() if s < current.GetScore() then print('Improvement to',current.GetScore(),current.GetScore()-s) end end

Comments


Rav3n_pl Lv 1

THIS SCRIPT STARTED ON PUZZLE 537 WILL MAKE IT UNUSABLE AND SCORE WILL NOT COUNT!
537 PUZZLE IS BUGGED!