bio 0.7.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.
- data/bin/bioruby +107 -0
- data/bin/br_biofetch.rb +59 -0
- data/bin/br_bioflat.rb +294 -0
- data/bin/br_biogetseq.rb +57 -0
- data/bin/br_pmfetch.rb +431 -0
- data/doc/BioRuby.rd.ja +225 -0
- data/doc/Changes-0.7.rd +236 -0
- data/doc/Design.rd.ja +341 -0
- data/doc/KEGG_API.rd +1437 -0
- data/doc/KEGG_API.rd.ja +1399 -0
- data/doc/TODO.rd.ja +138 -0
- data/doc/Tutorial.rd +1138 -0
- data/doc/Tutorial.rd.ja +2110 -0
- data/etc/bioinformatics/seqdatabase.ini +210 -0
- data/lib/bio.rb +256 -0
- data/lib/bio/alignment.rb +1906 -0
- data/lib/bio/appl/bl2seq/report.rb +350 -0
- data/lib/bio/appl/blast.rb +269 -0
- data/lib/bio/appl/blast/format0.rb +1402 -0
- data/lib/bio/appl/blast/format8.rb +95 -0
- data/lib/bio/appl/blast/report.rb +652 -0
- data/lib/bio/appl/blast/rexml.rb +151 -0
- data/lib/bio/appl/blast/wublast.rb +553 -0
- data/lib/bio/appl/blast/xmlparser.rb +222 -0
- data/lib/bio/appl/blat/report.rb +392 -0
- data/lib/bio/appl/clustalw.rb +191 -0
- data/lib/bio/appl/clustalw/report.rb +154 -0
- data/lib/bio/appl/emboss.rb +68 -0
- data/lib/bio/appl/fasta.rb +262 -0
- data/lib/bio/appl/fasta/format10.rb +428 -0
- data/lib/bio/appl/fasta/format6.rb +37 -0
- data/lib/bio/appl/genscan/report.rb +570 -0
- data/lib/bio/appl/hmmer.rb +129 -0
- data/lib/bio/appl/hmmer/report.rb +556 -0
- data/lib/bio/appl/mafft.rb +222 -0
- data/lib/bio/appl/mafft/report.rb +119 -0
- data/lib/bio/appl/psort.rb +555 -0
- data/lib/bio/appl/psort/report.rb +473 -0
- data/lib/bio/appl/sim4.rb +134 -0
- data/lib/bio/appl/sim4/report.rb +501 -0
- data/lib/bio/appl/sosui/report.rb +166 -0
- data/lib/bio/appl/spidey/report.rb +604 -0
- data/lib/bio/appl/targetp/report.rb +283 -0
- data/lib/bio/appl/tmhmm/report.rb +238 -0
- data/lib/bio/command.rb +166 -0
- data/lib/bio/data/aa.rb +354 -0
- data/lib/bio/data/codontable.rb +740 -0
- data/lib/bio/data/na.rb +226 -0
- data/lib/bio/db.rb +340 -0
- data/lib/bio/db/aaindex.rb +280 -0
- data/lib/bio/db/embl/common.rb +332 -0
- data/lib/bio/db/embl/embl.rb +446 -0
- data/lib/bio/db/embl/sptr.rb +954 -0
- data/lib/bio/db/embl/swissprot.rb +32 -0
- data/lib/bio/db/embl/trembl.rb +31 -0
- data/lib/bio/db/embl/uniprot.rb +32 -0
- data/lib/bio/db/fantom.rb +604 -0
- data/lib/bio/db/fasta.rb +869 -0
- data/lib/bio/db/genbank/common.rb +299 -0
- data/lib/bio/db/genbank/ddbj.rb +34 -0
- data/lib/bio/db/genbank/genbank.rb +354 -0
- data/lib/bio/db/genbank/genpept.rb +73 -0
- data/lib/bio/db/genbank/refseq.rb +31 -0
- data/lib/bio/db/gff.rb +106 -0
- data/lib/bio/db/go.rb +497 -0
- data/lib/bio/db/kegg/brite.rb +51 -0
- data/lib/bio/db/kegg/cell.rb +88 -0
- data/lib/bio/db/kegg/compound.rb +130 -0
- data/lib/bio/db/kegg/enzyme.rb +125 -0
- data/lib/bio/db/kegg/expression.rb +173 -0
- data/lib/bio/db/kegg/genes.rb +293 -0
- data/lib/bio/db/kegg/genome.rb +362 -0
- data/lib/bio/db/kegg/glycan.rb +213 -0
- data/lib/bio/db/kegg/keggtab.rb +418 -0
- data/lib/bio/db/kegg/kgml.rb +299 -0
- data/lib/bio/db/kegg/ko.rb +178 -0
- data/lib/bio/db/kegg/reaction.rb +97 -0
- data/lib/bio/db/litdb.rb +131 -0
- data/lib/bio/db/medline.rb +317 -0
- data/lib/bio/db/nbrf.rb +199 -0
- data/lib/bio/db/pdb.rb +38 -0
- data/lib/bio/db/pdb/atom.rb +60 -0
- data/lib/bio/db/pdb/chain.rb +117 -0
- data/lib/bio/db/pdb/model.rb +106 -0
- data/lib/bio/db/pdb/pdb.rb +1682 -0
- data/lib/bio/db/pdb/residue.rb +122 -0
- data/lib/bio/db/pdb/utils.rb +234 -0
- data/lib/bio/db/prosite.rb +616 -0
- data/lib/bio/db/rebase.rb +417 -0
- data/lib/bio/db/transfac.rb +387 -0
- data/lib/bio/feature.rb +201 -0
- data/lib/bio/io/brdb.rb +103 -0
- data/lib/bio/io/das.rb +471 -0
- data/lib/bio/io/dbget.rb +212 -0
- data/lib/bio/io/ddbjxml.rb +614 -0
- data/lib/bio/io/fastacmd.rb +123 -0
- data/lib/bio/io/fetch.rb +114 -0
- data/lib/bio/io/flatfile.rb +496 -0
- data/lib/bio/io/flatfile/bdb.rb +266 -0
- data/lib/bio/io/flatfile/index.rb +1308 -0
- data/lib/bio/io/flatfile/indexer.rb +778 -0
- data/lib/bio/io/higet.rb +92 -0
- data/lib/bio/io/keggapi.rb +863 -0
- data/lib/bio/io/pubmed.rb +189 -0
- data/lib/bio/io/registry.rb +308 -0
- data/lib/bio/io/soapwsdl.rb +114 -0
- data/lib/bio/io/sql.rb +428 -0
- data/lib/bio/location.rb +650 -0
- data/lib/bio/pathway.rb +991 -0
- data/lib/bio/reference.rb +308 -0
- data/lib/bio/sequence.rb +593 -0
- data/lib/bio/shell.rb +51 -0
- data/lib/bio/shell/core.rb +512 -0
- data/lib/bio/shell/plugin/codon.rb +228 -0
- data/lib/bio/shell/plugin/entry.rb +85 -0
- data/lib/bio/shell/plugin/flatfile.rb +119 -0
- data/lib/bio/shell/plugin/keggapi.rb +187 -0
- data/lib/bio/shell/plugin/midi.rb +448 -0
- data/lib/bio/shell/plugin/obda.rb +63 -0
- data/lib/bio/shell/plugin/seq.rb +238 -0
- data/lib/bio/shell/session.rb +214 -0
- data/lib/bio/util/color_scheme.rb +214 -0
- data/lib/bio/util/color_scheme/buried.rb +78 -0
- data/lib/bio/util/color_scheme/helix.rb +78 -0
- data/lib/bio/util/color_scheme/hydropathy.rb +83 -0
- data/lib/bio/util/color_scheme/nucleotide.rb +50 -0
- data/lib/bio/util/color_scheme/strand.rb +78 -0
- data/lib/bio/util/color_scheme/taylor.rb +69 -0
- data/lib/bio/util/color_scheme/turn.rb +78 -0
- data/lib/bio/util/color_scheme/zappo.rb +69 -0
- data/lib/bio/util/contingency_table.rb +337 -0
- data/lib/bio/util/sirna.rb +306 -0
- data/lib/bioruby.rb +34 -0
- data/sample/biofetch.rb +475 -0
- data/sample/color_scheme_na.rb +99 -0
- data/sample/dbget +37 -0
- data/sample/fasta2tab.rb +99 -0
- data/sample/fsplit.rb +51 -0
- data/sample/gb2fasta.rb +31 -0
- data/sample/gb2tab.rb +325 -0
- data/sample/gbtab2mysql.rb +161 -0
- data/sample/genes2nuc.rb +33 -0
- data/sample/genes2pep.rb +33 -0
- data/sample/genes2tab.rb +81 -0
- data/sample/genome2rb.rb +29 -0
- data/sample/genome2tab.rb +76 -0
- data/sample/goslim.rb +311 -0
- data/sample/gt2fasta.rb +47 -0
- data/sample/pmfetch.rb +42 -0
- data/sample/pmsearch.rb +42 -0
- data/sample/psortplot_html.rb +222 -0
- data/sample/ssearch2tab.rb +96 -0
- data/sample/tdiary.rb +158 -0
- data/sample/tfastx2tab.rb +100 -0
- data/sample/vs-genes.rb +212 -0
- data/test/data/SOSUI/sample.report +11 -0
- data/test/data/TMHMM/sample.report +21 -0
- data/test/data/blast/eco:b0002.faa +15 -0
- data/test/data/blast/eco:b0002.faa.m0 +128 -0
- data/test/data/blast/eco:b0002.faa.m7 +65 -0
- data/test/data/blast/eco:b0002.faa.m8 +1 -0
- data/test/data/embl/AB090716.embl +65 -0
- data/test/data/genscan/sample.report +63 -0
- data/test/data/prosite/prosite.dat +2233 -0
- data/test/data/refseq/nm_126355.entret +64 -0
- data/test/data/uniprot/p53_human.uniprot +1456 -0
- data/test/runner.rb +10 -0
- data/test/unit/bio/appl/blast/test_report.rb +427 -0
- data/test/unit/bio/appl/blast/test_xmlparser.rb +400 -0
- data/test/unit/bio/appl/genscan/test_report.rb +195 -0
- data/test/unit/bio/appl/sosui/test_report.rb +94 -0
- data/test/unit/bio/appl/targetp/test_report.rb +159 -0
- data/test/unit/bio/appl/test_blast.rb +159 -0
- data/test/unit/bio/appl/test_fasta.rb +142 -0
- data/test/unit/bio/appl/tmhmm/test_report.rb +139 -0
- data/test/unit/bio/data/test_aa.rb +103 -0
- data/test/unit/bio/data/test_codontable.rb +120 -0
- data/test/unit/bio/data/test_na.rb +89 -0
- data/test/unit/bio/db/embl/test_common.rb +130 -0
- data/test/unit/bio/db/embl/test_embl.rb +227 -0
- data/test/unit/bio/db/embl/test_sptr.rb +268 -0
- data/test/unit/bio/db/embl/test_uniprot.rb +44 -0
- data/test/unit/bio/db/kegg/test_genes.rb +58 -0
- data/test/unit/bio/db/test_fasta.rb +263 -0
- data/test/unit/bio/db/test_gff.rb +140 -0
- data/test/unit/bio/db/test_prosite.rb +1450 -0
- data/test/unit/bio/io/test_ddbjxml.rb +87 -0
- data/test/unit/bio/io/test_soapwsdl.rb +45 -0
- data/test/unit/bio/shell/plugin/test_seq.rb +175 -0
- data/test/unit/bio/test_alignment.rb +1028 -0
- data/test/unit/bio/test_command.rb +71 -0
- data/test/unit/bio/test_db.rb +109 -0
- data/test/unit/bio/test_feature.rb +128 -0
- data/test/unit/bio/test_location.rb +51 -0
- data/test/unit/bio/test_pathway.rb +485 -0
- data/test/unit/bio/test_sequence.rb +386 -0
- data/test/unit/bio/test_shell.rb +31 -0
- data/test/unit/bio/util/test_color_scheme.rb +45 -0
- data/test/unit/bio/util/test_contingency_table.rb +106 -0
- data/test/unit/bio/util/test_sirna.rb +258 -0
- metadata +295 -0
|
@@ -0,0 +1,386 @@
|
|
|
1
|
+
#
|
|
2
|
+
# test/unit/bio/tc_sequence.rb - Unit test for Bio::Sequencce
|
|
3
|
+
#
|
|
4
|
+
# Copyright (C) 2004 Moses Hohman <mmhohman@northwestern.edu>
|
|
5
|
+
#
|
|
6
|
+
# This library is free software; you can redistribute it and/or
|
|
7
|
+
# modify it under the terms of the GNU Lesser General Public
|
|
8
|
+
# License as published by the Free Software Foundation; either
|
|
9
|
+
# version 2 of the License, or (at your option) any later version.
|
|
10
|
+
#
|
|
11
|
+
# This library is distributed in the hope that it will be useful,
|
|
12
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
13
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
14
|
+
# Lesser General Public License for more details.
|
|
15
|
+
#
|
|
16
|
+
# You should have received a copy of the GNU Lesser General Public
|
|
17
|
+
# License along with this library; if not, write to the Free Software
|
|
18
|
+
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
19
|
+
#
|
|
20
|
+
# $Id: test_sequence.rb,v 1.5 2005/11/26 06:51:45 nakao Exp $
|
|
21
|
+
#
|
|
22
|
+
|
|
23
|
+
require 'pathname'
|
|
24
|
+
libpath = Pathname.new(File.join(File.dirname(__FILE__), ['..'] * 3, 'lib')).cleanpath.to_s
|
|
25
|
+
$:.unshift(libpath) unless $:.include?(libpath)
|
|
26
|
+
|
|
27
|
+
require 'test/unit'
|
|
28
|
+
require 'bio/sequence'
|
|
29
|
+
|
|
30
|
+
module Bio
|
|
31
|
+
class TestSequence < Test::Unit::TestCase
|
|
32
|
+
def setup
|
|
33
|
+
@na = Sequence::NA.new('atgcatgcatgcatgcaaaa')
|
|
34
|
+
@rna = Sequence::NA.new('augcaugcaugcaugcaaaa')
|
|
35
|
+
@aa = Sequence::AA.new('ACDEFGHIKLMNPQRSTVWYU')
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def test_to_s_returns_self_as_string
|
|
39
|
+
s = "abcefghijklmnop"
|
|
40
|
+
sequence = Sequence.new(s)
|
|
41
|
+
assert_equal(s, sequence.to_s, "wrong value")
|
|
42
|
+
assert_instance_of(String, sequence.to_s, "not a String")
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def test_subseq_returns_nil_blank_sequence_default_end
|
|
46
|
+
sequence = Sequence.new("")
|
|
47
|
+
assert_nil(sequence.subseq(5))
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def test_subseq_returns_nil_start_less_than_one
|
|
51
|
+
sequence = Sequence.new("blahblah")
|
|
52
|
+
assert_nil(sequence.subseq(0))
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def test_subseq_returns_subsequence
|
|
56
|
+
sequence = Sequence.new("hahasubhehe")
|
|
57
|
+
assert_equal("sub", sequence.subseq(5,7))
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
# "main" method tests translated into unit tests
|
|
61
|
+
|
|
62
|
+
# Test Sequence::NA.new
|
|
63
|
+
|
|
64
|
+
def test_DNA_new_blank_sequence
|
|
65
|
+
sequence = Sequence::NA.new('')
|
|
66
|
+
assert_equal(0, sequence.size)
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
def test_DNA_new_sequence_downcases_symbols
|
|
70
|
+
string = 'atgcatgcATGCATGCAAAA'
|
|
71
|
+
sequence = Sequence::NA.new(string)
|
|
72
|
+
assert_equal(string.downcase, sequence.to_s)
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
def test_RNA_new_sequence
|
|
76
|
+
string = 'augcaugcaugcaugcaaaa'
|
|
77
|
+
sequence = Sequence::NA.new(string)
|
|
78
|
+
assert_equal(string, sequence.to_s)
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
# added
|
|
82
|
+
|
|
83
|
+
def test_DNA_new_sequence_removes_whitespace
|
|
84
|
+
sequence = Sequence::NA.new("a g\tc\nt\ra")
|
|
85
|
+
assert_equal("agcta", sequence)
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
# Test Sequence::AA.new
|
|
89
|
+
|
|
90
|
+
def test_AA_new_blank_sequence
|
|
91
|
+
sequence = Sequence::AA.new('')
|
|
92
|
+
assert_equal(0, sequence.size)
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
def test_AA_new_sequence_all_legal_symbols
|
|
96
|
+
string = 'ACDEFGHIKLMNPQRSTVWYU'
|
|
97
|
+
sequence = Sequence::AA.new(string)
|
|
98
|
+
assert_equal(string, sequence.to_s)
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
# added
|
|
102
|
+
|
|
103
|
+
def test_AA_new_sequence_upcases_symbols
|
|
104
|
+
string = 'upcase'
|
|
105
|
+
sequence = Sequence::AA.new(string)
|
|
106
|
+
assert_equal(string.upcase, sequence.to_s)
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
def test_AA_new_sequence_removes_whitespace
|
|
110
|
+
sequence = Sequence::AA.new("S T\tR\nI\rP")
|
|
111
|
+
assert_equal("STRIP", sequence)
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
# test element indexing
|
|
115
|
+
|
|
116
|
+
def test_element_reference_operator_with_two_arguments
|
|
117
|
+
sequence = Sequence::NA.new("atggggggtc")
|
|
118
|
+
assert_equal("gggggg", sequence[2,6])
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
# added
|
|
122
|
+
def test_element_reference_operator_with_one_argument
|
|
123
|
+
sequence = Sequence::NA.new("atggggggtc")
|
|
124
|
+
assert_equal(?t, sequence[1])
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
# Test Sequence#to_fasta
|
|
128
|
+
|
|
129
|
+
def test_to_fasta
|
|
130
|
+
sequence = Sequence.new("agtc"*10)
|
|
131
|
+
header = "the header"
|
|
132
|
+
assert_equal(">the header\n" + ("agtc"*5) + "\n" + ("agtc"*5) + "\n", sequence.to_fasta(header, 20))
|
|
133
|
+
end
|
|
134
|
+
|
|
135
|
+
# Test Sequence#window_wearch
|
|
136
|
+
|
|
137
|
+
def test_window_search_with_width_3_default_step_no_residual
|
|
138
|
+
sequence = Sequence.new("agtca")
|
|
139
|
+
windows = []
|
|
140
|
+
returned_value = sequence.window_search(3) { |window| windows << window }
|
|
141
|
+
assert_equal(["agt", "gtc", "tca"], windows, "windows wrong")
|
|
142
|
+
assert_equal("", returned_value, "returned value wrong")
|
|
143
|
+
end
|
|
144
|
+
|
|
145
|
+
# added
|
|
146
|
+
def test_window_search_with_width_3_step_two_with_residual
|
|
147
|
+
sequence = Sequence::NA.new("agtcat")
|
|
148
|
+
windows = []
|
|
149
|
+
returned_value = sequence.window_search(3, 2) { |window| windows << window }
|
|
150
|
+
assert_equal(["agt", "tca"], windows, "windows wrong")
|
|
151
|
+
assert_equal("t", returned_value, "returned value wrong")
|
|
152
|
+
end
|
|
153
|
+
|
|
154
|
+
# Test Sequence#total
|
|
155
|
+
|
|
156
|
+
def test_total
|
|
157
|
+
sequence = Sequence::NA.new("catccagtccctggt")
|
|
158
|
+
assert_equal(2346, sequence.total({'a'=>1000, 'g'=>100, 't'=>10, 'c'=>1}))
|
|
159
|
+
end
|
|
160
|
+
|
|
161
|
+
# Test Sequence#composition
|
|
162
|
+
|
|
163
|
+
def test_dna_composition
|
|
164
|
+
sequence = Sequence::NA.new("aggtttcccc")
|
|
165
|
+
expected = {'a'=>1,'g'=>2,'t'=>3,'c'=>4}
|
|
166
|
+
expected.default = 0
|
|
167
|
+
assert_equal(expected, sequence.composition)
|
|
168
|
+
end
|
|
169
|
+
|
|
170
|
+
def test_rna_composition
|
|
171
|
+
sequence = Sequence::NA.new("agguuucccc")
|
|
172
|
+
expected = {'a'=>1,'g'=>2,'u'=>3,'c'=>4}
|
|
173
|
+
expected.default = 0
|
|
174
|
+
assert_equal(expected, sequence.composition)
|
|
175
|
+
end
|
|
176
|
+
|
|
177
|
+
# I don't get splicing
|
|
178
|
+
|
|
179
|
+
# Test Sequence::NA#complement
|
|
180
|
+
|
|
181
|
+
def test_dna_sequence_complement
|
|
182
|
+
assert_equal('ttttgcatgcatgcatgcat', @na.complement)
|
|
183
|
+
end
|
|
184
|
+
|
|
185
|
+
def test_rna_sequence_complement
|
|
186
|
+
assert_equal('uuuugcaugcaugcaugcau', @rna.complement)
|
|
187
|
+
end
|
|
188
|
+
|
|
189
|
+
def test_ambiguous_dna_sequence_complement
|
|
190
|
+
assert_equal("nwsbvhdkmyrcgta", Sequence::NA.new('tacgyrkmhdbvswn').complement)
|
|
191
|
+
end
|
|
192
|
+
|
|
193
|
+
def test_ambiguous_rna_sequence_complement
|
|
194
|
+
assert_equal("nwsbvhdkmyrcgua", Sequence::NA.new('uacgyrkmhdbvswn').complement)
|
|
195
|
+
end
|
|
196
|
+
|
|
197
|
+
# Test Sequence::NA#translate
|
|
198
|
+
|
|
199
|
+
def test_dna_sequence_translate
|
|
200
|
+
assert_equal("MHACMQ", @na.translate)
|
|
201
|
+
end
|
|
202
|
+
|
|
203
|
+
def test_rna_sequence_translate
|
|
204
|
+
assert_equal("MHACMQ", @rna.translate)
|
|
205
|
+
end
|
|
206
|
+
|
|
207
|
+
# Test Sequence::NA#gc_percent
|
|
208
|
+
|
|
209
|
+
def test_dna_gc_percent
|
|
210
|
+
assert_equal(40, @na.gc_percent)
|
|
211
|
+
end
|
|
212
|
+
|
|
213
|
+
def test_rna_gc_percent
|
|
214
|
+
assert_equal(40, @rna.gc_percent)
|
|
215
|
+
end
|
|
216
|
+
|
|
217
|
+
# Test Sequence::NA#illegal_bases
|
|
218
|
+
|
|
219
|
+
def test_valid_dna_sequence_illegal_bases
|
|
220
|
+
assert_equal([], @na.illegal_bases)
|
|
221
|
+
end
|
|
222
|
+
|
|
223
|
+
def test_invalid_nucleic_acid_illegal_bases
|
|
224
|
+
string = 'tacgyrkmhdbvswn'
|
|
225
|
+
expected = []
|
|
226
|
+
string[4..-1].each_byte { |val| expected << val.chr }
|
|
227
|
+
assert_equal(expected.sort, Sequence::NA.new(string).illegal_bases)
|
|
228
|
+
end
|
|
229
|
+
|
|
230
|
+
def test_invalid_nucleic_acid_illegal_bases_more
|
|
231
|
+
string = ('abcdefghijklmnopqrstuvwxyz-!%#$@')
|
|
232
|
+
expected = []
|
|
233
|
+
'bdefhijklmnopqrsvwxyz-!%#$@'.each_byte { |val| expected << val.chr }
|
|
234
|
+
assert_equal(expected.sort, Sequence::NA.new(string).illegal_bases)
|
|
235
|
+
end
|
|
236
|
+
|
|
237
|
+
# Test Sequence::NA#molecular_weight
|
|
238
|
+
|
|
239
|
+
def test_dna_molecular_weight
|
|
240
|
+
assert_in_delta(6174.3974, @na.molecular_weight, 1e-5)
|
|
241
|
+
end
|
|
242
|
+
|
|
243
|
+
def test_rna_molecular_weight
|
|
244
|
+
assert_in_delta(6438.2774, @rna.molecular_weight, 1e-5)
|
|
245
|
+
end
|
|
246
|
+
|
|
247
|
+
# Test Sequence::NA#to_re
|
|
248
|
+
|
|
249
|
+
def test_dna_to_re
|
|
250
|
+
assert_equal(/atgc[ag][tc][ac][tg][atg][atc][agc][tgc][gc][at][atgc]/, Sequence::NA.new('atgcrymkdhvbswn').to_re)
|
|
251
|
+
end
|
|
252
|
+
|
|
253
|
+
def test_rna_to_re
|
|
254
|
+
assert_equal(/augc[ag][uc][ac][ug][aug][auc][agc][ugc][gc][au][augc]/, Sequence::NA.new('augcrymkdhvbswn').to_re)
|
|
255
|
+
end
|
|
256
|
+
|
|
257
|
+
# Test Sequence::NA#names
|
|
258
|
+
|
|
259
|
+
def test_nucleic_acid_names
|
|
260
|
+
# It is a Bio::NucleicAcid feature.
|
|
261
|
+
# assert_equal(["adenine", "cytosine", "guanine", "thymine", "uracil"], Sequence::NA.new('acgtu').names)
|
|
262
|
+
assert(Sequence::NA.new('acgtu').names)
|
|
263
|
+
end
|
|
264
|
+
|
|
265
|
+
# Test Sequence::NA#pikachu
|
|
266
|
+
|
|
267
|
+
def test_dna_pikachu
|
|
268
|
+
assert_equal("pika", Sequence::NA.new('atgc').pikachu)
|
|
269
|
+
end
|
|
270
|
+
|
|
271
|
+
def test_rna_pikachu
|
|
272
|
+
assert_equal("pika", Sequence::NA.new('augc').pikachu)
|
|
273
|
+
end
|
|
274
|
+
|
|
275
|
+
# Test Sequence::NA#randomize
|
|
276
|
+
|
|
277
|
+
def test_randomize_dna_retains_composition
|
|
278
|
+
assert_equal(@na.composition, @na.randomize.composition)
|
|
279
|
+
end
|
|
280
|
+
|
|
281
|
+
# this test has a neglibly small chance of failure
|
|
282
|
+
def test_two_consecutive_dna_randomizations_not_equal
|
|
283
|
+
assert_not_equal(@na.randomize, @na.randomize)
|
|
284
|
+
end
|
|
285
|
+
|
|
286
|
+
def test_randomize_dna_can_be_chained
|
|
287
|
+
assert_equal(@na.composition, @na.randomize.randomize.composition)
|
|
288
|
+
end
|
|
289
|
+
|
|
290
|
+
def test_randomize_dna_with_block
|
|
291
|
+
appended = ""
|
|
292
|
+
@na.randomize {|x| appended << x}
|
|
293
|
+
assert_equal(@na.composition, Sequence::NA.new(appended).composition)
|
|
294
|
+
end
|
|
295
|
+
|
|
296
|
+
# Test Sequence::NA.randomize(counts)
|
|
297
|
+
|
|
298
|
+
def test_NA_randomize_with_counts
|
|
299
|
+
counts = {'a'=>10,'c'=>20,'g'=>30,'u'=>40}
|
|
300
|
+
counts.default = 0
|
|
301
|
+
assert_equal(counts, Sequence::NA.randomize(counts).composition)
|
|
302
|
+
end
|
|
303
|
+
|
|
304
|
+
def test_NA_randomize_with_counts_and_block
|
|
305
|
+
appended = ""
|
|
306
|
+
counts = {'a'=>10,'c'=>20,'g'=>30,'u'=>40}
|
|
307
|
+
counts.default = 0
|
|
308
|
+
Sequence::NA.randomize(counts) {|x| appended << x}
|
|
309
|
+
assert_equal(counts, Sequence::NA.new(appended).composition)
|
|
310
|
+
end
|
|
311
|
+
|
|
312
|
+
# Test Sequence::AA#codes
|
|
313
|
+
|
|
314
|
+
def test_amino_acid_codes
|
|
315
|
+
assert_equal(["Ala", "Cys", "Asp", "Glu", "Phe", "Gly", "His", "Ile", "Lys",
|
|
316
|
+
"Leu", "Met", "Asn", "Pro", "Gln", "Arg", "Ser", "Thr", "Val", "Trp",
|
|
317
|
+
"Tyr", "Sec"], @aa.codes)
|
|
318
|
+
end
|
|
319
|
+
|
|
320
|
+
# Test Sequence::AA#names
|
|
321
|
+
|
|
322
|
+
def test_amino_acid_names
|
|
323
|
+
assert_equal(["alanine", "cysteine", "aspartic acid", "glutamic acid", "phenylalanine",
|
|
324
|
+
"glycine", "histidine", "isoleucine", "lysine", "leucine", "methionine",
|
|
325
|
+
"asparagine", "proline", "glutamine", "arginine", "serine", "threonine",
|
|
326
|
+
"valine", "tryptophan", "tyrosine", "selenocysteine"], @aa.names)
|
|
327
|
+
end
|
|
328
|
+
|
|
329
|
+
# Test Sequence::AA#molecular_weight
|
|
330
|
+
|
|
331
|
+
def test_amino_acid_molecular_weight
|
|
332
|
+
assert_in_delta(2395.725, @aa.subseq(1,20).molecular_weight, 0.0001)
|
|
333
|
+
end
|
|
334
|
+
|
|
335
|
+
#Test Sequence::AA#randomize
|
|
336
|
+
|
|
337
|
+
def test_amino_acid_randomize_has_same_composition
|
|
338
|
+
aaseq = 'MRVLKFGGTSVANAERFLRVADILESNARQGQVATVLSAPAKITNHLVAMIEKTISGQDA'
|
|
339
|
+
s = Sequence::AA.new(aaseq)
|
|
340
|
+
assert_equal(s.composition, s.randomize.composition)
|
|
341
|
+
end
|
|
342
|
+
|
|
343
|
+
# this test has a neglibly small chance of failure
|
|
344
|
+
def test_consecutive_amino_acid_randomizes_are_not_equal
|
|
345
|
+
aaseq = 'MRVLKFGGTSVANAERFLRVADILESNARQGQVATVLSAPAKITNHLVAMIEKTISGQDA'
|
|
346
|
+
s = Sequence::AA.new(aaseq)
|
|
347
|
+
assert_not_equal(s.randomize, s.randomize)
|
|
348
|
+
end
|
|
349
|
+
|
|
350
|
+
def test_amino_acid_randomize_can_be_chained
|
|
351
|
+
aaseq = 'MRVLKFGGTSVANAERFLRVADILESNARQGQVATVLSAPAKITNHLVAMIEKTISGQDA'
|
|
352
|
+
s = Sequence::AA.new(aaseq)
|
|
353
|
+
assert_equal(s.randomize.composition, s.randomize.randomize.composition)
|
|
354
|
+
end
|
|
355
|
+
end
|
|
356
|
+
|
|
357
|
+
|
|
358
|
+
class TestNATranslate < Test::Unit::TestCase
|
|
359
|
+
def setup
|
|
360
|
+
@obj = Bio::Sequence::NA.new("AAA")
|
|
361
|
+
end
|
|
362
|
+
|
|
363
|
+
def test_translate
|
|
364
|
+
assert_equal("K", @obj.translate)
|
|
365
|
+
end
|
|
366
|
+
def test_translate_1
|
|
367
|
+
assert_equal("K", @obj.translate(1))
|
|
368
|
+
end
|
|
369
|
+
def test_translate_2
|
|
370
|
+
assert_equal("", @obj.translate(2))
|
|
371
|
+
end
|
|
372
|
+
def test_translate_3
|
|
373
|
+
assert_equal("", @obj.translate(3))
|
|
374
|
+
end
|
|
375
|
+
def test_translate_4
|
|
376
|
+
assert_equal("F", @obj.translate(4))
|
|
377
|
+
end
|
|
378
|
+
def test_translate_5
|
|
379
|
+
assert_equal("", @obj.translate(5))
|
|
380
|
+
end
|
|
381
|
+
def test_translate_5
|
|
382
|
+
assert_equal("", @obj.translate(6))
|
|
383
|
+
end
|
|
384
|
+
end
|
|
385
|
+
|
|
386
|
+
end
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
#
|
|
2
|
+
# test/unit/bio/test_shell.rb - Unit test for Bio::Shell
|
|
3
|
+
#
|
|
4
|
+
# Copyright (C) 2005 Mitsuteru Nakao <n@bioruby.org>
|
|
5
|
+
#
|
|
6
|
+
# This library is free software; you can redistribute it and/or
|
|
7
|
+
# modify it under the terms of the GNU Lesser General Public
|
|
8
|
+
# License as published by the Free Software Foundation; either
|
|
9
|
+
# version 2 of the License, or (at your option) any later version.
|
|
10
|
+
#
|
|
11
|
+
# This library is distributed in the hope that it will be useful,
|
|
12
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
13
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
14
|
+
# Lesser General Public License for more details.
|
|
15
|
+
#
|
|
16
|
+
# You should have received a copy of the GNU Lesser General Public
|
|
17
|
+
# License along with this library; if not, write to the Free Software
|
|
18
|
+
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
19
|
+
#
|
|
20
|
+
# $Id: test_shell.rb,v 1.4 2005/12/18 17:00:10 k Exp $
|
|
21
|
+
#
|
|
22
|
+
|
|
23
|
+
require 'pathname'
|
|
24
|
+
libpath = Pathname.new(File.join(File.dirname(__FILE__), ['..'] * 3, 'lib')).cleanpath.to_s
|
|
25
|
+
$:.unshift(libpath) unless $:.include?(libpath)
|
|
26
|
+
|
|
27
|
+
require 'test/unit'
|
|
28
|
+
require 'bioruby'
|
|
29
|
+
|
|
30
|
+
module Bio
|
|
31
|
+
end
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
#
|
|
2
|
+
# test/unit/bio/util/test_color_scheme.rb - Unit test for Bio::ColorScheme
|
|
3
|
+
#
|
|
4
|
+
# Copyright (C) 2005 Trevor Wennblom <trevor@corevx.com>
|
|
5
|
+
#
|
|
6
|
+
# This library is free software; you can redistribute it and/or
|
|
7
|
+
# modify it under the terms of the GNU Lesser General Public
|
|
8
|
+
# License as published by the Free Software Foundation; either
|
|
9
|
+
# version 2 of the License, or (at your option) any later version.
|
|
10
|
+
#
|
|
11
|
+
# This library is distributed in the hope that it will be useful,
|
|
12
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
13
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
14
|
+
# Lesser General Public License for more details.
|
|
15
|
+
#
|
|
16
|
+
# You should have received a copy of the GNU Lesser General Public
|
|
17
|
+
# License along with this library; if not, write to the Free Software
|
|
18
|
+
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
19
|
+
#
|
|
20
|
+
# $Id: test_color_scheme.rb,v 1.1 2005/10/23 08:40:41 k Exp $
|
|
21
|
+
#
|
|
22
|
+
|
|
23
|
+
require 'pathname'
|
|
24
|
+
libpath = Pathname.new(File.join(File.dirname(__FILE__), ['..'] * 4 , 'lib')).cleanpath.to_s
|
|
25
|
+
$:.unshift(libpath) unless $:.include?(libpath)
|
|
26
|
+
|
|
27
|
+
require 'test/unit'
|
|
28
|
+
require 'bio/util/color_scheme'
|
|
29
|
+
|
|
30
|
+
module Bio
|
|
31
|
+
class TestColorScheme < Test::Unit::TestCase
|
|
32
|
+
|
|
33
|
+
def test_buried
|
|
34
|
+
s = Bio::ColorScheme::Buried
|
|
35
|
+
assert_equal('00DC22', s['A'])
|
|
36
|
+
assert_equal('00BF3F', s[:c])
|
|
37
|
+
assert_equal(nil, s[nil])
|
|
38
|
+
assert_equal('FFFFFF', s['-'])
|
|
39
|
+
assert_equal('FFFFFF', s[7])
|
|
40
|
+
assert_equal('FFFFFF', s['junk'])
|
|
41
|
+
assert_equal('00CC32', s['t'])
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
end
|
|
45
|
+
end
|