bio 0.7.1 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (142) hide show
  1. data/bin/bioruby +71 -27
  2. data/bin/br_biofetch.rb +5 -17
  3. data/bin/br_bioflat.rb +14 -26
  4. data/bin/br_biogetseq.rb +6 -18
  5. data/bin/br_pmfetch.rb +6 -16
  6. data/doc/Changes-0.7.rd +35 -0
  7. data/doc/KEGG_API.rd +287 -172
  8. data/doc/KEGG_API.rd.ja +273 -160
  9. data/doc/Tutorial.rd +18 -9
  10. data/doc/Tutorial.rd.ja +656 -138
  11. data/lib/bio.rb +6 -24
  12. data/lib/bio/alignment.rb +5 -5
  13. data/lib/bio/appl/blast.rb +132 -98
  14. data/lib/bio/appl/blast/format0.rb +9 -19
  15. data/lib/bio/appl/blast/wublast.rb +5 -18
  16. data/lib/bio/appl/emboss.rb +40 -47
  17. data/lib/bio/appl/hmmer.rb +116 -82
  18. data/lib/bio/appl/hmmer/report.rb +509 -364
  19. data/lib/bio/appl/spidey/report.rb +7 -18
  20. data/lib/bio/data/na.rb +3 -21
  21. data/lib/bio/db.rb +3 -21
  22. data/lib/bio/db/aaindex.rb +147 -52
  23. data/lib/bio/db/embl/common.rb +27 -6
  24. data/lib/bio/db/embl/embl.rb +18 -10
  25. data/lib/bio/db/embl/sptr.rb +87 -67
  26. data/lib/bio/db/embl/swissprot.rb +32 -3
  27. data/lib/bio/db/embl/trembl.rb +32 -3
  28. data/lib/bio/db/embl/uniprot.rb +32 -3
  29. data/lib/bio/db/fasta.rb +327 -289
  30. data/lib/bio/db/medline.rb +25 -4
  31. data/lib/bio/db/nbrf.rb +12 -20
  32. data/lib/bio/db/pdb.rb +4 -1
  33. data/lib/bio/db/pdb/chemicalcomponent.rb +240 -0
  34. data/lib/bio/db/pdb/pdb.rb +13 -8
  35. data/lib/bio/db/rebase.rb +93 -97
  36. data/lib/bio/feature.rb +2 -31
  37. data/lib/bio/io/ddbjxml.rb +167 -139
  38. data/lib/bio/io/fastacmd.rb +89 -56
  39. data/lib/bio/io/flatfile.rb +994 -278
  40. data/lib/bio/io/flatfile/index.rb +257 -194
  41. data/lib/bio/io/flatfile/indexer.rb +37 -29
  42. data/lib/bio/reference.rb +147 -64
  43. data/lib/bio/sequence.rb +57 -417
  44. data/lib/bio/sequence/aa.rb +64 -0
  45. data/lib/bio/sequence/common.rb +175 -0
  46. data/lib/bio/sequence/compat.rb +68 -0
  47. data/lib/bio/sequence/format.rb +134 -0
  48. data/lib/bio/sequence/generic.rb +24 -0
  49. data/lib/bio/sequence/na.rb +189 -0
  50. data/lib/bio/shell.rb +9 -23
  51. data/lib/bio/shell/core.rb +130 -125
  52. data/lib/bio/shell/demo.rb +143 -0
  53. data/lib/bio/shell/{session.rb → interface.rb} +42 -40
  54. data/lib/bio/shell/object.rb +52 -0
  55. data/lib/bio/shell/plugin/codon.rb +4 -22
  56. data/lib/bio/shell/plugin/emboss.rb +23 -0
  57. data/lib/bio/shell/plugin/entry.rb +34 -25
  58. data/lib/bio/shell/plugin/flatfile.rb +5 -23
  59. data/lib/bio/shell/plugin/keggapi.rb +11 -24
  60. data/lib/bio/shell/plugin/midi.rb +5 -23
  61. data/lib/bio/shell/plugin/obda.rb +4 -22
  62. data/lib/bio/shell/plugin/seq.rb +6 -24
  63. data/lib/bio/shell/rails/Rakefile +10 -0
  64. data/lib/bio/shell/rails/app/controllers/application.rb +4 -0
  65. data/lib/bio/shell/rails/app/controllers/shell_controller.rb +94 -0
  66. data/lib/bio/shell/rails/app/helpers/application_helper.rb +3 -0
  67. data/lib/bio/shell/rails/app/models/shell_connection.rb +30 -0
  68. data/lib/bio/shell/rails/app/views/layouts/shell.rhtml +37 -0
  69. data/lib/bio/shell/rails/app/views/shell/history.rhtml +5 -0
  70. data/lib/bio/shell/rails/app/views/shell/index.rhtml +2 -0
  71. data/lib/bio/shell/rails/app/views/shell/show.rhtml +13 -0
  72. data/lib/bio/shell/rails/config/boot.rb +19 -0
  73. data/lib/bio/shell/rails/config/database.yml +85 -0
  74. data/lib/bio/shell/rails/config/environment.rb +53 -0
  75. data/lib/bio/shell/rails/config/environments/development.rb +19 -0
  76. data/lib/bio/shell/rails/config/environments/production.rb +19 -0
  77. data/lib/bio/shell/rails/config/environments/test.rb +19 -0
  78. data/lib/bio/shell/rails/config/routes.rb +19 -0
  79. data/lib/bio/shell/rails/doc/README_FOR_APP +2 -0
  80. data/lib/bio/shell/rails/public/404.html +8 -0
  81. data/lib/bio/shell/rails/public/500.html +8 -0
  82. data/lib/bio/shell/rails/public/dispatch.cgi +10 -0
  83. data/lib/bio/shell/rails/public/dispatch.fcgi +24 -0
  84. data/lib/bio/shell/rails/public/dispatch.rb +10 -0
  85. data/lib/bio/shell/rails/public/favicon.ico +0 -0
  86. data/lib/bio/shell/rails/public/images/icon.png +0 -0
  87. data/lib/bio/shell/rails/public/images/rails.png +0 -0
  88. data/lib/bio/shell/rails/public/index.html +277 -0
  89. data/lib/bio/shell/rails/public/javascripts/controls.js +750 -0
  90. data/lib/bio/shell/rails/public/javascripts/dragdrop.js +584 -0
  91. data/lib/bio/shell/rails/public/javascripts/effects.js +854 -0
  92. data/lib/bio/shell/rails/public/javascripts/prototype.js +1785 -0
  93. data/lib/bio/shell/rails/public/robots.txt +1 -0
  94. data/lib/bio/shell/rails/public/stylesheets/main.css +187 -0
  95. data/lib/bio/shell/rails/script/about +3 -0
  96. data/lib/bio/shell/rails/script/breakpointer +3 -0
  97. data/lib/bio/shell/rails/script/console +3 -0
  98. data/lib/bio/shell/rails/script/destroy +3 -0
  99. data/lib/bio/shell/rails/script/generate +3 -0
  100. data/lib/bio/shell/rails/script/performance/benchmarker +3 -0
  101. data/lib/bio/shell/rails/script/performance/profiler +3 -0
  102. data/lib/bio/shell/rails/script/plugin +3 -0
  103. data/lib/bio/shell/rails/script/process/reaper +3 -0
  104. data/lib/bio/shell/rails/script/process/spawner +3 -0
  105. data/lib/bio/shell/rails/script/process/spinner +3 -0
  106. data/lib/bio/shell/rails/script/runner +3 -0
  107. data/lib/bio/shell/rails/script/server +42 -0
  108. data/lib/bio/shell/rails/test/test_helper.rb +28 -0
  109. data/lib/bio/shell/web.rb +90 -0
  110. data/lib/bio/util/contingency_table.rb +231 -225
  111. data/sample/any2fasta.rb +59 -0
  112. data/test/data/HMMER/hmmpfam.out +64 -0
  113. data/test/data/HMMER/hmmsearch.out +88 -0
  114. data/test/data/aaindex/DAYM780301 +30 -0
  115. data/test/data/aaindex/PRAM900102 +20 -0
  116. data/test/data/bl2seq/cd8a_cd8b_blastp.bl2seq +53 -0
  117. data/test/data/bl2seq/cd8a_p53_e-5blastp.bl2seq +37 -0
  118. data/test/data/blast/{eco:b0002.faa → b0002.faa} +0 -0
  119. data/test/data/blast/{eco:b0002.faa.m0 → b0002.faa.m0} +2 -2
  120. data/test/data/blast/{eco:b0002.faa.m7 → b0002.faa.m7} +1 -1
  121. data/test/data/blast/{eco:b0002.faa.m8 → b0002.faa.m8} +0 -0
  122. data/test/unit/bio/appl/bl2seq/test_report.rb +134 -0
  123. data/test/unit/bio/appl/blast/test_report.rb +15 -12
  124. data/test/unit/bio/appl/blast/test_xmlparser.rb +4 -4
  125. data/test/unit/bio/appl/hmmer/test_report.rb +355 -0
  126. data/test/unit/bio/appl/test_blast.rb +5 -5
  127. data/test/unit/bio/data/test_na.rb +9 -18
  128. data/test/unit/bio/db/pdb/test_pdb.rb +169 -0
  129. data/test/unit/bio/db/test_aaindex.rb +197 -0
  130. data/test/unit/bio/io/test_fastacmd.rb +55 -0
  131. data/test/unit/bio/sequence/test_aa.rb +102 -0
  132. data/test/unit/bio/sequence/test_common.rb +178 -0
  133. data/test/unit/bio/sequence/test_compat.rb +82 -0
  134. data/test/unit/bio/sequence/test_na.rb +242 -0
  135. data/test/unit/bio/shell/plugin/test_seq.rb +29 -19
  136. data/test/unit/bio/test_alignment.rb +15 -7
  137. data/test/unit/bio/test_reference.rb +198 -0
  138. data/test/unit/bio/test_sequence.rb +4 -49
  139. data/test/unit/bio/test_shell.rb +2 -2
  140. metadata +118 -15
  141. data/lib/bio/io/brdb.rb +0 -103
  142. data/lib/bioruby.rb +0 -34
@@ -2,25 +2,9 @@
2
2
  # = bio/appl/spidey/report.rb - SPIDEY result parser
3
3
  #
4
4
  # Copyright:: Copyright (C) 2004 GOTO Naohisa <ng@bioruby.org>
5
- # License:: LGPL
5
+ # License:: Ruby's
6
6
  #
7
- #--
8
- # This library is free software; you can redistribute it and/or
9
- # modify it under the terms of the GNU Lesser General Public
10
- # License as published by the Free Software Foundation; either
11
- # version 2 of the License, or (at your option) any later version.
12
- #
13
- # This library is distributed in the hope that it will be useful,
14
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
15
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16
- # Lesser General Public License for more details.
17
- #
18
- # You should have received a copy of the GNU Lesser General Public
19
- # License along with this library; if not, write to the Free Software
20
- # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21
- #++
22
- #
23
- # $Id: report.rb,v 1.8 2005/12/18 15:58:41 k Exp $
7
+ # $Id: report.rb,v 1.9 2006/02/22 08:46:15 ngoto Exp $
24
8
  #
25
9
  # NCBI Spidey result parser.
26
10
  # Currently, output of default (-p 0 option) or -p 1 option are supported.
@@ -44,6 +28,8 @@ module Bio
44
28
  class Spidey
45
29
 
46
30
  # Spidey report parser class.
31
+ # Please see bio/appl/spidey/report.rb for details.
32
+ #
47
33
  # Its object may contain some Bio::Spidey::Report::Hit objects.
48
34
  class Report #< DB
49
35
  #--
@@ -53,6 +39,9 @@ module Bio
53
39
  # Delimiter of each entry. Bio::FlatFile uses it.
54
40
  DELIMITER = RS = "\n--SPIDEY "
55
41
 
42
+ # (Integer) excess read size included in DELIMITER.
43
+ DELIMITER_OVERRUN = 9 # "--SPIDEY ".length
44
+
56
45
  # Creates a new Bio::Spidey::Report object from String.
57
46
  # You can use Bio::FlatFile to read a file.
58
47
  def initialize(str)
@@ -3,9 +3,9 @@
3
3
  #
4
4
  # Copyright:: Copyright (C) 2001, 2005
5
5
  # Toshiaki Katayama <k@bioruby.org>
6
- # License:: LGPL
6
+ # License:: Ruby's
7
7
  #
8
- # $Id: na.rb,v 0.19 2005/12/10 18:14:22 k Exp $
8
+ # $Id: na.rb,v 0.20 2006/02/08 12:15:42 k Exp $
9
9
  #
10
10
  # == Synopsis
11
11
  #
@@ -38,24 +38,6 @@
38
38
  # puts "# Bio::NucleicAcid.weight('atgc')"
39
39
  # p Bio::NucleicAcid.weight('atgc')
40
40
  #
41
- #--
42
- #
43
- # This library is free software; you can redistribute it and/or
44
- # modify it under the terms of the GNU Lesser General Public
45
- # License as published by the Free Software Foundation; either
46
- # version 2 of the License, or (at your option) any later version.
47
- #
48
- # This library is distributed in the hope that it will be useful,
49
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
50
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
51
- # Lesser General Public License for more details.
52
- #
53
- # You should have received a copy of the GNU Lesser General Public
54
- # License along with this library; if not, write to the Free Software
55
- # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
56
- #
57
- #++
58
- #
59
41
 
60
42
  module Bio
61
43
 
@@ -176,7 +158,7 @@ class NucleicAcid
176
158
  end
177
159
 
178
160
  def to_re(seq, rna = false)
179
- str = seq.to_s
161
+ str = seq.to_s.downcase
180
162
  str.gsub!(/[^atgcu]/) { |base|
181
163
  NAMES[base] || '.'
182
164
  }
@@ -3,9 +3,9 @@
3
3
  #
4
4
  # Copyright:: Copyright (C) 2001, 2002, 2005
5
5
  # KATAYAMA Toshiaki <k@bioruby.org>
6
- # License:: LGPL
6
+ # License:: Ruby's
7
7
  #
8
- # $Id: db.rb,v 0.32 2006/01/12 08:58:27 k Exp $
8
+ # $Id: db.rb,v 0.34 2006/02/27 09:13:08 k Exp $
9
9
  #
10
10
  # == On-demand parsing and cache
11
11
  #
@@ -144,24 +144,6 @@
144
144
  #
145
145
  # The name of the organism.
146
146
  #
147
- #--
148
- #
149
- # This library is free software; you can redistribute it and/or
150
- # modify it under the terms of the GNU Lesser General Public
151
- # License as published by the Free Software Foundation; either
152
- # version 2 of the License, or (at your option) any later version.
153
- #
154
- # This library is distributed in the hope that it will be useful,
155
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
156
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
157
- # Lesser General Public License for more details.
158
- #
159
- # You should have received a copy of the GNU Lesser General Public
160
- # License along with this library; if not, write to the Free Software
161
- # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
162
- #
163
- #++
164
- #
165
147
 
166
148
  require 'bio/sequence'
167
149
  require 'bio/reference'
@@ -267,7 +249,7 @@ class NCBIDB < DB
267
249
  # Splits an entry into an Array of Strings at the level of top tags.
268
250
  def toptag2array(str)
269
251
  sep = "\001"
270
- str.gsub(/\n([A-Za-z\/])/, "\n#{sep}\\1").split(sep)
252
+ str.gsub(/\n([A-Za-z\/\*])/, "\n#{sep}\\1").split(sep)
271
253
  end
272
254
 
273
255
  # Splits a field into an Array of Strings at the level of sub tags.
@@ -1,26 +1,37 @@
1
1
  #
2
2
  # = bio/db/aaindex.rb - AAindex database class
3
3
  #
4
- # Copyright:: Copyright (C) 2001 KAWASHIMA Shuichi <s@bioruby.org>
4
+ # Copyright:: Copyright (C) 2001
5
+ # KAWASHIMA Shuichi <s@bioruby.org>
6
+ # Copyright:: Copyright (C) 2006
7
+ # Mitsuteru C. Nakao <n@bioruby.org>
5
8
  # License:: LGPL
6
9
  #
7
- # $Id: aaindex.rb,v 1.16 2005/12/18 15:58:41 k Exp $
10
+ # $Id: aaindex.rb,v 1.18 2006/02/22 07:35:19 nakao Exp $
8
11
  #
9
12
  # == Description
13
+ #
10
14
  # Classes for Amino Acid Index Database (AAindex and AAindex2).
11
15
  # * AAindex Manual: http://www.genome.jp/dbget-bin/show_man?aaindex
12
16
  #
13
17
  # == Examples
18
+ #
19
+ # aax1 = Bio::AAindex.auto("PRAM900102.aaindex1")
20
+ # aax2 = Bio::AAindex.auto("DAYM780301.aaindex2")
21
+ #
14
22
  # aax1 = Bio::AAindex1.new("PRAM900102.aaindex1")
15
23
  # aax1.entry_id
16
24
  # aax1.index
17
25
  #
18
- # aax2 = Bio::AAindex2.new("HENS920102.aaindex2")
26
+ # aax2 = Bio::AAindex2.new("DAYM780301.aaindex2")
19
27
  # aax2.entry_id
20
28
  # aax2.matrix
21
29
  # aax2.matrix[2,2]
30
+ # aax2.matrix('R', 'A')
31
+ # aax2['R', 'A']
22
32
  #
23
33
  # == References
34
+ #
24
35
  # * http://www.genome.jp/aaindex/
25
36
  #
26
37
  #--
@@ -47,6 +58,7 @@ require "matrix"
47
58
 
48
59
  module Bio
49
60
 
61
+ # Super class for AAindex1 and AAindex2
50
62
  class AAindex < KEGGDB
51
63
 
52
64
  # Delimiter
@@ -58,62 +70,117 @@ module Bio
58
70
  # Bio::DB API
59
71
  TAGSIZE = 2
60
72
 
73
+ # Auto detecter for two AAindex formats.
74
+ # returns a Bio::AAindex1 object or a Bio::AAindex2 object.
75
+ def self.auto(str)
76
+ case str
77
+ when /^I /m
78
+ Bio::AAindex1.new(str)
79
+ when /^M /m
80
+ Bio::AAindex2.new(str)
81
+ else
82
+ raise
83
+ end
84
+ end
61
85
 
86
+ #
62
87
  def initialize(entry)
63
88
  super(entry, TAGSIZE)
64
89
  end
65
90
 
66
- # Returns
91
+ # Returns entry_id in the H line.
67
92
  def entry_id
68
- field_fetch('H')
93
+ if @data['entry_id']
94
+ @data['entry_id']
95
+ else
96
+ @data['entry_id'] = field_fetch('H')
97
+ end
69
98
  end
70
99
 
71
- # Returns
100
+ # Returns definition in the D line.
72
101
  def definition
73
- field_fetch('D')
102
+ if @data['definition']
103
+ @data['definition']
104
+ else
105
+ @data['definition'] = field_fetch('D')
106
+ end
74
107
  end
75
108
 
76
- # Returns
109
+ # Returns database links in the R line.
110
+ # cf.) ['LIT:123456', 'PMID:12345678']
77
111
  def dblinks
78
- field_fetch('R')
112
+ if @data['ref']
113
+ @data['ref']
114
+ else
115
+ @data['ref'] = field_fetch('R').split(' ')
116
+ end
79
117
  end
80
118
 
81
- # Returns
119
+ # Returns authors in the A line.
82
120
  def author
83
- field_fetch('A')
121
+ if @data['author']
122
+ @data['author']
123
+ else
124
+ @data['author'] = field_fetch('A')
125
+ end
84
126
  end
85
127
 
86
- # Returns
128
+ # Returns title in the T line.
87
129
  def title
88
- field_fetch('T')
130
+ if @data['title']
131
+ @data['title']
132
+ else
133
+ @data['title'] = field_fetch('T')
134
+ end
89
135
  end
90
136
 
91
- # Returns
137
+ # Returns journal name in the J line.
92
138
  def journal
93
- field_fetch('J')
139
+ if @data['journal']
140
+ @data['journal']
141
+ else
142
+ @data['journal'] = field_fetch('J')
143
+ end
94
144
  end
95
145
 
96
- # Returns
146
+ # Returns comment (if any).
97
147
  def comment
98
- get('*')
148
+ if @data['comment']
149
+ @data['comment']
150
+ else
151
+ @data['comment'] = field_fetch('*')
152
+ end
99
153
  end
100
-
101
154
  end
102
155
 
103
156
 
157
+ # Class for AAindex1 format.
104
158
  class AAindex1 < AAindex
105
159
 
106
-
107
160
  def initialize(entry)
108
161
  super(entry)
109
162
  end
110
163
 
111
- # Returns
164
+ # Returns correlation_coefficient (Hash) in the C line.
165
+ #
166
+ # cf.) {'ABCD12010203' => 0.999, 'CDEF123456' => 0.543, ...}
112
167
  def correlation_coefficient
113
- field_fetch('C')
168
+ if @data['correlation_coefficient']
169
+ @data['correlation_coefficient']
170
+ else
171
+ hash = {}
172
+ ary = field_fetch('C').split(' ')
173
+ ary.each do |x|
174
+ next unless x =~ /^[A-Z]/
175
+ hash[x] = ary[ary.index(x) + 1].to_f
176
+ end
177
+ @data['correlation_coefficient'] = hash
178
+ end
114
179
  end
115
180
 
116
- # Returns
181
+ # Returns the index (Array) in the I line.
182
+ #
183
+ # an argument: :string, :float, :zscore or :integer
117
184
  def index(type = :float)
118
185
  aa = %w( A R N D C Q E G H I L K M F P S T W Y V )
119
186
  values = field_fetch('I', 1).split(' ')
@@ -162,43 +229,62 @@ module Bio
162
229
  end
163
230
 
164
231
 
232
+ # Class for AAindex2 format.
165
233
  class AAindex2 < AAindex
166
234
 
167
-
168
235
  def initialize(entry)
169
236
  super(entry)
170
237
  end
171
238
 
172
- # Returns
239
+ # Returns row labels.
173
240
  def rows
174
- label_data
175
- @rows
241
+ if @data['rows']
242
+ @data['rows']
243
+ else
244
+ label_data
245
+ @rows
246
+ end
176
247
  end
177
248
 
178
- # Returns
249
+ # Returns col labels.
179
250
  def cols
180
- label_data
181
- @cols
251
+ if @data['cols']
252
+ @data['cols']
253
+ else
254
+ label_data
255
+ @cols
256
+ end
182
257
  end
183
258
 
184
- # Returns
185
- def matrix
186
- ma = Array.new
259
+ # Returns the value of amino acids substitution (aa1 -> aa2).
260
+ def [](aa1 = nil, aa2 = nil)
261
+ matrix[cols.index(aa1), rows.index(aa2)]
262
+ end
187
263
 
188
- data = label_data
189
- data.each_line do |line|
190
- list = line.strip.split(/\s+/).map{|x| x.to_f}
191
- ma.push(list)
192
- end
264
+ # Returns amino acids matrix in Matrix.
265
+ def matrix(aa1 = nil, aa2 = nil)
266
+ return self[aa1, aa2] if aa1 and aa2
193
267
 
194
- Matrix[*ma]
268
+ if @data['matrix']
269
+ @data['matrix']
270
+ else
271
+ ma = []
272
+ label_data.each_line do |line|
273
+ ma << line.strip.split(/\s+/).map {|x| x.to_f }
274
+ end
275
+ @data['matrix'] = Matrix[*ma]
276
+ end
195
277
  end
196
278
 
197
- # Returns
279
+ # Returns amino acids matrix in Matrix for the old format (<= ver 5.0).
198
280
  def old_matrix # for AAindex <= ver 5.0
281
+ return @data['matrix'] if @data['matrix']
199
282
 
200
- @aa = {} # used to determine row/column of the aa
283
+ @aa = {}
284
+ # used to determine row/column of the aa
201
285
  attr_reader :aa
286
+ alias_method :aa, :rows
287
+ alias_method :aa, :cols
202
288
 
203
289
  field = field_fetch('I')
204
290
 
@@ -222,8 +308,7 @@ module Bio
222
308
  ma[j][i] = ma[i][j]
223
309
  end
224
310
  end
225
- Matrix[*ma]
226
-
311
+ @data['matrix'] = Matrix[*ma]
227
312
  when / -ARNDCQEGHILKMFPSTWYV / # 21x20/2 matrix (with gap)
228
313
  raise NotImplementedError
229
314
  when / ACDEFGHIKLMNPQRSTVWYJ- / # 21x21 matrix (with gap)
@@ -234,18 +319,22 @@ module Bio
234
319
  private
235
320
 
236
321
  def label_data
237
- label, data = get('M').split("\n", 2)
238
- if /M rows = (\S+), cols = (\S+)/.match(label)
239
- rows, cols = $1, $2
240
- @rows = rows.split('')
241
- @cols = cols.split('')
322
+ if @data['data']
323
+ @data['data']
324
+ else
325
+ label, data = get('M').split("\n", 2)
326
+ if /M rows = (\S+), cols = (\S+)/.match(label)
327
+ rows, cols = $1, $2
328
+ @rows = rows.split('')
329
+ @cols = cols.split('')
330
+ end
331
+ @data['data'] = data
242
332
  end
243
- return data
244
333
  end
245
334
 
246
- end
335
+ end # class AAindex2
247
336
 
248
- end
337
+ end # module Bio
249
338
 
250
339
 
251
340
  if __FILE__ == $0
@@ -259,22 +348,28 @@ if __FILE__ == $0
259
348
  p aax1.author
260
349
  p aax1.title
261
350
  p aax1.journal
351
+ p aax1.comment
262
352
  p aax1.correlation_coefficient
263
353
  p aax1.index
264
- puts "### AAindex2 (HENS920102)"
265
- aax2 = Bio::AAindex2.new(Bio::Fetch.query('aaindex', 'HENS920102', 'raw'))
354
+ p aax1
355
+ puts "### AAindex2 (DAYM780301)"
356
+ aax2 = Bio::AAindex2.new(Bio::Fetch.query('aaindex', 'DAYM780301', 'raw'))
266
357
  p aax2.entry_id
267
358
  p aax2.definition
268
359
  p aax2.dblinks
269
360
  p aax2.author
270
361
  p aax2.title
271
362
  p aax2.journal
363
+ p aax1.comment
272
364
  p aax2.rows
273
365
  p aax2.cols
274
366
  p aax2.matrix
275
367
  p aax2.matrix[2,2]
368
+ p aax2.matrix[2,3]
369
+ p aax2.matrix[4,3]
276
370
  p aax2.matrix.determinant
277
371
  p aax2.matrix.rank
278
372
  p aax2.matrix.transpose
373
+ p aax2
279
374
  end
280
375