Class Bio::GO::External2go
In: lib/bio/db/go.rb
Parent: Array

Container class for files in geneontology.org/go/external2go/*2go.

The line syntax is:

database:<identifier> > GO:<term> ; GO:<GO_id>

Example

 spkw2go = Bio::GO::External2go.new(File.read("spkw2go"))
 spkw2go.size
 spkw2go.each do |relation|
   relation # -> {:db => "", :db_id => "", :go_term => "", :go_id => ""}
 end
 spkw2go.dbs

SAMPLE

 !date: 2005/02/08 18:02:54
 !Mapping of SWISS-PROT KEYWORDS to GO terms.
 !Evelyn Camon, SWISS-PROT.
 !
 SP_KW:ATP synthesis > GO:ATP biosynthesis ; GO:0006754
 ...

Methods

db_ids   dbs   go_ids   go_terms   new   parser   set_date   set_desc   to_str  

Attributes

header  [R]  Returns aHash of the external2go header information

Public Class methods

Constructor. relation := {:db => aStr, :db_id => aStr, :go_term => aStr, :go_id => aStr}

[Source]

     # File lib/bio/db/go.rb, line 355
355:     def initialize
356:       @header = {:date => '', :desc => []}
357:       super
358:     end

Constructor from parsing external2go file.

[Source]

     # File lib/bio/db/go.rb, line 335
335:     def self.parser(str)
336:       e2g = self.new
337:       str.each_line do |line|
338:         line.chomp!
339:         if line =~ /^\!date: (.+)/
340:           e2g.header[:date] = $1
341:         elsif line =~ /^\!(.*)/
342:           e2g.header[:desc] << $1
343:         elsif ary = line.scan(/^(.+?):(.+) > GO:(.+) ; (GO:\d{7})/).first
344:           e2g << {:db_id => ary[1], :db => ary[0], :go_term => ary[2], :go_id => ary[3]}
345:         else
346:           raise("Invalid Format Line: \n #{line.inspect}\n")
347:         end
348:       end
349:       return e2g
350:     end

Public Instance methods

Returns ary of database IDs.

[Source]

     # File lib/bio/db/go.rb, line 390
390:     def db_ids
391:       self.map {|rel| rel[:db_id] }.uniq
392:     end

Returns ary of databases.

[Source]

     # File lib/bio/db/go.rb, line 384
384:     def dbs
385:       self.map {|rel| rel[:db] }.uniq
386:     end

Returns ary of GO IDs.

[Source]

     # File lib/bio/db/go.rb, line 400
400:     def go_ids
401:       self.map {|rel| rel[:go_id] }.uniq
402:     end

Returns ary of GO Terms.

[Source]

     # File lib/bio/db/go.rb, line 395
395:     def go_terms
396:       self.map {|rel| rel[:go_term] }.uniq
397:     end

Bio::GO::External2go#set_date(value)

[Source]

     # File lib/bio/db/go.rb, line 362
362:     def set_date(value)
363:       @header[:date] = value
364:     end

Bio::GO::External2go#set_desc(ary)

[Source]

     # File lib/bio/db/go.rb, line 368
368:     def set_desc(ary)
369:       @header[:desc] = ary
370:     end

Bio::GO::External2go#to_str Returns the contents in the external2go format.

[Source]

     # File lib/bio/db/go.rb, line 375
375:     def to_str
376:       ["!date: #{@header[:date]}",
377:        @header[:desc].map {|e| "!#{e}" },
378:         self.map { |e| [e[:db], ':', e[:db_id], ' > GO:', e[:go_term], ' ; ', e[:go_id]].join }
379:       ].join("\n")
380:     end

[Validate]