Icon representing a recipe

Recipe: nicm25.htb.MagneticBinder v1.02

created by Nicm25

Profile


Name
nicm25.htb.MagneticBinder v1.02
ID
104860
Shared with
Public
Parent
None
Children
None
Created on
June 30, 2021 at 12:02 PM UTC
Updated on
June 30, 2021 at 12:02 PM UTC
Description

attracting separate proteins! (segment select, number threshold, number length, number strength)

Best for


Code


-- created by Nicm25; function pldc() local retd=dialog.CreateDialog("MagneticBinder Ver 1.02") retd.la=dialog.AddLabel(" none... ...many") retd.sn=dialog.AddSlider("threshold",0.1,0.0,1.0,2) retd.si=dialog.AddSlider("band length",0.5,0.0,2.0,2) retd.ss=dialog.AddSlider("band strength",1.0,0.5,1.5,2) retd.bt=dialog.AddButton("OK",1) return retd end function plfa(avx,avy,avz,ava) local lfx=structure.GetDistance(avx,avz) local lfy=structure.GetDistance(avy,avz) return (lfx+lfy)*(lfx-lfy)*0.5/ava end function plfb(avx,avy,avz,ava) local retv=1.0 if ava>0.01 then retv=(avx>avy and avx-avy or avy-avx)-ava retv=retv*(retv<0.0 and -2.0 or 2.0)+(avx+avy<0.0 and -avx-avy or avx+avy) retv=1.0-1.0/(retv*0.05+1.0) retv=1.0-(retv*retv) end retv=(avx>avy and avx-avy or avy-avx)/avz*retv return retv end function plfc() local lc=0 local lfd=dialog.SelectSegments() selection.DeselectAll() for lc=1,#lfd do selection.Select(lfd[lc]) end 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,avz) local segs=0 local sege=0 local segl=0 local stci=0 local stcl=0.0 local stcs=0.0 local stcd={} local lc=0 local setbl=0.0 local setbs=0.0 local setth=0.0 if avx<-0.001 or avx>1.001 or avy<-0.001 or avy>2.001 or avz<-0.001 or avz>10.001 then return 1 end setth=1.0-avx setbl=avy-1.0 setbs=avz setbl=(setbl*setbl)*(setbl<0.0 and -1.0 or 1.0) sege=#avs segl=sege if selection.GetCount()<1.5 then plfc() end if selection.GetCount()<1.5 then print("input error not 2 selected") return 1 end for lc=segs+1,sege do if selection.IsSelected(lc) then if segs<0.5 then segs=lc else sege=lc end end end stcl=structure.GetDistance(segs,sege) for lc=1,segl do stcd[lc]=plfa(segs,sege,lc,stcl) end undo.SetUndo(false) for lc=1,segl do for lpo=lc+5,segl do stcs=structure.GetDistance(lc,lpo) if plfb(stcd[lc],stcd[lpo],stcs,stcl)>setth then stci=band.AddBetweenSegments(lc,lpo,2,2,0) band.SetGoalLength(stci,(plfb(stcd[lc],stcd[lpo],stcs,0.0)*setbl+1.0)*stcs) band.SetStrength(stci,setbs) end end end undo.SetUndo(true) if stci>0.5 then band.SetStrength(stci,setbs) end return 0 end local lfi=0 local tdr=pldc() lfi=dialog.Show(tdr) if lfi>0.5 then lfi=run(plss(),tdr.sn.value,tdr.si.value,tdr.ss.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, Bands such package'(htb).

In this little script, bands attaching as selected distant proteins each targeting 2 segments.
(no support symmetry puzzles)
4 arguments
select: currently 2 selected segment will be this argument, if none select is error.
threshold: based on consistency to target, you can adjust to ignore anything irrelevant.
range: 0.0-1.0, default: 0.1, function: 1.0 is all valid, 0.0 is almost ignore
length: set band length, multiply by current distance and pulling.
range: 0.0-2.0, default: 0.5, function: 1.0 is current distance, 2.0 is far distance, 0.0 is zero distance
strength: set band strength, same as band strength
range: 0.5-1.5 (ext0.0-10.0), default: 1.0, function: 1.0 is standard, 0.5 is weak, 1.5 is intense
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.