module Bio::GFFbrowser::Helpers::Gff3Component
Constants
- COMPONENT_TYPES
Public Instance Methods
find_component(rec)
click to toggle source
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.
# 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