[BioRuby-cvs] bioruby/lib/bio/db/kegg ortholog.rb, NONE, 1.1 ko.rb, 1.6, NONE
Katayama Toshiaki
k at dev.open-bio.org
Thu Mar 8 00:20:23 UTC 2007
Update of /home/repository/bioruby/bioruby/lib/bio/db/kegg
In directory dev.open-bio.org:/tmp/cvs-serv14066
Added Files:
ortholog.rb
Removed Files:
ko.rb
Log Message:
* Recently, KEGG KO database is renamed to KEGG ORTHOLOG, so we follow the change as
* ko.rb is renamed to ortholog.rb
* Bio::KEGG::KO is renamed to Bio::KEGG::ORTHOLOG
* genes and dblinks methods are rewrited to use lines_fetch
--- NEW FILE: ortholog.rb ---
#
# = bio/db/kegg/ortholog.rb - KEGG ORTHOLOG database class
#
# Copyright:: Copyright (C) 2003-2007 Toshiaki Katayama <k at bioruby.org>
# Copyright:: Copyright (C) 2003 Masumi Itoh <m at bioruby.org>
#
# $Id: ortholog.rb,v 1.1 2007/03/08 00:20:21 k Exp $
#
require 'bio/db'
module Bio
class KEGG
# == Description
#
# KO (KEGG Orthology) entry parser.
#
# == References
#
# * http://www.genome.jp/dbget-bin/get_htext?KO
# * ftp://ftp.genome.jp/pub/kegg/tarfiles/ko
#
class ORTHOLOG < KEGGDB
DELIMITER = RS = "\n///\n"
TAGSIZE = 12
# Reads a flat file format entry of the KO database.
def initialize(entry)
super(entry, TAGSIZE)
end
# Returns ID of the entry.
def entry_id
field_fetch('ENTRY')[/\S+/]
end
# Returns NAME field of the entry.
def name
field_fetch('NAME')
end
# Returns an Array of names in NAME field.
def names
name.split(', ')
end
# Returns DEFINITION field of the entry.
def definition
field_fetch('DEFINITION')
end
# Returns CLASS field of the entry.
def keggclass
field_fetch('CLASS')
end
# Returns an Array of biological classes in CLASS field.
def keggclasses
keggclass.gsub(/ \[[^\]]+/, '').split(/\] ?/)
end
# Returns an Array of KEGG/PATHWAY ID in CLASS field.
def pathways
keggclass.scan(/\[PATH:(.*?)\]/).flatten
end
# Returns a Hash of Array of a database name and entry IDs in DBLINKS field.
def dblinks
unless @data['DBLINKS']
@data['DBLINKS'] = lines_fetch('DBLINKS')
end
@data['DBLINKS']
end
# Returns a Hash of Array of the organism ID and entry IDs in GENES field.
def genes
unless @data['GENES']
@data['GENES'] = lines_fetch('GENES')
end
@data['DBLINKS']
end
end # KO
end # KEGG
end # Bio
if __FILE__ == $0
require 'bio/io/fetch'
flat = Bio::Fetch.query('ko', 'K00001')
entry = Bio::KEGG::KO.new(flat)
p entry.entry_id
p entry.name
p entry.names
p entry.definition
p entry.keggclass
p entry.keggclasses
p entry.pathways
p entry.dblinks
p entry.genes
end
--- ko.rb DELETED ---
More information about the bioruby-cvs
mailing list