Icon representing a recipe

Recipe: nicm25.hti.ABChecker v1.01

created by Nicm25

Profile


Name
nicm25.hti.ABChecker v1.01
ID
104862
Shared with
Public
Parent
None
Children
None
Created on
June 30, 2021 at 12:05 PM UTC
Updated on
June 30, 2021 at 12:05 PM UTC
Description

judging only by bending of backbone! (nullable segment select, number threshold, boolean highquality)

Best for


Code


-- created by Nicm25; function pldc() local retd=dialog.CreateDialog("ABChecker Ver 1.01") retd.la=dialog.AddLabel(" beta... ...alpha") retd.si=dialog.AddSlider("threshold",0.5,0.0,1.0,2) retd.ck=dialog.AddCheckbox("high Quality",false) retd.bt=dialog.AddButton("OK",1) return retd end function plss() local lc=1 local retd={} for lc=1,structure.GetCount() do retd[lc]=selection.IsSelected(lc) and 1 or 0 end return retd end function run(avs,avx,avy) local segs=0 local sege=0 local stcd={} local lc=0 local setdi=0.0 local sethq=false if avx<-0.001 or avx>1.001 then return 1 end setdi=avx+0.2 setdi=setdi*setdi*1.8 sethq=avy and true or false sege=#avs if selection.GetCount()>1.5 then for lc=1,sege do if avs[lc]>0.5 then if segs<0.5 then segs=lc else sege=lc end end end else segs=1 for lc=1,sege do if structure.IsLocked(lc) then segs=lc+1 end end end if segs>sege-2 then print("not supported partial puzzle") return 1 end for lc=segs+1,sege-1 do stcd[lc-segs+1]=structure.GetDistance(lc-1,lc+1)+ (sethq and(structure.GetDistance(lc-1,lc)+structure.GetDistance(lc,lc+1)-7.63)*7.0 or 0.0) end selection.DeselectAll() selection.SelectRange(segs,sege) undo.SetUndo(false) structure.SetSecondaryStructureSelected("l") selection.DeselectAll() for lc=segs+1,sege-1 do if stcd[lc-segs+1]<4.7+setdi then selection.Select(lc) end end structure.SetSecondaryStructureSelected("h") selection.DeselectAll() for lc=segs+1,sege-1 do if stcd[lc-segs+1]>5.2+setdi then selection.Select(lc) end end undo.SetUndo(true) structure.SetSecondaryStructureSelected("e") selection.DeselectAll() return 0 end local lfi=0 local tdr=pldc() lfi=dialog.Show(tdr) if lfi>0.5 then lfi=run(plss(),tdr.si.value,tdr.ck.value) 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 'Hand Tools, Information such package'(hti).

In this little script, setting secondary structure based on shape of backbone
set like straight line is sheets, and bending is helices, else is loops.
3 arguments
select: currently selected segment will be this argument(not in dialog), if none select is 'all apply'.
threshold: when biased ratio of helices(alpha) and sheets(beta), you can adjust to balance.
range: 0.0-1.0, default: 0.5, function: 1.0 is alpha side, 0.0 is beta side
highquality: additional checking backbone distortion on assumption that it has already been idealized.
default: false, function: false is none, true is additional checking
int return: whether it was successfully. function: 0 is okay, else is problem

Nicm25 Lv 1

improved to undo history into one task.
other that, there are no changes to specifications.