[BioRuby-cvs] bioruby/lib/bio/db aaindex.rb,1.16,1.17

Mitsuteru C. Nakao nakao at pub.open-bio.org
Sat Feb 18 14:44:43 UTC 2006


Update of /home/repository/bioruby/bioruby/lib/bio/db
In directory pub.open-bio.org:/tmp/cvs-serv1774/lib/bio/db

Modified Files:
	aaindex.rb 
Log Message:
* db.rb: added '*' in the toptag.
* aaindex.rb: added RDoc. 
              added a facade method for both file formats 
              (Bio::AAindex.auto).
* test_aaindex.rb: added


Index: aaindex.rb
===================================================================
RCS file: /home/repository/bioruby/bioruby/lib/bio/db/aaindex.rb,v
retrieving revision 1.16
retrieving revision 1.17
diff -C2 -d -r1.16 -r1.17
*** aaindex.rb	18 Dec 2005 15:58:41 -0000	1.16
--- aaindex.rb	18 Feb 2006 14:44:40 -0000	1.17
***************
*** 2,6 ****
  # = bio/db/aaindex.rb - AAindex database class
  #
! # Copyright::  Copyright (C) 2001 KAWASHIMA Shuichi <s at bioruby.org>
  # License::    LGPL
  #
--- 2,9 ----
  # = bio/db/aaindex.rb - AAindex database class
  #
! # Copyright::  Copyright (C) 2001 
! #              KAWASHIMA Shuichi <s at bioruby.org>
! # Copyright::  Copyright (C) 2006
! #              Mitsuteru C. Nakao <n at bioruby.org>
  # License::    LGPL
  #
***************
*** 8,15 ****
--- 11,23 ----
  #
  # == Description
+ #
  # Classes for Amino Acid Index Database (AAindex and AAindex2).
  # * AAindex Manual: http://www.genome.jp/dbget-bin/show_man?aaindex
  #
  # == Examples
+ #
+ #  aax1 = Bio::AAindex.auto("PRAM900102.aaindex1")
+ #  aax2 = Bio::AAindex.auto("HENS920102.aaindex2")
+ #
  #  aax1 = Bio::AAindex1.new("PRAM900102.aaindex1")
  #  aax1.entry_id
***************
*** 22,25 ****
--- 30,34 ----
  #
  # == References
+ #
  # * http://www.genome.jp/aaindex/
  #
***************
*** 48,51 ****
--- 57,61 ----
  module Bio
  
+   # Super class for AAindex1 and AAindex2
    class AAindex < KEGGDB
  
***************
*** 59,118 ****
      TAGSIZE = 2
  
  
      def initialize(entry)
        super(entry, TAGSIZE)
      end
  
!     # Returns
      def entry_id
        field_fetch('H')
      end
  
!     # Returns
      def definition
        field_fetch('D')
      end
  
!     # Returns
      def dblinks
!       field_fetch('R')
      end
  
!     # Returns
      def author
        field_fetch('A')
      end
  
!     # Returns
      def title
        field_fetch('T')
      end
  
!     # Returns
      def journal
        field_fetch('J')
      end
  
!     # Returns
      def comment
!       get('*')
      end
- 
    end
  
  
    class AAindex1 < AAindex
  
- 
      def initialize(entry)
        super(entry)
      end
  
!     # Returns
      def correlation_coefficient
!       field_fetch('C')
      end
  
!     # Returns
      def index(type = :float)
        aa = %w( A R N D C Q E G H I L K M F P S T W Y V )
--- 69,151 ----
      TAGSIZE = 2
  
+     # Auto detecter for two AAindex formats.
+     # returns a Bio::AAindex1 object or a Bio::AAindex2 object.
+     def self.auto(str)
+       case str
+       when /^I /m 
+         Bio::AAindex1.new(str)
+       when /^M /m
+         Bio::AAindex2.new(str)
+       else
+         raise
+       end        
+     end
  
+     # 
      def initialize(entry)
        super(entry, TAGSIZE)
      end
  
!     # Returns entry_id in the H line.
      def entry_id
        field_fetch('H')
      end
  
!     # Returns definition in the D line.
      def definition
        field_fetch('D')
      end
  
!     # Returns database links in the R line.
!     # cf.) ['LIT:123456', 'PMID:12345678']
      def dblinks
!       field_fetch('R').split(' ')
      end
  
!     # Returns authors in the A line.
      def author
        field_fetch('A')
      end
  
!     # Returns title in the T line.
      def title
        field_fetch('T')
      end
  
!     # Returns journal name in the J line.
      def journal
        field_fetch('J')
      end
  
!     # Returns comment (if any).
      def comment
!       field_fetch("*")
      end
    end
  
  
+   # Class for AAindex1 format.
    class AAindex1 < AAindex
  
      def initialize(entry)
        super(entry)
      end
  
!     # Returns correlation_coefficient (Hash) in the C line.
!     #
!     # cf.) {'ABCD12010203' => 0.999, 'CDEF123456' => 0.543, ...}
      def correlation_coefficient
!       hash = {}
!       ary = field_fetch('C').split(' ')
!       ary.each do |x|
!         next unless x =~ /^[A-Z]/
!         hash[x] = ary[ary.index(x) + 1].to_f
!       end
!       hash
      end
  
!     # Returns the index (Array) in the I line.
!     #
!     # an argument: :string, :float, :zscore or :integer
      def index(type = :float)
        aa = %w( A R N D C Q E G H I L K M F P S T W Y V )
***************
*** 163,174 ****
  
  
    class AAindex2 < AAindex
  
- 
      def initialize(entry)
        super(entry)
      end
  
!     # Returns
      def rows
        label_data
--- 196,207 ----
  
  
+   # Class for AAindex2 format.
    class AAindex2 < AAindex
  
      def initialize(entry)
        super(entry)
      end
  
!     # Returns row labels.
      def rows
        label_data
***************
*** 176,180 ****
      end
  
!     # Returns
      def cols
        label_data
--- 209,213 ----
      end
  
!     # Returns col labels.
      def cols
        label_data
***************
*** 182,186 ****
      end
  
!     # Returns
      def matrix
        ma = Array.new
--- 215,219 ----
      end
  
!     # Returns matrix in Matrix.
      def matrix
        ma = Array.new
***************
*** 195,199 ****
      end
  
!     # Returns
      def old_matrix # for AAindex <= ver 5.0
  
--- 228,232 ----
      end
  
!     # Returns 
      def old_matrix # for AAindex <= ver 5.0
  
***************
*** 244,250 ****
      end
  
!   end
  
! end
  
  
--- 277,283 ----
      end
  
!   end # class AAindex2
  
! end # module Bio
  
  
***************
*** 260,263 ****
--- 293,297 ----
    p aax1.title
    p aax1.journal
+   p aax1.comment
    p aax1.correlation_coefficient
    p aax1.index
***************
*** 270,273 ****
--- 304,308 ----
    p aax2.title
    p aax2.journal
+   p aax1.comment
    p aax2.rows
    p aax2.cols




More information about the bioruby-cvs mailing list