Profile
- Name
- Note 10 worst V1.0
- ID
- 43913
- Shared with
- Public
- Parent
- None
- Children
- None
- Created on
- August 16, 2012 at 01:53 AM UTC
- Updated on
- August 16, 2012 at 01:53 AM UTC
- Description
places a brief Note onto segs with worst scores (10 segs by default)
Best for
Code
-- Note 10 worst V1.0
--
-- places a brief Note onto segs with worst scores (10 segs by default)
--
-- by gramps (John McLeod)
-- V1.0 -- August 16, 2012
--
progname = "Note 10 worst V1.0"
--
function NoteSpecified(turkey_count_arg, use_badrank, use_score,
use_segno, use_AA) -- Notes the specified segs
local hit_count = 0
local begin_no = 0
local end_no = 0
local the_note = ""
-- sort code adapted from Mutate Tweak Worst v0.1 BETA - Brow 42
targets = {}
for i = 1,structure.GetCount() do
if structure.GetSecondaryStructure(i) ~= 'M' then
targets[#targets+1] = {i, current.GetSegmentEnergyScore(i) }
end
end
function SortFunc(a,b) -- pairs are sorted ascending by seg score
return a[2] < b[2]
end
table.sort(targets,SortFunc)
print('Sorted',#targets,'segments.')
-- for i = 1, #targets do
-- print(i,targets[i][1],string.format("%3.1f",(targets[i][2])))
-- end
begin_no=1
if tonumber(turkey_count_arg) < #targets then
end_no = tonumber(turkey_count_arg)
else
end_no = #targets
end
for i = begin_no, end_no do
hit_count = hit_count + 1
the_note=""
if use_badrank then
the_note = the_note .. " " .. i
end
if use_score then
the_note = the_note .. " " .. string.format("%3.1f",(targets[i][2]))
end
if use_segno then
the_note = the_note .. " " .. targets[i][1]
end
if use_AA then
the_note = the_note .. " " .. string.upper(structure.GetAminoAcid(targets[i][1]))
end
structure.SetNote(targets[i][1], the_note)
print(the_note)
end
print("segments Noted:", hit_count)
end -- function NoteSpecified
--
-- MAIN stuff
--
print(progname,"started")
--
local ask = dialog.CreateDialog("Note 10 worst")
ask.Instructions = dialog.AddLabel("worst scoring segs will be Noted: 10 by default")
ask.OK = dialog.AddButton("OK", 1)
ask.Cancel = dialog.AddButton("Cancel", 0)
ask.TurkeyCount = dialog.AddTextbox("Number to list", "10")
ask.BadRank = dialog.AddCheckbox("Note the Badness Rank", true)
ask.Score = dialog.AddCheckbox("Note the score", true)
ask.SegNo = dialog.AddCheckbox("Note the seg num", false)
ask.AA = dialog.AddCheckbox("Note the AA code", false)
if (dialog.Show(ask) > 0) then
if nil ~= tonumber(ask.TurkeyCount.value) then
NoteSpecified(ask.TurkeyCount.value, ask.BadRank.value,
ask.Score.value, ask.SegNo.value, ask.AA.value)
else
print("invalid worst count")
end
else
print("user canceled operation")
end
--
print(progname,"ended")
--
-- end Note 10 worst V1.0