bio 1.5.2 → 1.6.0.pre.20181210
Sign up to get free protection for your applications and to get access to all the features.
- 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
@@ -1,334 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# = test/unit/bio/db/test_phyloxml_writer.rb - Unit test for Bio::PhyloXML::Writer
|
3
|
-
#
|
4
|
-
# Copyright:: Copyright (C) 2009
|
5
|
-
# Diana Jaunzeikare <latvianlinuxgirl@gmail.com>
|
6
|
-
# License:: The Ruby License
|
7
|
-
#
|
8
|
-
|
9
|
-
# loading helper routine for testing bioruby
|
10
|
-
require 'pathname'
|
11
|
-
load Pathname.new(File.join(File.dirname(__FILE__), ['..'] * 3,
|
12
|
-
'bioruby_test_helper.rb')).cleanpath.to_s
|
13
|
-
|
14
|
-
# libraries needed for the tests
|
15
|
-
require 'test/unit'
|
16
|
-
require 'singleton'
|
17
|
-
require 'bio/command'
|
18
|
-
|
19
|
-
begin
|
20
|
-
require 'libxml'
|
21
|
-
rescue LoadError
|
22
|
-
end
|
23
|
-
|
24
|
-
if defined?(LibXML) then
|
25
|
-
require 'bio/db/phyloxml/phyloxml_writer'
|
26
|
-
end
|
27
|
-
|
28
|
-
module Bio
|
29
|
-
class TestPhyloXMLWriter_Check_LibXML < Test::Unit::TestCase
|
30
|
-
def test_libxml
|
31
|
-
assert(defined?(LibXML),
|
32
|
-
"Error: libxml-ruby library is not present. Please install libxml-ruby library. It is needed for Bio::PhyloXML module. Unit test for PhyloXML will not be performed.")
|
33
|
-
end
|
34
|
-
end #class TestPhyloXMLWriter_Check_LibXML
|
35
|
-
end #module Bio
|
36
|
-
|
37
|
-
module Bio
|
38
|
-
|
39
|
-
module TestPhyloXMLWriterData
|
40
|
-
|
41
|
-
PHYLOXML_WRITER_TEST_DATA = Pathname.new(File.join(BioRubyTestDataPath, 'phyloxml')).cleanpath.to_s
|
42
|
-
|
43
|
-
def self.example_xml
|
44
|
-
File.join PHYLOXML_WRITER_TEST_DATA, 'phyloxml_examples.xml'
|
45
|
-
end
|
46
|
-
|
47
|
-
def self.mollusca_short_xml
|
48
|
-
File.join PHYLOXML_WRITER_TEST_DATA, 'ncbi_taxonomy_mollusca_short.xml'
|
49
|
-
end
|
50
|
-
|
51
|
-
def self.made_up_xml
|
52
|
-
File.join PHYLOXML_WRITER_TEST_DATA, 'made_up.xml'
|
53
|
-
end
|
54
|
-
|
55
|
-
end #end module TestPhyloXMLWriterData
|
56
|
-
|
57
|
-
class TestPhyloXMLWriter < Test::Unit::TestCase
|
58
|
-
|
59
|
-
# helper class to write files using temporary directory
|
60
|
-
class WriteTo
|
61
|
-
include Singleton
|
62
|
-
|
63
|
-
def initialize
|
64
|
-
@leave_tmpdir = ENV['BIORUBY_TEST_DEBUG'].to_s.empty? ? false : true
|
65
|
-
@tests = nil
|
66
|
-
@tests_passed = 0
|
67
|
-
@tmpdir = nil
|
68
|
-
end
|
69
|
-
|
70
|
-
attr_accessor :tests
|
71
|
-
|
72
|
-
def test_passed
|
73
|
-
@tests_passed += 1
|
74
|
-
if !@leave_tmpdir and @tmpdir and @tests and
|
75
|
-
@tests_passed >= @tests then
|
76
|
-
#$stderr.print "Removing #{@tmpdir.path}\n"
|
77
|
-
@tmpdir.close!
|
78
|
-
@tmpdir = nil
|
79
|
-
@tests_passed = 0
|
80
|
-
end
|
81
|
-
end
|
82
|
-
|
83
|
-
def tmpdir
|
84
|
-
@tmpdir ||= Bio::Command::Tmpdir.new('PhyloXML')
|
85
|
-
@tmpdir
|
86
|
-
end
|
87
|
-
|
88
|
-
def file(f)
|
89
|
-
File.join(self.tmpdir.path, f)
|
90
|
-
end
|
91
|
-
|
92
|
-
def example_xml_test
|
93
|
-
self.file('phyloxml_examples_written.xml')
|
94
|
-
end
|
95
|
-
end #class WriteTo
|
96
|
-
|
97
|
-
def setup
|
98
|
-
@writeto = WriteTo.instance
|
99
|
-
@writeto.tests ||= self.methods.collect { |x|
|
100
|
-
x.to_s }.find_all { |y|
|
101
|
-
/\Atest\_/ =~ y }.size
|
102
|
-
end
|
103
|
-
|
104
|
-
def teardown
|
105
|
-
@writeto.test_passed
|
106
|
-
end
|
107
|
-
|
108
|
-
# def test_write
|
109
|
-
# # @todo this is test for Tree.write
|
110
|
-
# tree = Bio::PhyloXML::Tree.new
|
111
|
-
# filename = @writeto.file('test.xml')
|
112
|
-
# tree.write(filename)
|
113
|
-
# end
|
114
|
-
|
115
|
-
def test_init
|
116
|
-
filename = @writeto.file("test2.xml")
|
117
|
-
writer = Bio::PhyloXML::Writer.new(filename)
|
118
|
-
|
119
|
-
tree = Bio::PhyloXML::Parser.open(TestPhyloXMLWriterData.mollusca_short_xml) { |px| px.next_tree }
|
120
|
-
|
121
|
-
writer.write(tree)
|
122
|
-
|
123
|
-
assert_nothing_thrown do
|
124
|
-
Bio::PhyloXML::Parser.open(filename) { |px| true }
|
125
|
-
end
|
126
|
-
|
127
|
-
#File.delete(filename)
|
128
|
-
end
|
129
|
-
|
130
|
-
def test_simple_xml
|
131
|
-
filename = @writeto.file("sample.xml")
|
132
|
-
writer = Bio::PhyloXML::Writer.new(filename)
|
133
|
-
tree = Bio::PhyloXML::Tree.new
|
134
|
-
tree.rooted = true
|
135
|
-
tree.name = "Test tree"
|
136
|
-
root_node = Bio::PhyloXML::Node.new
|
137
|
-
tree.root = root_node
|
138
|
-
root_node.name = "A"
|
139
|
-
#root_node.taxonomies[0] = Bio::PhyloXML::Taxonomy.new
|
140
|
-
root_node.taxonomies << Bio::PhyloXML::Taxonomy.new
|
141
|
-
root_node.taxonomies[0].scientific_name = "Animal animal"
|
142
|
-
node2 = Bio::PhyloXML::Node.new
|
143
|
-
node2.name = "B"
|
144
|
-
tree.add_node(node2)
|
145
|
-
tree.add_edge(root_node, node2)
|
146
|
-
writer.write(tree)
|
147
|
-
|
148
|
-
lines = File.readlines(filename)
|
149
|
-
assert_equal("<phyloxml xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.phyloxml.org http://www.phyloxml.org/1.10/phyloxml.xsd\" xmlns=\"http://www.phyloxml.org\">",
|
150
|
-
lines[1].chomp)
|
151
|
-
assert_equal(" <phylogeny rooted=\"true\">", lines[2].chomp)
|
152
|
-
assert_equal(" <name>Test tree</name>", lines[3].chomp)
|
153
|
-
assert_equal(" <clade>", lines[4].chomp)
|
154
|
-
assert_equal(" <name>A</name>", lines[5].chomp)
|
155
|
-
assert_equal(" <taxonomy>", lines[6].chomp)
|
156
|
-
assert_equal(" <scientific_name>Animal animal</scientific_name>", lines[7].chomp)
|
157
|
-
assert_equal(" </taxonomy>", lines[8].chomp)
|
158
|
-
assert_equal(" <name>B</name>", lines[10].chomp)
|
159
|
-
assert_equal(" </clade>", lines[12].chomp)
|
160
|
-
assert_equal(" </phylogeny>", lines[13].chomp)
|
161
|
-
assert_equal("</phyloxml>", lines[14].chomp)
|
162
|
-
|
163
|
-
#File.delete(filename)
|
164
|
-
end
|
165
|
-
|
166
|
-
def test_phyloxml_examples_tree1
|
167
|
-
tree = Bio::PhyloXML::Parser.open(TestPhyloXMLWriterData.example_xml) { |px| px.next_tree }
|
168
|
-
|
169
|
-
filename = @writeto.file('example_tree1.xml')
|
170
|
-
writer = Bio::PhyloXML::Writer.new(filename)
|
171
|
-
writer.write_branch_length_as_subelement = false
|
172
|
-
writer.write(tree)
|
173
|
-
|
174
|
-
assert_nothing_thrown do
|
175
|
-
Bio::PhyloXML::Parser.open(filename) { |px| true }
|
176
|
-
end
|
177
|
-
|
178
|
-
#File.delete(filename)
|
179
|
-
|
180
|
-
#@todo check if branch length is written correctly
|
181
|
-
end
|
182
|
-
|
183
|
-
def test_phyloxml_examples_tree2
|
184
|
-
phyloxml = Bio::PhyloXML::Parser.open(TestPhyloXMLWriterData.example_xml)
|
185
|
-
2.times do
|
186
|
-
@tree = phyloxml.next_tree
|
187
|
-
end
|
188
|
-
phyloxml.close
|
189
|
-
|
190
|
-
filename = @writeto.file('example_tree2.xml')
|
191
|
-
writer = Bio::PhyloXML::Writer.new(filename)
|
192
|
-
writer.write(@tree)
|
193
|
-
|
194
|
-
assert_nothing_thrown do
|
195
|
-
Bio::PhyloXML::Parser.open(filename) { |px| true }
|
196
|
-
end
|
197
|
-
|
198
|
-
#File.delete(filename)
|
199
|
-
end
|
200
|
-
|
201
|
-
def test_phyloxml_examples_tree4
|
202
|
-
phyloxml = Bio::PhyloXML::Parser.open(TestPhyloXMLWriterData.example_xml)
|
203
|
-
4.times do
|
204
|
-
@tree = phyloxml.next_tree
|
205
|
-
end
|
206
|
-
phyloxml.close
|
207
|
-
#@todo tree = phyloxml[4]
|
208
|
-
filename = @writeto.file('example_tree4.xml')
|
209
|
-
writer = Bio::PhyloXML::Writer.new(filename)
|
210
|
-
writer.write(@tree)
|
211
|
-
assert_nothing_thrown do
|
212
|
-
@tree2 = Bio::PhyloXML::Parser.open(filename) { |px| px.next_tree }
|
213
|
-
end
|
214
|
-
assert_equal(@tree.name, @tree2.name)
|
215
|
-
assert_equal(@tree.get_node_by_name('A').taxonomies[0].scientific_name, @tree2.get_node_by_name('A').taxonomies[0].scientific_name)
|
216
|
-
assert_equal(@tree.get_node_by_name('B').sequences[0].annotations[0].desc,
|
217
|
-
@tree2.get_node_by_name('B').sequences[0].annotations[0].desc)
|
218
|
-
# assert_equal(@tree.get_node_by_name('B').sequences[0].annotations[0].confidence.value,@tree2.get_node_by_name('B').sequences[0].annotations[0].confidence.value)
|
219
|
-
#File.delete(filename)
|
220
|
-
end
|
221
|
-
|
222
|
-
def test_phyloxml_examples_sequence_relation
|
223
|
-
phyloxml = Bio::PhyloXML::Parser.open(TestPhyloXMLWriterData.example_xml)
|
224
|
-
filename = @writeto.example_xml_test
|
225
|
-
writer = Bio::PhyloXML::Writer.new(filename)
|
226
|
-
phyloxml.each do |tree|
|
227
|
-
writer.write(tree)
|
228
|
-
end
|
229
|
-
phyloxml.close
|
230
|
-
|
231
|
-
assert_nothing_thrown do
|
232
|
-
@phyloxml_test = Bio::PhyloXML::Parser.open(filename)
|
233
|
-
end
|
234
|
-
|
235
|
-
5.times do
|
236
|
-
@tree = @phyloxml_test.next_tree
|
237
|
-
end
|
238
|
-
|
239
|
-
@phyloxml_test.close
|
240
|
-
|
241
|
-
assert_equal("x", @tree.sequence_relations[0].id_ref_0)
|
242
|
-
assert_equal("z", @tree.sequence_relations[1].id_ref_1)
|
243
|
-
assert_equal(nil, @tree.sequence_relations[2].distance)
|
244
|
-
assert_equal("orthology", @tree.sequence_relations[2].type)
|
245
|
-
|
246
|
-
#File.delete(filename)
|
247
|
-
end
|
248
|
-
|
249
|
-
def test_generate_xml_with_sequence
|
250
|
-
tree = Bio::PhyloXML::Tree.new
|
251
|
-
r = Bio::PhyloXML::Node.new
|
252
|
-
tree.add_node(r)
|
253
|
-
tree.root = r
|
254
|
-
n = Bio::PhyloXML::Node.new
|
255
|
-
tree.add_node(n)
|
256
|
-
tree.add_edge(tree.root, n)
|
257
|
-
tree.rooted = true
|
258
|
-
|
259
|
-
n.name = "A"
|
260
|
-
seq = PhyloXML::Sequence.new
|
261
|
-
n.sequences[0] = seq
|
262
|
-
seq.annotations[0] = PhyloXML::Annotation.new
|
263
|
-
seq.annotations[0].desc = "Sample annotation"
|
264
|
-
seq.name = "sequence name"
|
265
|
-
seq.location = "somewhere"
|
266
|
-
seq.accession = PhyloXML::Accession.new
|
267
|
-
seq.accession.source = "ncbi"
|
268
|
-
seq.accession.value = "AAB80874"
|
269
|
-
seq.symbol = "adhB"
|
270
|
-
seq.mol_seq = "TDATGKPIKCMAAIAWEAKKPLSIEEVEVAPPKSGEVRIKILHSGVCHTD"
|
271
|
-
seq.uri = PhyloXML::Uri.new
|
272
|
-
seq.uri.desc = "EMBL REPTILE DATABASE"
|
273
|
-
seq.uri.uri = "http://www.embl-heidelberg.de/~uetz/families/Varanidae.html"
|
274
|
-
seq.domain_architecture = PhyloXML::DomainArchitecture.new
|
275
|
-
seq.domain_architecture.length = 1249
|
276
|
-
domain1 = PhyloXML::ProteinDomain.new
|
277
|
-
seq.domain_architecture.domains << domain1
|
278
|
-
domain1.from = 6
|
279
|
-
domain1.to = 90
|
280
|
-
domain1.confidence = "7.0E-26"
|
281
|
-
domain1.value = "CARD"
|
282
|
-
domain2 = PhyloXML::ProteinDomain.new
|
283
|
-
seq.domain_architecture.domains << domain2
|
284
|
-
domain2.from = 109
|
285
|
-
domain2.to = 414
|
286
|
-
domain2.confidence = "7.2E-117"
|
287
|
-
domain2.value = "NB-ARC"
|
288
|
-
|
289
|
-
filename = @writeto.file('sequence.xml')
|
290
|
-
Bio::PhyloXML::Writer.new(filename).write(tree)
|
291
|
-
|
292
|
-
assert_nothing_thrown do
|
293
|
-
Bio::PhyloXML::Parser.open(filename) { |px| px.next_tree }
|
294
|
-
end
|
295
|
-
|
296
|
-
#File.delete(filename)
|
297
|
-
end
|
298
|
-
|
299
|
-
def test_phyloxml_examples_file
|
300
|
-
outputfn = "phyloxml_examples_generated_in_test.xml"
|
301
|
-
phyloxml = Bio::PhyloXML::Parser.open(TestPhyloXMLWriterData.example_xml)
|
302
|
-
filename = @writeto.file(outputfn)
|
303
|
-
writer = Bio::PhyloXML::Writer.new(filename)
|
304
|
-
phyloxml.each do |tree|
|
305
|
-
writer.write(tree)
|
306
|
-
end
|
307
|
-
writer.write_other(phyloxml.other)
|
308
|
-
|
309
|
-
assert_nothing_thrown do
|
310
|
-
Bio::PhyloXML::Parser.open(filename) { |px| true }
|
311
|
-
end
|
312
|
-
# The output file is not deleted since it might be used in the phyloxml
|
313
|
-
# parser test. But since the order of tests can't be assumed, I can't
|
314
|
-
# hard code it in.
|
315
|
-
end
|
316
|
-
|
317
|
-
def test_made_up_xml_file
|
318
|
-
phyloxml = Bio::PhyloXML::Parser.open(TestPhyloXMLWriterData.made_up_xml)
|
319
|
-
filename = @writeto.file("made_up_generated_in_test.xml")
|
320
|
-
writer = Bio::PhyloXML::Writer.new(filename)
|
321
|
-
# The output file is not deleted since it might be used in the phyloxml
|
322
|
-
# parser test. But since the order of tests can't be assumed, I can't
|
323
|
-
# hard code it in.
|
324
|
-
phyloxml.each do |tree|
|
325
|
-
writer.write(tree)
|
326
|
-
end
|
327
|
-
phyloxml.close
|
328
|
-
end
|
329
|
-
|
330
|
-
end
|
331
|
-
|
332
|
-
|
333
|
-
end if defined?(LibXML) #end module Bio
|
334
|
-
|
@@ -1,187 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# test/unit/bio/shell/plugin/test_seq.rb - Unit test for Bio::Shell plugin for biological sequence manipulations
|
3
|
-
#
|
4
|
-
# Copyright:: Copyright (C) 2005
|
5
|
-
# Mitsuteru Nakao <n@bioruby.org>
|
6
|
-
# License:: The Ruby License
|
7
|
-
#
|
8
|
-
# $Id:$
|
9
|
-
#
|
10
|
-
|
11
|
-
# loading helper routine for testing bioruby
|
12
|
-
require 'pathname'
|
13
|
-
load Pathname.new(File.join(File.dirname(__FILE__), ['..'] * 4,
|
14
|
-
'bioruby_test_helper.rb')).cleanpath.to_s
|
15
|
-
|
16
|
-
# libraries needed for the tests
|
17
|
-
require 'test/unit'
|
18
|
-
require 'bio/shell'
|
19
|
-
require 'bio/shell/plugin/seq'
|
20
|
-
|
21
|
-
module Bio
|
22
|
-
|
23
|
-
class TestShellPluginSeq < Test::Unit::TestCase
|
24
|
-
include Bio::Shell
|
25
|
-
|
26
|
-
Bio::Shell.config = {:color => false}
|
27
|
-
|
28
|
-
def test_htmlseq
|
29
|
-
str = 'ATGC'
|
30
|
-
html =<<END
|
31
|
-
<div style="font-family:monospace;">
|
32
|
-
<span style="background:#64F73F;">a</span>
|
33
|
-
<span style="background:#3C88EE;">t</span>
|
34
|
-
<span style="background:#EB413C;">g</span>
|
35
|
-
<span style="background:#FFB340;">c</span>
|
36
|
-
<br>
|
37
|
-
</div>
|
38
|
-
END
|
39
|
-
assert_equal(html, htmlseq(str))
|
40
|
-
end
|
41
|
-
|
42
|
-
|
43
|
-
def test_naseq
|
44
|
-
str = 'ACGT'
|
45
|
-
assert_equal(Bio::Sequence, getseq(str).class)
|
46
|
-
assert_equal(Bio::Sequence::NA, getseq(str).moltype)
|
47
|
-
assert_equal('acgt', getseq(str).seq)
|
48
|
-
end
|
49
|
-
|
50
|
-
|
51
|
-
def test_aaseq
|
52
|
-
str = 'WD'
|
53
|
-
assert_equal(Bio::Sequence, getseq(str).class)
|
54
|
-
assert_equal(Bio::Sequence::AA, getseq(str).moltype)
|
55
|
-
assert_equal('WD', getseq(str).seq)
|
56
|
-
end
|
57
|
-
|
58
|
-
|
59
|
-
def test_na_seqstat
|
60
|
-
naseq = 'atgcatgcatgc'
|
61
|
-
output =<<END
|
62
|
-
|
63
|
-
* * * Sequence statistics * * *
|
64
|
-
|
65
|
-
5'->3' sequence : atgcatgcatgc
|
66
|
-
3'->5' sequence : gcatgcatgcat
|
67
|
-
Translation 1 : MHAC
|
68
|
-
Translation 2 : CMH
|
69
|
-
Translation 3 : ACM
|
70
|
-
Translation -1 : ACMH
|
71
|
-
Translation -2 : HAC
|
72
|
-
Translation -3 : MHA
|
73
|
-
Length : 12 bp
|
74
|
-
GC percent : 50 %
|
75
|
-
Composition : a - 3 ( 25.00 %)
|
76
|
-
c - 3 ( 25.00 %)
|
77
|
-
g - 3 ( 25.00 %)
|
78
|
-
t - 3 ( 25.00 %)
|
79
|
-
Codon usage :
|
80
|
-
|
81
|
-
*---------------------------------------------*
|
82
|
-
| | 2nd | |
|
83
|
-
| 1st |-------------------------------| 3rd |
|
84
|
-
| | U | C | A | G | |
|
85
|
-
|-------+-------+-------+-------+-------+-----|
|
86
|
-
| U U |F 0.0%|S 0.0%|Y 0.0%|C 0.0%| u |
|
87
|
-
| U U |F 0.0%|S 0.0%|Y 0.0%|C 25.0%| c |
|
88
|
-
| U U |L 0.0%|S 0.0%|* 0.0%|* 0.0%| a |
|
89
|
-
| UUU |L 0.0%|S 0.0%|* 0.0%|W 0.0%| g |
|
90
|
-
|-------+-------+-------+-------+-------+-----|
|
91
|
-
| CCCC |L 0.0%|P 0.0%|H 25.0%|R 0.0%| u |
|
92
|
-
| C |L 0.0%|P 0.0%|H 0.0%|R 0.0%| c |
|
93
|
-
| C |L 0.0%|P 0.0%|Q 0.0%|R 0.0%| a |
|
94
|
-
| CCCC |L 0.0%|P 0.0%|Q 0.0%|R 0.0%| g |
|
95
|
-
|-------+-------+-------+-------+-------+-----|
|
96
|
-
| A |I 0.0%|T 0.0%|N 0.0%|S 0.0%| u |
|
97
|
-
| A A |I 0.0%|T 0.0%|N 0.0%|S 0.0%| c |
|
98
|
-
| AAAAA |I 0.0%|T 0.0%|K 0.0%|R 0.0%| a |
|
99
|
-
| A A |M 25.0%|T 0.0%|K 0.0%|R 0.0%| g |
|
100
|
-
|-------+-------+-------+-------+-------+-----|
|
101
|
-
| GGGG |V 0.0%|A 0.0%|D 0.0%|G 0.0%| u |
|
102
|
-
| G |V 0.0%|A 0.0%|D 0.0%|G 0.0%| c |
|
103
|
-
| G GGG |V 0.0%|A 25.0%|E 0.0%|G 0.0%| a |
|
104
|
-
| GG G |V 0.0%|A 0.0%|E 0.0%|G 0.0%| g |
|
105
|
-
*---------------------------------------------*
|
106
|
-
|
107
|
-
Molecular weight : 3701.61444
|
108
|
-
Protein weight : 460.565
|
109
|
-
//
|
110
|
-
END
|
111
|
-
$str = ''
|
112
|
-
alias puts_orig puts
|
113
|
-
def puts(*args)
|
114
|
-
args.each do |obj|
|
115
|
-
$str << obj.to_s
|
116
|
-
end
|
117
|
-
end
|
118
|
-
seqstat(naseq)
|
119
|
-
undef puts
|
120
|
-
alias puts puts_orig
|
121
|
-
assert_equal(output, $str)
|
122
|
-
end
|
123
|
-
|
124
|
-
|
125
|
-
def test_aa_seqstat
|
126
|
-
aaseq = 'WD'
|
127
|
-
output =<<END
|
128
|
-
|
129
|
-
* * * Sequence statistics * * *
|
130
|
-
|
131
|
-
N->C sequence : WD
|
132
|
-
Length : 2 aa
|
133
|
-
Composition : D Asp - 1 ( 50.00 %) aspartic acid
|
134
|
-
W Trp - 1 ( 50.00 %) tryptophan
|
135
|
-
Protein weight : 319.315
|
136
|
-
//
|
137
|
-
END
|
138
|
-
$str = ''
|
139
|
-
alias puts_orig puts
|
140
|
-
def puts(*args)
|
141
|
-
args.each do |obj|
|
142
|
-
$str << obj.to_s
|
143
|
-
end
|
144
|
-
end
|
145
|
-
seqstat(aaseq)
|
146
|
-
undef puts
|
147
|
-
alias puts puts_orig
|
148
|
-
assert_equal(output, $str)
|
149
|
-
end
|
150
|
-
|
151
|
-
|
152
|
-
def test_doublehelix
|
153
|
-
seq = 'ACGTACGTACGTACGT'
|
154
|
-
output = <<END
|
155
|
-
at
|
156
|
-
c--g
|
157
|
-
g---c
|
158
|
-
t----a
|
159
|
-
a----t
|
160
|
-
c---g
|
161
|
-
g--c
|
162
|
-
ta
|
163
|
-
ta
|
164
|
-
g--c
|
165
|
-
c---g
|
166
|
-
a----t
|
167
|
-
t----a
|
168
|
-
g---c
|
169
|
-
c--g
|
170
|
-
at
|
171
|
-
END
|
172
|
-
$str = ''
|
173
|
-
alias puts_orig puts
|
174
|
-
def puts(*args)
|
175
|
-
args.each do |obj|
|
176
|
-
$str << obj.to_s
|
177
|
-
end
|
178
|
-
end
|
179
|
-
doublehelix(seq)
|
180
|
-
undef puts
|
181
|
-
alias puts puts_orig
|
182
|
-
assert_equal(output, $str)
|
183
|
-
end
|
184
|
-
|
185
|
-
end
|
186
|
-
|
187
|
-
end
|