class GeneOntology::Term

synonym, xref, consider and is_a are arrays. level is how far down the heirarchy the term is. 0 is the top level (molecular function, biological process…)

Constants

FIELDS
PLURAL

Public Class Methods

new() click to toggle source
# File lib/gene_ontology.rb, line 122
def initialize
  PLURAL.each {|k| self.send("#{k}=", []) }
  @level = nil
end

Public Instance Methods

each(&block) click to toggle source

starting with that term, traverses upwards in the tree

# File lib/gene_ontology.rb, line 132
def each(&block)
  block.call(self)
  is_a.each do |term|
    term.each(&block)
  end
end
find_level() click to toggle source

returns the number of levels below the top (top 3 categories [mf, bp, cc] are at level 0)

# File lib/gene_ontology.rb, line 152
def find_level
  if @level
    @level
  else
    @level =
      if @is_a.size == 0 ; 0
      else
        @is_a.map {|term| term.find_level }.min + 1
      end
  end
end
inspect() click to toggle source
# File lib/gene_ontology.rb, line 127
def inspect
  "<[#{level}]#{@id}: #{@name} is_a.size=#{@is_a.size}>"
end
trace_to_level(n=1) click to toggle source

returns a unique array of go terms at that level

# File lib/gene_ontology.rb, line 140
def trace_to_level(n=1)
  if self.level == n
    [self]
  elsif n > self.level
    []
  else
    self.is_a.map {|anc| anc.trace_to_level(n) }.flatten.uniq
  end
end