Icon representing a recipe

Recipe: Rav3n_pl v1 in v2 Bitspawn Overload Filters on/off PrintlinesRemoved

created by Vredeman

Profile


Name
Rav3n_pl v1 in v2 Bitspawn Overload Filters on/off PrintlinesRemoved
ID
100457
Shared with
Public
Parent
Bitspawn Overload Filters on/off PrintlinesRemoved
Children
None
Created on
December 30, 2014 at 17:39 PM UTC
Updated on
December 30, 2014 at 17:39 PM UTC
Description

Add to start of script to toggle filters on and off as well as to use v1 commands in V2...this is bitspawns and Ravs

Best for


Code


-- "lua v1 in v2" library by rav3n_pl --just add it in front of your v1 code and use v2 and v1 code in v2 scripts :) -- print(arg1[,...,argN]) no change :) function are_conditions_met() return current.AreConditionsMet() end function band_add_segment_segment(sgi1, sgi2) band.AddBetweenSegments(sgi1, sgi2) end function band_delete(bndIdx) if bndIdx~= nil then band.Delete(bndIdx) else band.DeleteAll() end end function band_disable(bndIdx) if bndIdx~=nil then band.Disable(bndIdx) else band.DisableAll() end end function band_enable(bndIdx) if bndIdx~=nil then band.Enable(bndIdx) else band.EnableAll() end end function band_set_length(bndIdx, len) band.SetGoalLength(bndIdx, len) end function band_set_strength(bndIdx, str) band.SetStrength(bndIdx, str) end function get_band_count() return band.GetCount() end function deselect_all() selection.DeselectAll() end function deselect_index(sgn) selection.Deselect(sgn) end function select_all() selection.SelectAll() end function select_index(sgn) selection.Select(sgn) end function select_index_range(sg1,sg2) selection.SelectRange(sg1,sg2) end function do_freeze(bbone,schain) freeze.FreezeSelected(bbone,schain) end function do_unfreeze_all() freeze.UnfreezeAll() end function do_global_wiggle_all(iters) structure.WiggleAll(iters,true,true) end function do_global_wiggle_backbone(iters) structure.WiggleAll(iters, true,false) end function do_global_wiggle_sidechains(iters) structure.WiggleAll(iters,false,true) end function do_local_rebuild(iters) structure.RebuildSelected(iters) end function do_local_wiggle(iters) structure.LocalWiggleSelected(iters,true,true) end function do_mutate(iters) structure.MutateSidechainsSelected(iters) end function do_shake(iters) structure.ShakeSidechainsSelected(iters) end function do_sidechain_snap(sgn, snap) rotamer.SetRotamer(sgn, snap) end function get_sidechain_snap_count(sgn) return rotamer.GetCount(sgn) end function load_structure() save.LoadSecondaryStructure() end function save_structure() save.SaveSecondaryStructure() end function quickload(slot) save.Quickload(slot) end function quicksave(slot) save.Quicksave(slot) end function get_exploration_score() return current.GetExplorationMultiplier() end function get_ranked_score() return current.GetScore() end function get_score() return current.GetEnergyScore() end function get_segment_distance(sg1,sg2) return structure.GetDistance(sg1,sg2) end function get_aa(sn) return structure.GetAminoAcid(sn) end function get_segment_count() return structure.GetCount() end function get_ss(sn) return structure.GetSecondaryStructure(sn) end function is_hydrophobic(sn) return structure.IsHydrophobic(sn) end function replace_aa(aa) for i=1,structure.GetCount() do if selection.IsSelected(i) then structure.SetAminoAcid(i, aa) end end end function replace_ss(ss) for i=1,structure.GetCount() do if selection.IsSelected(i) then structure.SetSecondaryStructure(i,ss) end end end function get_segment_score(sg) return current.GetSegmentEnergyScore(sg) end function get_segment_score_part(score_part,sg) return current.GetSegmentEnergySubscore(sg,score_part) end function reset_puzzle() puzzle.StartOver() end function restore_abs_best() absolutebest.Restore() end function restore_credit_best() creditbest.Restore() end function reset_recent_best() recentbest.Save() end function restore_recent_best() recentbest.Restore() end function set_behavior_clash_importance(ci) behavior.SetClashImportance(ci) end -- end of library -- function to copy class/table function CopyTable(orig) local copy = {} for orig_key, orig_value in pairs(orig) do copy[orig_key] = orig_value end return copy end -- functions for filters function FiltersOn() if behavior.GetSlowFiltersDisabled() then behavior.SetSlowFiltersDisabled(false) end end function FiltersOff() if behavior.GetSlowFiltersDisabled()==false then behavior.SetSlowFiltersDisabled(true) end end -- function to overload a funtion function mutFunction(func) local currentfunc = func local function mutate(func, newfunc) local lastfunc = currentfunc currentfunc = function(...) return newfunc(lastfunc, ...) end end local wrapper = function(...) return currentfunc(...) end return wrapper, mutate end -- function to overload a class -- to do: set the name of function classes_copied = 0 myclcp = {} function MutClass(cl, filters) classes_copied = classes_copied+1 myclcp[classes_copied] = CopyTable(cl) local mycl =myclcp[classes_copied] for orig_key, orig_value in pairs(cl) do myfunc, mutate = mutFunction(mycl[orig_key]) if filters==true then mutate(myfunc, function(...) FiltersOn() if table.getn(arg)>1 then -- first arg is self (function pointer), we pack from second argument local arguments = {} for i=2,table.getn(arg) do arguments[i-1]=arg[i] end return mycl[orig_key](unpack(arguments)) else --print("No arguments") return mycl[orig_key]() end end) cl[orig_key] = myfunc else mutate(myfunc, function(...) FiltersOff() if table.getn(arg)>1 then local arguments = {} for i=2, table.getn(arg) do arguments[i-1]=arg[i] end return mycl[orig_key](unpack(arguments)) else return mycl[orig_key]() end end) cl[orig_key] = myfunc end end end -- how to use: MutClass(structure, false) MutClass(band, false) MutClass(current, true)

Comments