class Bio::GO::External2go

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
...

Attributes

header[R]

Returns aHash of the external2go header information

Public Class Methods

new() click to toggle source

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

Calls superclass method
    # File lib/bio/db/go.rb
354 def initialize
355   @header = {:date => '', :desc => []}
356   super
357 end
parser(str) click to toggle source

Constructor from parsing external2go file.

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

Public Instance Methods

db_ids() click to toggle source

Returns ary of database IDs.

    # File lib/bio/db/go.rb
389 def db_ids
390   self.map {|rel| rel[:db_id] }.uniq
391 end
dbs() click to toggle source

Returns ary of databases.

    # File lib/bio/db/go.rb
383 def dbs
384   self.map {|rel| rel[:db] }.uniq
385 end
go_ids() click to toggle source

Returns ary of GO IDs.

    # File lib/bio/db/go.rb
399 def go_ids
400   self.map {|rel| rel[:go_id] }.uniq
401 end
go_terms() click to toggle source

Returns ary of GO Terms.

    # File lib/bio/db/go.rb
394 def go_terms
395   self.map {|rel| rel[:go_term] }.uniq
396 end
set_date(value) click to toggle source

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

    # File lib/bio/db/go.rb
361 def set_date(value)
362   @header[:date] = value
363 end
set_desc(ary) click to toggle source

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

    # File lib/bio/db/go.rb
367 def set_desc(ary)
368   @header[:desc] = ary
369 end
to_str() click to toggle source

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

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