Module: Bio::GFFbrowser::Helpers::Gff3Component

Includes:
Logger
Defined in:
lib/bio/db/gff/gffcomponent.rb

Constant Summary collapse

COMPONENT_TYPES =
Set.new(%w{
  gene SO:0000704 contig transcript component region
}.map { |s| s.upcase })

Instance Method Summary collapse

Methods included from Logger

#debug, #error, #info, #log_sys_info, #warn

Instance Method Details

#find_component(rec) ⇒ Object

Walk the component list to find a matching component/container for a record. First use the parent ID. If that is missing go by sequence name.



47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/bio/db/gff/gffcomponent.rb', line 47

def find_component rec
  parent = rec.get_attribute('Parent')
  if @componentlist[parent] 
    # nice, there is a match
    info "find_component: Matched parent", parent
    return @componentlist[parent]
  end
  search = rec.seqname
  if @componentlist[search]
    info "find_component: Matched seqname", search
    return @componentlist[search] 
  end
  @componentlist.each do | componentid, component |
    # dissemble id
    (id, start, stop) = componentid.split(/ /)
    if id==search and rec.start >= start.to_i and rec.end <= stop.to_i
      info "find_component: Matched column 0 and location", componentid
      return component
    end
  end
  # Ah, painful. At this point the record has no matching container, probably
  # because it has no parent ID and the component has an ID. We have to go by
  # ID for every component individually
  @componentlist.each do | componentid, component |
    if component.seqname==search and rec.start >= component.start and rec.end <= component.end
      # p ["----",search,rec]
      # p component
      info "find_component: Matched (long search) column 0 and location", componentid
      return component
    end
  end
  $stderr.print @componentlist
  raise "Could not find <#{search}> container/component for #{Record::formatID(rec)}"
end