Icon representing a recipe

Recipe: Tvdl Show worst subscoring parts 1.1.1

created by LociOiling

Profile


Name
Tvdl Show worst subscoring parts 1.1.1
ID
49601
Shared with
Public
Parent
Tvdl Show worst subscoring parts 1.1.0
Children
Created on
July 15, 2014 at 03:35 AM UTC
Updated on
July 15, 2014 at 03:35 AM UTC
Description

Displays the totals of all active subscores. Selects the worst segments based on the subscores and percentage of segments you specify. A list of the selected segments and their scores is printed. This version uses dynamic subscore detection, adapted from EDRW.

Best for


Code


--[[ TvdL Show worst subscoring parts version 1.1.1 - 2014/07/14 - LociOiling -- add FindActiveSubscores (brutally yank'd from TvdL EDRW) -- this version of FindActiveSubscores totals subscores for *all* segments -- add some score and subscore reporting to the dialog ]]-- -- -- globals section -- segCnt = structure.GetCount() scrPart = {} -- new dynamic score part array -- -- old fixed list of score parts -- --scrParts = {'density','disulfides','backbone','sidechain','clashing','hiding','bonding','reference','pairwise'} -- pct = 15 Recipe = "TvdL Show worst subscoring parts" Version = "1.1.1" ReVersion = Recipe .. " v." .. Version -- -- end of globals section -- function round ( x )--cut all afer 3-rd place return x - x % 0.001 end function FindActiveSubscores ( show ) local result = {} local Subs = puzzle.GetPuzzleSubscoreNames () local Showlist = "Computing Active Subscores" if show then print ( Showlist ) end for ii = 1, #Subs do local total = 0 local abstotal = 0 local part for jj = 1, segCnt do part = current.GetSegmentEnergySubscore ( jj, Subs [ ii ] ) total = total + part abstotal = abstotal + math.abs ( part ) end if abstotal > 10 then result [ #result + 1 ] = { Subs [ ii ], total } if show then print ( "Active subscore: " .. Subs [ ii ] .. ", total = " .. round ( total ) ) end end end return result end function AskSelScores ( scrParts ) local ask = dialog.CreateDialog ( ReVersion ) ask.tot0 = dialog.AddLabel ( "Subscore totals (all segments)" ) local gtot = 0 for ii = 1, #scrParts do ask [ scrParts [ ii ] [ 1 ] .. "tot" ] = dialog.AddLabel ( scrParts [ ii ] [ 1 ] .. ": " .. round ( scrParts [ ii ] [ 2 ] ) ) gtot = gtot + round ( scrParts [ ii ] [ 2 ] ) end ask.gtot = dialog.AddLabel ( "Total of all subscores: " .. round ( gtot ) ) ask.energyscore = dialog.AddLabel ( "current.GetEnergyScore(): " .. round ( current.GetEnergyScore() ) ) if current.GetEnergyScore() ~= current.GetScore() then ask.score = dialog.AddLabel ( "current.GetScore(): " .. round ( current.GetScore() ) ) ask.exmult = dialog.AddLabel ( "current.GetExplorationMultiplier(): " .. round ( current.GetExplorationMultiplier() ) ) end ask.l1 = dialog.AddLabel ( "Specify which worst subscore totals to count" ) for ii = 1,#scrParts do ask [ scrParts [ ii ] [ 1 ] ] = dialog.AddCheckbox ( scrParts [ ii ] [ 1 ], false ) end ask.perc = dialog.AddSlider ( "Percent to select:", pct, 1, 100, 0 ) ask.OK = dialog.AddButton ( "OK", 1 ) ask.Cancel = dialog.AddButton ( "Cancel", 0 ) scrPart = {} if dialog.Show ( ask ) > 0 then for ii = 1, #scrParts do if ask [ scrParts [ ii ] [ 1 ] ].value then scrPart [ #scrPart + 1 ] = scrParts [ ii ] [ 1 ] end end pct = ask.perc.value Compute () Sort () Showresult () end end segscores={} function Compute() for ii = 1, segCnt do local sub = 0 for jj = 1, #scrPart do sub = sub + current.GetSegmentEnergySubscore ( ii, scrPart [ jj ] ) end segscores [ ii ] = { ii, sub } end end function Sort() table.sort ( segscores, function ( a, b ) return a [ 2 ] < b [ 2 ] end) end function Showresult() selection.DeselectAll () print ( "Selected segments" ) for ii = 1, pct * segCnt / 100 do selection.Select ( segscores [ ii ] [ 1 ] ) print ( "Segment " .. segscores [ ii ] [ 1 ] .. ", score = " .. round ( segscores [ ii ] [ 2 ] ) ) end end scoreParts = FindActiveSubscores ( true ) AskSelScores ( scoreParts )

Comments


LociOiling Lv 1

The main goal of this version of the recipe was to allow selecting segments based on their ideality subscore.

This version of the recipe uses a modified version of the dynamic subscore detection found in recent version of EDRW. This approach avoids the fixed list of subscores found in the previous version of the recipe.

This version of the recipe displays the totals of all active subscores in the dialog. Then, as in previous versions, you can select which subscores to use and the percentage of subscores to select. The recipe then selects the specified percentage of segments with the worst total of the specified subscores.

The recipe also prints the segments selected and the total of the specified subscores for each.