Icon representing a recipe

Recipe: ScanFiles0jonEnergyFixBide4

created by zo3xiaJonWeinberg

Profile


Name
ScanFiles0jonEnergyFixBide4
ID
104096
Shared with
Public
Parent
ScanFiles0jonEnergyFix
Children
None
Created on
November 06, 2020 at 01:14 AM UTC
Updated on
November 06, 2020 at 01:14 AM UTC
Description

*0a4.txt 11/5/2020 350pm code

Best for


Code


-- ScanFiles by jeff101 -- last updated 350pm 11/5/2020. function Main() local sol,soli,ii local nseg,score,way,mssg,jj,aa -- -- See below for more details: -- https://foldit.fandom.com/wiki/Foldit_Lua_Functions#save.GetSolutions -- https://foldit.fandom.com/wiki/Foldit_Lua_Functions#save.LoadSolution -- https://foldit.fandom.com/wiki/Foldit_Lua_Functions#save.LoadSolutionByName -- https://foldit.fandom.com/wiki/Foldit_Lua_Functions#save.SaveSolution -- sol=save.GetSolutions() print('Found '..((#sol)+1)..' solution files:') for ii=0,#sol do print(' Solution # '..ii..':') soli=sol[ii] print(' filename = '..soli.filename..'.') print(' name = '..soli.name..'.') print(' score = '..trunc3to0(soli.score)..'.') end print(' ') for ii=0,#sol do stime=os.clock() while os.clock()<stime+0.5 do structure.DeleteCut(structure.GetCount()) end --useless action to bide time so Foldit doesn't crash. --Instead, CPU usage is capped at 103% in Activity Monitor. --Without the useless action, Foldit seemingly goes from 70% to 0.5% CPU, from before recipe to --freezing. But really it probably overshoots and does 200% CPU or something without you knowing. --Must be a foldit action, at least something like print. --a non-Foldit Lua function such as bideTime=0 can still freeze Foldit soli=sol[ii] save.LoadSolutionByName(soli.name) nseg=structure.GetCount() score=current.GetEnergyScore() for way=1,2 do mssg=string.format('(%2d) %.3f: ', ii,trunc3to0(score)) for jj=1,nseg do aa=structure.GetAminoAcid(jj) if way==1 and aa=='p' then -- list proline h-bonds mssg=string.format('%sp%d=%3.1f ', mssg,jj,current.GetSegmentEnergySubscore(jj,'Bonding')) elseif way==2 and aa=='c' then -- list cysteine s-s bonds mssg=string.format('%sc%d=%3.1f ', mssg,jj,current.GetSegmentEnergySubscore(jj,'Disulfides')) end -- if way end -- for jj mssg=string.format('%sfor %3d segments.', mssg,nseg) print(mssg) end -- for way end -- for ii end -- Main() -- below truncates val to nearest 0.001 towards 0 -- so 500.0029 becomes 500.002 -- and -5.0029 becomes -5.002 function trunc3to0(val) if val>=0 then return math.floor(val*1000)/1000 else return math.ceil(val*1000)/1000 end -- if val end -- trunc3to0() -- above works right for positive and negative scores 11/5/2020. -- below truncates val down to nearest 0.001 -- so 500.0029 becomes 500.002 -- and -5.0029 becomes -5.003 function trunc3(val) return val-(val % 0.001) end -- trunc3() Main()

Comments