Icon representing a recipe

Recipe: nicm25.htc.ChoppedPeptide v1.02

created by Nicm25

Profile


Name
nicm25.htc.ChoppedPeptide v1.02
ID
104866
Shared with
Public
Parent
None
Children
None
Created on
June 30, 2021 at 12:04 PM UTC
Updated on
June 30, 2021 at 12:04 PM UTC
Description

cutting at regular intervals! (nullable segment select, number length, number offset, boolean resetcuts)

Best for


Code


-- created by Nicm25; function pldc() local retd=dialog.CreateDialog("ChoppedPeptide 1.02") retd.si=dialog.AddSlider("length",3,1,16,0) retd.so=dialog.AddSlider("offset",0,0,15,0) retd.ck=dialog.AddCheckbox("reset cuts",false) retd.bt=dialog.AddButton("OK",1) return retd end function plfa(avx,avy) local lc=1 local lfd=structure.GetCuts() undo.SetUndo(false) for lc=1,#lfd do if #lfd<lc+0.5 then undo.SetUndo(true) end if lfd[lc]>avx-0.5 and lfd[lc]<avy+0.5 then structure.DeleteCut(lfd[lc]) end 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 lc=0 local setil=0 local setio=0 if avx<0.6 or avx>999.4 or avy<-0.4 or avy>999.4 then return 1 end setil=math.floor(avx+0.5) setio=math.floor(avy+0.5) sege=#avs if selection.GetCount()>1.5 then for lc=1,sege do if selection.IsSelected(lc) 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 if avz then plfa(segs,sege) end if setil<setio+0.5 then print("input error if length<=offset") return 1 end undo.SetUndo(false) for lc=0,(sege-segs-setio-0.5)/setil do if (sege-segs-setio-0.5)/setil<lc+1.0 then undo.SetUndo(true) end structure.InsertCut(lc*setil+setio+segs) end 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.so.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, Cuts such package'(htc).

In this little script, finely chopping protein at regular intervals,
can also close with resetcuts.
4 arguments
select: currently selected segment will be this argument(not in dialog), if none select is 'all apply'.
length: you can adjust cutting interval by segments.
range: 1-16 (ext1-999), default: 3, function: 1 is all cutting, any else is almost not cutting
offset: you can adjust cutting offset by segments.
range: 0-15 (ext0-999), default: 0, function: 0 is N-terminus side offset, any else is C-terminus side offset, if length<=offset is error
resetcuts: set whether to running reset cuts.
default: false, function: false is none, true is run reset cuts
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.