Icon representing a recipe

Recipe: nspc - Mutate Interface

created by nspc

Profile


Name
nspc - Mutate Interface
ID
105281
Shared with
Public
Parent
None
Children
Created on
October 16, 2021 at 13:04 PM UTC
Updated on
October 16, 2021 at 13:04 PM UTC
Description

for binder puzzles, detect interface (Binder segments near target) and apply mutate.

Best for


Code


-- Functions Utils -- function GetUnlockedAndLockedSegments() local count = structure.GetCount() local lockeds = {} local unlockeds = {} for i = 1, count do if structure.IsLocked(i) then lockeds[#lockeds+1] = i else unlockeds[#unlockeds+1] = i end end return lockeds, unlockeds end function IsNearLocked(index, lockeds, lockedsCount) minDistance = 10000 -- like a max value for i = 1, lockedsCount do local distance = structure.GetDistance(index, lockeds[i]) if (distance < minDistance) then minDistance = distance; end end return minDistance <= parameters.minDistance end function DetectInterface() selection.DeselectAll() local lockeds, unlockeds = GetUnlockedAndLockedSegments() local lockedCount = #lockeds local unlockedsCount = #unlockeds local selectedCount = 0 for i = 1, unlockedsCount do local segmentIndex = unlockeds[i] if IsNearLocked(segmentIndex, lockeds, lockedCount) then selection.Select(segmentIndex) selectedCount = selectedCount + 1 end end print ("Selected segments count " .. selectedCount) end -- Parameters -- parameters = {} function GetParameters() local dialogBox = dialog.CreateDialog("nspc - Mutate Interface") dialogBox.ok = dialog.AddButton("OK" , 1) dialogBox.cancel = dialog.AddButton("Cancel" , 0) dialogBox.margin1 = dialog.AddLabel(" ") dialogBox.description = dialog.AddLabel("Detect and select binder segments near target\nand apply a mutate on it") dialogBox.margin2 = dialog.AddLabel(" ") dialogBox.minDistance = dialog.AddSlider("Min dist with target", 9, 5, 15, 1) dialogBox.mutateIterations = dialog.AddSlider("Mutate iterations", 3, 1, 10, 0) dialogBox.disableFilters = dialog.AddCheckbox("Force Disable Filters", false) if (dialog.Show(dialogBox ) == 1) then parameters.minDistance = dialogBox.minDistance.value; parameters.disableFilters = dialogBox.disableFilters.value; parameters.mutateIterations = dialogBox.mutateIterations.value; return true end return false end -- Main Functions -- function Cleanup() print ("Cleanup") if (parameters.disableFilters == true) then behavior.SetFiltersDisabled(false) end end function ErrorHandler(errorMessage) if errorMessage ~= nil then if string.find(errorMessage, "Cancelled") then print( "User cancel" ) Cleanup(); else print(errorMessage) end end end function Main() if (GetParameters () == false) then return end if (parameters.disableFilters == true) then behavior.SetFiltersDisabled(true) end print ("Start recipe") DetectInterface() structure.MutateSidechainsSelected(parameters.mutateIterations); Cleanup(); end xpcall(Main, ErrorHandler)

Comments


nspc Lv 1

An example vidéo that show the use.
It is useful when you want to quickly work on interface near target, without mutate the whole protein.