Icon representing a recipe

Recipe: Contact Ditty 1.11

created by drjr

Profile


Name
Contact Ditty 1.11
ID
49839
Shared with
Public
Parent
None
Children
None
Created on
August 15, 2014 at 00:05 AM UTC
Updated on
August 15, 2014 at 00:05 AM UTC
Description

wwww

Best for


Code


TimesIn = 0 SlotNo = 1 function PrepareForContacts() for t=1,structure.GetCount() do if structure.GetSecondaryStructure(t) == "H" or structure.GetSecondaryStructure(t) == "E" then freeze.Freeze(t, true, false) end end for t = 1, structure.GetCount()-1 do if structure.GetSecondaryStructure(t) == "L" and structure.GetSecondaryStructure(t+1) == "H" then structure.InsertCut(t) end if structure.GetSecondaryStructure(t) == "L" and structure.GetSecondaryStructure(t+1) == "E" then structure.InsertCut(t) end if structure.GetSecondaryStructure(t) == "E" and structure.GetSecondaryStructure(t+1) == "L" then structure.InsertCut(t) end if structure.GetSecondaryStructure(t) == "H" and structure.GetSecondaryStructure(t+1) == "L" then structure.InsertCut(t) end if structure.GetSecondaryStructure(t) == "H" and structure.GetSecondaryStructure(t+1) == "E" then structure.InsertCut(t) end if structure.GetSecondaryStructure(t) == "E" and structure.GetSecondaryStructure(t+1) == "H" then structure.InsertCut(t) end end end function RepairCutpoints() for k = 1, structure.GetCount()-1 do structure.DeleteCut(k) end end function CountContacts() --instead, this returns number of contacts made bcount = 0 count = structure.GetCount() for i = 1, count-2 do for j = i+2, count do if contactmap.GetHeat(i, j) > 0 then if contactmap.IsContact(i,j) == true then bcount = bcount + 1 end end end end return bcount end function GetSlot() TimesIn = TimesIn + 1 if TimesIn == 1 then print("Anything after slot", lll, "is junk!") end local dlg = dialog.CreateDialog("Quicksave Slot Retrieval") dlg.RS = dialog.AddSlider("Retrieve Slot#", SlotNo, 1, 99, 0) dlg.QA = dialog.AddCheckbox("Quit Already", false) dlg.OK = dialog.AddButton("Do It",1) dialog.Show(dlg) DoRetrieveSlot=dlg.RS.value save.Quickload(DoRetrieveSlot) print("Slot", DoRetrieveSlot, "restored", CountContacts(), "contacts", current.GetScore()) if dlg.QA.value == false then SlotNo = dlg.RS.value + 1 GetSlot() end end function Cleanup(err) behavior.SetClashImportance(1) print(err) -- StopItAlready = NowIMeanIT end function Crapshoot() band.DeleteAll() print("This runs for 99 iterations.") print("You may cancel at any time.") for lll = 1, 99 do Susband() PrepareForContacts() behavior.SetClashImportance(0) structure.WiggleAll(5) behavior.SetClashImportance(1) structure.ShakeSidechainsAll(1) structure.WiggleAll(5) band.DeleteAll() RepairCutpoints() freeze.UnfreezeAll() structure.ShakeSidechainsAll(1) structure.WiggleAll(25) save.Quicksave(lll) print(CountContacts(), "contacts, slot", lll, current.GetScore()) band.DeleteAll() end end PullClusters = true function Susband() GOOD_MULT = 0.9 BAD_MULT = 0.75 HIGH_STRENGTH = 1.3 LOW_STRENGTH = 0.9 bcount = 0 count = structure.GetCount() for i = 2, count-2 do for j = i+2, count-1 do if contactmap.GetHeat(i, j) > 0 then b = band.AddBetweenSegments(i,j,5,5) bcount = bcount + 1 if contactmap.IsContact(i,j) then do band.SetGoalLength(b, GOOD_MULT * band.GetLength(b)) band.SetStrength(b, LOW_STRENGTH) end else band.SetGoalLength(b, BAD_MULT * band.GetLength(b)) band.SetStrength(b, HIGH_STRENGTH) end if structure.GetSecondaryStructure(i) == "E" and structure.GetSecondaryStructure(j) == "E" then band.SetStrength(b, 3) band.SetGoalLength(b, 3.5) end if PullClusters == true then b = band.AddBetweenSegments(i-1,j-1,5,5) band.SetGoalLength(b, 0.7 * band.GetLength(b)) band.SetStrength(b, 0.5) bcount = bcount + 1 b = band.AddBetweenSegments(i,j-1,5,5) band.SetGoalLength(b, 0.7 * band.GetLength(b)) band.SetStrength(b, 0.5) bcount = bcount + 1 b = band.AddBetweenSegments(i-1,j,5,5) band.SetGoalLength(b, 0.7 * band.GetLength(b)) band.SetStrength(b, 0.5) bcount = bcount + 1 b = band.AddBetweenSegments(i+1,j+1,5,5) band.SetGoalLength(b, 0.7 * band.GetLength(b)) band.SetStrength(b, 0.5) bcount = bcount + 1 b = band.AddBetweenSegments(i,j+1,5,5) band.SetGoalLength(b, 0.7 * band.GetLength(b)) band.SetStrength(b, 0.5) bcount = bcount + 1 b = band.AddBetweenSegments(i+1,j,5,5) band.SetGoalLength(b, 0.7 * band.GetLength(b)) band.SetStrength(b, 0.5) bcount = bcount + 1 end end end end --print(bcount.." contact bands placed") --print(b.." total bands") end function PushOut() bcount = 0 count = structure.GetCount() for i = 1, count-2 do for j = i+4, count do if contactmap.GetHeat(i, j) == 0 then if contactmap.IsContact(i,j) then b = band.AddBetweenSegments(i,j,5,5) bcount = bcount + 1 band.SetGoalLength(b, 1.1 * band.GetLength(b)) band.SetStrength(b, 0.3) end end end end end function PrepareForContacts() for t=1,structure.GetCount() do if structure.GetSecondaryStructure(t) == "H" or structure.GetSecondaryStructure(t) == "E" then freeze.Freeze(t, true, false) end end for t = 1, structure.GetCount()-1 do if structure.GetSecondaryStructure(t) == "L" and structure.GetSecondaryStructure(t+1) == "H" then structure.InsertCut(t) end if structure.GetSecondaryStructure(t) == "L" and structure.GetSecondaryStructure(t+1) == "E" then structure.InsertCut(t) end if structure.GetSecondaryStructure(t) == "E" and structure.GetSecondaryStructure(t+1) == "L" then structure.InsertCut(t) end if structure.GetSecondaryStructure(t) == "H" and structure.GetSecondaryStructure(t+1) == "L" then structure.InsertCut(t) end if structure.GetSecondaryStructure(t) == "H" and structure.GetSecondaryStructure(t+1) == "E" then structure.InsertCut(t) end if structure.GetSecondaryStructure(t) == "E" and structure.GetSecondaryStructure(t+1) == "H" then structure.InsertCut(t) end end end function BandDelete() if BandNo > 0 then do while BandNo < band.GetCount() do band.Delete(band.GetCount()) end end else band.DeleteAll() end end function CountContacts() --instead, this returns number of contacts made bcount = 0 count = structure.GetCount() for i = 1, count-2 do for j = i+2, count do if contactmap.GetHeat(i, j) > 0 then if contactmap.IsContact(i,j) == true then bcount = bcount + 1 end end end end return bcount end function Cleanup(err) behavior.SetClashImportance(1) print(err) -- StopItAlready = NowIMeanIT end function GetBestContacts() recentbest.Save() BestContactsAt = 1 Contacts = CountContacts() for y = 1, 100 do save.Quickload(y) NewContacts = CountContacts() if Contacts < NewContacts then Contacts = NewContacts BestContactsAt = y end save.Quickload(BestContactsAt) end print("slot", BestContactsAt, CountContacts(), "contacts") end function GetBestSlot() BestScoreAt = 1 Score = current.GetScore() for y = 1, 100 do save.Quickload(y) if Score < current.GetScore() then Score = current.GetScore() BestScoreAt = y end end print("Best score =", Score, "Slot", BestScoreAt, CountContacts() , "contacts" ) end function GetSlot() local dlg = dialog.CreateDialog("Quicksave Slot Retrieval") dlg.RS = dialog.AddSlider("Retrieve Slot#", SlotNo, 1, 100, 0) dlg.GBS = dialog.AddCheckbox("Get Best Score Slot", false) dlg.GBCS = dialog.AddCheckbox("Get Best Contacts Slot", false) dlg.QA = dialog.AddCheckbox("Quit Already", QuitAlready) dlg.OK = dialog.AddButton("Do It",1) dialog.Show(dlg) DoRetrieveSlot=dlg.RS.value DoGetBestSlot = dlg.GBS.value DoGetBestContactsSlot = dlg.GBCS.value QuitAlready = dlg.QA.value if DoGetBestContactsSlot == true then GetBestContacts() end if DoGetBestSlot == true then GetBestSlot() end if QuitAlready == false then save.Quickload(DoRetrieveSlot) print("Slot", DoRetrieveSlot, "restored", current.GetScore()) SlotNo = dlg.RS.value + 1 GetSlot() end freeze.UnfreezeAll() for t = 1,structure.GetCount() do structure.DeleteCut(t) end band.DeleteAll() end function ContactDitty() print(CountContacts(), "contacts", current.GetScore()) PrepareForContacts() BandNo = band.GetCount() for l = 1,99 do PushOut() behavior.SetClashImportance(0) structure.WiggleAll(5) BandDelete() Susband() structure.WiggleAll(5) behavior.SetClashImportance(1) structure.ShakeSidechainsAll(1) structure.WiggleAll(15) BandDelete() save.Quicksave(l) print("slot",l, CountContacts(), "contacts", current.GetScore()) end end --xpcall(ContactDitty, GetSlot) xpcall(ContactDitty,GetSlot)

Comments