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

Bio::GO::Ontology.new(str) The DAG Edit format ontology data parser.

Calls superclass method Bio::Pathway::new
   # File lib/bio/db/go.rb
68 def initialize(str)
69   @id2term      = {}
70   @header_lines = {}
71   @id2id        = {}
72   adj_list = dag_edit_format_parser(str)
73   super(adj_list)
74 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
39 def self.parse_goids(line)
40   goids = []
41   loop {
42     if /^ *[$%<]\S.+?;/ =~ line
43       endpoint = line.index(';') + 1
44       line = line[endpoint..line.size]
45     elsif /^,* GO:(\d{7}),*/ =~ line
46       goids << $1.clone
47       endpoint = line.index(goids.last) + goids.last.size
48       line = line[endpoint..line.size]
49     else
50       break
51     end
52   }
53   return goids
54 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
78 def goid2term(goid)
79   term = id2term[goid]
80   term = id2term[id2id[goid]] if term == nil
81   return term
82 end