[BioRuby-cvs] bioruby/lib/bio/db/kegg orthology.rb,1.9,1.10

Katayama Toshiaki k at dev.open-bio.org
Fri Dec 14 16:19:56 UTC 2007


Update of /home/repository/bioruby/bioruby/lib/bio/db/kegg
In directory dev.open-bio.org:/tmp/cvs-serv23360/lib/bio/db/kegg

Modified Files:
	orthology.rb 
Log Message:
* added dblinks_as_hash and genes_as_hash methods for convenience


Index: orthology.rb
===================================================================
RCS file: /home/repository/bioruby/bioruby/lib/bio/db/kegg/orthology.rb,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -d -r1.9 -r1.10
*** orthology.rb	5 Apr 2007 15:42:59 -0000	1.9
--- orthology.rb	14 Dec 2007 16:19:54 -0000	1.10
***************
*** 68,72 ****
    end
    
!   # Returns a Hash of Array of a database name and entry IDs in DBLINKS field.
    def dblinks
      unless @data['DBLINKS']
--- 68,72 ----
    end
    
!   # Returns an Array of a database name and entry IDs in DBLINKS field.
    def dblinks
      unless @data['DBLINKS']
***************
*** 76,80 ****
    end
  
!   # Returns a Hash of Array of the organism ID and entry IDs in GENES field.
    def genes
      unless @data['GENES']
--- 76,91 ----
    end
  
!   # Returns a Hash of the DB name and an Array of entry IDs in DBLINKS field.
!   def dblinks_as_hash
!     hash = {}
!     dblinks.each do |line|
!       name, *list = line.split(/\s+/)
!       db = name.downcase.sub(/:/, '')
!       hash[db] = list
!     end
!     return hash
!   end
! 
!   # Returns an Array of the organism ID and entry IDs in GENES field.
    def genes
      unless @data['GENES']
***************
*** 83,86 ****
--- 94,110 ----
      @data['GENES']
    end
+ 
+   # Returns a Hash of the organism ID and an Array of entry IDs in GENES field.
+   def genes_as_hash
+     hash = {}
+     genes.each do |line|
+       name, *list = line.split(/\s+/)
+       org = name.downcase.sub(/:/, '')
+       genes = list.map {|x| x.sub(/\(.*\)/, '')}
+       #names = list.map {|x| x.scan(/.*\((.*)\)/)}
+       hash[org] = genes
+     end
+     return hash
+   end
    
  end # ORTHOLOGY




More information about the bioruby-cvs mailing list