Back to Recipes Homepage
recipe picture
Recipe: StraightenRange V1.0
0
Your rating: None
Used 5 times with an average impact of -16953 points.

Profile

Name: StraightenRange V1.0
ID: 7275
Created on: Sun, 08/08/2010 - 07:10
Updated on: Sun, 08/08/2010 - 14:10
Description:

This script straightens an example range between Segment 19 and 25. change parameters in last script line to your needs. See script for details.



Best For


Comments

Joined: 09/18/2009
Groups: SETI.Germany
That's how the code does look like

-- StraightenRegion V1.0 by Crashguard303
-- Inspired by Tlaloc's "Make Denovo"
-- Instead of stretching the whole puzzle, here you can set a start and ending segment,
-- in which range the puzzle is straightened out.
-- Useful if you can't reach the straighten out knob, or you don't want to hold it down all the time.
-- Plus, it keeps your previously applied bands.
-- This script does straighten out the region from segment 19 to 25 as example.
-- change the values of the last line to apply it to your desired region.
-- This script does not work as perfect as the original straightening,
-- but comes relatively close.

function StraightenRange(SegA,SegB) -- Straightens the region between SegA and SegB
local k
local SegA=SegA
local SegB=SegB
if SegB SegB, swap them

deselect_all()
for k=SegA,SegB do -- select region for wiggle later
print("Selecting segment:",k)
select_index(k)
end -- k loop

SegA=SegA-2
-- As we connect the segments with its 2nd next neighbour, we have to start 2 segments before with banding
if SegA<1 then SegA=1 end
if SegB>get_segment_count()-2 then SegB=get_segment_count()-2 end

local FirstSBand
local LastSBand
for k=SegA,SegB do -- apply bands
print("Applying band from ",k," to ",k+2)
band_add_segment_segment(k,k+2)
if k==SegA then FirstSBand=get_band_count() end -- if this is the first band, store
if k==SegB then LastSBand=get_band_count() end -- if this is the last band, store
end -- k loop

for k=FirstSBand,LastSBand do -- Set strength and length of all new generated to maximum
print("Setting length and strength of band#",k)
band_set_length(k,20)
band_set_strength(k,2)
-- band_disable(k) -- and disable them first
end -- k loop

-- for k=FirstSBand,LastSBand do
-- band_enable(k)
local exit_condition=false
local iter=0
repeat -- wiggle backbone until absoulte score change is low enough
iter=iter+1
print ("wiggling with iterations:",iter)
local Score=get_score(true) -- get score before wiggle
do_global_wiggle_all(iter) -- wiggle
local Delta=(get_score(true)-Score)/iter -- get relative difference
if Delta<0 then Delta=-Delta end -- if negative, make it positive = absolute value
if Delta<0.1 then exit_condition=true end
-- if abs score change is below 0.1, we don't need to repeat wiggle
until exit_condition==true
-- band_disable(k)
-- end -- k loop

print("Removing bands.")
for k=LastSBand,FirstSBand,-1 do -- remove generated bands
band_delete(k)
end -- k loop
end -- function

StraightenRange(19,25)

Joined: 09/18/2009
Groups: SETI.Germany
-- StraightenRegion V1.0 by

-- StraightenRegion V1.0 by Crashguard303
-- Inspired by Tlaloc's "Make Denovo"
-- Instead of stretching the whole puzzle, here you can set a start and ending segment,
-- in which range the puzzle is straightened out.
-- Useful if you can't reach the straighten out knob, or you don't want to hold it down all the time.
-- Plus, it keeps your previously applied bands.
-- This script does straighten out the region from segment 19 to 25 as example.
-- change the values of the last line to apply it to your desired region.
-- This script does not work as perfect as the original straightening,
-- but comes relatively close.

function StraightenRange(SegA,SegB) -- Straightens the region between SegA and SegB
local k
local SegA=SegA
local SegB=SegB
if SegB -- if SegA > SegB, swap them

deselect_all()
for k=SegA,SegB do -- select region for wiggle later
print("Selecting segment:",k)
select_index(k)
end -- k loop

SegA=SegA-2
-- As we connect the segments with its 2nd next neighbour, we have to start 2 segments before with banding
if SegA<1 then SegA=1 end
if SegB>get_segment_count()-2 then SegB=get_segment_count()-2 end

local FirstSBand
local LastSBand
for k=SegA,SegB do -- apply bands
print("Applying band from ",k," to ",k+2)
band_add_segment_segment(k,k+2)
if k==SegA then FirstSBand=get_band_count() end -- if this is the first band, store
if k==SegB then LastSBand=get_band_count() end -- if this is the last band, store
end -- k loop

for k=FirstSBand,LastSBand do -- Set strength and length of all new generated to maximum
print("Setting length and strength of band#",k)
band_set_length(k,20)
band_set_strength(k,2)
-- band_disable(k) -- and disable them first
end -- k loop

-- for k=FirstSBand,LastSBand do
-- band_enable(k)
local exit_condition=false
local iter=0
repeat -- wiggle backbone until absoulte score change is low enough
iter=iter+1
print ("wiggling with iterations:",iter)
local Score=get_score(true) -- get score before wiggle
do_global_wiggle_all(iter) -- wiggle
local Delta=(get_score(true)-Score)/iter -- get relative difference
if Delta<0 then Delta=-Delta end -- if negative, make it positive = absolute value
if Delta<0.1 then exit_condition=true end
-- if abs score change is below 0.1, we don't need to repeat wiggle
until exit_condition==true
-- band_disable(k)
-- end -- k loop

print("Removing bands.")
for k=LastSBand,FirstSBand,-1 do -- remove generated bands
band_delete(k)
end -- k loop
end -- function

StraightenRange(19,25)

Want to try?
Add to Cookbook!
To download recipes to your cookbook, you need to have the game client running.
Parent

none

Children
Authors
Sitemap

Developed by: UW Center for Game Science, UW Institute for Protein Design, Northeastern University, Vanderbilt University Meiler Lab, UC Davis
Supported by: DARPA, NSF, NIH, HHMI, Amazon, Microsoft, Adobe, Boehringer Ingelheim, RosettaCommons