class Bio::GO::Ontology

Bio::GO::Ontology

Container class for ontologies in the DAG Edit format.

Example

c_data = File.open('component.oontology').read
go_c = Bio::GO::Ontology.new(c_data)
p go_c.bfs_shortest_path('0003673','0005632')

Attributes

header_lines[R]

Returns a Hash instance of the header lines in ontology flatfile.

id2id[R]
id2term[R]

Public Class Methods

new(str) click to toggle source

::new The DAG Edit format ontology data parser.

Calls superclass method Bio::Pathway.new
# File lib/bio/db/go.rb, line 68
def initialize(str)
  @id2term      = {}
  @header_lines = {}
  @id2id        = {}
  adj_list = dag_edit_format_parser(str)
  super(adj_list)
end
parse_goids(line) click to toggle source

Bio::GO::Ontology.parse_ogids(line)

Parsing GOID line in the DAGEdit format

GO:ID[ ; GO:ID...]
# File lib/bio/db/go.rb, line 39
def self.parse_goids(line)
  goids = []
  loop {
    if /^ *[$%<]\S.+?;/ =~ line
      endpoint = line.index(';') + 1
      line = line[endpoint..line.size]
    elsif /^,* GO:(\d{7}),*/ =~ line
      goids << $1.clone
      endpoint = line.index(goids.last) + goids.last.size
      line = line[endpoint..line.size]
    else
      break
    end
  }
  return goids
end

Public Instance Methods

goid2term(goid) click to toggle source

Returns a GO_Term correspondig with the given GO_ID.

# File lib/bio/db/go.rb, line 78
def goid2term(goid)
  term = id2term[goid]
  term = id2term[id2id[goid]] if term == nil
  return term
end