Profile
- Name
- extruder2 by jeff101
- ID
- 109231
- Shared with
- Public
- Parent
- extruder2
- Children
- None
- 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.Label1 = dialog.AddLabel(" \nstartres is the number of amino acids\non each strand you want to begin unfrozen:\n ")
ask.Startres = dialog.AddSlider("startres: ", 1, 1, maxlen, 0) -- default is 1, pick values from 1 to maxlen, 0 means use intergers only
ask.Label2 = dialog.AddLabel(" \nconlo is the lowest value to use for con\nwhere con is the Clash Importance:\n ")
ask.Conlo = dialog.AddSlider("conlo: ",0.05,0.01,1.00,2) -- default is 0.05, range is 0.01 to 1.00, precision is 10^-2 or 0.01
ask.Label3 = dialog.AddLabel(" \nconhi is the highest value to use for con:\n ")
ask.Conhi = dialog.AddSlider("conhi: ",1.00,0.01,1.00,2)
ask.Label4 = dialog.AddLabel(" \ncsteps is the number of values\nfor con to have between conlo and conhi:\n ")
ask.Csteps = dialog.AddSlider("csteps: ",20,2,100,0) -- default is 20, range is 2 to 100, precision is 10^-0 or 1
ask.OK = dialog.AddButton("OK", 1)
dialog.Show(ask)
startres=ask.Startres.value
csteps=ask.Csteps.value
conlo=ask.Conlo.value
conhi=ask.Conhi.value
if conlo > conhi then -- make sure conlo <= conhi holds
tmp = conhi
conhi = conlo
conlo = tmp
end -- if conlo
if startres > maxlen then
startres = maxlen
end -- if startres
print('startres='..startres..' conlo='..conlo..' conhi='..conhi..' csteps='..csteps)
--
-- Next fold it all.
--
freeze.FreezeAll() -- freeze it all
j=1 -- j is how long each unfrozen strand section is
while j<=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
for cstep=1,csteps do
con=conlo+(conhi-conlo)*(cstep-1)/(csteps-1)
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 -- if newscore
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 cstep
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 -- if j
j=j+1
end -- while j
print('all done now')