Profile
- Name
- extruder by jeff101
- ID
- 109230
- Shared with
- Public
- Parent
- extruder
- Children
- Created on
- October 28, 2025 at 08:21 AM UTC
- Updated on
- October 28, 2025 at 08:22 AM UTC
- Description
fold strands 'naturally' from N-terminus to C-terminus
Best for
Code
-- extruder made 4/27/12 by jeff101.
--
-- Goal is to fold protein 'naturally' starting with the N-terminus of each strand.
-- This script assumes all strands start as widely-separated parallel linear chains
-- with loop as their secondary structure.
--
-- startres = 1 -- use 1 for the first run, use higher numbers if restarting a cancelled run
-- startres = 17 -- tells how many residues per strand to unfreeze at the start
-- startres = 1000 -- use a very high number to start with all residues unfrozen
--
-- First get information about the protein strands.
--
tot=structure.GetCount() -- find # of residues in the protein
nstr=1 -- # of strands in the protein
starts={1} -- # beginnings of strands
ends={} -- # ends of strands
for i=2,tot do
im=i-1
dist=structure.GetDistance(im,i) -- find distance between residues i-1 and i
if dist > 5 then
print('break between residues '..im..' and '..i)
ends[nstr]=i-1
nstr=nstr+1
starts[nstr]=i
end -- if dist
end -- for i
ends[nstr]=tot
print('for '..tot..' residues we have '..nstr..' strands')
lens=ends
--
-- Next report the endings of each strand.
--
maxlen=0
for i=1,nstr do
lens[i]=ends[i]-starts[i]+1
if lens[i]>maxlen then
maxlen=lens[i]
end -- if lens
print('strand '..i..' goes from residue '..starts[i]..' to '..ends[i]..' and has length '..lens[i])
end -- for i
print('the longest of the '..nstr..' strands has length '..maxlen)
local ask=dialog.CreateDialog('Extruder')
ask.Instructions = dialog.AddLabel("Set startres to the number of amino acids\non each strand you want to begin unfrozen:")
ask.Startres = dialog.AddSlider("startres:", 1, 1, maxlen, 0) -- default is 1, pick values from 1 to maxlen, 0 means use intergers only
ask.OK = dialog.AddButton("OK", 1)
dialog.Show(ask)
startres=ask.Startres.value
if startres > maxlen then
startres = maxlen
end
print('startres='..startres)
--
-- Next fold it all.
--
freeze.FreezeAll() -- freeze it all
for j=1,maxlen do -- j is how long each unfrozen strand section is
print('about to wiggle and shake up to '..j..' residues on each strand')
for i=1,nstr do -- i is which strand we are doing
nlo=starts[i]
nhi=starts[i]+j-1
if nhi>ends[i] then
nhi=ends[i]
end -- if nhi
freeze.Unfreeze(nhi,true,true) -- unfreezing nhi each time should eventually unfreeze all parts
end -- for i
if j >= startres then
conlo=0.05
conhi=1.00
constp=0.05
for con=conlo,conhi,constp do
behavior.SetClashImportance(1) -- set Clash Importance to 1
oldscore=current.GetScore() -- get current score
recentbest.Save() -- save current score's pose
selection.SelectAll() -- select everything
structure.RebuildSelected(1)
behavior.SetClashImportance(con) -- set Clash Importance to con
print('just rebuilt, now doing wiggle, shake, wiggle with con='..con..' for up to '..j..' residues per strand')
structure.WiggleAll(5) -- wiggle unfrozen parts
structure.ShakeSidechainsAll(2) -- shake unfrozen parts
structure.WiggleAll(5) -- wiggle unfrozen parts
behavior.SetClashImportance(1) -- set Clash Importance to 1
newscore=current.GetScore()
if newscore > oldscore then
print('new score '..newscore..' beats '..oldscore..' so save new')
recentbest.Save()
else
print('old score '..oldscore..' beats '..newscore..' so restore old')
recentbest.Restore() -- reload oldscore's pose
end
behavior.SetClashImportance(con) -- set Clash Importance to con
print('doing wiggle, shake, wiggle with con='..con..' for up to '..j..' residues per strand')
structure.WiggleAll(5) -- wiggle unfrozen parts
structure.ShakeSidechainsAll(2) -- shake unfrozen parts
structure.WiggleAll(5) -- wiggle unfrozen parts
end -- for con
end -- if j
if j == maxlen then
j = maxlen-1 -- this will prevent j from ever exceeding maxlen
-- and will keep the loop going until the script is cancelled
end
end -- for j
print('all done now')