[BioRuby-cvs] bioruby/lib/bio/db/kegg keggtab.rb,1.7,1.8
Katayama Toshiaki
k at dev.open-bio.org
Mon May 8 14:26:37 UTC 2006
- Previous message: [BioRuby-cvs] bioruby/lib/bio/db/kegg expression.rb, 1.9, 1.10 kgml.rb, 1.2, 1.3
- Next message: [BioRuby-cvs] bioruby/lib/bio/io dbget.rb, 1.11, 1.12 ddbjxml.rb, 1.10, 1.11 fetch.rb, 1.7, 1.8 registry.rb, 1.16, 1.17 soapwsdl.rb, 1.3, 1.4
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /home/repository/bioruby/bioruby/lib/bio/db/kegg
In directory dev.open-bio.org:/tmp/cvs-serv16846/db/kegg
Modified Files:
keggtab.rb
Log Message:
* license is changed to Ruby's
Index: keggtab.rb
===================================================================
RCS file: /home/repository/bioruby/bioruby/lib/bio/db/kegg/keggtab.rb,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** keggtab.rb 26 Sep 2005 13:00:07 -0000 1.7
--- keggtab.rb 8 May 2006 14:26:35 -0000 1.8
***************
*** 1,21 ****
#
! # bio/db/kegg/keggtab.rb - KEGG keggtab class
! #
! # Copyright (C) 2001 Mitsuteru C. Nakao <n at bioruby.org>
! # Copyright (C) 2003 KATAYAMA Toshiaki <k at bioruby.org>
! #
! # This library is free software; you can redistribute it and/or
! # modify it under the terms of the GNU Lesser General Public
! # License as published by the Free Software Foundation; either
! # version 2 of the License, or (at your option) any later version.
! #
! # This library is distributed in the hope that it will be useful,
! # but WITHOUT ANY WARRANTY; without even the implied warranty of
! # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
! # Lesser General Public License for more details.
#
! # You should have received a copy of the GNU Lesser General Public
! # License along with this library; if not, write to the Free Software
! # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# $Id$
--- 1,8 ----
#
! # = bio/db/kegg/keggtab.rb - KEGG keggtab class
#
! # Copyright:: Copyright (C) 2001 Mitsuteru C. Nakao <n at bioruby.org>
! # Copyright (C) 2003, 2006 KATAYAMA Toshiaki <k at bioruby.org>
! # License:: Ruby's
#
# $Id$
***************
*** 23,214 ****
module Bio
! class KEGG
! class Keggtab
! def initialize(file_path, bioroot = nil)
! @bioroot = ENV['BIOROOT'] || bioroot
! @db_names = Hash.new
! @database = Hash.new
! @taxonomy = Hash.new
! parse_keggtab(File.open(file_path).read)
! end
! attr_reader :bioroot, :db_names
! # Bio::KEGG::Keggtab::DB
! class DB
! def initialize(db_name, db_type, db_path, db_abbrev)
! @name = db_name
! @type = db_type
! @path = db_path
! @abbrev = db_abbrev
! @aliases = Array.new
! end
! attr_reader :name, :type, :path, :abbrev, :aliases
! alias korg abbrev
! alias keggorg abbrev
! end
! # DB section
! def database(db_abbrev = nil)
! if db_abbrev
! @database[db_abbrev]
! else
! @database
! end
! end
! def aliases(db_abbrev)
! if @database[db_abbrev]
! @database[db_abbrev].aliases
! end
! end
! def name(db_abbrev)
! if @database[db_abbrev]
! @database[db_abbrev].name
! end
! end
! def path(db_abbrev)
! if @database[db_abbrev]
! file = @database[db_abbrev].name
! if @bioroot
! "#{@database[db_abbrev].path.sub(/\$BIOROOT/, at bioroot)}/#{file}"
! else
! "#{@database[db_abbrev].path}/#{file}"
! end
! end
end
! def alias_list(db_name)
! if @db_names[db_name]
! @db_names[db_name].aliases
! end
! end
! def db_path(db_name)
! if @bioroot
! "#{@db_names[db_name].path.sub(/\$BIOROOT/, at bioroot)}/#{db_name}"
! else
! "#{@db_names[db_name].path}/#{db_name}"
! end
! end
! def db_by_abbrev(db_abbrev)
! @db_names.each do |k, db|
! return db if db.abbrev == db_abbrev
! end
! return nil
! end
! def name_by_abbrev(db_abbrev)
! db_by_abbrev(db_abbrev).name
! end
! def db_path_by_abbrev(db_abbrev)
! db_name = name_by_abbrev(db_abbrev)
! db_path(db_name)
! end
! # Taxonomy section
! def taxonomy(node = nil)
! if node
! @taxonomy[node]
! else
! @taxonomy
! end
! end
! def taxa_list
! @taxonomy.keys.sort
! end
! def child_nodes(node = 'genes')
! return @taxonomy[node]
! end
! def taxo2korgs(node = 'genes')
! if node.length == 3
! return node
! else
! if @taxonomy[node]
! tmp = Array.new
! @taxonomy[node].each do |x|
! tmp.push(taxo2korgs(x))
! end
! return tmp
! else
! return nil
! end
end
end
! alias taxo2keggorgs taxo2korgs
! alias taxon2korgs taxo2korgs
! alias taxon2keggorgs taxo2korgs
! def korg2taxo(keggorg)
! tmp = Array.new
! traverse = Proc.new {|keggorg|
! @taxonomy.each do |k,v|
! if v.include?(keggorg)
! tmp.push(k)
! traverse.call(k)
! break
! end
! end
! }
! traverse.call(keggorg)
! return tmp
end
! alias keggorg2taxo korg2taxo
! alias korg2taxonomy korg2taxo
! alias keggorg2taxonomy korg2taxo
! private
! def parse_keggtab(keggtab)
! in_taxonomy = nil
! keggtab.each do |line|
! case line
! when /^# Taxonomy/ # beginning of the taxonomy section
! in_taxonomy = true
! when /^#|^$/
! next
! when /(^\w\S+)\s+(\w+)\s+(\$\S+)\s+(\w+)/ # db
! db_name = $1
! db_type = $2
! db_path = $3
! db_abbrev = $4
! @db_names[db_name] =
! Bio::KEGG::Keggtab::DB.new(db_name, db_type, db_path, db_abbrev)
! when /(^\w\S+)\s+alias\s+(\w.+\w)/ # alias
! db_alias = $1
! db_name = $2#.downcase
! if in_taxonomy
! @taxonomy.update(db_alias => db_name.split('+'))
! elsif @db_names[db_name]
! @db_names[db_name].aliases.push(db_alias)
! end
! end
! end
! # convert keys-by-names hash @db_names to keys-by-abbrev hash @database
! @db_names.each do |k,v|
! @database[v.abbrev] = v
end
end
-
end
!
end
! end
--- 10,209 ----
module Bio
! class KEGG
! # Parse 'keggtab' KEGG database definition file which also includes
! # Taxonomic category of the KEGG organisms. The 'keggtab' file can
! # be found in
! #
! # * ((<URL:ftp://ftp.genome.jp/pub/kegg/tarfiles/genes.tar.gz>))
! #
! class Keggtab
! def initialize(file_path, bioroot = nil)
! @bioroot = ENV['BIOROOT'] || bioroot
! @db_names = Hash.new
! @database = Hash.new
! @taxonomy = Hash.new
! File.open(file_path) do |f|
! parse_keggtab(f.read)
! end
! end
! attr_reader :bioroot, :db_names
! # Bio::KEGG::Keggtab::DB
! class DB
! def initialize(db_name, db_type, db_path, db_abbrev)
! @name = db_name
! @type = db_type
! @path = db_path
! @abbrev = db_abbrev
! @aliases = Array.new
! end
! attr_reader :name, :type, :path, :abbrev, :aliases
! alias korg abbrev
! alias keggorg abbrev
! end
! # DB section
! def database(db_abbrev = nil)
! if db_abbrev
! @database[db_abbrev]
! else
! @database
! end
! end
! def aliases(db_abbrev)
! if @database[db_abbrev]
! @database[db_abbrev].aliases
! end
! end
! def name(db_abbrev)
! if @database[db_abbrev]
! @database[db_abbrev].name
! end
! end
! def path(db_abbrev)
! if @database[db_abbrev]
! file = @database[db_abbrev].name
! if @bioroot
! "#{@database[db_abbrev].path.sub(/\$BIOROOT/, at bioroot)}/#{file}"
! else
! "#{@database[db_abbrev].path}/#{file}"
end
+ end
+ end
! def alias_list(db_name)
! if @db_names[db_name]
! @db_names[db_name].aliases
! end
! end
! def db_path(db_name)
! if @bioroot
! "#{@db_names[db_name].path.sub(/\$BIOROOT/, at bioroot)}/#{db_name}"
! else
! "#{@db_names[db_name].path}/#{db_name}"
! end
! end
! def db_by_abbrev(db_abbrev)
! @db_names.each do |k, db|
! return db if db.abbrev == db_abbrev
! end
! return nil
! end
! def name_by_abbrev(db_abbrev)
! db_by_abbrev(db_abbrev).name
! end
! def db_path_by_abbrev(db_abbrev)
! db_name = name_by_abbrev(db_abbrev)
! db_path(db_name)
! end
! # Taxonomy section
! def taxonomy(node = nil)
! if node
! @taxonomy[node]
! else
! @taxonomy
! end
! end
! def taxa_list
! @taxonomy.keys.sort
! end
! def child_nodes(node = 'genes')
! return @taxonomy[node]
! end
! def taxo2korgs(node = 'genes')
! if node.length == 3
! return node
! else
! if @taxonomy[node]
! tmp = Array.new
! @taxonomy[node].each do |x|
! tmp.push(taxo2korgs(x))
end
+ return tmp
+ else
+ return nil
end
! end
! end
! alias taxo2keggorgs taxo2korgs
! alias taxon2korgs taxo2korgs
! alias taxon2keggorgs taxo2korgs
! def korg2taxo(keggorg)
! tmp = Array.new
! traverse = Proc.new {|keggorg|
! @taxonomy.each do |k,v|
! if v.include?(keggorg)
! tmp.push(k)
! traverse.call(k)
! break
! end
end
! }
! traverse.call(keggorg)
! return tmp
! end
! alias keggorg2taxo korg2taxo
! alias korg2taxonomy korg2taxo
! alias keggorg2taxonomy korg2taxo
! private
! def parse_keggtab(keggtab)
! in_taxonomy = nil
! keggtab.each do |line|
! case line
! when /^# Taxonomy/ # beginning of the taxonomy section
! in_taxonomy = true
! when /^#|^$/
! next
! when /(^\w\S+)\s+(\w+)\s+(\$\S+)\s+(\w+)/ # db
! db_name = $1
! db_type = $2
! db_path = $3
! db_abbrev = $4
! @db_names[db_name] =
! Bio::KEGG::Keggtab::DB.new(db_name, db_type, db_path, db_abbrev)
! when /(^\w\S+)\s+alias\s+(\w.+\w)/ # alias
! db_alias = $1
! db_name = $2#.downcase
! if in_taxonomy
! @taxonomy.update(db_alias => db_name.split('+'))
! elsif @db_names[db_name]
! @db_names[db_name].aliases.push(db_alias)
end
end
end
! # convert keys-by-names hash @db_names to keys-by-abbrev hash @database
! @db_names.each do |k,v|
! @database[v.abbrev] = v
! end
end
!
! end # Keggtab
!
! end # KEGG
! end # Bio
- Previous message: [BioRuby-cvs] bioruby/lib/bio/db/kegg expression.rb, 1.9, 1.10 kgml.rb, 1.2, 1.3
- Next message: [BioRuby-cvs] bioruby/lib/bio/io dbget.rb, 1.11, 1.12 ddbjxml.rb, 1.10, 1.11 fetch.rb, 1.7, 1.8 registry.rb, 1.16, 1.17 soapwsdl.rb, 1.3, 1.4
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the bioruby-cvs
mailing list