Icon representing a recipe

Recipe: Idealize 2.0 (NC)

created by spvincent

Profile


Name
Idealize 2.0 (NC)
ID
47961
Shared with
Public
Parent
None
Children
Created on
January 30, 2014 at 02:38 AM UTC
Updated on
January 30, 2014 at 02:38 AM UTC
Description

See first comment

Best for


Code


kFallApartThreshold = 800 -- If Idealize results in a loss greater than this, skip the subsequent wiggle as the protein has probably exploded kMaxIterations = 10 -- Sanity check for the new wiggle loop n_residues = 0 ss_starts = {} ss_ends = {} kOriginalStructureOrNewBest = 8 function r3 ( i ) -- printing convenience return i - i % 0.001 end function GetScore () score = current.GetEnergyScore () return score end function get_structures ( starts , ends ) curr_type = 'x' for i = 1, n_residues do ss_type = structure.GetSecondaryStructure ( i ) if ( ss_type ~= curr_type ) then -- start of a new struct curr_type = ss_type starts [ #starts + 1 ] = i if ( i > 1 ) then ends [ #ends + 1 ] = i -1 end end end -- for i ends [ #ends + 1 ] = n_residues end function Wiggle ( step , threshold ) n_it = 0 new_score = GetScore () repeat prev_score = new_score structure.WiggleSelected ( step ) new_score = GetScore () n_it = n_it + 1 until ( ( math.abs ( new_score - prev_score ) < threshold ) or ( n_it > kMaxIterations ) ) end function main () print ( "Idealize 2.0 : New Chapters" ) curr_best_score = GetScore () print ( "Init score : " .. r3 ( curr_best_score ) ) save.Quicksave ( kOriginalStructureOrNewBest ) n_residues = structure.GetCount () behavior.SetClashImportance ( 1 ) get_structures ( ss_starts , ss_ends ) for i = 1 , #ss_starts do save.Quickload ( kOriginalStructureOrNewBest ) selection.DeselectAll () selection.SelectRange ( ss_starts [ i ] , ss_ends [ i ] ) print ( "Idealizing " .. ss_starts [ i ] .. "-" .. ss_ends [ i ] ) structure.IdealizeSelected () score = GetScore () if ( ( curr_best_score - score ) > kFallApartThreshold ) then print ( "Loss exceeded threshold" ) elseif ( math.abs ( score - curr_best_score ) > 1e-3 ) then selection.SelectAll () Wiggle ( 6 , 0.1 ) score = GetScore () if ( score > curr_best_score ) then curr_best_score = score save.Quicksave ( kOriginalStructureOrNewBest ) print ( "Improvement to : " .. r3 ( curr_best_score ) ) end end end save.Quickload ( kOriginalStructureOrNewBest ) end function cleanup () save.Quickload ( kOriginalStructureOrNewBest ) end --main () xpcall ( main , cleanup )

Comments


spvincent Lv 1

Updated for New Chapters

For each secondary structure element : Idealize then Wiggle

Doesn't Wiggle if Idealize lost too many points as this probably means the protein exploded.