Profile
- Name
- softwalker+gmn
- ID
- 107983
- Shared with
- Public
- Parent
- None
- Children
- Created on
- September 21, 2022 at 22:12 PM UTC
- Updated on
- May 25, 2023 at 02:56 AM UTC
- Description
Best for
Code
--[[------------------------------------------------------------------------------------------------
-- ST - softwalker v1.0.0.0.
-- gently LWS (Local Wiggle Segments) protein in a way which prevents stiffening.
Copyright (C) 2011 Seagat2011 <http://fold.it/port/user/1992490>
Copyright (C) 2011 thom001 <http://fold.it/port/user/172510>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
$Id$
- Port to APIv2 by SemperRabbit 20220911
------------------------------------------------------------------------------------------------]]--
-- OPTIONS
local duration = 25 -- LWS duration
---------------------------------------------------------------------------------------------------
local function _floor ( seg ) -- math: round upward to nearest whole number ( integer )
local n = seg.count / seg.groups
return n - n % 1
end
local function select_range ( seg ) -- Select the next index range, according to the required number of groups, then return the next index.
local i
local c
local g
i = seg.idx
g = _floor ( seg )
c = seg.count
selection.DeselectAll ( )
if i + g <= c then
print ( "Range: ", i, " - ", i + g )
selection.SelectRange ( i, i + g )
if i + g + 1 <= c then
seg.idx = i + g + 1
else
seg.idx = c
end
else
print ( "Ending Range: ", i, " - ", c )
selection.SelectRange ( i, c )
end
return seg
end
local function set_range ( seg ) -- Set the total segment count into groups
seg.groups = seg.groups * 2
return seg
end
local function lws ( seg ) -- Continue with LWS while threshold is met
local a
local b
local duration
local deep_duration
duration = seg.duration
a = current.GetScore ( )
structure.LocalWiggleSelected ( duration )
b = current.GetScore ( )
while ( b - a > seg.thr ) do
print ( "Gain: ", b, " + ", b - a )
a = current.GetScore ( )
structure.LocalWiggleSelected ( duration )
b = current.GetScore ( )
end
recentbest.Restore ( )
end
recentbest.Restore ( )
print ( "Starting score = ", current.GetScore ( ) )
while ( 1 ) do -- local wiggle Init
seg = {
thr = 10,
idx = 1,
idx_reset = 1,
groups = 2,
groups_reset = 2,
duration = duration,
count = structure.GetCount ( ),
}
duration = duration + 1
while ( 1 ) do -- local wiggle at this threshold
print ( "\nStep_", seg.thr, "\n\n" )
while ( 1 ) do -- local wiggle at this range
while ( 1 ) do -- local wiggle at this index
local idx = seg.idx
seg = select_range ( seg )
lws ( seg )
if idx == seg.idx then break end
end -- while ( 1 )
seg.idx = seg.idx_reset
seg = set_range ( seg )
print ( "\n" )
if seg.groups > seg.count then break end
end -- while ( 1 )
seg.groups = seg.groups_reset
selection.SelectAll ( )
structure.WiggleAll ( duration )
structure.ShakeSidechainsAll ( 1 )
if seg.thr > 0.0002 then
seg.thr = seg.thr / 5
else
break
end
end -- while ( 1 )
end -- while ( 1 )