Icon representing a recipe

Recipe: nspc - Rotamer check

created by nspc

Profile


Name
nspc - Rotamer check
ID
106448
Shared with
Public
Parent
None
Children
None
Created on
April 03, 2022 at 17:05 PM UTC
Updated on
April 03, 2022 at 17:05 PM UTC
Description

Set best rotamers subscore in selected sidechains, ignoring other subscore like clash.

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() print ("Auto detect segment near target..") 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 function IsAValidSegmentSelected() local count = structure.GetCount() for seg = 1, count do if selection.IsSelected(seg) and structure.IsLocked(seg) == false then return true; end end return false; end function PrintScore(score) return string.format("%.4f", score) end -- Parameters -- parameters = {} function GetParameters() local dialogBox = dialog.CreateDialog("nspc - Rotamer") dialogBox.ok = dialog.AddButton("OK" , 1) dialogBox.cancel = dialog.AddButton("Cancel" , 0) dialogBox.margin1 = dialog.AddLabel(" ") dialogBox.description1 = dialog.AddLabel("Set best rotamer subscore in selected sidechains,") dialogBox.description2 = dialog.AddLabel("ignoring other subscores.") dialogBox.description3 = dialog.AddLabel(" ") dialogBox.description4 = dialog.AddLabel("This can help to find bad rotamers") dialogBox.description5 = dialog.AddLabel("in binder designs that can cause binder fail.") dialogBox.margin2 = dialog.AddLabel(" ") dialogBox.disableFilters = dialog.AddCheckbox("Force Disable Filters", false) dialogBox.autoSelectDesc = dialog.AddLabel("You can auto select sidechains near binder :") dialogBox.autoSelectionNearTarget = dialog.AddCheckbox("Auto selection near target", false) dialogBox.minDistance = dialog.AddSlider("Min dist with target", 9, 5, 15, 1) if (dialog.Show(dialogBox ) == 1) then parameters.minDistance = dialogBox.minDistance.value; parameters.disableFilters = dialogBox.disableFilters.value; parameters.autoSelectionNearTarget = dialogBox.autoSelectionNearTarget.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 SetBestRotamers() save.Quicksave(3) for seg = 1, structure.GetCount() do save.Quicksave(4) if selection.IsSelected(seg) then local startScore = current.GetSegmentEnergySubscore(seg, "sidechain") local maxScore = startScore local bestRotamer = 1; print("Working on segment " .. seg .. " : current score : " .. PrintScore(startScore)) for rot = 1, rotamer.GetCount(seg) do rotamer.SetRotamer(seg, rot) local currentScore = current.GetSegmentEnergySubscore (seg, "sidechain") if currentScore > maxScore then maxScore = currentScore; bestRotamer = rot; end end if (maxScore > startScore) then rotamer.SetRotamer(seg, bestRotamer) save.Quicksave(4) print("Increased rotamer score to " .. PrintScore(maxScore)) else save.Quickload(4) print("No score change") end print("-----") print(" ") end end -- load starting protein and just after new one save.Quicksave(2) save.Quickload(3) save.Quickload(2) end function Main() if (GetParameters() == false) then return end if (parameters.disableFilters == true) then behavior.SetFiltersDisabled(true) end print ("Start recipe Rotamer") if (parameters.autoSelectionNearTarget == true) then DetectInterface() elseif (IsAValidSegmentSelected() == false) then print ("No Valid segment selected") print ("Use auto selection option or select some segments before start") end SetBestRotamers(); Cleanup(); end xpcall(Main, ErrorHandler)

Comments


nspc Lv 1

This recipe is a tool to set all selected rotamers in the best "ideality" position, ignoring other subscores.
It is only to check rotamers, it is not a tool that realy improve them automatically in the puzzle.

In binder puzzles, If thistool result have too mush clashes, and can't be resolve with wiggle, maybe those sidechains can cause problem in lab.
So maybe we have to choose a different sidechain in some situation.

It is a tool that cans help during Hand Folding