File: filter_hmms.lua

package info (click to toggle)
barrnap 0.9%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, sid
  • size: 22,256 kB
  • sloc: perl: 226; makefile: 62; sh: 15
file content (35 lines) | stat: -rwxr-xr-x 653 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/usr/bin/env lua

function usage()
  io.stderr:write(string.format("Usage: %s <filter> [<invert>] < file\n", arg[0]))
  io.stderr:write('Filters out a HMM with NAME matching <filter>.\n')
  os.exit(1)
end

if #arg < 1 then
  usage()
end

lastname = nil
lines = {}
for l in io.lines() do
  name = l:match('NAME%s+(.*)')
  table.insert(lines, l)
  if name then
    lastname = name
  elseif l:match('//') then
    if arg[2] then
      if lastname:match(arg[1]) then
        print(table.concat(lines, '\n'))
      end
    else
      if not lastname:match(arg[1]) then
        print(table.concat(lines, '\n'))
      end
    end
    lines = {}
  end
end