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=1,#sol do
soli=sol[ii]
save.LoadSolutionByName(soli.name)
nseg=structure.GetCount()
score=current.GetScore()
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()