Code
--[[------------------------------------------------------------------------------------------------
-- This recipe finds worst-scoring segment, based on SegmentEnergy Subscore
-- Features are selectable
REFERENCES
1. N/A
Copyright (C) 2014 Seagat2011 <http://fold.it/port/user/1992490>
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$
------------------------------------------------------------------------------------------------]]--
--[[
v1
- Inception
]]--
local AA = { a='Ala/A',c='Cys/C',d='Asp/D',e='Glu/E',f='Phe/F',g='Gly/G',h='His/H',i='Ile/I',k='Lys/K',l='Leu/L',m='Met/M',n='Asn/N',p='Pro/P',q='Gln/Q',r='Arg/R',s='Ser/S',t='Thr/T',u='Sec/U',v='Val/V',w='Trp/W',y='Tyr/Y' }
local SubS = {}
SubS [ 1 ] = 'clashing'
SubS [ 2 ] = 'hiding'
SubS [ 3 ] = 'packing'
SubS [ 4 ] = 'ideality'
SubS [ 5 ] = 'sidechain'
SubS [ 6 ] = 'bonding'
SubS [ 7 ] = 'other'
SubS [ 8 ] = 'reference'
SubS [ 9 ] = 'backbone'
local str = 'Anthropic Dreams Solution - ref#:'..puzzle.GetExpirationTime ()..user.GetPlayerID ()
local return_value = {
OK = 1,
HELP = 2,
CANCEL = 0
}
local status = 0
local ask = dialog.CreateDialog ( "Anthropic Dreams - Find Worst v1.0 " )
ask.l1 = dialog.AddLabel ( "Adjust to necessary value. ( if any )" )
--[[
ask.spacer03 = dialog.AddLabel ( '' )
ask.spacer04 = dialog.AddLabel ( '' )
ask.spacer05 = dialog.AddLabel ( '' )
ask.spacer06 = dialog.AddLabel ( '' )
ask.spacer07 = dialog.AddLabel ( '' )
ask.spacer08 = dialog.AddLabel ( '' )
ask.spacer09 = dialog.AddLabel ( '' )]]--
ask.spacer10 = dialog.AddLabel ( 'Segment Energy Subscore Component' )
ask.l4 = dialog.AddSlider ( '',1,1,9,0 )
ask.spacer7 = dialog.AddLabel ( '' )
ask.OK = dialog.AddButton("OK",1)
ask.HELP = dialog.AddButton("HELP",2)
local askhelp = dialog.CreateDialog ( 'Anthropic Dreams - Help Window ' )
askhelp.spacer02 = dialog.AddLabel ( '' )
askhelp.spacer03 = dialog.AddLabel ( '' )
askhelp.spacer04 = dialog.AddLabel ( '' )
askhelp.spacer05 = dialog.AddLabel ( '' )
askhelp.spacer01 = dialog.AddLabel ( [[ Segment Energy Subscore Parts:
- 1. Clashing
- 2. Hiding
- 3. Packing
- 4. Ideality
- 5. Sidechain
- 6. Bonding
- 7. Other
- 8. Reference
- 9. Backbone ]] )
askhelp.spacer06 = dialog.AddLabel ( '' )
askhelp.spacer07 = dialog.AddLabel ( '' )
askhelp.spacer08 = dialog.AddLabel ( '' )
askhelp.spacer09 = dialog.AddLabel ( '' )
askhelp.OK = dialog.AddButton ( "OK",1 )
status = dialog.Show ( ask )
while ( status == return_value.HELP ) do
dialog.Show ( askhelp )
status = dialog.Show ( ask )
end
function current.FindWorst ( str )
local idx2 = structure.GetCount ()
local neg = {
score = 0,
idx=0,
printInfo=function (v)
print ( AA [ structure.GetAminoAcid ( v.idx ) ]..'-'..v.idx..' -- '..str..':'..v.score)
structure.SetNote ( v.idx, AA [ structure.GetAminoAcid ( v.idx ) ]..'-'..v.idx..' -- '..str..':'..v.score )
end
}
for idx=1,idx2 do
local s = current.GetSegmentEnergySubscore ( idx,str )
if s < neg.score then neg.score = s neg.idx = idx end
end
return neg
end -- FindWorst () --
local function main ()
local neg = current.FindWorst ( SubS [ ask.l4.value ] )
neg.printInfo(neg)
end -- main ()
local function cleanup ()
print ( 'Done.' )
end
if ( status == return_value.OK ) then
--while ( 1 ) do
xpcall (main,cleanup)
--end
else
cleanup ()
end