Code
-- Toolbox v1.4
-- MurloW
p = print
p("")
nSegs = structure.GetCount()
Magic = 220
ItMu = 2
if ItMu <= 0.2 then ItMu = 1 end
function wig(how, it, iters, minppi)
if how == nil then how = "wa" end
if iters == nil then iters = 2 end
if iters > 1 then if it == nil then it = 10 * ItMu else it = it * ItMu end 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
s = current.GetScore()
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()
if DisFil then filter.EnableAll() end
if Explo then
Nuff = filter.ConditionSatisfied("Exploration") else Nuff = true end
local sc = score()
if DisFil then filter.DisableAll() end
local gain = 0
if (bestscore < sc) and Nuff then
gain = sc - bestscore
bestscore = sc
save.Quicksave(20)
Delbands()
save.Quicksave(1)
save.Quickload(20)
if Dsp == 1 then oneG = 1 else oneG = 0 end
if cut(gain) > oneG then p("", string.format(" %.4f pts, new score: %.4f", gain, sc), os.date("%X")) end
end end
function qStab()
setCI(cival / 2)
wig() Check()
setCI(cival)
wig("s") Check()
wig() Check()
setCI(cival / 3)
wig() 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() Check()
if Dsp == 4 then
setCI(.07)
wig("s") Check()
setCI(cival)
wig() Check()
setCI(cival / 3)
wig() Check() end
setCI(cival)
wig("s") Check()
wig() Check() end
function mutaFuze()
Check()
setCI(0.15)
structure.MutateSidechainsAll(1) Check()
setCI(cival / 3)
wig() Check()
setCI(cival)
wig() Check()
if Dsp == 4 then
setCI(0.2)
wig("s") Check()
setCI(cival / 2)
wig() 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
end
function Test()
if (Qscore - score()) >= (Qscore / 4) then
setCI(cival / 3)
wig() Check()
wig("s") Check() end
setCI(cival)
wig() Check()
setCI(cival / 3)
wig() Check()
setCI(cival)
wig() Check()
if Dsp >= 2 then qStab()
if Dsp == 3 then
if score() >= (Qscore + (Qscore / Magic)) then
Fuzit() end
elseif Dsp == 4 then
if score() >= (Qscore - (Qscore / Magic)) then
Fuzit() end end end
recentbest.Restore() Check()
end
function sort(part)
Mseg = {}
for x = 1, nSegs do
if part ~= 'total' then Mseg[x] = {x, current.GetSegmentEnergySubscore(x, part)} else Mseg[x] = {x, current.GetSegmentEnergyScore(x)} end
end
if WorstFirst then table.sort(Mseg, function (x, y) return x[2] < y[2] end) else table.sort(Mseg, function (x, y) return x[2] > y[2] end) end
return Mseg end
function cut(x)
return x - x % 0.01
end
function setCI(ci)
return behavior.SetClashImportance(ci) end
function getSS(x)
return structure.GetSecondaryStructure(x) end
function checkLocked()
lockd = 0 -- locked seg quantity counter
locklist = {}
for k = 1, nSegs do -- k = seg identity counter
if not isMovable(k, k) 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 checkSelLengths(length)
local b = 0
cnt = 0
broken = true
for e = 1, nSegs do
if selection.IsSelected(e) then b = b + 1
if b > cnt then cnt = b end
else b = 0 end
if b >= length then
broken = false
break end
end
return cnt, broken end
function shallowcopy(t)
local t2 = {}
for k,v in pairs(t) do
t2[k] = v
end
return t2
end
function selectsphere(seg, radius)
for i = 1, nSegs do --p(i)
if structure.GetDistance(seg, i) <= radius then selection.Select(i) --p(selected)
end end
end
function contains(tab, value)
for _, v in pairs(tab) do
if v == value then
return true
end
end
return false end
function Rbld()
local sco = score()
local its = 0
Disbands()
setCI(math.random(5, 18)/100)
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(20) Check()
save.Quickload(1)
Delbands()
p("", os.date("%X"))
zTime = os.clock()
if DisFil then behavior.SetSlowFiltersDisabled(false) end
local Tgain = (score() - startscore)
if Tgain >= 0.0001 then
p(string.format(" Startscore: %.4f",startscore))
p(string.format(" Score: %.4f",score()))
p(" Total gain: " .. Tgain .. " pts.")
elseif (PrB == nil) and (ShSt == nil) then
p(" No change.. :/ ") end
if ((zTime-aTime)/60)/60 > 1 then
p(" Total time: " ..cut(((zTime-aTime)/60)/60).." hours")
elseif (zTime-aTime)/60 > 1 then
p(" Total time: " ..cut((zTime-aTime)/60).." minutes")
end
setCI(cival)
selection.DeselectAll()
for ii = 1, #selList do selection.Select(StartSelCopy[ii]) end
end
function init()
if user.GetPlayerName() == 'MurloW' then MW = true end
cival = behavior.GetClashImportance()
if cival < 0.1 then cival = 1 end
cutlist = {}
checkLocked()
if lockd > nSegs - 1 then lckd = true end
checkSelected()
StartSelCopy = shallowcopy(selList)
Qbands = 0
Qscore = score()
--[[for i = 1, #selList do
if not isMovable(selList[i], selList[i]) then selection.Deselect(selList[i]) end
end
checkSelected()]]
oldbands = 0
Cbds = band.GetCount()
if Cbds >= 1 then bands = true end
oldbands = Cbds
WorstFirst = true
filt = filter.GetNames ()
for i = 1, #filt do if contains(filt, "Exploration") then Explo = true
elseif contains(filt, "Network") then HBNt = true end end
for i = 2, nSegs - 1 do -- mutable?
if structure.IsMutable(i) then MM = true break end end
ConP = false
for y = nSegs/6, nSegs/2 do -- contact?
for j = y + 2, nSegs/1.5 do
if contactmap.GetHeat(y, j) ~= 0 then ConP = true
break
end
end
if ConP then break end
end
return ConP, MM, locklist, selList, bands, oldbands, Explo, HBNt, WorstFirst, Qbands
end
function dia()
opt = dialog.CreateDialog(" Toolbox. ")
opt.pbl = dialog.AddCheckbox(" Create Zero Length Bands on: ", false)
opt.pbb = dialog.AddLabel("Helices(1), Sheets(2), Both(3), Selected(4), Non-Selected(5)")
opt.pb = dialog.AddSlider("", 3, 1, 5, 0)
opt.shS = dialog.AddCheckbox(" Sheet Stitcher", false)
opt.rlx = dialog.AddCheckbox(" 'Fast' Relax to MaxCI ", false)
if bands then opt.inE = dialog.AddCheckbox(" Work existing bands for a bit", false) end
opt.ing = dialog.AddCheckbox(" Short round of BandFuze", false)
if not lckd then
if sels then
opt.sel = dialog.AddCheckbox(" Rebuild all selected residues simultaneously", false)
opt.selS = dialog.AddSlider(" ^ x times ", 3, 1, 9, 0)
opt.selR = dialog.AddCheckbox(" Rebuild selected residues one area at a time", false)
opt.selY = dialog.AddSlider(" x times per area ", 9, 1, 9, 0)
opt.Rem = dialog.AddCheckbox(" Remix selected residues one area at a time", false)
opt.remTs = dialog.AddSlider(" x times per area ", 9, 2, 9, 0) end
opt.rr = dialog.AddCheckbox(" Rainbow Rebuild", false)
opt.cuts = dialog.AddCheckbox(" Cut and Wiggle", false)
opt.id = dialog.AddCheckbox(" Idealize", false) end
if sels then if MM then opt.bfo = dialog.AddCheckbox(" Bruteforce selected AAs", false) end end
if HBNt then opt.ntw = dialog.AddCheckbox(" Rotamer test", false) end
if not lckd then if sels then opt.ran = dialog.AddCheckbox(" Random rebuilds/remix among selected (loops forever)", false)
opt.ranb = dialog.AddSlider("Rebuilds(1), Remix(2), Both(3)", 2, 1, 3, 0)
opt.rani = dialog.AddSlider(" Min. length: ", 4, 2, nSegs / 3, 0)
opt.rana = dialog.AddSlider(" Max. length: ", nSegs / 5, 2, nSegs, 0) end end
if ConP then opt.cb = dialog.AddCheckbox(" Contact Bander (loops forever)", true) end
if bands then opt.wb = dialog.AddCheckbox(" Work Existing Bands (loops forever)", false) end
opt.bf = dialog.AddCheckbox(" BandFuze (loops forever)", 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 dia() end
if not lckd then
if sels then
randr = opt.ran.value
RanB=opt.ranb.value
minr = opt.rani.value
maxr = opt.rana.value
if minr > maxr then
mnnrb = minr
mxxrb = maxr
minr = mxxrb
maxr = mnnrb
end
checkSelLengths(maxr)
if broken then maxr = cnt end -- p(maxr)
remTrs = opt.remTs.value
RMX = opt.Rem.value
sim = opt.sel.value
simTrs = opt.selS.value
selTrs = opt.selY.value
selR = opt.selR.value end
rr = opt.rr.value
ide = opt.id.value
cuts = opt.cuts.value end
BF = opt.bf.value
if sels then if MM then BForce = opt.bfo.value end end
if HBNt then NTW = opt.ntw.value end
rlx = opt.rlx.value
ingo = opt.ing.value
if bands then
inego = opt.inE.value
wb = opt.wb.value
else PrB = opt.pbl.value
SS = opt.pb.value
ShSt= opt.shS.value end
if ConP then CB = opt.cb.value end
dia2()
return rr, rlx, wb, muta, cuts, ide, sim, KB, KBE, KBSTR, CB, tacu, tid, selR, simTrs, BF, NTW, Snt, BForce, selTrs, randr, minr, maxr, PrB, SS, ShSt, ingo, inego
end
function dia2()
opt = dialog.CreateDialog(" Options: ")
opt.mxc = dialog.AddSlider(" MaxCI:", cival, 0.1, 1, 2)
opt.dd = dialog.AddSlider("Desperation level: ", 1, 1, 4, 0)
if MM then opt.Muta = dialog.AddCheckbox(" Mutate (after perturb, during fuze, etc.)", true) end
opt.qu = dialog.AddCheckbox(" Quick quake here and there during Actions", false)
if sels then if cuts then opt.tac = dialog.AddCheckbox(" Target selected residues with Cut & Wiggle", true) end end
if cuts then opt.sorr = dialog.AddCheckbox(" Target worst backbone scores with C & W", false)
opt.cutz = dialog.AddCheckbox(" Target all loops with C & W", false) end
if sels then if ide then opt.tid = dialog.AddCheckbox(" Target selected residues only with Idealize", false) end
if BForce then opt.brt = dialog.AddLabel(" Style of bruteforcing: Polar AAs(1), Similar(2), all AAs(3)")
opt.brSt = dialog.AddSlider("", 1, 1, 3, 0) opt.cy = dialog.AddSlider(" Cycles of bruteforce:", 1, 1, 20, 0)
opt.cycw = dialog.AddLabel(" After every cycle: (1) qStab, (2) single Wiggle, (3) no action")
opt.cycwig = dialog.AddSlider("", 3, 1, 3, 0)
opt.Qd = dialog.AddCheckbox(" Quick and dirty bruteforce, no shake-wiggle", false)
opt.exha = dialog.AddCheckbox(" Rotamer test every AA tried during bruteforce", false) end
if NTW then opt.sn = dialog.AddCheckbox(" Target selected residues only with Rotamer Test", true) end
end
if rr then opt.rldr = dialog.AddLabel("Rainbow Rebuild.")
opt.mnlng = dialog.AddSlider("Min. rebuild length", (nSegs - lockd) / 4, 2, (nSegs / 2) - 1, 0)
opt.mxlng = dialog.AddSlider("Max. rebuild length", (nSegs - lockd) / 4, 2, (nSegs / 2) - 1, 0)
opt.lf = dialog.AddCheckbox("Longest first", true)
opt.LF = dialog.AddCheckbox("Loop forever (unchecked = 1 cycle through lengths)", false) end
if bands then
opt.KB = dialog.AddCheckbox(" Keep original bands", true)
opt.KBE = dialog.AddCheckbox(" Keep enabled always", false)
opt.KBE2 = dialog.AddCheckbox(" ^only for bands with strength >= 10", true)
opt.KBSTR = dialog.AddCheckbox(" Keep original strength", false)
opt.KBSTR2 = dialog.AddCheckbox(" ^only for bands with strength >= 10", true)
elseif ShSt then opt.shS = dialog.AddLabel(" Sheet Stitcher")
opt.Bstr = dialog.AddSlider("Band Strength:", 0.7, 0.1, 1, 2)
opt.dis = dialog.AddSlider("Distance:", 6, 5, 30, 0)
if not lckd then opt.frz = dialog.AddCheckbox("Freeze sheet backbone.", false) end
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 dia2() end
Dsp = opt.dd.value
QO = opt.qu.value
cival = opt.mxc.value
if MM then muta = opt.Muta.value end
if cuts then lolc = opt.cutz.value
sortr = opt.sorr.value end
if rr then
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 end
if bands then
KB = opt.KB.value
KBE = opt.KBE.value
KBE2 = opt.KBE2.value
KBSTR = opt.KBSTR.value
KBSTR2 = opt.KBSTR2.value
elseif ShSt then
BStr = opt.Bstr.value
distance = opt.dis.value
frzz = opt.frz.value
end
DisFil = opt.df.value
if sels then
if cuts then tacu = opt.tac.value end
if ide then tid = opt.tid.value end
if NTW then Snt = opt.sn.value end
if BForce then bruSt = opt.brSt.value
bfcy = opt.cy.value
CycWig = opt.cycwig.value
Exh = opt.exha.value
FD = opt.Qd.value end
end
return CycWig, muta, cuts, cival, KB, KBE, KBSTR, QO, DisFil, tacu, tid, Snt, KBSTR2, KBE2, Dsp, minlng, maxlng, lFirst, LoFo, BStr, distance, frzz, lolc, sortr, bruSt, bfcy, Exh, FD
end
PoAs = {"r", "n", "d", "q", "e", "h", "k", "y", "w", "s", "t"}
AAs = {"a", "c", "d", "e", "f", "g", "h", "i", "k", "l", "m", "n", "p", "q", "r", "s", "t", "v", "w", "y"}
Phil = {"r", "s", "t", "n", "d", "q", "e", "h", "k"}
Phob = {"g", "a", "c", "v", "l", "m", "i", "p", "f", "y", "w"}
for i = 1, #PoAs do -- shuffle list
local x = math.random(#PoAs)
PoAs[i], PoAs[x] = PoAs[x], PoAs[i] end
---- Actions functions
function Relx()
setCI(cival*0.1)
wig("s") Check()
wig() Check()
setCI(cival*0.5)
if MM then structure.MutateSidechainsAll(1) else
wig("s") end
Check()
setCI(cival)
wig() Check()
setCI(cival*0.1)
wig("s") Check()
wig() Check()
if MM then structure.MutateSidechainsAll(1) else
wig("s") end
setCI(cival)
wig() Check()
save.Quicksave(1)-- save.Quicksave(20)
recentbest.Save()
p(" Score after Relax:", score())
end
function ZLBandSS(SS)
if SS == 1 then SeSe = 'H'
elseif SS == 2 then SeSe = 'E'
elseif SS == 4 then for i = 1, #selList do ZLBand(selList[i], 10, 0) end
elseif SS == 5 then for i = 1, nSegs do
if not contains(selList, i) then ZLBand(i, 10, 0) end end
else for i = 1, nSegs do
if getSS(i) == 'H' then ZLBand(i, 10, 0) end end
SeSe = 'E'
end
for i = 1, nSegs do
if getSS(i) == SeSe then ZLBand(i, 10, 0) end
end
end
function SheetStitcher()
for i = 1, nSegs do
if frzz then if getSS(i) == 'E' then freeze.Freeze(i, true, false) end end
for y = i + 1, nSegs do
if (structure.GetDistance(i, y) <= distance and getSS(i) == 'E' and getSS(y) == 'E' ) and i ~= y - 1 then
band.AddBetweenSegments(i, y) -- p(i,y)
local lb = band.GetCount()
band.SetStrength(lb, BStr)
band.SetGoalLength(lb, ((band.GetLength(lb)/100)*80)) end
end end end
function simul()
p(" Rebuild All Selected", os.date("%X"))
save.Quicksave(80)
for i = 1, simTrs do
save.Quickload(80)
Qscore = score()
Rbld() Check()
if cut(score()) ~= cut(Qscore) then
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()
end
if QO then QuakeOnce() end
save.Quicksave(60 + i)
end
end
for yj = 1, simTrs do
save.Quickload(60 + yj) Check() end
recentbest.Restore() Check() end
function selReb()
save.Quickload(1)
p(" Rebuild Selected", os.date("%X"))
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
save.Quicksave(80)
for yh = 1, selTrs do
save.Quickload(80)
Qscore = score()
Rbld() Check()
if cut(score()) ~= cut(Qscore) then
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()
selection.SelectRange(selStr, selEnd)
Test()
if CB then
BandSelectedContacts()
BandTest()
end
if QO then QuakeOnce() end
end
end
end
recentbest.Restore() Check()
for ii = 1, #selList do selection.Select(selList[ii]) end
end
function Remix()
save.Quickload(1)
p(" Remix Selected", os.date("%X"))
local v = 0
local tag = 2
local tac = 1
local tec = 0
local rmx = function ()
remS6 = true
recentbest.Save()
structure.RemixSelected(5, remTrs-1) Check()
setCI(cival * 0.8)
for y = 1, remTrs do
save.Quickload(3 + y)
for x = selStr, selEnd do --p(x,y)
selectsphere(x, 8) end
if muta then structure.MutateSidechainsSelected(1) Check()
structure.ShakeSidechainsSelected(1) Check()
else
structure.ShakeSidechainsSelected(1) Check()
end
wig() Check()
structure.ShakeSidechainsSelected(1) Check()
end
recentbest.Restore() Check()
selection.DeselectAll()
Test()
if CB then
BandSelectedContacts()
BandTest()
end
if QO then QuakeOnce() end
end
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]
local selC = 0
for i = selStr, selEnd do
selection.Select(i)
selC = selC + 1
tac = tac + 1 end
local tS = selC - 1
p(" segs " .. selStr .. " to " .. selEnd, "")
tag = tec + 1
remS6 = false
Qscore = score()
structure.RemixSelected(4, 1) Check()
if cut(score()) ~= cut(Qscore) then
rmx()
else
local zer = 0
while tS > 4 do tS = tS - 1
if selEnd == nSegs then selection.Deselect(nSegs - zer) else selection.Deselect((selStr + tS) + 1) end
structure.RemixSelected(4, 1) Check()
zer = zer + 1
if cut(score()) ~= cut(Qscore) then break end
end
if cut(score()) ~= cut(Qscore) then
rmx() end
end
if remS6 ~= true then
local tS = selC - 1
selection.SelectRange(selStr,selEnd)
local zer = 0
while tS > 4 do tS = tS - 1
if selStr == 1 then selection.Deselect(1 + zer) else selection.Deselect((selEnd - tS) - 2) end
structure.RemixSelected(4, 1) Check()
zer = zer + 1
if cut(score()) ~= cut(Qscore) then break end
end
if cut(score()) ~= cut(Qscore) then
rmx() end
end
if remS6 ~= true then p(" no remix available ") end
end
recentbest.Restore() Check()
for ii = 1, #selList do selection.Select(selList[ii]) end
end
function RR()
p(" Rainbow Rebuild ", os.date("%X"))
local rrD = function ()
if isMovable(TargetS, TargetS + (rrlng - 1)) then
save.Quickload(1)
Qscore = score()
selection.DeselectAll()
selection.SelectRange(TargetS, TargetS + (rrlng - 1))
checkSelected()
Rbld() Check()
if cut(score()) ~= cut(Qscore) then
recentbest.Save()
setCI(cival * 0.8)
for x = 1, #selList do selectsphere(selList[x], 7) end
if muta then structure.MutateSidechainsSelected(1) Check() end
structure.ShakeSidechainsSelected(1) 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 = TargetS, TargetS + (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) * (1 - contactmap.GetHeat(y, j))) end end
end
end
BandTest()
end
if QO then QuakeOnce() end
end
end -- isMov
end
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
while true do
TargetS = 1
for i = 1, nSegs, nSegs / rrlng do
if (TargetS + rrlng ) > nSegs then break end
if not isMovable(TargetS, TargetS + (rrlng)) then repeat
TargetS = TargetS + 1
if (TargetS + rrlng) > nSegs then break end
until isMovable(TargetS, TargetS + (rrlng)) end
rrD() TargetS = TargetS + (rrlng)
if (TargetS + (rrlng)) > nSegs then break end end
if lFirst then rrlng = rrlng - 1
if rrlng < minlng then rrlng = maxlng end
elseif not lFirst then rrlng = rrlng + 1
if rrlng > maxlng then rrlng = minlng end end
end -- while
else
RRc = (maxlng - minlng) + 1
for rc = 1, RRc do
TargetS = 1
for i = 1, nSegs, nSegs / rrlng do
if (TargetS + (rrlng)) > nSegs then break end
if not isMovable(TargetS, TargetS + (rrlng)) then repeat
TargetS = TargetS + 1
if (TargetS + (rrlng)) > nSegs then break end
until isMovable(TargetS, TargetS + (rrlng)) end
rrD() TargetS = TargetS + (rrlng)
if (TargetS + (rrlng)) > nSegs then break end end
if lFirst then rrlng = rrlng - 1 elseif not lFirst then rrlng = rrlng + 1 end -- p("",rrlng,"rrlng,","end of rc, RRc")
end
end -- LoFo
selList = shallowcopy(StartSelCopy)
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()
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()
end
if QO then QuakeOnce() end
end -- tacu
if sortr then
sort('backbone')
cuts = 0
local ab = 0
while cuts < (nSegs - lockd) / 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()
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()
end
if QO then QuakeOnce() end
end -- sortr
if lolc then
cuts = 0
for xy = 1, nSegs do
if (getSS(xy) == 'L') and isMovable(xy, xy) then structure.InsertCut(xy)
cuts = cuts + 1
cutlist[cuts] = xy
if xy > 1 then structure.InsertCut(xy-1)
cuts = cuts + 1
cutlist[cuts] = xy-1 end
end
end
p("", cuts .. " cuts", os.date("%X"))
cutheal()
if CB then
BandAllContacts()
BandTest()
end
if QO then QuakeOnce() end
end -- lolc
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()
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.wh = dialog.AddSlider("whole structure(1) or worst scoring only(2)", 2, 1, 2, 0)
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
wh = opt.wh.value
uc = opt.uc.value
if not tid then Ilng = opt.iln.value end
return Ilng, uc, wh
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()
end
if QO then QuakeOnce() end
end
else -- tid
if wh == 2 then
sort('ideality')
local y=0
for x = 1, (nSegs - lockd) / (Ilng - 1) do
local segC=x
local segI=segC+y
if contains(locklist,Mseg[segI][1]) then repeat y=y+1
segI=segC+y until not contains(locklist,Mseg[segI][1]) end
if Mseg[segI][1] + (Ilng / 2) > nSegs then IdStrt, IdEnd = nSegs - (Ilng - 1), nSegs
elseif Mseg[segI][1] - (Ilng / 2) < 1 then IdStrt, IdEnd = 1, Ilng
else
if Ilng % 2 ~= 0 then
IdStrt = Mseg[segI][1] - math.floor(Ilng / 2)
IdEnd = Mseg[segI][1] + math.floor(Ilng / 2) else
IdStrt = Mseg[segI][1] - (math.floor(Ilng / 2) - 1)
IdEnd = Mseg[segI][1] + math.floor(Ilng / 2)
end end -- p(IdStrt,IdEnd)
selection.DeselectAll()
local Csc = score()
selection.SelectRange(IdStrt, IdEnd)
if uc then
cuts = 0
if IdStrt > 1 then structure.InsertCut(IdStrt - 1)
cuts = cuts + 1
cutlist[cuts] = IdStrt - 1 end
if (IdEnd) < nSegs then structure.InsertCut(IdEnd)
cuts = cuts + 1
cutlist[cuts] = IdEnd end
end
structure.IdealizeSelected()
if uc then cutheal() else
if cut(score()) ~= cut(Csc) then
Test() end
end -- uc
if cut(score()) ~= cut(Csc) then
if CB then
BandSelectedContacts()
BandTest()
end
if QO then QuakeOnce() end
end
recentbest.Restore() Check()
end -- for x
else
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()
end
if QO then QuakeOnce() end
end -- isMov
end
selection.DeselectAll()
end
end -- if tid
recentbest.Restore() Check() end
function NetwTest()
p(" Rotamer Test ", os.date("%X"))
save.Quickload(1)
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(st) end
else Snap(st) end
end 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()end
function Snap(x)
Check()
selectsphere(x, 10)
nTest()
snaps = rotamer.GetCount(x)
for y = 1, snaps do -- p(y,"snaps","of",snaps)
Qscore = score()
rotamer.SetRotamer(x, y) Check()
if cut(score()) ~= cut(Qscore) then
selectsphere(x, 10)
selection.Deselect(x)
nTest() end
end
end
function BrFo()
local Sbf = true
p(" Bruteforcing AAs ", os.date("%X"))
selection.DeselectAll()
local k = 0
local targets = 0
if Sbf then targets = #selList else targets = nSegs end
p(" ", targets .. " targets,", bfcy .. " cycle(s)")
for bcy = 1, bfcy do
if bfcy > 1 then p( "cycle: ".. bcy) end
if bcy > 1 then if CycWig == 2 then setCI(cival) wig()
elseif CycWig == 1 then Test() end end
k = 0
for jj = 1, targets do
selection.DeselectAll()
k = k + 1
if Sbf then st = selList[k] else st = k end
if not structure.IsMutable(st) then return end
oriAA = structure.GetAminoAcid(st)
--[[ if not Sbf then
if contains(PoAs, structure.GetAminoAcid(st)) then BruF(st) end else]]
BruF(st) --end
save.Quickload(1)
newAAeh = structure.GetAminoAcid(st)
if newAAeh ~= oriAA then p(" Target: " .. jj, "cycle: " .. bcy .. ", seg " .. st .. " changed from " .. oriAA .. " to " .. newAAeh) end
end
end -- bfcy
end -- BForce
function BruF(x)
save.Quicksave(94)
if bruSt == 1 then
for i = 1, #PoAs do
save.Quickload(94)
origA = structure.GetAminoAcid(x)
BB, SC = freeze.IsFrozen(x)
if SC == false then structure.SetAminoAcid(x, PoAs[i]) Check()
newA = structure.GetAminoAcid(x)
if not FD then if (newA ~= origA) then selectsphere(x, 10) nTest() end end
if Exh then Snap(x) end
end
end -- PoAs--p(os.date("%X"))
elseif bruSt == 2 then
origA = structure.GetAminoAcid(x)
if structure.IsHydrophobic(x) then
for i = 1, 11 do aanew = Phob[i]
structure.SetAminoAcid(x, aanew) Check()
newA = structure.GetAminoAcid(x)
if not FD then if (newA ~= origA) then selectsphere(x, 10) nTest() end end
if Exh then Snap(x) end
end
save.Quickload(94)
else
for i = 1, 9 do aanew = Phil[i]
structure.SetAminoAcid(x, aanew) Check()
if not FD then if (newA ~= origA) then selectsphere(x, 10) nTest() end end
if Exh then Snap(x) end
end
save.Quickload(94)
end
elseif bruSt == 3 then
for i = 1, #AAs do
save.Quickload(94)
origA = structure.GetAminoAcid(x)
BB, SC = freeze.IsFrozen(x)
if SC == false then structure.SetAminoAcid(x, AAs[i])
newA = structure.GetAminoAcid(x)
if not FD then if (newA ~= origA) then selectsphere(x, 10) nTest() end end
if Exh then Snap(x) end
end
end
end
end
function ran()
local rmx = function()
recentbest.Save()
structure.RemixSelected(4, 5) Check()
setCI(cival * 0.8)
for y = 1, 5 do
save.Quickload(3 + y)
for x = selStr, selEnd do selectsphere(x, 8) end
if muta then structure.MutateSidechainsSelected(1) Check() else
structure.ShakeSidechainsSelected(1) Check() end
wig() Check()
structure.ShakeSidechainsSelected(1) Check()
end
recentbest.Restore() Check()
selection.DeselectAll()
end --end
if RanB==2 then p(" Random Remixes ", os.date("%X"))
elseif RanB==3 then p(" Random Rebuilds and Remixes", os.date("%X"))
elseif RanB==1 then p(" Random Rebuilds ", os.date("%X")) end
while true do
save.Quickload(1)
Qscore = score()
rsz = math.random(minr, maxr) -- rebuild length p(rsz)
broken = true
while broken ~= false do
broken = false
Oseg = selList[math.random(1, #selList)]
for yh = Oseg, (Oseg + rsz) - 1 do -- p(yh, Oseg,(Oseg+rsz)-1)
if not contains(selList, yh) then broken = true end -- p(broken)
end
end
selStr = Oseg
selEnd = (Oseg + rsz) - 1
selection.DeselectAll()
selection.SelectRange(selStr, selEnd) -- p(" segs "..selStr.." to "..selEnd,"lng",rsz)
if RanB~=2 then
Rbld() Check() elseif RanB==2 then rmx() end
if cut(score()) ~= cut(Qscore) then
recentbest.Save()
setCI(cival * 0.8)
for x = selStr, selEnd do
selectsphere(x, 7) end
if muta then structure.MutateSidechainsSelected(1) Check()
wig("s") Check() else
structure.ShakeSidechainsSelected(1) Check() end
selection.DeselectAll()
wig()
if RanB==3 then selection.SelectRange(selStr, selEnd)
rmx() end
Test()
if CB then
BandSelectedContacts()
BandTest()
end
if QO then QuakeOnce() end
end
recentbest.Restore() Check()
for ii = 1, #selList do selection.Select(selList[ii]) end
end end
function ContactBander()
p(" Band Contacts")
BandAllContacts()
CBe = true
if (band.GetCount() < 1) or BF then wb = false else
wb = true end
end
function WorkExBands()
p(" Work Bands", os.date("%X"))
Qscore = score()
if inego then for xzy=1, 3 do save.Quickload(1)
BandTest() end
inego = false else
while true do save.Quickload(1)
BandTest() end
end -- ingo
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)
if not lckd then opt.Tg = dialog.AddCheckbox(" Tailgrab.", false) end
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
if not lckd then TG = opt.Tg.value end
Combo = opt.Cmb.value
return QQ, BiS, Shock, TG, Combo
end
function BFuze()
p(" BandFuze ", os.date("%X"))
local fBf = function()
save.Quickload(1)
Qscore = score()
if QQ or Combo then Quaker() end
BiSs()
if TG then BandAcross() end
end
if ingo then ingo = false
for xy=1, 2 do fBf() end else
while true do fBf() end
end end
---- Band functions
function DisRdm() --p("disrdm")
band.EnableAll()
local RMr = function ()
RM = math.random(-100, 100)
if RM >= 0 then BdOff = false
else BdOff = true end
end
if band.GetCount() > 1 then
if KBE and KBE2 then
for b = 1, band.GetCount() do
if band.GetStrength(b) < 10 then
RMr()
if BdOff then band.Disable(b) end
end
end
elseif not KBE2 and KBE then
for b = oldbands+1, band.GetCount() do
RMr()
if BdOff then band.Disable(b) end
end
else
for b = 1, band.GetCount() do
RMr()
if BdOff then band.Disable(b) end
end
end
end
end
function Delbands() --p("delbands",Cbds)
local BDC = band.GetCount()
if CBe then
for cn = Cbds, BDC - 1 do band.Delete(Cbds + 1) end
elseif KB then
for h = oldbands, BDC - 1 do band.Delete(oldbands + 1) end
else
band.DeleteAll() end
end
function Disbands() --p("disbands")
if KBE and KBE2 then
for b = 1, band.GetCount() do
if band.GetStrength(b) < 10 then
band.Disable(b) end
end
elseif not KBE2 and KBE then
for b = oldbands+1, band.GetCount() do
band.Disable(b) end
else band.DisableAll() end
end
function ZLBand(seg, Str, atom)
local seg2, seg3
local phi =0
local theta = 0
local minlen = 0.1
atom = atom or 0
Str = Str or 10
if (seg == 1) then seg2, seg3 = 2, 3
elseif seg == nSegs then seg2, seg3 = nSegs-1, nSegs-2
else seg2, seg3 = seg-1, seg+1 end
local lb = band.Add(seg, seg2, seg3, 0.1, theta, phi, atom)
if lb > 0 then
band.SetGoalLength(lb, band.GetLength(lb))
band.SetStrength(lb, Str) end
return lb end
function bandpull(minBS, maxBS)
local ss = score()
local perc = math.random(80, 180) / 100
local loss = ((perc * ss) / 100) -- p("ss,perc,loss",ss,perc,loss)
local lastBS = minBS
for str = lastBS, maxBS, 0.1 do
if KBSTR and KBSTR2 then
for i = 1, band.GetCount() do
if band.GetStrength(i) < 10 then band.SetStrength(i, str) end
end
elseif (not KBSTR2 and KBSTR) or ShSt 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") 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() --p("bandtest")
if band.GetCount() > 0 then
band.EnableAll()
if (CBe or (wb and (not BF))) or inego then DisRdm() end
setCI(cival * 0.9)
if SHK then bandpull(5, 5.3) else bandpull(0.2, 3) end
Delbands()
Disbands()
recentbest.Save()
Check()
if muta then
save.Quicksave(93)
setCI(math.random(10, cival * 100) / 100)
structure.MutateSidechainsAll(1) Check()
setCI(cival)
wig() Check()
setCI(cival / 2)
wig() Check()
setCI(cival)
wig() Check()
wig("s") Check()
wig() Check()
recentbest.Restore() Check()
save.Quickload(93) end
wig("s") Check()
Test()
end end
function QuakeOnce()
local dd = math.floor((nSegs - lockd) / 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 not lckd then
if (y <= nSegs) and (isMovable(y,y) or isMovable(x,x)) then band.AddBetweenSegments(x, y) end else
if (y <= nSegs) then band.AddBetweenSegments(x, y) end end
end end
until (band.GetCount() + oldbands) > (oldbands + 3)
BandTest() 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) * 0.7) end
end
end
Cbds = band.GetCount()
save.Quicksave(20)
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]) >= 2) then
if contactmap.GetHeat(y, selList[j]) ~= 0 then lb = band.AddBetweenSegments(y, selList[j])
band.SetGoalLength(lb, band.GetLength(lb) * 0.7) end end
end
end
end
function bandage()
bloat = false
if (cival >= 0.9) and not (CB or ShSt) then
RM = math.random(-100, 100)
if RM >= 0 then bloat = false
else bloat = true end
end
if bloat then
for i = oldbands + 1, band.GetCount() do
if band.GetStrength(i) < 10 then
band.SetGoalLength(i, band.GetLength(i) + 4) end
end
else
for i = oldbands + 1, band.GetCount() do
local leng = band.GetLength(i)
local perc = math.random(20, 50)
local loss = ((perc * leng) / 100)
if band.GetStrength(i) < 10 then
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+oldbands do
if not lckd then
repeat segO = math.random(nSegs)
until not structure.IsLocked(segO)
else segO = math.random(nSegs)
end
if SHK 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 SHK then
band.SetGoalLength(lb, math.random(1))
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
if not lckd then spacebands(((nSegs - lockd) / 2)+1)
else spacebands(nSegs/5) end
BandTest()
end
end -- bis
end -- combo
if Shock then
SHK = true
for u = 1, 2 do
if not lckd then spacebands(((nSegs - lockd) / 2)+1)
else spacebands(nSegs/5) end
BandTest()
end
SHK = false
end end
function BandAcross()
for i = 1, nSegs do
if not structure.IsLocked(i) then first = i break end end
for u = nSegs, 1, -1 do
if not structure.IsLocked(u) then last = u break end end
band.AddBetweenSegments(first, last)
bandage()
BandTest()
band.AddBetweenSegments(nSegs / 2, first)
band.AddBetweenSegments(nSegs / 2, last)
bandage()
BandTest()
end
function Quaker()
if Combo then
for i = 1, 4 do
nrR = math.random(1, 19)
if not lckd then
for u = 1, nrR do
repeat
y = math.random(1, nSegs)
x = math.random(1, nSegs)
until (y ~= x) and isMovable(y,y) or isMovable(x,x)
band.AddBetweenSegments(y, x)
end
else
for u = 1, nrR do
repeat
y = math.random(1, nSegs)
x = math.random(1, nSegs)
until (y ~= x) band.AddBetweenSegments(y, x)
end
end
bandage()
Qbands = band.GetCount()
spacebands(10)
BandTest()
end
else
for i = 1, 2 do
nrR = math.random(1, 19)
if not lckd then
for u = 1, nrR do
repeat
y = math.random(1, nSegs)
x = math.random(1, nSegs)
until (y ~= x) and isMovable(y,y) or isMovable(x,x)
band.AddBetweenSegments(y, x)
end
else
for u = 1, nrR do
repeat
y = math.random(1, nSegs)
x = math.random(1, nSegs)
until (y ~= x) band.AddBetweenSegments(y, x)
end
end
bandage()
BandTest()
end -- quake
end -- combo
end
---- Container
function main()
init()
--if lockd < nSegs - 2 then
dia() --else return end
if DisFil then filter.DisableAll() end
Delbands()
if KBE then band.EnableAll() end
if PrB then ZLBandSS(SS) end
if ShSt then SheetStitcher() end
for nr = 1, 25 do save.Quicksave(nr) end
recentbest.Save()
if DisFil then filter.EnableAll() end
startscore = score()
if DisFil then filter.DisableAll() end
bestscore = startscore
p(string.format(" Startscore: %.4f",startscore))
p(" Best score in quicksave slot 1, start in slot 2 ")
p(" ")
p(" maxCI = " .. cival, " Start time:", os.date("%X"))
p("")
aTime = os.clock()
if ide then
if not tid then Idia() end end
if BF or ingo then BFdia() end
if (PrB or ShSt) then
oldbands = band.GetCount()
KB, KBE = true, true end
if rlx then Relx() end
if inego then WorkExBands() end
if ingo then BFuze() end
if sim then simul() end
if selR then selReb() end
if RMX then Remix() end
if rr then RR() end
if cuts then Cuts() end
if ide then Ide() end
if BForce then BrFo() end
if NTW then NetwTest() end
if randr then ran() end
if CB then ContactBander() end
if wb then WorkExBands() end
if BF then BFuze() end
Result()
end
--[[
Toolbox includes:
-Zero Length Bands, this helps to preserve your general structure and severely limits rebuilds (remix seems unaffected though the subsequent wiggles will get things back in place);
-'Fast' Relax to MaxCI, 4 sets of shake+wiggle of varying CI scaled to MaxCI, with 2/4 of the shakes being mutates when checked; seems suited for going up or down. Based on the Fast Relax protocol.
-Rebuilders, Rainbow whole structure and Selected residues;
-a Remix routine, selected residues only;
-Cut and Wiggle routines, selected residues, worst backbone scores, all loops;
-an Idealize routine, selected residues only or worst scoring ('ideality') only or whole structure variable length with the option to use cutpoints;
-Bruteforce selected AAs, tries every Amino Acid on a segment and does a local shake n wiggle. Polar(1) tries only AAs that can form hbonds, Similar(2) tries only hydrophobic or -philic AAs similar to the original AA.
-a Rotamer Tester, selected residues only (recommended) or all polar residues (hydrophilics + TYR & TRYP), tries all rotamers of current sidechain and local wiggles;
-Contact Bander, bands all contacts with a heat >=0.75 and runs WorkExBands or BandFuze;
-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.
----
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 after the stabilization wiggles if checked.
Random rebuilds/remix, 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)