Class | Bio::GO::Ontology
In: | lib/bio/db/go.rb
Parent: | Bio::Pathway

# 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')

### Methods

goid2term new parse_goids

### Attributes

header_lines | [R] | Returns a Hash instance of the header lines in ontology flatfile.
id2id | [R] |
id2term | [R] |

### Public Class methods

new(str)

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

[Source]

        # File lib/bio/db/go.rb, line 69
    69:     def initialize(str)
    70:       @id2term      = {}
    71:       @header_lines = {}
    72:       @id2id        = {}
    73:       adj_list = dag_edit_format_parser(str)
    74:       super(adj_list)
    75:     end

parse_goids(line)

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

Parsing GOID line in the DAGEdit format

     GO:ID[ ; GO:ID...]

[Source]

        # File lib/bio/db/go.rb, line 40
    40:     def self.parse_goids(line)
    41:       goids = []
    42:       loop {
    43:         if /^ *[$%<]\S.+?;/ =~ line
    44:           endpoint = line.index(';') + 1
    45:           line = line[endpoint..line.size]
    46:         elsif /^,* GO:(\d{7}),*/ =~ line
    47:           goids << $1.clone
    48:           endpoint = line.index(goids.last) + goids.last.size
    49:           line = line[endpoint..line.size]
    50:         else
    51:           break
    52:         end
    53:       }
    54:       return goids
    55:     end

### Public Instance methods

goid2term(goid)

Returns a GO_Term correspondig with the given GO_ID.

[Source]

        # File lib/bio/db/go.rb, line 79
    79:     def goid2term(goid)
    80:       term = id2term[goid]
    81:       term = id2term[id2id[goid]] if term == nil
    82:       return term
    83:     end

[Validate]