Icon representing a recipe

Recipe: Note range V1.1

created by gramps

Profile


Name
Note range V1.1
ID
43977
Shared with
Public
Parent
None
Children
None
Created on
August 24, 2012 at 20:02 PM UTC
Updated on
August 24, 2012 at 20:02 PM UTC
Description

places a brief Note onto segs from a range of seg numbers new score option

Best for


Code


-- Note range V1.1 -- -- places a brief Note onto segs from a range of seg numbers -- -- by gramps (John McLeod) -- V1.0 -- August 15, 2012 -- V1.1 -- August 24, 2012 added score option -- progname = "Note range V1.1" -- function NoteSpecified(from_arg, to_arg, use_segno, use_AA, use_score) -- Notes the specified segs local hit_count = 0 local begin_no = 0 local end_no = 0 local the_note = "" begin_no = tonumber(from_arg) if begin_no < 1 then begin_no = 1 end end_no = tonumber(to_arg) if end_no > structure.GetCount() then end_no = structure.GetCount() end for i = begin_no, end_no do hit_count = hit_count + 1 the_note="" if use_segno then the_note = the_note .. " " .. i end if use_AA then the_note = the_note .. " " .. string.upper(structure.GetAminoAcid(i)) end if use_score then the_note = the_note .. " " .. string.format("%3.1f", current.GetSegmentEnergyScore(i)) end structure.SetNote(i, the_note) print(the_note) end print("segments Noted:", hit_count) end -- function NoteSpecified -- -- MAIN stuff -- print(progname,"started") -- local ask = dialog.CreateDialog("Note range") ask.Instructions = dialog.AddLabel("Segs in given range will be Noted") ask.OK = dialog.AddButton("OK", 1) ask.Cancel = dialog.AddButton("Cancel", 0) ask.FromString = dialog.AddTextbox("From", "1") ask.ToString = dialog.AddTextbox("To", structure.GetCount()) ask.SegNo = dialog.AddCheckbox("Note the seg num", true) ask.AA = dialog.AddCheckbox("Note the AA code", true) ask.score = dialog.AddCheckbox("Note the score", false) if (dialog.Show(ask) > 0) then if (nil ~= tonumber(ask.FromString.value)) and (nil ~= tonumber(ask.ToString.value)) then -- both good NoteSpecified(ask.FromString.value, ask.ToString.value, ask.SegNo.value, ask.AA.value, ask.score.value) elseif (nil ~= tonumber(ask.FromString.value)) then -- from good NoteSpecified(ask.FromString.value, ask.FromString.value, ask.SegNo.value, ask.AA.value, ask.score.value) elseif (nil ~= tonumber(ask.ToString.value)) then -- to good NoteSpecified(ask.ToString.value, ask.ToString.value, ask.SegNo.value, ask.AA.value,ask.score.value) else -- neither good print("invalid range") end else print("user canceled operation") end -- print(progname,"ended") -- -- end Note range V1.1

Comments