Icon representing a recipe

Recipe: Aromatic Remove 1.1

created by Bruno Kestemont

Profile


Name
Aromatic Remove 1.1
ID
102284
Shared with
Public
Parent
None
Children
None
Created on
November 15, 2017 at 17:50 PM UTC
Updated on
November 15, 2017 at 17:50 PM UTC
Description

Mutate penalizing aromatics to something else in order to recover the full filter bonus

Best for


Code


--Aromatic remove by Bruno Kestemont v1.1 --It tries mutating penalized aromatic segments to something else --Mutate action does not take penalties into account. This recipe is there to try to correct this. --v1.1: default kill + added shakes segCnt=structure.GetCount() segCnt2=segCnt while structure.GetSecondaryStructure(segCnt2)=="M" do segCnt2=segCnt2-1 end -- not used yet (ligand) local OriginalFilterSetting = behavior.GetFiltersDisabled() --start Options Aromatickill=true -- true = even if loozing points --end options function round(x)--cut all afer 3-rd place return x-x%0.001 end -- functions for filters function FiltersOn() if behavior.GetFiltersDisabled() then behavior.SetFiltersDisabled(false) end end function FiltersOff() if behavior.GetFiltersDisabled()==false then behavior.SetFiltersDisabled(true) end end function FiltersReset() -- to original one behavior.SetFiltersDisabled(OriginalFilterSetting) end function Score() return current.GetEnergyScore() end --START Mutate stuffs by Bruno Kestemont chains={'a', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'k', 'l', 'm', 'n', 'p', 'q', 'r', 's', 't', 'v', 'w', 'y'} -- all of them TNTchains={"G";"A";"V";"C";"P";"T";"S";"I";"L";"N";"M";"Q";"F";"Y";"W"} --desired for TNT: no ASP, GLU, ARG, LYS, HIS BPbanished= {'f', 'y', 'w'} BPall={'d', 'e', 'h', 'i', 'k', 'l', 'm', 'n', 'q', 'r', 's', 't', 'v'} -- no "a g p c" prohibided or "f y w" penalized aaall={'a', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'k', 'l', 'm', 'n', 'p', 'q', 'r', 's', 't', 'v', 'w', 'y'} aaphilic={'d','e','h','k','n','q','r','s','t'} aaphobic={'a','c','f','g','i','l','m','p','v','w','y'} aasheet={'t','c','f','i','v','w','y'} aahelix={'e','k','q','r','a','l','m'} aaloop={'d','h','n','s','g','p'} aanotloop={'t','c','f','i','v','w','y','e','k','q','r','a','l','m'} aanothelix={'d','h','n','s','g','p','t','c','f','i','v','w','y'} aanotsheet={'e','k','q','r','a','l','m','d','h','n','s','g','p'} aasheetphilic={'t'} aasheetphobic={'c','f','i','v','w','y'} aahelixphilic={'e','k','q','r'} aahelixphobic={'a','l','m'} aaloopphilic={'d','h','n','s'} aaloopphobic={'g','p'} aanotloopphilic={'t','e','k','q','r'} aanotloopphobic={'c','f','i','v','w','y','a','l','m'} aanothelixphilic={'t','e','k','q','r'} aanothelixphobic={'c','f','i','v','w','y','g','p'} aanotsheetphilic={'d','e','h','k','n','q','r','s'} aanotsheetphobic={'a','l','m','g','p'} aadonnors= {'s','t','n','q','r','h','k','d','e','w','y'} -- +1 (or may be it's acceptor? To verify aaacceptors= {'s','t','n','q','h','d','e','y'} -- -1 aaneutral= {'v','l','m','p','i','a','c','f','g'} -- non H binding {v l m p i a c f g} aabonding= {'s','t','n','q','r','h','k','d','e','w','y'} -- = aadonnors {s t n q r h k d e w y} aahelixbonding= {'q','r','k','e'} aasheetbonding= {'t','w','y'} aaloopbonding= {'s','n','h','d'} aabondingphilic= {'s','t','n','q','r','h','k','d','e','w','y'} -- = aadonnors aahelixbondingphilic= {'q','r','k','e'} -- = aahelixphilic aasheetbondingphilic= {'t'} -- = aasheetphilic aaloopbondingphilic= {'s','n','h','d'} -- = aaloopphilic function SegmentInList(s,list) -- reports if s in the list table.sort(list) for i=1,#list do if list[i]==s then return true elseif list[i]>s then return false end end return false end function FilterScore() local OriginalFilterSetting = behavior.GetFiltersDisabled() FiltersOn() local onS=Score() FiltersOff() local offS=Score() FiltersReset() return onS-offS end function AromaticMute() local AAi="g" local ss=Score() local es=ss local sf=FilterScore() StartScore=ss StartFilter=sf print("Start Score: "..round(StartScore)) print("Start Filter: "..round(StartFilter)) local ef=sf local fc=es-ss for i= 1, segCnt2 do AAi= structure.GetAminoAcid(i) if SegmentInList(AAi,BPbanished) then save.Quicksave(3) recentbest.Save() sf=FilterScore() structure.SetAminoAcid(i,'h') ef=FilterScore() fc=ef-sf if fc ~= 0 then print("Mutating "..AAi.." from seg "..i) if Aromatickill then recentbest.Save() else recentbest.Restore() end for j= 1, #BPall do structure.SetAminoAcid(i, BPall[j]) end --QuickShake(1) recentbest.Restore() es=Score() ef=FilterScore() local scorechange=es-ss local filtergain=ef-sf print("Score change:"..round(scorechange).." / Filter gain: "..round(filtergain)) if filtergain < 0.01 and scorechange< 0.01 then save.Quickload(3) print("Failed. Recovering "..AAi) recentbest.Save() else print("Mutated to "..structure.GetAminoAcid(i)) print("Score:"..round(es).." / Filter: "..round(ef)) end end recentbest.Restore() end end QuickShake(1) structure.ShakeSidechainsAll ( 1 ) recentbest.Restore() es=Score() ef=FilterScore() print("Total score change:"..round(es-StartScore).." / Total filter gain: "..round(ef-StartFilter)) print ("End score= "..round(es)) print ("End filter= "..round(ef)) end --END Mutate stuffs by Bruno Kestemont --START quick shake algorithm function QuickShake(iter) local iter=iter or 1 --[[------------------------------------------------------------------------------------------------ -- Algorithm for faster shake REFERENCES 1. N/A Copyright (C) 2014 Seagat2011 <http://fold.it/port/user/1992490> This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. $Id$ ------------------------------------------------------------------------------------------------]]-- --[[ v1 - Inception 1.2 - Loops until nogain ]]-- local idx = 1 local idx2 = structure.GetCount () local hash = {} local cs = current.GetScore () --print ( 'Quick Shake Algorithm v1.2 SG2011 - Current Score: '..cs ) local function New ( obj ) return obj -- pass-new-obj-by-value end local _gses = New ( current.GetSegmentEnergySubscore ) local function SmartShake ( iters ) local gain = true while (gain) do gain = false for i=idx,idx2 do local ci = _gses ( i,'clashing' ) if ci < _gses ( i,'hiding' ) and ci < _gses ( i,'packing' ) and ci < _gses ( i,'ideality' ) and ci < _gses ( i,'sidechain') and ci < _gses ( i,'bonding' ) and ci < _gses ( i,'other' ) and ci < _gses ( i,'reference') then selection.Select ( i ) end -- test ci -- end -- loop -- if selection.GetCount () then local css = current.GetScore () structure.ShakeSidechainsSelected ( iters ) selection.DeselectAll () if current.GetScore () > css then gain = true end -- test -- end -- test -- end -- loopf -- end structure.SmartShake = SmartShake structure.SmartShake ( iter ) --print ( 'Done.' ) end --END quick shake algorithm AromaticMute() --suggesion: you may now shake and wiggle

Comments


Bruno Kestemont Lv 1

In design puzzles only.
When the filters says "Residues scoring too low" after mutating all, this short recipe mutates the bad aromatics to something else.
The result is a better filter bonus and, most of the time, a better score as well.

I suggest to wiggle and shake after the recipe before to decide.

If you are not satisfied with the result, simply restore credited best.