Icon representing a recipe

Recipe: nicm25.exi.SubScoring v1.00

created by Nicm25

Profile


Name
nicm25.exi.SubScoring v1.00
ID
105208
Shared with
Public
Parent
None
Children
None
Created on
September 30, 2021 at 12:09 PM UTC
Updated on
September 30, 2021 at 12:09 PM UTC
Description

get sub scoring color (number mode, number passcount, nullable array data)

Best for


Code


-- created by Nicm25; function pldc() local retd=dialog.CreateDialog("SubScoring ver0.00 - message") retd.la=dialog.AddLabel("choose one of subscores to be coloring.") retd.cc=dialog.AddCheckbox("clashing",false) retd.ci=dialog.AddCheckbox("ideality",false) retd.ca=dialog.AddCheckbox("backbone",false) retd.cs=dialog.AddCheckbox("sidechain",false) retd.cb=dialog.AddCheckbox("bonding",false) retd.ch=dialog.AddCheckbox("hiding",false) retd.cp=dialog.AddCheckbox("packing",false) retd.cw=dialog.AddCheckbox("pairwise",false) retd.cd=dialog.AddCheckbox("density",false) -- retd.ce=dialog.AddCheckbox("extended",false) retd.si=dialog.AddSlider("pass count",3,1,10,0) retd.bt=dialog.AddButton("GO!",1) return retd end function plfa(avx,avd,avt) local lc=0 local lfx=0 local lfy=0 local lfz=0 for lc=1,avt[1] do lfy=lc+(avt[4]-avt[3])*3+9 for lfx=1,7 do if lc+lfx>8.5 then avt[lfy+lfx-8]=avt[lfy+lfx-8]+avt[lc+(avt[4]-avt[3])*2+8]*avd[33-lfx]*avx end end for lfx=1,7 do if avt[1]-lc-lfx>-1.5 then avt[lfy+lfx-1]=avt[lfy+lfx-1]+avt[lc+(avt[4]-avt[3])*2+8]*avd[lfx+25]*avx end end end lfx=(avt[4]-avt[3])*3+9 lfy=100.0 lfz=100.0 for lc=1,avt[1] do if (lc-0.5)%2.0<1.0 and avt[lc+lfx]<lfy then lfy=avt[lc+lfx] elseif avt[lc+lfx]<lfz then lfz=avt[lc+lfx] end end for lc=1,avt[1] do avt[lc+lfx]=avt[lc+lfx]-((lc-0.5)%2.0>1.0 and lfz or lfy)+avx*0.1 if avt[lc+lfx]>1.5 then avt[lc+lfx]=1.5 end end lfx=(avt[4]-avt[3])*3+9 for lc=1,avt[1]-1 do avt[lc+(avt[4]-avt[3])*4+10]=math.sqrt(avt[lc+lfx]) end end function run(avx,avy,avt) local lc=0 local lfx=0 local stcn="" local stcd={} local stcs={} stcs[1]=structure.GetCount() stcs[2]=band.GetCount(false) stcd[1]=5 stcd[2]=0 stcd[3]=6 stcd[4]=8 stcd[5]=9 stcd[6]=11 stcd[7]=4 stcd[8]=10 stcd[9]=8 stcd[10]=0 stcd[11]=9 stcd[12]=8 stcd[13]=8 stcd[14]=8 stcd[15]=0 stcd[16]=8 stcd[17]=9 stcd[18]=11 stcd[19]=6 stcd[20]=7 stcd[21]=0 stcd[22]=7 stcd[23]=14 stcd[24]=0 stcd[25]=12 stcd[26]=1.0 stcd[27]=-0.778 stcd[28]=0.589 stcd[29]=-0.429 stcd[30]=0.293 stcd[31]=-0.177 stcd[32]=0.079 stcs[3]=1 stcs[4]=stcs[1] stcs[5]=0 stcs[6]=0 if avx<-0.5 or avx>9.5 or avy<0.5 or avy>100.5 then return 1 end if stcs[1]<2.5 then print("sorry not support too few residues.") return 1 end stcn=avx>0.5 and avx<1.5 and"clashing"or stcn stcn=avx>1.5 and avx<2.5 and"ideality"or stcn stcn=avx>2.5 and avx<3.5 and"backbone"or stcn stcn=avx>3.5 and avx<4.5 and"sidechain"or stcn stcn=avx>4.5 and avx<5.5 and"bonding"or stcn stcn=avx>5.5 and avx<6.5 and"hiding"or stcn stcn=avx>6.5 and avx<7.5 and"packing"or stcn stcn=avx>7.5 and avx<8.5 and"pairwise"or stcn stcn=avx>8.5 and avx<9.5 and"density"or stcn undo.SetUndo(false) behavior.SetWigglePower("m") stcs[5]=-2000 stcs[6]=200 for lc=1,stcs[1] do stcs[lc+6]=current.GetSegmentEnergyScore(lc) if stcs[lc+6]>stcs[5] then stcs[5]=stcs[lc+6] end if stcs[lc+6]<stcs[6] then stcs[6]=stcs[lc+6] end end if stcs[6]<-300 or stcs[5]-stcs[6]>150 then return 1 end stcs[5]=-500 for lc=1,stcs[1] do if avx<0.5 then lfx=avt[lc]+stcs[6] else lfx=current.GetSegmentEnergySubscore(lc,stcn) end stcs[lc+(stcs[4]-stcs[3])+7]=lfx if lfx-stcs[lc+6]>stcs[5] then stcs[5]=lfx-stcs[lc+6] end end stcs[5]=stcs[5]+30.0 lfx=(stcs[4]-stcs[3])+7 for lc=1,stcs[1] do stcs[lc+lfx]=stcs[lc+lfx]-stcs[5] stcs[lc+(stcs[4]-stcs[3])*2+8]=stcs[lc+6]-stcs[lc+lfx] end lfx=(stcs[4]-stcs[3])*3+9 for lc=1,stcs[1] do stcs[lc+lfx]=0.0 end plfa(0.0025,stcd,stcs) stcs[(stcs[4]-stcs[3])*5+11]=1.0 for lc=1,stcs[1]-1 do lfx=band.AddBetweenSegments(lc,lc+1,3, stcd[string.byte(structure.GetAminoAcid(lc+1),1)-96]+(stcs[1]-lc<1.5 and 2 or 1),0) stcs[lc+(stcs[4]-stcs[3])*5+11]=band.GetLength(lfx) band.SetStrength(lfx,9.99) band.SetGoalLength(lfx,stcs[lc+(stcs[4]-stcs[3])*5+11]-stcs[lc+(stcs[4]-stcs[3])*4+10]) end structure.WiggleAll(10) stcs[5]=1 while stcs[5]<avy-0.5 do lfx=(stcs[4]-stcs[3])+7 for lc=1,stcs[1] do stcs[lc+(stcs[4]-stcs[3])*2+8]=current.GetSegmentEnergyScore(lc)-stcs[lc+lfx] end plfa(0.0025,stcd,stcs) lfx=stcs[4]-stcs[3] for lc=1,stcs[1]-1 do band.SetGoalLength(stcs[2]+lc,stcs[lc+lfx*5+11]-stcs[lc+lfx*4+10]) end structure.WiggleAll(10) stcs[5]=stcs[5]+1 end undo.SetUndo(true) band.DeleteAll() return 0 end local lc=0 local lfi=0 local slen=0 local tdr=pldc() local demod={} lfi=dialog.Show(tdr) if lfi>0.5 then lfi=(tdr.cc.value and 11 or 0)+(tdr.ci.value and 12 or 0)+(tdr.ca.value and 13 or 0)+ (tdr.cs.value and 14 or 0)+(tdr.cb.value and 15 or 0)+(tdr.ch.value and 16 or 0)+ (tdr.cp.value and 17 or 0)+(tdr.cw.value and 18 or 0)+(tdr.cd.value and 19 or 0) -- (tdr.ce.value and 10 or 0) if lfi<9.5 or lfi>20.5 then print("choose error") else if lfi<10.5 then -- demodata, can be exchange freely. slen=structure.GetCount() for lc=1,slen do -- rainbow score demod[lc]=math.abs(0.5-lc/slen)*100.0 -- reverse score -- demod[lc]=current.GetSegmentEnergyScore(lc)*-1.0 end end lfi=run(lfi-10,tdr.si.value,demod) end if lfi>0.5 then print("terminated by exception error") end end

Comments


Nicm25 Lv 1

thank you for your interest.
this is by product of bootstrap, where i prepare tools myself from beginning
and my personal 'Executable Information such package'(exi).

In this little script, get coloring by sub score each segment.
this script will try to change the ideality to change scores, and you will set result using relative score coloring.

3 arguments
mode: select that subscores to evaluate and switch modes. check and select them in the dialog window.
range: 0-9, function:
0:"extended"(deactivated)
1:"clashing", 2:"ideality", 3:"backbone"
4:"sidechain", 5:"bonding", 6:"hiding"
7:"packing", 8:"pairwise", 9:"density"
passcount: compare residuals to cancel out errors, more passes, more accurate coloring will be.
range: 1-10 (ext1-100), default: 3, function: 1 is one passing, 10 is ten passing
data: you can extend this source code and color it into any pattern you like. and rainbow and reverse score are attached as demo codes.
default: nil, function: try color according to number array
int return: whether it was successfully. function: 0 is okay, else is problem