bio 1.5.2 → 1.6.0.pre.20181210
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.
- checksums.yaml +5 -5
- data/.travis.yml +12 -11
- data/ChangeLog +14 -3106
- data/{gemfiles/Gemfile.travis-ruby2.2 → Gemfile} +0 -1
- data/KNOWN_ISSUES.rdoc +0 -5
- data/README.rdoc +11 -18
- data/RELEASE_NOTES.rdoc +34 -291
- data/Rakefile +13 -9
- data/appveyor.yml +21 -0
- data/bioruby.gemspec +7 -78
- data/bioruby.gemspec.erb +8 -27
- data/doc/ChangeLog-1.5.0 +2919 -0
- data/doc/RELEASE_NOTES-1.5.0.rdoc +285 -0
- data/doc/Tutorial.rd +6 -108
- data/doc/Tutorial.rd.html +19 -98
- data/gemfiles/Gemfile.travis-jruby1.8 +3 -5
- data/gemfiles/Gemfile.travis-jruby1.9 +0 -3
- data/gemfiles/Gemfile.travis-rbx +0 -1
- data/gemfiles/Gemfile.travis-ruby1.8 +4 -4
- data/gemfiles/Gemfile.travis-ruby1.9 +0 -1
- data/gemfiles/prepare-gemspec.rb +4 -0
- data/lib/bio.rb +0 -10
- data/lib/bio/data/codontable.rb +99 -3
- data/lib/bio/io/togows.rb +5 -5
- data/lib/bio/version.rb +6 -8
- data/sample/test_restriction_enzyme_long.rb +1 -1
- data/test/unit/bio/data/test_codontable.rb +3 -0
- metadata +11 -77
- data/bin/bioruby +0 -47
- data/bin/br_biofetch.rb +0 -71
- data/bin/br_bioflat.rb +0 -293
- data/bin/br_biogetseq.rb +0 -45
- data/bin/br_pmfetch.rb +0 -422
- data/lib/bio/db/biosql/biosql_to_biosequence.rb +0 -78
- data/lib/bio/db/biosql/sequence.rb +0 -444
- data/lib/bio/db/phyloxml/phyloxml.xsd +0 -582
- data/lib/bio/db/phyloxml/phyloxml_elements.rb +0 -1197
- data/lib/bio/db/phyloxml/phyloxml_parser.rb +0 -1001
- data/lib/bio/db/phyloxml/phyloxml_writer.rb +0 -227
- data/lib/bio/io/biosql/ar-biosql.rb +0 -257
- data/lib/bio/io/biosql/biosql.rb +0 -39
- data/lib/bio/io/biosql/config/database.yml +0 -21
- data/lib/bio/io/sql.rb +0 -79
- data/lib/bio/shell.rb +0 -44
- data/lib/bio/shell/core.rb +0 -578
- data/lib/bio/shell/demo.rb +0 -146
- data/lib/bio/shell/interface.rb +0 -217
- data/lib/bio/shell/irb.rb +0 -94
- data/lib/bio/shell/object.rb +0 -71
- data/lib/bio/shell/plugin/blast.rb +0 -42
- data/lib/bio/shell/plugin/codon.rb +0 -218
- data/lib/bio/shell/plugin/das.rb +0 -58
- data/lib/bio/shell/plugin/emboss.rb +0 -23
- data/lib/bio/shell/plugin/entry.rb +0 -137
- data/lib/bio/shell/plugin/flatfile.rb +0 -101
- data/lib/bio/shell/plugin/midi.rb +0 -430
- data/lib/bio/shell/plugin/ncbirest.rb +0 -68
- data/lib/bio/shell/plugin/obda.rb +0 -45
- data/lib/bio/shell/plugin/psort.rb +0 -56
- data/lib/bio/shell/plugin/seq.rb +0 -248
- data/lib/bio/shell/plugin/togows.rb +0 -40
- data/lib/bio/shell/rails/vendor/plugins/bioruby/generators/bioruby/bioruby_generator.rb +0 -29
- data/lib/bio/shell/rails/vendor/plugins/bioruby/generators/bioruby/templates/_classes.rhtml +0 -4
- data/lib/bio/shell/rails/vendor/plugins/bioruby/generators/bioruby/templates/_log.rhtml +0 -27
- data/lib/bio/shell/rails/vendor/plugins/bioruby/generators/bioruby/templates/_methods.rhtml +0 -11
- data/lib/bio/shell/rails/vendor/plugins/bioruby/generators/bioruby/templates/_modules.rhtml +0 -4
- data/lib/bio/shell/rails/vendor/plugins/bioruby/generators/bioruby/templates/_variables.rhtml +0 -7
- data/lib/bio/shell/rails/vendor/plugins/bioruby/generators/bioruby/templates/bioruby-bg.gif +0 -0
- data/lib/bio/shell/rails/vendor/plugins/bioruby/generators/bioruby/templates/bioruby-gem.png +0 -0
- data/lib/bio/shell/rails/vendor/plugins/bioruby/generators/bioruby/templates/bioruby-link.gif +0 -0
- data/lib/bio/shell/rails/vendor/plugins/bioruby/generators/bioruby/templates/bioruby.css +0 -368
- data/lib/bio/shell/rails/vendor/plugins/bioruby/generators/bioruby/templates/bioruby.rhtml +0 -47
- data/lib/bio/shell/rails/vendor/plugins/bioruby/generators/bioruby/templates/bioruby_controller.rb +0 -144
- data/lib/bio/shell/rails/vendor/plugins/bioruby/generators/bioruby/templates/bioruby_helper.rb +0 -47
- data/lib/bio/shell/rails/vendor/plugins/bioruby/generators/bioruby/templates/commands.rhtml +0 -8
- data/lib/bio/shell/rails/vendor/plugins/bioruby/generators/bioruby/templates/history.rhtml +0 -10
- data/lib/bio/shell/rails/vendor/plugins/bioruby/generators/bioruby/templates/index.rhtml +0 -26
- data/lib/bio/shell/rails/vendor/plugins/bioruby/generators/bioruby/templates/spinner.gif +0 -0
- data/lib/bio/shell/script.rb +0 -25
- data/lib/bio/shell/setup.rb +0 -108
- data/lib/bio/shell/web.rb +0 -102
- data/sample/test_phyloxml_big.rb +0 -205
- data/test/data/phyloxml/apaf.xml +0 -666
- data/test/data/phyloxml/bcl_2.xml +0 -2097
- data/test/data/phyloxml/made_up.xml +0 -144
- data/test/data/phyloxml/ncbi_taxonomy_mollusca_short.xml +0 -65
- data/test/data/phyloxml/phyloxml_examples.xml +0 -415
- data/test/unit/bio/db/biosql/tc_biosql.rb +0 -114
- data/test/unit/bio/db/biosql/ts_suite_biosql.rb +0 -8
- data/test/unit/bio/db/test_phyloxml.rb +0 -821
- data/test/unit/bio/db/test_phyloxml_writer.rb +0 -334
- data/test/unit/bio/shell/plugin/test_seq.rb +0 -187
- data/test/unit/bio/test_shell.rb +0 -20
data/lib/bio/shell/object.rb
DELETED
@@ -1,71 +0,0 @@
|
|
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:: The Ruby License
|
8
|
-
#
|
9
|
-
# $Id: object.rb,v 1.3 2007/04/05 23:35:41 trevor Exp $
|
10
|
-
#
|
11
|
-
|
12
|
-
require 'pp'
|
13
|
-
require 'cgi'
|
14
|
-
require 'yaml'
|
15
|
-
|
16
|
-
### Object extention
|
17
|
-
|
18
|
-
class Object
|
19
|
-
# Couldn't work for Fixnum (Marshal)
|
20
|
-
attr_accessor :memo
|
21
|
-
|
22
|
-
def output(format = :yaml)
|
23
|
-
case format
|
24
|
-
when :yaml
|
25
|
-
self.to_yaml
|
26
|
-
when :html
|
27
|
-
format_html
|
28
|
-
when :inspect
|
29
|
-
format_pp
|
30
|
-
when :png
|
31
|
-
# *TODO*
|
32
|
-
when :svg
|
33
|
-
# *TODO*
|
34
|
-
when :graph
|
35
|
-
# *TODO* (Gruff, RSRuby etc.)
|
36
|
-
else
|
37
|
-
#self.inspect.to_s.fold(80)
|
38
|
-
self.to_s
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
private
|
43
|
-
|
44
|
-
def format_html
|
45
|
-
"<pre>#{CGI.escapeHTML(format_pp)}</pre>"
|
46
|
-
end
|
47
|
-
|
48
|
-
def format_pp
|
49
|
-
str = ""
|
50
|
-
PP.pp(self, str)
|
51
|
-
return str
|
52
|
-
end
|
53
|
-
|
54
|
-
end
|
55
|
-
|
56
|
-
class Hash
|
57
|
-
|
58
|
-
private
|
59
|
-
|
60
|
-
def format_html
|
61
|
-
html = ""
|
62
|
-
html += "<table>"
|
63
|
-
@data.each do |k, v|
|
64
|
-
html += "<tr><td>#{k}</td><td>#{v}</td></tr>"
|
65
|
-
end
|
66
|
-
html += "</table>"
|
67
|
-
return html
|
68
|
-
end
|
69
|
-
|
70
|
-
end
|
71
|
-
|
@@ -1,42 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# = bio/shell/plugin/blast.rb - plugin for BLAST services
|
3
|
-
#
|
4
|
-
# Copyright:: Copyright (C) 2006
|
5
|
-
# Toshiaki Katayama <k@bioruby.org>
|
6
|
-
# License:: The Ruby License
|
7
|
-
#
|
8
|
-
# $Id: blast.rb,v 1.3 2007/04/05 23:35:41 trevor Exp $
|
9
|
-
#
|
10
|
-
|
11
|
-
module Bio::Shell
|
12
|
-
|
13
|
-
private
|
14
|
-
|
15
|
-
# GenomeNet
|
16
|
-
|
17
|
-
def keggblast(query)
|
18
|
-
server = Bio::Blast.remote("blastp", "genes", "", "genomenet_tab")
|
19
|
-
|
20
|
-
if query[/^>/]
|
21
|
-
data = Bio::FastaFormat.new(query)
|
22
|
-
desc = data.definition
|
23
|
-
tmp = getseq(data.seq)
|
24
|
-
else
|
25
|
-
desc = "query"
|
26
|
-
tmp = getseq(query)
|
27
|
-
end
|
28
|
-
|
29
|
-
if tmp.respond_to?(:translate)
|
30
|
-
aaseq = tmp.translate
|
31
|
-
else
|
32
|
-
aaseq = tmp
|
33
|
-
end
|
34
|
-
|
35
|
-
fasta = aaseq.to_fasta(desc, 60)
|
36
|
-
result = server.query(fasta)
|
37
|
-
puts server.output
|
38
|
-
return result
|
39
|
-
end
|
40
|
-
|
41
|
-
end
|
42
|
-
|
@@ -1,218 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# = bio/shell/plugin/codon.rb - plugin for the codon table
|
3
|
-
#
|
4
|
-
# Copyright:: Copyright (C) 2005
|
5
|
-
# Toshiaki Katayama <k@bioruby.org>
|
6
|
-
# License:: The Ruby License
|
7
|
-
#
|
8
|
-
# $Id: codon.rb,v 1.16 2007/04/05 23:35:41 trevor Exp $
|
9
|
-
#
|
10
|
-
|
11
|
-
module Bio::Shell
|
12
|
-
|
13
|
-
class ColoredCodonTable
|
14
|
-
|
15
|
-
@@properties = {
|
16
|
-
:basic => %w( H K R ),
|
17
|
-
:polar => %w( S T Y Q N S ),
|
18
|
-
:acidic => %w( D E ),
|
19
|
-
:nonpolar => %w( F L I M V P A C W G ),
|
20
|
-
:stop => %w( * ),
|
21
|
-
}
|
22
|
-
|
23
|
-
def initialize(number, cuhash = nil)
|
24
|
-
@aacode = Bio::AminoAcid.names
|
25
|
-
@table = Bio::CodonTable[number]
|
26
|
-
@number = number
|
27
|
-
@cuhash = cuhash
|
28
|
-
setup_colors
|
29
|
-
if Bio::Shell.config[:color]
|
30
|
-
generate_colored_text
|
31
|
-
else
|
32
|
-
generate_mono_text
|
33
|
-
end
|
34
|
-
end
|
35
|
-
attr_reader :table
|
36
|
-
|
37
|
-
def setup_colors
|
38
|
-
c = Bio::Shell.colors
|
39
|
-
|
40
|
-
@colors = {
|
41
|
-
:text => c[:none],
|
42
|
-
:aa => c[:green],
|
43
|
-
:start => c[:red],
|
44
|
-
:stop => c[:red],
|
45
|
-
:basic => c[:cyan],
|
46
|
-
:polar => c[:blue],
|
47
|
-
:acidic => c[:magenta],
|
48
|
-
:nonpolar => c[:yellow],
|
49
|
-
}
|
50
|
-
end
|
51
|
-
|
52
|
-
def generate_mono_text
|
53
|
-
@table.each do |codon, aa|
|
54
|
-
if aa == '*'
|
55
|
-
code = 'STOP'
|
56
|
-
aa = '' unless @cuhash
|
57
|
-
else
|
58
|
-
code = @aacode[aa]
|
59
|
-
end
|
60
|
-
if @cuhash
|
61
|
-
percent = @cuhash[codon].to_s.rjust(6)
|
62
|
-
eval("@#{codon} = '#{aa}#{percent}'")
|
63
|
-
else
|
64
|
-
eval("@#{codon} = ' #{code} #{aa} '")
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
|
-
@hydrophilic = [
|
69
|
-
@@properties[:basic].join(" "), "(basic),",
|
70
|
-
@@properties[:polar].join(" "), "(polar),",
|
71
|
-
@@properties[:acidic].join(" "), "(acidic)",
|
72
|
-
].join(" ")
|
73
|
-
@hydrophobic = @@properties[:nonpolar].join(" ") + " (nonpolar)"
|
74
|
-
end
|
75
|
-
|
76
|
-
def generate_colored_text
|
77
|
-
@table.each do |codon, aa|
|
78
|
-
property, = @@properties.detect {|key, list| list.include?(aa)}
|
79
|
-
|
80
|
-
if aa == '*'
|
81
|
-
if @cuhash
|
82
|
-
color_code = "#{@colors[:stop]}STOP"
|
83
|
-
color_aa = "#{@colors[:stop]}#{aa}"
|
84
|
-
else
|
85
|
-
color_code = "#{@colors[:stop]}STP"
|
86
|
-
case codon
|
87
|
-
when 'tga'
|
88
|
-
color_aa = "#{@colors[:text]}U"
|
89
|
-
when 'tag'
|
90
|
-
color_aa = "#{@colors[:text]}O"
|
91
|
-
else
|
92
|
-
color_aa = "#{@colors[:text]}*"
|
93
|
-
end
|
94
|
-
end
|
95
|
-
else
|
96
|
-
color_code = "#{@colors[property]}#{@aacode[aa]}"
|
97
|
-
if @table.start_codon?(codon)
|
98
|
-
if @cuhash
|
99
|
-
color_aa = "#{@colors[:aa]}#{aa}"
|
100
|
-
else
|
101
|
-
color_aa = "#{@colors[:start]}#{aa}"
|
102
|
-
end
|
103
|
-
else
|
104
|
-
if @cuhash
|
105
|
-
color_aa = "#{@colors[property]}#{aa}"
|
106
|
-
else
|
107
|
-
color_aa = "#{@colors[:aa]}#{aa}"
|
108
|
-
end
|
109
|
-
end
|
110
|
-
end
|
111
|
-
|
112
|
-
if @cuhash
|
113
|
-
percent = @cuhash[codon].to_s.rjust(6)
|
114
|
-
eval("@#{codon} = '#{color_aa}#{@colors[:text]}#{percent}'")
|
115
|
-
else
|
116
|
-
eval("@#{codon} = ' #{color_code} #{color_aa}#{@colors[:text]} '")
|
117
|
-
end
|
118
|
-
end
|
119
|
-
|
120
|
-
@hydrophilic = [
|
121
|
-
"#{@colors[:basic]}basic#{@colors[:text]},",
|
122
|
-
"#{@colors[:polar]}polar#{@colors[:text]},",
|
123
|
-
"#{@colors[:acidic]}acidic#{@colors[:text]}"
|
124
|
-
].join(" ")
|
125
|
-
@hydrophobic = "#{@colors[:nonpolar]}nonpolar"
|
126
|
-
end
|
127
|
-
|
128
|
-
def output
|
129
|
-
header = <<-END
|
130
|
-
#
|
131
|
-
# = Codon table #{@number} : #{@table.definition}
|
132
|
-
#
|
133
|
-
# hydrophilic: #{@hydrophilic}
|
134
|
-
# hydrophobic: #{@hydrophobic}
|
135
|
-
END
|
136
|
-
table = <<-END
|
137
|
-
#
|
138
|
-
# *---------------------------------------------*
|
139
|
-
# | | 2nd | |
|
140
|
-
# | 1st |-------------------------------| 3rd |
|
141
|
-
# | | U | C | A | G | |
|
142
|
-
# |-------+-------+-------+-------+-------+-----|
|
143
|
-
# | U U |#{@ttt}|#{@tct}|#{@tat}|#{@tgt}| u |
|
144
|
-
# | U U |#{@ttc}|#{@tcc}|#{@tac}|#{@tgc}| c |
|
145
|
-
# | U U |#{@tta}|#{@tca}|#{@taa}|#{@tga}| a |
|
146
|
-
# | UUU |#{@ttg}|#{@tcg}|#{@tag}|#{@tgg}| g |
|
147
|
-
# |-------+-------+-------+-------+-------+-----|
|
148
|
-
# | CCCC |#{@ctt}|#{@cct}|#{@cat}|#{@cgt}| u |
|
149
|
-
# | C |#{@ctc}|#{@ccc}|#{@cac}|#{@cgc}| c |
|
150
|
-
# | C |#{@cta}|#{@cca}|#{@caa}|#{@cga}| a |
|
151
|
-
# | CCCC |#{@ctg}|#{@ccg}|#{@cag}|#{@cgg}| g |
|
152
|
-
# |-------+-------+-------+-------+-------+-----|
|
153
|
-
# | A |#{@att}|#{@act}|#{@aat}|#{@agt}| u |
|
154
|
-
# | A A |#{@atc}|#{@acc}|#{@aac}|#{@agc}| c |
|
155
|
-
# | AAAAA |#{@ata}|#{@aca}|#{@aaa}|#{@aga}| a |
|
156
|
-
# | A A |#{@atg}|#{@acg}|#{@aag}|#{@agg}| g |
|
157
|
-
# |-------+-------+-------+-------+-------+-----|
|
158
|
-
# | GGGG |#{@gtt}|#{@gct}|#{@gat}|#{@ggt}| u |
|
159
|
-
# | G |#{@gtc}|#{@gcc}|#{@gac}|#{@ggc}| c |
|
160
|
-
# | G GGG |#{@gta}|#{@gca}|#{@gaa}|#{@gga}| a |
|
161
|
-
# | GG G |#{@gtg}|#{@gcg}|#{@gag}|#{@ggg}| g |
|
162
|
-
# *---------------------------------------------*
|
163
|
-
#
|
164
|
-
END
|
165
|
-
if @cuhash
|
166
|
-
text = table
|
167
|
-
else
|
168
|
-
text = header + table
|
169
|
-
end
|
170
|
-
if Bio::Shell.config[:color]
|
171
|
-
text.gsub(/^\s+#/, @colors[:text])
|
172
|
-
else
|
173
|
-
text.gsub(/^\s+#/, '')
|
174
|
-
end
|
175
|
-
end
|
176
|
-
|
177
|
-
end
|
178
|
-
|
179
|
-
private
|
180
|
-
|
181
|
-
def codontable(num = 1, codon_usage = nil)
|
182
|
-
cct = ColoredCodonTable.new(num, codon_usage)
|
183
|
-
if codon_usage
|
184
|
-
return cct
|
185
|
-
else
|
186
|
-
puts cct.output
|
187
|
-
return cct.table
|
188
|
-
end
|
189
|
-
end
|
190
|
-
|
191
|
-
def codontables
|
192
|
-
tables = Bio::CodonTable::DEFINITIONS
|
193
|
-
tables.sort.each do |i, definition|
|
194
|
-
puts "#{i}\t#{definition}"
|
195
|
-
end
|
196
|
-
return tables
|
197
|
-
end
|
198
|
-
|
199
|
-
def aminoacids
|
200
|
-
names = Bio::AminoAcid.names
|
201
|
-
names.sort.each do |aa, code|
|
202
|
-
if aa.length == 1
|
203
|
-
puts "#{aa}\t#{code}\t#{names[code]}"
|
204
|
-
end
|
205
|
-
end
|
206
|
-
return names
|
207
|
-
end
|
208
|
-
|
209
|
-
def nucleicacids
|
210
|
-
names = Bio::NucleicAcid.names
|
211
|
-
%w(a t g c u r y w s k m b v h d n).each do |base|
|
212
|
-
puts "#{base}\t#{names[base]}\t#{names[base.upcase]}"
|
213
|
-
end
|
214
|
-
return names
|
215
|
-
end
|
216
|
-
|
217
|
-
end
|
218
|
-
|
data/lib/bio/shell/plugin/das.rb
DELETED
@@ -1,58 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# = bio/shell/plugin/keggdas.rb - plugin for KEGG DAS
|
3
|
-
#
|
4
|
-
# Copyright:: Copyright (C) 2006
|
5
|
-
# Toshiaki Katayama <k@bioruby.org>
|
6
|
-
# License:: The Ruby License
|
7
|
-
#
|
8
|
-
# $Id: das.rb,v 1.3 2007/04/05 23:35:41 trevor Exp $
|
9
|
-
#
|
10
|
-
|
11
|
-
module Bio
|
12
|
-
|
13
|
-
class DAS
|
14
|
-
def list_sequences
|
15
|
-
result = ""
|
16
|
-
self.get_dsn.each do |dsn|
|
17
|
-
src = dsn.source_id
|
18
|
-
self.get_entry_points(src).each do |ep|
|
19
|
-
data = [src, ep.entry_id, ep.start.to_i, ep.stop.to_i, "# #{ep.description}"].join("\t") + "\n"
|
20
|
-
puts data
|
21
|
-
result += data
|
22
|
-
end
|
23
|
-
end
|
24
|
-
return result
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
end
|
29
|
-
|
30
|
-
module Bio::Shell
|
31
|
-
|
32
|
-
private
|
33
|
-
|
34
|
-
# http://www.biodas.org/
|
35
|
-
# http://www.dasregistry.org/
|
36
|
-
|
37
|
-
def das(url = nil)
|
38
|
-
if url
|
39
|
-
@das = Bio::DAS.new(url)
|
40
|
-
else
|
41
|
-
@das ||= keggdas
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
def keggdas(url = "http://das.hgc.jp/cgi-bin/")
|
46
|
-
das(url)
|
47
|
-
end
|
48
|
-
|
49
|
-
def ensembl(url = "http://das.ensembl.org/")
|
50
|
-
das(url)
|
51
|
-
end
|
52
|
-
|
53
|
-
def wormbase(url = "http://www.wormbase.org/db/")
|
54
|
-
das(url)
|
55
|
-
end
|
56
|
-
|
57
|
-
end
|
58
|
-
|
@@ -1,23 +0,0 @@
|
|
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:: The Ruby License
|
7
|
-
#
|
8
|
-
# $Id: emboss.rb,v 1.3 2007/04/05 23:35:41 trevor 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,137 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# = bio/shell/plugin/entry.rb - extract entry and sequence
|
3
|
-
#
|
4
|
-
# Copyright:: Copyright (C) 2005
|
5
|
-
# Toshiaki Katayama <k@bioruby.org>
|
6
|
-
# License:: The Ruby License
|
7
|
-
#
|
8
|
-
#
|
9
|
-
|
10
|
-
module Bio::Shell
|
11
|
-
|
12
|
-
private
|
13
|
-
|
14
|
-
# Read a text file and collect the first word of each line in array
|
15
|
-
def readlist(filename)
|
16
|
-
list = []
|
17
|
-
File.open(filename).each do |line|
|
18
|
-
list << line[/^\S+/]
|
19
|
-
end
|
20
|
-
return list
|
21
|
-
end
|
22
|
-
|
23
|
-
# Obtain a Bio::Sequence::NA (DNA) or a Bio::Sequence::AA (Amino Acid)
|
24
|
-
# sequence from
|
25
|
-
# * String -- "atgcatgc" or "MQKKP"
|
26
|
-
# * IO -- io = IO.popen("gzip -dc db.gz") (first entry only)
|
27
|
-
# * "filename" -- "gbvrl.gbk" (first entry only)
|
28
|
-
# * "db:entry" -- "embl:BUM" (entry is retrieved by the ent method)
|
29
|
-
def getseq(arg)
|
30
|
-
seq = ""
|
31
|
-
if arg.kind_of?(Bio::Sequence)
|
32
|
-
seq = arg
|
33
|
-
elsif arg.respond_to?(:gets) or File.exist?(arg)
|
34
|
-
ent = flatauto(arg)
|
35
|
-
elsif arg[/:/]
|
36
|
-
ent = getobj(arg)
|
37
|
-
else
|
38
|
-
tmp = arg
|
39
|
-
end
|
40
|
-
|
41
|
-
if ent.respond_to?(:seq)
|
42
|
-
tmp = ent.seq
|
43
|
-
elsif ent.respond_to?(:naseq)
|
44
|
-
#seq = ent.naseq
|
45
|
-
tmp = ent.naseq
|
46
|
-
elsif ent.respond_to?(:aaseq)
|
47
|
-
#seq = ent.aaseq
|
48
|
-
tmp = ent.aaseq
|
49
|
-
end
|
50
|
-
|
51
|
-
if tmp and tmp.is_a?(String) and not tmp.empty?
|
52
|
-
#seq = Bio::Sequence.auto(tmp).seq
|
53
|
-
seq = Bio::Sequence.auto(tmp)
|
54
|
-
end
|
55
|
-
return seq
|
56
|
-
end
|
57
|
-
|
58
|
-
# Obtain a database entry from
|
59
|
-
# * IO -- IO object (first entry only)
|
60
|
-
# * "filename" -- local file (first entry only)
|
61
|
-
# * "db:entry" -- local BioFlat, OBDA, EMBOSS, KEGG API
|
62
|
-
def getent(arg)
|
63
|
-
entry = ""
|
64
|
-
db, entry_id = arg.to_s.strip.split(/\:/, 2)
|
65
|
-
|
66
|
-
# local file
|
67
|
-
if arg.respond_to?(:gets) or File.exist?(arg)
|
68
|
-
puts "Retrieving entry from file (#{arg})"
|
69
|
-
entry = flatfile(arg)
|
70
|
-
|
71
|
-
# BioFlat in ./.bioruby/bioflat/ or ~/.bioinformatics/.bioruby/bioflat/
|
72
|
-
elsif Bio::Shell.find_flat_dir(db)
|
73
|
-
puts "Retrieving entry from local BioFlat database (#{arg})"
|
74
|
-
entry = flatsearch(db, entry_id)
|
75
|
-
|
76
|
-
# OBDA in ~/.bioinformatics/seqdatabase.ini
|
77
|
-
elsif obdadbs.include?(db)
|
78
|
-
puts "Retrieving entry from OBDA (#{arg})"
|
79
|
-
entry = obdaentry(db, entry_id)
|
80
|
-
|
81
|
-
else
|
82
|
-
# EMBOSS USA in ~/.embossrc
|
83
|
-
begin
|
84
|
-
str = entret(arg)
|
85
|
-
rescue SystemCallError
|
86
|
-
str = ''
|
87
|
-
end
|
88
|
-
if $? and $?.exitstatus == 0 and str.length != 0
|
89
|
-
puts "Retrieving entry from EMBOSS (#{arg})"
|
90
|
-
entry = str
|
91
|
-
|
92
|
-
# via Internet
|
93
|
-
else
|
94
|
-
case db.to_s.downcase
|
95
|
-
when 'genbank', 'gb', 'nuccore', 'indsc'
|
96
|
-
# NCBI
|
97
|
-
puts "Retrieving entry from NCBI eUtils"
|
98
|
-
entry = efetch(entry_id)
|
99
|
-
|
100
|
-
when 'embl', 'emb', /\Aembl/, /\Auni/, 'sp', /\Aensembl/
|
101
|
-
# EBI
|
102
|
-
puts "Retrieving entry from EBI Dbfetch"
|
103
|
-
db = 'embl' if db == 'emb'
|
104
|
-
db = 'uniprotkb' if db == 'uniprot' or db == 'sp'
|
105
|
-
entry = biofetch(db, entry_id)
|
106
|
-
|
107
|
-
when 'ddbj', 'dbj', 'dad'
|
108
|
-
# TogoWS REST
|
109
|
-
puts "Retrieving entry from TogoWS"
|
110
|
-
db = 'ddbj' if db == 'dbj'
|
111
|
-
entry = togowsentry(db, entry_id)
|
112
|
-
|
113
|
-
else
|
114
|
-
togodblist = Bio::TogoWS::REST.entry_database_list rescue []
|
115
|
-
if togodblist.include?(db) then
|
116
|
-
# TogoWS REST
|
117
|
-
puts "Retrieving entry from TogoWS"
|
118
|
-
entry = togowsentry(db, entry_id)
|
119
|
-
else
|
120
|
-
# KEGG API at http://www.genome.jp/kegg/soap/
|
121
|
-
puts "Retrieving entry from KEGG API (#{arg})"
|
122
|
-
entry = bget(arg)
|
123
|
-
end
|
124
|
-
end
|
125
|
-
end
|
126
|
-
end
|
127
|
-
|
128
|
-
return entry
|
129
|
-
end
|
130
|
-
|
131
|
-
# Obtain a parsed object from sources that ent() supports.
|
132
|
-
def getobj(arg)
|
133
|
-
str = getent(arg)
|
134
|
-
flatparse(str)
|
135
|
-
end
|
136
|
-
|
137
|
-
end
|