Icon representing a recipe

Recipe: Toolbox - selection interface

created by MurloW

Profile


Name
Toolbox - selection interface
ID
101820
Shared with
Public
Parent
None
Children
None
Created on
February 07, 2016 at 20:57 PM UTC
Updated on
February 07, 2016 at 20:57 PM UTC
Description

See first comment.

Best for


Code


-- Toolbox -- MurloW p = print p("") nSegs=structure.GetCount() ItMu = 1.4 if ItMu<=0.2 then ItMu=1 end function wig(how,it,iters,minppi) if how==nil then how="wa" end if it==nil then it=10*ItMu else it=it*ItMu end if iters==nil then iters=2 end if minppi==nil then minppi=1 end it=math.ceil(it) if iters>0 then iters=iters-1 local sp=score() if how == "s" then structure.ShakeSidechainsAll(1) elseif how == "wb" then structure.WiggleAll(it, true, false) elseif how == "ws" then structure.WiggleAll(it, false, true) elseif how == "wa" then structure.WiggleAll(it, true, true) end if score()-sp > minppi and how ~= "s" then return wig(how,it,iters,minppi) end end end function score() local s=0 if DisFil then behavior.SetSlowFiltersDisabled(false) end s=current.GetScore() if DisFil then behavior.SetSlowFiltersDisabled(true) end return s end function Seed() seed=os.time()/math.abs(current.GetEnergyScore()) seed=seed%0.001 seed=1/seed while seed<10000000 do seed=seed*10 end seed=seed-seed%1 math.randomseed(seed) end Seed() function isMovable(seg1, seg2) local FT = true for i=seg1, seg2 do BB, SC = freeze.IsFrozen(i) if (BB == true) then FT = false end sl = structure.IsLocked(i) if ( sl == true ) then FT = false end end return FT end function Check() local sc=score() local gain=0 if (bestscore < sc) then gain = sc - bestscore bestscore = sc save.Quicksave(50) Delbands() save.Quicksave(1) save.Quickload(50) if cut(gain)>0 then p("",string.format(" %.4f pts, new score: %.4f",gain,sc),os.date("%X")) end end end function setCI(ci) return behavior.SetClashImportance(ci) end function qStab() setCI(cival/2) wig("wa",5) Check() setCI(cival) wig("s") Check() wig() Check() setCI(cival/3) wig("wa",5) Check() setCI(cival) wig() Check() wig("s") Check() wig() Check() end function Fuze() Check() setCI(.05) wig("s") Check() setCI(cival) wig() Check() setCI(cival/3) wig("wa",5) Check() if Sf == false then setCI(.07) wig("s") Check() setCI(cival) wig() Check() setCI(cival/3) wig("wa",5) Check() end setCI(cival) wig("s") Check() wig() Check() end function mutaFuze() Check() setCI(0.15) structure.MutateSidechainsAll(1) Check() setCI(cival/3) wig("wa",4) Check() setCI(cival) wig() Check() if Sf==false then setCI(0.2) wig("s") Check() setCI(cival/2) wig("wa",5) Check() setCI(0.87*cival) structure.MutateSidechainsSAll(1) Check() selection.DeselectAll() end setCI(cival) wig() Check() wig("s") Check() wig() Check() end function Fuzit() if muta then mutaFuze() else Fuze() end recentbest.Restore() Check() end function Test() if (Qscore-score())>(Qscore/4) then setCI(cival/3) wig("wa",5) Check() wig("s") Check() end setCI(cival) wig() Check() setCI(cival/3) wig("wa",5) Check() setCI(cival) wig() Check() recentbest.Restore() Check() if qst then qStab() end recentbest.Restore() Check() if fuzt>=0 then if score()>(Qscore-fuzt) then Fuzit() end else if score()>=(Qscore+FF) then Fuzit() end end end function sort(part) Mseg = {} for x=1,nSegs do Mseg[x]={x,current.GetSegmentEnergySubscore(x, part)} end table.sort(Mseg,function(x,y) return x[2]<y[2] end) return Mseg end function cut(x) return x-x%0.0001 end function checkLocked() lockd=0 -- locked seg quantity counter locklist = {} for k=1,nSegs do -- k = seg identity counter if isMovable(k,k) == false then lockd=lockd+1 locklist[lockd] = k end end return lockd,locklist end function checkSelected() selected=0 selList = {} for k=1, nSegs do if selection.IsSelected(k) then selected=selected+1 selList[selected] = k end end if selected>0 then sels=true else sels=false end return selList,sels end function selectsphere(seg, radius) if seg>nSegs then seg = nSegs end if seg<1 then seg = 1 end for i=1, nSegs do if structure.GetDistance(seg,i) <= radius then selection.Select(i) end end end function contains(x, value) for _, v in pairs(x) do if v == value then return true end end return false end function Delbands() if KB then freshbands = band.GetCount() for h = oldbands, freshbands-1 do band.Delete(oldbands+1) end else band.DeleteAll() end end function Disbands() if KBE then newbands = band.GetCount() for i = oldbands, newbands-1 do band.Disable(i+1) end else band.DisableAll() end end function Rbld() local sco=score() local its=0 Disbands() setCI(0.1) repeat its=its+1 if its>4 then break end structure.RebuildSelected(its) until cut(score())~=cut(sco) end function End(errmsg) if done then return end done=true if string.find(errmsg,"Cancelled") then p("") p(" User cancel.") Result() p("") else p("") p(errmsg) Result() end return errmsg end function Result() Check() recentbest.Restore() Check() save.Quickload(1) Delbands() p("",os.date("%X")) if DisFil then behavior.SetSlowFiltersDisabled(false) end local Tgain = (score()-startscore) if Tgain<0.0001 then p(" No change.. :/ ") else p(" Startscore: "..cut(startscore)) p(" Score: "..cut(score())) p(" Total gain: "..Tgain.." pts.") end setCI(cival) selection.DeselectAll() for ii=1, #selList do selection.Select(selList[ii]) end end function init() cival=behavior.GetClashImportance() if cival<0.1 then cival = 1 end cutlist = { } checkLocked() checkSelected() Qbands=0 for i=1, #selList do if not isMovable(i,i) then selection.Deselect(i) end end checkSelected() local gc=band.GetCount() if gc>=1 then bands=true end oldbands=gc for i=2, nSegs-1 do -- mutable? if structure.IsMutable(i) then MM = true break end end ConP=false for y = 1, nSegs-2 do -- contact? for j = y+2, nSegs do if contactmap.GetHeat(y, j) ~= 0 then ConP=true break end end if ConP then break end end return ConP, plank, MM, locklist, selList, bands, oldbands end function dia() opt=dialog.CreateDialog(" Toolbox. ") opt.mxc=dialog.AddSlider(" MaxCI:",cival,0.1,1,2) opt.dfff=dialog.AddLabel(" ") opt.lb=dialog.AddLabel(" Actions: ") if sels then opt.sel=dialog.AddCheckbox(" Rebuild all selected residues simultaneously.",false) opt.selS=dialog.AddSlider(" ^ x times ",2,1,9,0) opt.selR=dialog.AddCheckbox(" Rebuild selected residues one area at a time",false) else opt.rr=dialog.AddCheckbox(" Rainbow Rebuild",false) end opt.cuts=dialog.AddCheckbox(" Cut and Wiggle",false) opt.id=dialog.AddCheckbox(" Idealize",false) opt.ntw=dialog.AddCheckbox(" Rotamer test",false) if MM then opt.bfo=dialog.AddCheckbox(" and bruteforce polar AAs",false) end if ConP then opt.cb=dialog.AddCheckbox(" Contact Bander",true) end if bands then opt.wb=dialog.AddCheckbox(" Work Existing Bands",false) end opt.bf=dialog.AddCheckbox(" BandFuze",false) opt.dff=dialog.AddLabel(" ") opt.lb2=dialog.AddLabel(" Options: ") opt.fu = dialog.AddLabel("Fuzing threshold (negative value is gain)") opt.fuz = dialog.AddSlider("", -50, -200, 100, 1) opt.qst = dialog.AddCheckbox(" qStab",false) opt.qu=dialog.AddCheckbox(" Quick quake here and there during Actions",false) opt.Sf=dialog.AddCheckbox(" Short fuze", true) if MM then opt.muta=dialog.AddCheckbox(" Mutate (after perturb, during fuze, etc.)",true) end if sels then opt.tac=dialog.AddCheckbox(" Target selected residues only with Cut & Wiggle.",true) opt.tid=dialog.AddCheckbox(" Target selected residues only with Idealize.",true) opt.sn=dialog.AddCheckbox(" Target selected residues only with Rotamer Test.",true) end if bands then opt.KB=dialog.AddCheckbox(" Keep original bands", true) opt.KBE=dialog.AddCheckbox(" Keep enabled always",false) opt.KBSTR=dialog.AddCheckbox(" Keep original strength", false) end opt.df=dialog.AddCheckbox(" Disable Filters during operations.",true) opt.ok = dialog.AddButton("Go go!",1) opt.can = dialog.AddButton("Cancel.",2) local res=dialog.Show(opt) if res==2 then return Cancel() elseif res~=1 then return dia() end if sels then sim=opt.sel.value simTrs=opt.selS.value selR=opt.selR.value tacu=opt.tac.value tid=opt.tid.value Snt=opt.sn.value else rr=opt.rr.value end DisFil=opt.df.value QO=opt.qu.value qst=opt.qst.value Sf=opt.Sf.value ide=opt.id.value cuts=opt.cuts.value BF=opt.bf.value NTW=opt.ntw.value if MM then muta=opt.muta.value BForce=opt.bfo.value end if bands then KB=opt.KB.value KBE=opt.KBE.value KBSTR=opt.KBSTR.value wb=opt.wb.value end cival=opt.mxc.value if ConP then CB=opt.cb.value end fuzt=opt.fuz.value if fuzt<=0 then FF = (-1*fuzt) end --p(cival, rr, wb, muta, cuts, ide, sim, fuzt, FF, KB, KBE, KBSTR, CB, DisFil, Sf, qst, tacu, tid, selR, simTrs, QO, BF, NTW, Snt, BForce) return cival, rr, wb, muta, cuts, ide, sim, fuzt, FF, KB, KBE, KBSTR, CB, DisFil, Sf, qst, tacu, tid, selR, simTrs, QO, BF, NTW, Snt, BForce end PoAs={"r","n","d","q","e","h","k","y","w","s","t"} for i=1,#PoAs do --shuffle list local x=math.random(#PoAs) PoAs[i],PoAs[x]=PoAs[x],PoAs[i] end ---- Actions functions function simul() p(" Rebuild All Selected",os.date("%X")) save.Quicksave(80) Qscore=score() for i=1, simTrs do save.Quickload(80) Rbld() Check() recentbest.Save() for x=1, #selList do selectsphere(selList[x],8) end setCI(cival*0.8) if muta then structure.MutateSidechainsSelected(1) Check() wig("s") else structure.ShakeSidechainsSelected(1) end Check() selection.DeselectAll() for k=1, #selList do selection.Select(selList[k]) end Test() if CB then BandSelectedContacts() BandTest() recentbest.Restore() Delbands() Check() recentbest.Save() end if QO then QuakeOnce() end save.Quicksave(60+i) end for yj=1, simTrs do save.Quickload(60+yj) Check() end recentbest.Restore() Check() end function selReb() save.Quickload(1) Qscore=score() p(" Rebuild Selected",os.date("%X")) local Cs=1 local v=0 local tag=2 local tac=1 local tec=0 for i=2, #selList do if not (selList[i]==selList[i-1]+1) then v=v+1 end end for cnt=1, v+1 do for e=tag, #selList+1 do if not (selList[e]==selList[e-1]+1) then tec=e break end end selection.DeselectAll() save.Quickload(1) selStr=selList[tac] selEnd=selList[tec-1] for i=selStr, selEnd do selection.Select(i) tac=tac+1 end p(" segs "..selStr.." to "..selEnd,"") tag=tec+1 Rbld() Check() recentbest.Save() setCI(cival*0.8) for x=selStr, selEnd do selectsphere(x,8) end if muta then structure.MutateSidechainsSelected(1) Check() wig("s") Check() else structure.ShakeSidechainsSelected(1) Check() end selection.DeselectAll() for i=selStr, selEnd do selection.Select(i)end Test() if CB then for y = 1, nSegs do for j = 1, selList[Cs], tac-1 do if (structure.GetDistance(y,j) <= 10) and (structure.GetDistance(y,j) >= 4) then if contactmap.GetHeat(y, j) ~=0 then lb=band.AddBetweenSegments(y,j) band.SetGoalLength(lb, band.GetLength(lb)*(contactmap.GetHeat(y,j)-1)) end end end end BandTest() recentbest.Restore() Delbands() Check() recentbest.Save() end if QO then QuakeOnce() end Cs=tac end recentbest.Restore() Check() for ii=1, #selList do selection.Select(selList[ii]) end end function RRdia() opt=dialog.CreateDialog("Rainbow Rebuild.") opt.mnlng=dialog.AddSlider("Min. rebuild length",nSegs/4, 2, (nSegs/2)-1,0) opt.mxlng=dialog.AddSlider("Max. rebuild length", nSegs/4, 2, (nSegs/2)-1,0) opt.lf=dialog.AddCheckbox("Longest first",true) if ConP then opt.cb=dialog.AddCheckbox("Contact Bander after Rebuild",true) end opt.LF=dialog.AddCheckbox("Loop forever (unchecked = 1 cycle through lengths)",false) opt.ok = dialog.AddButton("Go go!",1) opt.can = dialog.AddButton("Cancel.",2) local res=dialog.Show(opt) if res==2 then return Cancel() elseif res~=1 then return RRdia() end if ConP then CB=opt.cb.value end minlng=opt.mnlng.value maxlng=opt.mxlng.value if minlng>maxlng then Mlng=maxlng maxlng=minlng minlng=Mlng end lFirst=opt.lf.value LoFo=opt.LF.value return minlng, maxlng, lFirst, LoFo, CB end function RR() p(" Rainbow Rebuild ",os.date("%X")) if lFirst then rrlng=maxlng if minlng~=maxlng then p(" Lengths "..maxlng.." to "..minlng) else p(" Length "..rrlng,os.date("%X")) end else rrlng=minlng if minlng~=maxlng then p(" Lengths "..minlng.." to "..maxlng) else p(" Length "..rrlng,os.date("%X")) end end if LoFo then xz=1 while true do for i=xz, nSegs, rrlng do if (i+rrlng)>nSegs then rrlng=(nSegs-i)+1 end if isMovable(i,i+(rrlng-1)) then save.Quickload(1) Qscore=score() selection.DeselectAll() selection.SelectRange(i,i+(rrlng-1)) checkSelected() p(" segs "..i.." to "..i+(rrlng-1),"") Rbld() Check() recentbest.Save() setCI(cival*0.8) structure.ShakeSidechainsSelected(1) Check() for x=1, #selList do selectsphere(selList[x],7) end if muta then structure.MutateSidechainsSelected(1) Check() end wig("s") Check() selection.DeselectAll() for k=1, #selList do selection.Select(selList[k]) end Test() if CB then for y = 1, nSegs-1 do for j = i, i+(rrlng-1) do if (structure.GetDistance(y,j) <= 10) and (structure.GetDistance(y,j) >= 4) then if contactmap.GetHeat(y, j) ~=0 then lb=band.AddBetweenSegments(y,j) band.SetGoalLength(lb, band.GetLength(lb)*(contactmap.GetHeat(y,j)-1)) end end end end BandTest() recentbest.Restore() Delbands() Check() recentbest.Save() end if QO then QuakeOnce() end end -- isMov end if lFirst then rrlng=rrlng-1 if rrlng<minlng then rrlng=maxlng end end if lFirst==false then rrlng=rrlng+1 if rrlng>maxlng then rrlng=minlng end end end --while else RRc=(maxlng-minlng)+1 for rc=1, RRc do local rrln=rrlng --p("",rc,RRc,"rc, RRc") for i=1, nSegs, rrln do if (i+rrln)>nSegs then rrln=(nSegs-i)+1 end if isMovable(i,i+(rrln-1)) then save.Quickload(1) Qscore=score() selection.DeselectAll() selection.SelectRange(i,i+(rrln-1)) checkSelected() p(" segs "..i.." to "..i+(rrln-1),"") Rbld() Check() recentbest.Save() setCI(cival*0.8) structure.ShakeSidechainsSelected(1) Check() for x=1, #selList do selectsphere(selList[x],7) end if muta then structure.MutateSidechainsSelected(1) Check() end wig("s") Check() selection.DeselectAll() for k=1, #selList do selection.Select(selList[k]) end Test() if CB then for y = 1, nSegs-1 do for j = i, i+(rrln-1) do if (structure.GetDistance(y,j) <= 10) and (structure.GetDistance(y,j) >= 4) then if contactmap.GetHeat(y, j) ~=0 then lb=band.AddBetweenSegments(y,j) band.SetGoalLength(lb, band.GetLength(lb)*(contactmap.GetHeat(y,j)-1)) end end end end BandTest() recentbest.Restore() Delbands() Check() recentbest.Save() end if QO then QuakeOnce() end end -- isMov end if lFirst then rrlng=rrlng-1 end if lFirst==false then rrlng=rrlng+1 end --p("",rrlng,"rrlng,","end of rc, RRc") end end -- LoFo end function Cuts() save.Quickload(1) Qscore=score() if tacu then cuts=0 for i=1, #selList do structure.InsertCut(selList[i]) cuts=cuts+1 cutlist[cuts] = selList[i] end p("",cuts.." cuts",os.date("%X")) cutheal() if CB then BandSelectedContacts() BandTest() recentbest.Restore() Delbands() Check() recentbest.Save() end if QO then QuakeOnce() end --------- cuts=0 CHu=true for i=1, #selList do structure.InsertCut(selList[i]) cuts=cuts+1 cutlist[cuts] = selList[i] cutheal() end CHu=false if CB then BandSelectedContacts() BandTest() recentbest.Restore() Delbands() Check() recentbest.Save() end if QO then QuakeOnce() end else -- no tacu sort('backbone') cuts=0 local ab=0 while cuts<nSegs/6 do ab=ab+1 local xi=Mseg[ab][1] if isMovable(xi,xi) then structure.InsertCut(xi) cuts=cuts+1 cutlist[cuts] = xi end end p("",cuts.." cuts",os.date("%X")) cutheal() if CB then BandAllContacts() BandTest() recentbest.Restore() Delbands() Check() recentbest.Save() end if QO then QuakeOnce() end --------- cuts=0 for xy=1, nSegs do if (structure.GetSecondaryStructure(xy)=='L') and isMovable(xy,xy) then structure.InsertCut(xy) cuts=cuts+1 cutlist[cuts] = xy end end p("",cuts.." cuts",os.date("%X")) cutheal() if CB then BandAllContacts() BandTest() recentbest.Restore() Delbands() Check() recentbest.Save() end if QO then QuakeOnce() end --------- sort('backbone') cuts=0 CHu=true local ab=0 p("","10 cuts",os.date("%X")) for ab=1, 10 do local xi=Mseg[ab][1] if xi~=nSegs then if (isMovable(xi,xi) or isMovable(xi+1,xi+1)) then structure.InsertCut(xi) cuts=cuts+1 cutlist[cuts] = xi cutheal() end end end CHu=false if CB then BandAllContacts() BandTest() recentbest.Restore() Delbands() Check() recentbest.Save() end if QO then QuakeOnce() end end -- tacu end function cutheal() setCI(cival) wig() save.Quicksave(90) for ch=1, #cutlist do structure.DeleteCut(cutlist[ch]) end Check() local Csc=score() recentbest.Save() wig() Check() if cut(score())~=cut(Csc) then Test() end if not CHu then save.Quickload(90) setCI(cival/3) wig("wa",5) setCI(cival) wig() for ch=1, #cutlist do structure.DeleteCut(cutlist[ch]) end Check() recentbest.Save() if cut(score())~=cut(Csc) then Test() end end end function Idia() opt=dialog.CreateDialog("Idealize.") opt.iln=dialog.AddSlider(" Length:",3,2,nSegs,0) opt.uc=dialog.AddCheckbox(" Use Cutpoints.",false) opt.ok = dialog.AddButton("Go go!",1) opt.can = dialog.AddButton("Cancel.",2) local res=dialog.Show(opt) if res==2 then return Cancel() elseif res~=1 then return Idia() end uc=opt.uc.value if not tid then Ilng=opt.iln.value end return Ilng, uc end function Ide() save.Quickload(1) p(" Idealize ",os.date("%X")) recentbest.Save() Qscore=score() if tid then local Csc=score() structure.IdealizeSelected() if cut(score())~=cut(Csc) then Test() if CB then BandSelectedContacts() BandTest() recentbest.Restore() Delbands() Check() recentbest.Save() end if QO then QuakeOnce() end end else -- tid if Ilng>nSegs-2 then uc=false end p(" Length "..Ilng) for i=1, nSegs, Ilng do if (i+Ilng)>nSegs then Ilng=(nSegs-i)+1 end if isMovable(i,i+(Ilng-1)) then selection.DeselectAll() selection.SelectRange(i,i+(Ilng-1)) local Csc=score() if uc then cuts=0 if (i-1)>=1 then structure.InsertCut(i-1) cuts=cuts+1 cutlist[cuts] = i-1 end if (i+Ilng)<nSegs then structure.InsertCut(i+(Ilng-1)) cuts=cuts+1 cutlist[cuts] = i+(Ilng-1) end end structure.IdealizeSelected() if uc then cutheal() else if cut(score())~=cut(Csc) then Test() end end -- uc if CB then BandSelectedContacts() BandTest() recentbest.Restore() Delbands() Check() recentbest.Save() end if QO then QuakeOnce() end end --isMov recentbest.Restore() Check() end selection.DeselectAll() end --if tid recentbest.Restore() Check() end function NetwTest() p(" Rotamer Test ",os.date("%X")) lscore=score() selection.DeselectAll() local k=0 local targets=0 if Snt then targets=#selList p(" ",targets.." segs to test") else targets=nSegs p(" "," all polar segs") end for jj=1, targets do k=k+1 if Snt then st=selList[k] else st=k end if not Snt then if contains(PoAs,structure.GetAminoAcid(st)) then Snap() end else Snap() end end if BForce then p(" ","bruteforcing polar AAs ",os.date("%X")) selection.DeselectAll() local k=0 local targets=0 if Snt then targets=#selList else targets=nSegs end for jj=1, targets do k=k+1 if Snt then st=selList[k] else st=k end if not Snt then if contains(PoAs,structure.GetAminoAcid(st)) then BruF() end else BruF() end end end -- BForce end function nTest() setCI(0.01) structure.WiggleSelected(5,false,true) Check() structure.ShakeSidechainsSelected(1) Check() setCI(cival) structure.WiggleSelected(5,false,true) Check() structure.ShakeSidechainsSelected(1) Check() selection.DeselectAll() wig("ws",3) Check() end function Snap() Check() selectsphere(st,10) nTest() snaps=rotamer.GetCount(st) for y=1, snaps do rotamer.SetRotamer(st, y) Check() selectsphere(st,10) selection.Deselect(st) nTest() end end function BruF() for i=1, #PoAs do save.Quickload(1) origA = structure.GetAminoAcid(st) BB, SC=freeze.IsFrozen(st) if structure.CanMutate(st, PoAs[i]) and SC==false then structure.SetAminoAcid(st, PoAs[i]) newA = structure.GetAminoAcid(st) Nlscore=score() if newA ~= origA then Snap() end save.Quickload(1) newA = structure.GetAminoAcid(st) if newA ~= origA then p(" seg "..st.." changed from "..origA.." to "..newA) end end end -- PoAs--p(os.date("%X")) end function WorkExBands() p(" Work Bands",os.date("%X")) Qscore=score() while true do band.EnableAll() if band.GetCount()>1 then if KBE then for b=oldbands+1, band.GetCount() do RM=math.random(-100,100) if RM>=0 then BdOff=false else BdOff=true end if BdOff then band.Disable(b) end end else for b=1, band.GetCount() do RM=math.random(-100,100) if RM>=0 then BdOff=false else BdOff=true end if BdOff then band.Disable(b) end end end end BandTest() recentbest.Restore() Disbands() Check() end -- while end function BFdia() opt = dialog.CreateDialog(" BandFuze. ") opt.Qq=dialog.AddCheckbox(" Quake.",true) opt.Bs=dialog.AddCheckbox(" BiS.",false) opt.Cmb=dialog.AddCheckbox(" Combine Quake and BiS.",false) opt.Sk=dialog.AddCheckbox(" Shock.",true) opt.Tg=dialog.AddCheckbox(" Tailgrab.",false) opt.ok = dialog.AddButton("Go go!",1) opt.can = dialog.AddButton("Cancel.",2) local res=dialog.Show(opt) if res==2 then return Cancel() elseif res~=1 then return BFdia() end QQ=opt.Qq.value BiS=opt.Bs.value Shock=opt.Sk.value TG=opt.Tg.value Combo=opt.Cmb.value return QQ,BiS,Shock,TG,Combo end function BFuze() p(" BandFuze ",os.date("%X")) while true do save.Quickload(1) Qscore=score() if QQ or Combo then Quaker() end BiSs() if TG then BandAcross() end end end ---- Band functions function bandpull(minBS,maxBS) local ss=score() local perc=math.random(80,180)/100 local loss=((perc*ss)/100) --p("perc,loss",perc,loss) local lastBS=minBS for str=lastBS,maxBS, 0.1 do if KBSTR then local NNbands = band.GetCount() for i=oldbands+1, NNbands do band.SetStrength(i, str) end else for i=1, band.GetCount() do band.SetStrength(i, str) end end wig("wb",5) Check() save.Quicksave(70) recentbest.Restore() Check() save.Quickload(70) if (ss-score()>=loss) or (score()>bestscore+5) then if band.GetCount()>(nSegs/10)*2 then lastBS=str-0.1 if lastBS<minBS then lastBS=minBS end else lastBS=minBS end break end end end function BandTest() if band.GetCount()>0 then setCI(cival*0.9) if ZL then wig("wb",5,1) Check() save.Quicksave(70) recentbest.Restore() Check() save.Quickload(70) else bandpull(0.2,3) end Disbands() recentbest.Save() Check() if muta then save.Quicksave(93) setCI(math.random(cival*100)/100) structure.MutateSidechainsAll(1) Check() setCI(cival) wig() Check() setCI(cival/2) wig("wa",5) Check() setCI(cival) wig() Check() wig("s") Check() wig() Check() save.Quickload(93) end wig("s") Check() Test() end end function QuakeOnce() if KB then band.EnableAll() if band.GetCount()>1 then if KBE then for b=oldbands+1, band.GetCount() do RM=math.random(-100,100) if RM>=0 then BdOff=false else BdOff=true end if BdOff then band.Disable(b) end end else for b=1, band.GetCount() do RM=math.random(-100,100) if RM>=0 then BdOff=false else BdOff=true end if BdOff then band.Disable(b) end end end end -- KBE end local dd = math.floor(nSegs/7) repeat local start=math.random(dd) local len=math.floor(math.random((nSegs-dd)/2)+dd) local step=math.floor(math.random((nSegs-dd)/2)+dd) for x=start,nSegs, step do for y=start+len, nSegs, step do if (y<=nSegs) and (isMovable(y,y) or isMovable(x,x)) then band.AddBetweenSegments(x,y) end end end until (band.GetCount()+oldbands)>(oldbands+3) BandTest() recentbest.Restore() Delbands() Check() recentbest.Save() end function BandAllContacts() for y = 1, nSegs-2 do for j = y+2, nSegs do HT=contactmap.GetHeat(y,j) if HT >= 0.75 then lb=band.AddBetweenSegments(y,j) band.SetGoalLength(lb, band.GetLength(lb)*(HT)) end end end end function BandSelectedContacts() for y = 1, nSegs do for j = 1, #selList do if (structure.GetDistance(y,selList[j]) <= 10) and (structure.GetDistance(y,selList[j]) >= 4) then if contactmap.GetHeat(y,selList[j]) ~=0 then lb=band.AddBetweenSegments(y,selList[j]) band.SetGoalLength(lb, band.GetLength(lb)*(contactmap.GetHeat(y,selList[j]))) end end end end end function ContactBander() p(" Band Contacts") BandAllContacts() if (band.GetCount()<1) or BF then wb=false else wb=true end end function bandage() bloat=false if cival>=0.9 then RM=math.random(-100,100) if RM>=0 then bloat=false else bloat=true end end if bloat then if KBSTR then local NNbands = band.GetCount() for i=oldbands+1, NNbands do band.SetGoalLength(i,band.GetLength(i)+4) end else for i=1, band.GetCount() do band.SetGoalLength(i,band.GetLength(i)+4) end end else if KBSTR then local NNbands = band.GetCount() for i=oldbands+1, NNbands do local leng=band.GetLength(i) local perc=math.random(20,50) local loss=((perc*leng)/100) band.SetGoalLength(i,band.GetLength(i)-loss) end else for i=1, band.GetCount() do local leng=band.GetLength(i) local perc=math.random(20,50) local loss=((perc*leng)/100) band.SetGoalLength(i,band.GetLength(i)-loss) end end end end function spacebands(amnt) local zeBands=math.random(amnt)+Qbands if zeBands<1 then zeBands = 1 end while band.GetCount()<zeBands do repeat segO = math.random(nSegs) until structure.IsLocked(segO)==false if ZL then rho=0.2 else rho=math.random(10) end theta = math.random(100,314.159)/100 phi = math.random(100,314.159)/100 if phi<1 then phi=phi+1 end if theta<1 then theta=theta+1 end if segO<=nSegs and segO>=1 then if segO==nSegs then segX = segO-1 segY = segO-2 elseif segO==1 then segX = segO+1 segY = segO+2 else segX = segO-1 segY = segO+1 end if segX>nSegs then segX=nSegs-1 end if segY>nSegs then segY=nSegs-1 end if segY<1 then segY=1 end if segX<1 then segX=1 end --p(segX,"X",segY,"Y",segO,"O",theta,"theta",phi,"phi") local lb=band.Add(segO, segX, segY, rho, theta, phi) if ZL then band.SetGoalLength(lb,math.random(1)) band.SetStrength(lb,math.random(10)) else band.SetGoalLength(lb,math.random(band.GetLength(lb)*2)) end end end end function BiSs() if Combo==false then if BiS then for i=1, 2 do spacebands(nSegs/2) BandTest() Delbands() end end--bis end--combo if Shock then ZL=true for u=1, 2 do spacebands(nSegs/2) BandTest() Delbands() end ZL=false end end function BandAcross() for i=1, nSegs do if structure.IsLocked(i)==false then first=i break end end for u=nSegs, 1, -1 do if structure.IsLocked(u)==false then last=u break end end band.AddBetweenSegments(first,last) bandage() BandTest() Delbands() band.AddBetweenSegments(nSegs/2,first) band.AddBetweenSegments(nSegs/2,last) bandage() BandTest() Delbands() end function Quaker() if Combo then for i=1, 4 do nrR=math.random(1, 19) for u=1, nrR do repeat seg1=math.random(1,nSegs) seg2=math.random(1,nSegs) until (seg1~=seg2) and (not structure.IsLocked(seg1) or not structure.IsLocked(seg2)) band.AddBetweenSegments(seg1,seg2) end bandage() Qbands=band.GetCount() spacebands(10) BandTest() Delbands() end else for i=1, 2 do nrR=math.random(1, 19) for u=1, nrR do repeat seg1=math.random(1,nSegs) seg2=math.random(1,nSegs) until (seg1~=seg2) and (not structure.IsLocked(seg1) or not structure.IsLocked(seg2)) band.AddBetweenSegments(seg1,seg2) end bandage() BandTest() Delbands() end --quake end --combo end ---- Container function main() init() if lockd<nSegs-2 then dia() else return end if DisFil then behavior.SetSlowFiltersDisabled(true) end Delbands() Disbands() save.Quicksave(1) save.Quicksave(2) recentbest.Save() startscore=score() bestscore=startscore p(" Startscore: "..cut(score())) p(" Best score in quicksave slot 1, start in slot 2 ") p(" maxCI = "..cival," Start time:",os.date("%X")) p("") if rr then RRdia() end if ide then if not tid then Idia() end end if BF then BFdia() end if sim then simul() end if selR then selReb() end if rr then RR() end if cuts then Cuts() end if ide then Ide() end if NTW then NetwTest() end if CB then ContactBander() end if wb then WorkExBands() end if BF then BFuze() end Result() end --[[ Toolbox includes: -A Rebuilder, Rainbow whole structure or Selected residues only; -a Cut and Wiggle routine, selected residues only or worst backbone scores and all loops; -an Idealize routine, selected residues only or whole structure variable length with the option to use cutpoints; -a Rotamer Tester, selected residues only (recommended, you're better off with AcidTweak/Mutators when not targetting specific segs) or all polar residues (hydrophilics + TYR & TRYP), tries all rotamers of current sidechain and local wiggles; -and bruteforce polar AAs, while testing their rotamers (very lengthy, up to ~30mins/residue), if you pick the right residues this will do wonders for finding HBonds, e.g.: a network is <75% satisfied -> select promising nearby residues (and/or those already contributing to the network) and run; -Contact Bander, bands all contacts with a heat >=0.75 and runs WorkExBands; -Work Existing Bands, randomly disables/enables bands and quakes the structure (needs user created bands, more bands = more profit); -BandFuze, creates random bands and quakes the structure. Updated/revised, same functionality. ---- If multiple Actions are checked they will happen in consecutive order, top to bottom, as displayed in the dialog (unless loop forever negates this). A single pull of Contact Bander and/or Quick Quake happen around the same time as qStab/fuze, after the rebuild/cuts/idealize stabilization wiggles. Contact Bander, Work Exist. Bands and BandFuze loop forever until cancelled. ---- If 'Disable filters during operations' is unchecked, recipe will not touch the filters and leave them as is, this can be used to run the recipe with only 1 filter enabled, or to keep any filter bonus from locking up the structure, etc. If it is checked, all filters will be enabled to check score, and disabled during any and all other operations. Has no effect on puzzles without filters, just ignore the option. ]] err = xpcall(main,End)

Comments


MurloW Lv 1

-A Rebuilder, Rainbow whole structure or Selected residues only;
-a Cut and Wiggle routine, selected residues only or worst backbone scores and all loops;
-an Idealize routine, selected residues only or whole structure variable length with the option to use cutpoints;
-a Rotamer Tester, selected residues only (recommended, you're better off with AcidTweak/Mutators when not targetting specific segs) or all polar residues (hydrophilics + TYR & TRYP), tries all rotamers of current sidechain and local wiggles;
-and bruteforce polar AAs, while testing their rotamers (very lengthy, up to ~30mins/residue), if you pick the right residues this will do wonders for finding HBonds,
e.g.: a network is <75% satisfied -> select promising nearby residues (and/or those already contributing to the network) and run;
-Contact Bander, bands all contacts with a heat >=0.75 and runs WorkExBands;
-Work Existing Bands, randomly disables/enables bands and quakes the structure (needs user created bands, more bands = more profit);
-BandFuze, creates random bands and quakes the structure. Updated/revised, same functionality.
—-
If multiple Actions are checked they will happen in consecutive order, top to bottom, as displayed in the dialog (unless loop forever negates this).
A single pull of Contact Bander and/or Quick Quake happen around the same time as qStab/fuze, after the rebuild/cuts/idealize stabilization wiggles.
Contact Bander, Work Exist. Bands and BandFuze loop forever until cancelled.
—-
If 'Disable filters during operations' is unchecked, recipe will not touch the filters and leave them as is,
this can be used to run the recipe with only 1 filter enabled, or to keep any filter bonus from locking up the structure, etc.
If it is checked, all filters will be enabled to check score, and disabled during any and all other operations.
Has no effect on puzzles without filters, just ignore the option.

MurloW Lv 1

2 bugfixes: rebuild length on rr not working right and occasional missed points from shock bands.

sorry about that.