File: filter_test_LTR.lua

package info (click to toggle)
genometools 1.6.6%2Bds-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 50,576 kB
  • sloc: ansic: 271,876; ruby: 29,930; python: 5,106; sh: 3,083; makefile: 1,213; perl: 219; pascal: 159; haskell: 37; sed: 5
file content (35 lines) | stat: -rw-r--r-- 937 bytes parent folder | download | duplicates (9)
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
name        = "LTR node type filter"
author      = "Sascha Kastens"
version     = "1.0"
email       = "mail@skastens.de"
short_descr = "Select nodes with two long terminal repeats."
description = "Selects a node if it contains a node of type " ..
              "LTR_retrotransposon with two child nodes of type " ..
              "long_terminal_repeat."

function filter(gn)
  target = "LTR_retrotransposon"
  subtarget = "long_terminal_repeat"
  gfi = gt.feature_node_iterator_new(gn)

  curnode = gfi:next()
  found_target = false;
  count = 0

  while not(curnode == nil) do
    if (curnode:get_type() == target) then
      found_target = true
    elseif ((found_target == true) and (curnode:get_type() == subtarget)) then
      count = count + 1
    end
    curnode = gfi:next()
  end

  if ((found_target == true) and (count == 2)) then
    return false
  elseif found_target == false then
    return false
  end

  return true
end