bio 0.7.1 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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
@@ -0,0 +1,143 @@
1
+ #
2
+ # = bio/shell/demo.rb - demo mode for the BioRuby shell
3
+ #
4
+ # Copyright:: Copyright (C) 2006
5
+ # Toshiaki Katayama <k@bioruby.org>
6
+ # License:: Ruby's
7
+ #
8
+ # $Id: demo.rb,v 1.1 2006/02/27 09:33:22 k Exp $
9
+ #
10
+
11
+ module Bio::Shell
12
+
13
+ private
14
+
15
+ def demo(part = nil)
16
+ demo = Demo.new
17
+ if part
18
+ demo.send(part)
19
+ else
20
+ demo.all
21
+ end
22
+ end
23
+
24
+ class Demo
25
+
26
+ def initialize
27
+ @bind = IRB.conf[:MAIN_CONTEXT].workspace.binding
28
+ end
29
+
30
+ def all
31
+ sequence &&
32
+ entry &&
33
+ shell &&
34
+ pdb &&
35
+ true
36
+ end
37
+
38
+ def tutorial
39
+ end
40
+
41
+ def mito
42
+ run(%q[entry = ent("data/kumamushi.gb")], "Load kumamushi gene from GenBank database entry ...", false) &&
43
+ run(%q[disp entry], "Check the contents ...", false) &&
44
+ run(%q[kuma = flatparse(entry)], "Parse the database entry ...", true) &&
45
+ run(%q[web], "Start BioRuby on Rails...", false) &&
46
+ run(%q[puts kuma.entry_id], "Extract entry ID ...", false) &&
47
+ run(%q[puts kuma.definition], "Extract definition ...", false) &&
48
+ run(%q[gene = kuma.seq], "Extract DNA sequence of the gene ...", true) &&
49
+ run(%q[doublehelix(gene)], "Show the sequence in ascii art ...", false) &&
50
+ run(%q[seqstat(gene)], "Statistics of the gene ...", false) &&
51
+ run(%q[config :color], "Change to color mode...", false) &&
52
+ run(%q[seqstat(gene)], "Statistics of the gene ...", false) &&
53
+ #run(%q[codontable], "Codontalble ...", false) &&
54
+ run(%q[protein = gene.translate], "Translate DNA into protein ...", true) &&
55
+ run(%q[comp = protein.composition], "Composition of the amino acids ...", false) &&
56
+ run(%q[pp comp], "Check the composition ...", false) &&
57
+ run(%q[puts protein.molecular_weight], "Molecular weight ...", false) &&
58
+ run(%q[midifile("data/kumamushi.mid", gene)], "Gene to music ...", false) &&
59
+ run(%q[`open "data/kumamushi.mid"`], "Let's listen ...", false) &&
60
+ true
61
+ end
62
+
63
+ def sequence
64
+ run(%q[dna = seq("atgc" * 100)], "Generating DNA sequence ...", true) &&
65
+ run(%q[doublehelix dna], "Double helix representation", false) &&
66
+ run(%q[protein = dna.translate], "Translate DNA into Protein ...", true) &&
67
+ run(%q[protein.molecular_weight], "Calculating molecular weight ...", true) &&
68
+ run(%q[protein.composition], "Amino acid composition ...", true) &&
69
+ true
70
+ end
71
+
72
+ def entry
73
+ run(%q[kuma = obj("gb:AF237819")], "Obtain an entry from GenBank database", false) &&
74
+ run(%q[kuma.definition], "Definition of the entry", true) &&
75
+ run(%q[kuma.naseq], "Sequence of the entry", true) &&
76
+ run(%q[kuma.naseq.translate], "Translate the sequence to protein", true) &&
77
+ run(%q[midifile("data/AF237819.mid", kuma.naseq)], "Generate gene music ...", false) &&
78
+ true
79
+ end
80
+
81
+ def shell
82
+ run(%q[pwd], "Show current working directory ...", false) &&
83
+ run(%q[dir], "Show directory contents ...", false) &&
84
+ run(%q[dir "session"], "Show directory contents ...", false) &&
85
+ true
86
+ end
87
+
88
+ def pdb
89
+ run(%q[ent_1bl8 = ent("pdb:1bl8")], "Retrieving PDB entry 1BL8 ...", false) &&
90
+ run(%q[head ent_1bl8], "Head part of the entry ...", false) &&
91
+ run(%q[savefile("1bl8.pdb", ent_1bl8)], "Saving the original entry in file ...", false) &&
92
+ run(%q[less "data/1bl8.pdb"], "Look through the entire entry ...", false) &&
93
+ run(%q[pdb_1bl8 = flatparse(ent_1bl8)], "Parsing the entry ...", false) &&
94
+ run(%q[pdb_1bl8.entry_id], "Showing the entry ID ...", true) &&
95
+ run(%q[pdb_1bl8.each_heterogen { |heterogen| p heterogen.resName }], "Showing each heterogen object ...", false) &&
96
+ true
97
+ end
98
+
99
+ def pdb_hetdic
100
+ run(%q[het_dic = open("http://deposit.pdb.org/het_dictionary.txt").read],
101
+ "Retrieving the het_dic database ...", false) &&
102
+ run(%q[savefile("data/het_dictionary.txt", het_dic)],
103
+ "Saving the file ... ", false) &&
104
+ run(%q[het_dic.size], "Bytes of the file ...", true) &&
105
+ run(%q[less "data/het_dictionary.txt"], "Take a look on the contents ...", true) &&
106
+ run(%q[flatindex("het_dic", "data/het_dictionary.txt")],
107
+ "Creating index to make the seaarchable database ...", false) &&
108
+ run(%q[ethanol = flatsearch("het_dic", "EOH")], "Search an ethanol entry ...", true) &&
109
+ run(%q[osake = flatparse(ethanol)], "Parse the entry ...", true) &&
110
+ run(%q[sake.conect], "Showing connect table (conect) of the molecule ...", true) &&
111
+ true
112
+ end
113
+
114
+ private
115
+
116
+ def run(cmd, msg, echo)
117
+ comment(msg)
118
+ splash(cmd)
119
+ result = eval(cmd, @bind)
120
+ if echo
121
+ pp result
122
+ end
123
+ continue?
124
+ end
125
+
126
+ def comment(msg)
127
+ puts "### #{msg}"
128
+ end
129
+
130
+ def splash(msg)
131
+ Bio::Shell.splash_message_action("bioruby> #{msg}")
132
+ print "bioruby> #{msg}"
133
+ gets
134
+ end
135
+
136
+ def continue?
137
+ Bio::Shell.ask_yes_or_no("Continue? [y/n] ")
138
+ end
139
+
140
+ end
141
+
142
+ end
143
+
@@ -1,29 +1,11 @@
1
1
  #
2
- # = bio/shell/session.rb - core user interface of the BioRuby shell
2
+ # = bio/shell/interface.rb - core user interface of the BioRuby shell
3
3
  #
4
- # Copyright:: Copyright (C) 2005
5
- # Toshiaki Katayama <k@bioruby.org>
6
- # License:: LGPL
4
+ # Copyright:: Copyright (C) 2005
5
+ # Toshiaki Katayama <k@bioruby.org>
6
+ # License:: Ruby's
7
7
  #
8
- # $Id: session.rb,v 1.11 2005/12/07 07:50:44 k Exp $
9
- #
10
- #--
11
- #
12
- # This library is free software; you can redistribute it and/or
13
- # modify it under the terms of the GNU Lesser General Public
14
- # License as published by the Free Software Foundation; either
15
- # version 2 of the License, or (at your option) any later version.
16
- #
17
- # This library is distributed in the hope that it will be useful,
18
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
19
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20
- # Lesser General Public License for more details.
21
- #
22
- # You should have received a copy of the GNU Lesser General Public
23
- # License along with this library; if not, write to the Free Software
24
- # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25
- #
26
- #++
8
+ # $Id: interface.rb,v 1.14 2006/02/27 09:36:35 k Exp $
27
9
  #
28
10
 
29
11
  module Bio::Shell
@@ -37,6 +19,7 @@ module Bio::Shell
37
19
  eval(x, conf.workspace.binding).nil?
38
20
  }
39
21
  puts list.inspect
22
+ return list
40
23
  end
41
24
 
42
25
  def rm(name)
@@ -82,10 +65,14 @@ module Bio::Shell
82
65
  Bio::Shell.config_echo
83
66
  when :color, "color"
84
67
  Bio::Shell.config_color
68
+ when :splash, "splash"
69
+ Bio::Shell.config_splash
85
70
  when :pager, "pager"
86
71
  Bio::Shell.config_pager(*opts)
87
72
  when :message, "message"
88
73
  Bio::Shell.config_message(*opts)
74
+ else
75
+ puts "Invalid mode (#{mode}) - :show, :echo, :color, :splash, :massage"
89
76
  end
90
77
  end
91
78
 
@@ -97,35 +84,46 @@ module Bio::Shell
97
84
 
98
85
  def pager(cmd = nil)
99
86
  unless Bio::Shell.config[:pager]
100
- cmd = ENV['PAGER'] || cmd
87
+ cmd ||= ENV['PAGER']
101
88
  end
102
89
  Bio::Shell.config_pager(cmd)
103
90
  puts "Pager is set to '#{cmd ? cmd : 'off'}'"
104
91
  end
105
92
 
106
- def display(*obj)
93
+ def disp(*objs)
107
94
  # The original idea is from http://sheepman.parfait.ne.jp/20050215.html
108
- if Bio::Shell.config[:pager]
109
- pg = IO.popen(Bio::Shell.config[:pager], "w")
95
+ if cmd = Bio::Shell.config[:pager]
96
+ pg = IO.popen(cmd, "w")
110
97
  begin
111
98
  stdout_save = STDOUT.clone
112
99
  STDOUT.reopen(pg)
113
- puts(*obj)
100
+ objs.each do |obj|
101
+ if obj.is_a?(String)
102
+ if File.exists?(obj)
103
+ system("#{cmd} #{obj}")
104
+ else
105
+ obj.display
106
+ end
107
+ else
108
+ pp obj
109
+ end
110
+ end
114
111
  ensure
115
112
  STDOUT.reopen(stdout_save)
116
113
  stdout_save.close
117
114
  pg.close
118
115
  end
119
116
  else
120
- puts(*obj)
117
+ objs.each do |obj|
118
+ if obj.is_a?(String)
119
+ obj.display
120
+ else
121
+ pp obj
122
+ end
123
+ end
121
124
  end
122
125
  end
123
126
 
124
- def less(file)
125
- pager = Bio::Shell.config[:pager] || ENV['PAGER'] || "less"
126
- system("#{pager} #{file}")
127
- end
128
-
129
127
  def head(arg, num = 10)
130
128
  str = ""
131
129
  if File.exists?(arg)
@@ -149,16 +147,20 @@ module Bio::Shell
149
147
  ### file save
150
148
 
151
149
  def savefile(file, *objs)
150
+ datadir = Bio::Shell.datadir
151
+ message = "Save file '#{file}' in '#{datadir}' directory? [y/n] "
152
+ if ! file[/^#{datadir}/] and Bio::Shell.ask_yes_or_no(message)
153
+ file = datadir + file
154
+ end
152
155
  if File.exists?(file)
153
- loop do
154
- print "Overwrite existing #{file}? [y/n]: "
155
- answer = gets
156
- return if /^\s*[Nn]/.match(answer)
157
- break if /^\s*[Yy]/.match(answer)
156
+ message = "Overwrite existing '#{file}' file? [y/n] "
157
+ if ! Bio::Shell.ask_yes_or_no(message)
158
+ puts " ... save aborted."
159
+ return
158
160
  end
159
161
  end
160
162
  begin
161
- print "Saving data (#{file}) ... "
163
+ print "Saving file (#{file}) ... "
162
164
  File.open(file, "w") do |f|
163
165
  objs.each do |obj|
164
166
  f.puts obj.to_s
@@ -0,0 +1,52 @@
1
+ #
2
+ # = bio/shell/object.rb - Object extension for the BioRuby shell
3
+ #
4
+ # Copyright:: Copyright (C) 2006
5
+ # Nobuya Tanaka <t@chemruby.org>,
6
+ # Toshiaki Katayama <k@bioruby.org>
7
+ # License:: Ruby's
8
+ #
9
+ # $Id: object.rb,v 1.1 2006/02/27 09:16:13 k Exp $
10
+ #
11
+
12
+ require 'cgi'
13
+ require 'pp'
14
+
15
+ ### Object extention
16
+
17
+ class Object
18
+ # Couldn't work for Fixnum (Marshal)
19
+ attr_accessor :memo
20
+
21
+ # *TODO*
22
+ def to_html
23
+ if self.is_a?(String)
24
+ "<pre>" + self + "</pre>"
25
+ else
26
+ str = ""
27
+ PP.pp(self, str)
28
+ "<pre>" + str + "</pre>"
29
+ #"<pre>" + CGI.escapeHTML(str) + "</pre>"
30
+ #self.inspect
31
+ #"<pre>" + self.inspect + "</pre>"
32
+ #"<pre>" + self.to_s + "</pre>"
33
+ end
34
+ end
35
+ end
36
+
37
+ =begin
38
+ module Bio
39
+ class DB
40
+ def to_html
41
+ html = ""
42
+ html += "<table>"
43
+ @data.each do |k, v|
44
+ html += "<tr><td>#{k}</td><td>#{v}</td></tr>"
45
+ end
46
+ html += "</table>"
47
+ end
48
+ end
49
+ end
50
+ =end
51
+
52
+
@@ -1,29 +1,11 @@
1
1
  #
2
2
  # = bio/shell/plugin/codon.rb - plugin for the codon table
3
3
  #
4
- # Copyright:: Copyright (C) 2005
5
- # Toshiaki Katayama <k@bioruby.org>
6
- # License:: LGPL
4
+ # Copyright:: Copyright (C) 2005
5
+ # Toshiaki Katayama <k@bioruby.org>
6
+ # License:: Ruby's
7
7
  #
8
- # $Id: codon.rb,v 1.12 2005/12/19 02:34:24 k Exp $
9
- #
10
- #--
11
- #
12
- # This library is free software; you can redistribute it and/or
13
- # modify it under the terms of the GNU Lesser General Public
14
- # License as published by the Free Software Foundation; either
15
- # version 2 of the License, or (at your option) any later version.
16
- #
17
- # This library is distributed in the hope that it will be useful,
18
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
19
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20
- # Lesser General Public License for more details.
21
- #
22
- # You should have received a copy of the GNU Lesser General Public
23
- # License along with this library; if not, write to the Free Software
24
- # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25
- #
26
- #++
8
+ # $Id: codon.rb,v 1.13 2006/02/09 20:48:53 k Exp $
27
9
  #
28
10
 
29
11
  module Bio::Shell
@@ -0,0 +1,23 @@
1
+ #
2
+ # = bio/shell/plugin/emboss.rb - methods to use EMBOSS
3
+ #
4
+ # Copyright:: Copyright (C) 2005
5
+ # Toshiaki Katayama <k@bioruby.org>
6
+ # License:: Ruby's
7
+ #
8
+ # $Id: emboss.rb,v 1.2 2006/02/09 20:48:53 k Exp $
9
+ #
10
+
11
+ module Bio::Shell
12
+
13
+ private
14
+
15
+ def seqret(usa)
16
+ Bio::EMBOSS.seqret(usa)
17
+ end
18
+
19
+ def entret(usa)
20
+ Bio::EMBOSS.entret(usa)
21
+ end
22
+
23
+ end
@@ -1,29 +1,11 @@
1
1
  #
2
2
  # = bio/shell/plugin/entry.rb - extract entry and sequence
3
3
  #
4
- # Copyright:: Copyright (C) 2005
5
- # Toshiaki Katayama <k@bioruby.org>
6
- # License:: LGPL
4
+ # Copyright:: Copyright (C) 2005
5
+ # Toshiaki Katayama <k@bioruby.org>
6
+ # License:: Ruby's
7
7
  #
8
- # $Id: entry.rb,v 1.4 2005/12/07 05:12:07 k Exp $
9
- #
10
- #--
11
- #
12
- # This library is free software; you can redistribute it and/or
13
- # modify it under the terms of the GNU Lesser General Public
14
- # License as published by the Free Software Foundation; either
15
- # version 2 of the License, or (at your option) any later version.
16
- #
17
- # This library is distributed in the hope that it will be useful,
18
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
19
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20
- # Lesser General Public License for more details.
21
- #
22
- # You should have received a copy of the GNU Lesser General Public
23
- # License along with this library; if not, write to the Free Software
24
- # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25
- #
26
- #++
8
+ # $Id: entry.rb,v 1.8 2006/02/27 09:37:14 k Exp $
27
9
  #
28
10
 
29
11
  module Bio::Shell
@@ -58,7 +40,7 @@ module Bio::Shell
58
40
  end
59
41
 
60
42
  if tmp and tmp.is_a?(String) and not tmp.empty?
61
- seq = Bio::Sequence.auto(tmp)
43
+ seq = Bio::Sequence.auto(tmp).seq
62
44
  end
63
45
  return seq
64
46
  end
@@ -66,20 +48,47 @@ module Bio::Shell
66
48
  # Obtain a database entry from
67
49
  # * IO -- IO object (first entry only)
68
50
  # * "filename" -- local file (first entry only)
69
- # * "db:entry" -- local bioflat, OBDA, KEGG API
51
+ # * "db:entry" -- local BioFlat, OBDA, EMBOSS, KEGG API
70
52
  def ent(arg)
71
53
  entry = ""
72
54
  db, entry_id = arg.to_s.strip.split(/:/)
55
+
56
+ # local file
73
57
  if arg.respond_to?(:gets) or File.exists?(arg)
58
+ puts "Retrieving entry from file (#{arg})"
74
59
  entry = flatfile(arg)
60
+
61
+ # BioFlat in ./.bioruby/bioflat/ or ~/.bioinformatics/.bioruby/bioflat/
75
62
  elsif Bio::Shell.find_flat_dir(db)
63
+ puts "Retrieving entry from local BioFlat database (#{arg})"
76
64
  entry = flatsearch(db, entry_id)
65
+
66
+ # OBDA in ~/.bioinformatics/seqdatabase.ini
77
67
  elsif obdadbs.include?(db)
68
+ puts "Retrieving entry from OBDA (#{arg})"
78
69
  entry = obdaentry(db, entry_id)
70
+
79
71
  else
80
- entry = bget(arg)
72
+ # EMBOSS USA in ~/.embossrc
73
+ str = entret(arg)
74
+ if $?.exitstatus == 0 and str.length != 0
75
+ puts "Retrieving entry from EMBOSS (#{arg})"
76
+ entry = str
77
+
78
+ # KEGG API at http://www.genome.jp/kegg/soap/
79
+ else
80
+ puts "Retrieving entry from KEGG API (#{arg})"
81
+ entry = bget(arg)
82
+ end
81
83
  end
84
+
82
85
  return entry
83
86
  end
84
87
 
88
+ # Obtain a parsed object from sources that ent() supports.
89
+ def obj(arg)
90
+ str = ent(arg)
91
+ flatparse(str)
92
+ end
93
+
85
94
  end