bio 1.2.1 → 1.3.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/ChangeLog +3421 -0
- data/KNOWN_ISSUES.rdoc +88 -0
- data/README.rdoc +252 -0
- data/README_DEV.rdoc +285 -0
- data/Rakefile +143 -0
- data/bin/bioruby +0 -0
- data/bin/br_biofetch.rb +0 -0
- data/bin/br_bioflat.rb +12 -1
- data/bin/br_biogetseq.rb +0 -0
- data/bin/br_pmfetch.rb +4 -3
- data/bioruby.gemspec +477 -0
- data/bioruby.gemspec.erb +117 -0
- data/doc/Changes-0.7.rd +7 -0
- data/doc/Changes-1.3.rdoc +239 -0
- data/doc/Tutorial.rd +296 -184
- data/doc/Tutorial.rd.html +1031 -0
- data/doc/Tutorial.rd.ja +111 -45
- data/doc/Tutorial.rd.ja.html +2225 -0
- data/doc/bioruby.css +281 -0
- data/extconf.rb +2 -0
- data/lib/bio.rb +29 -4
- data/lib/bio/appl/blast.rb +306 -121
- data/lib/bio/appl/blast/ddbj.rb +142 -0
- data/lib/bio/appl/blast/format0.rb +35 -25
- data/lib/bio/appl/blast/format8.rb +2 -2
- data/lib/bio/appl/blast/genomenet.rb +263 -0
- data/lib/bio/appl/blast/ncbioptions.rb +220 -0
- data/lib/bio/appl/blast/remote.rb +106 -0
- data/lib/bio/appl/blast/report.rb +260 -9
- data/lib/bio/appl/blast/rexml.rb +12 -5
- data/lib/bio/appl/blast/rpsblast.rb +277 -0
- data/lib/bio/appl/blast/wublast.rb +133 -12
- data/lib/bio/appl/blast/xmlparser.rb +35 -18
- data/lib/bio/appl/blat/report.rb +46 -5
- data/lib/bio/appl/emboss.rb +62 -13
- data/lib/bio/appl/fasta.rb +9 -11
- data/lib/bio/appl/genscan/report.rb +3 -3
- data/lib/bio/appl/hmmer.rb +1 -1
- data/lib/bio/appl/hmmer/report.rb +10 -10
- data/lib/bio/appl/paml/baseml.rb +95 -0
- data/lib/bio/appl/paml/baseml/report.rb +32 -0
- data/lib/bio/appl/paml/codeml.rb +242 -0
- data/lib/bio/appl/paml/codeml/rates.rb +67 -0
- data/lib/bio/appl/paml/codeml/report.rb +67 -0
- data/lib/bio/appl/paml/common.rb +348 -0
- data/lib/bio/appl/paml/common_report.rb +38 -0
- data/lib/bio/appl/paml/yn00.rb +103 -0
- data/lib/bio/appl/paml/yn00/report.rb +32 -0
- data/lib/bio/appl/psort.rb +2 -2
- data/lib/bio/appl/pts1.rb +5 -5
- data/lib/bio/appl/tmhmm/report.rb +10 -1
- data/lib/bio/command.rb +297 -41
- data/lib/bio/compat/features.rb +157 -0
- data/lib/bio/compat/references.rb +128 -0
- data/lib/bio/db/biosql/biosql_to_biosequence.rb +67 -0
- data/lib/bio/db/biosql/sequence.rb +508 -0
- data/lib/bio/db/embl/common.rb +28 -12
- data/lib/bio/db/embl/embl.rb +107 -9
- data/lib/bio/db/embl/embl_to_biosequence.rb +85 -0
- data/lib/bio/db/embl/format_embl.rb +190 -0
- data/lib/bio/db/embl/sptr.rb +15 -16
- data/lib/bio/db/fantom.rb +6 -8
- data/lib/bio/db/fasta.rb +10 -507
- data/lib/bio/db/fasta/defline.rb +532 -0
- data/lib/bio/db/fasta/fasta_to_biosequence.rb +63 -0
- data/lib/bio/db/fasta/format_fasta.rb +97 -0
- data/lib/bio/db/genbank/common.rb +25 -8
- data/lib/bio/db/genbank/format_genbank.rb +187 -0
- data/lib/bio/db/genbank/genbank.rb +36 -1
- data/lib/bio/db/genbank/genbank_to_biosequence.rb +86 -0
- data/lib/bio/db/gff.rb +1791 -119
- data/lib/bio/db/kegg/glycan.rb +2 -6
- data/lib/bio/db/lasergene.rb +3 -3
- data/lib/bio/db/medline.rb +4 -1
- data/lib/bio/db/newick.rb +10 -10
- data/lib/bio/db/pdb/chain.rb +6 -2
- data/lib/bio/db/pdb/pdb.rb +12 -3
- data/lib/bio/db/rebase.rb +7 -8
- data/lib/bio/db/soft.rb +3 -3
- data/lib/bio/feature.rb +1 -88
- data/lib/bio/io/biosql/biodatabase.rb +64 -0
- data/lib/bio/io/biosql/bioentry.rb +29 -0
- data/lib/bio/io/biosql/bioentry_dbxref.rb +11 -0
- data/lib/bio/io/biosql/bioentry_path.rb +12 -0
- data/lib/bio/io/biosql/bioentry_qualifier_value.rb +10 -0
- data/lib/bio/io/biosql/bioentry_reference.rb +10 -0
- data/lib/bio/io/biosql/bioentry_relationship.rb +10 -0
- data/lib/bio/io/biosql/biosequence.rb +11 -0
- data/lib/bio/io/biosql/comment.rb +7 -0
- data/lib/bio/io/biosql/config/database.yml +20 -0
- data/lib/bio/io/biosql/dbxref.rb +13 -0
- data/lib/bio/io/biosql/dbxref_qualifier_value.rb +12 -0
- data/lib/bio/io/biosql/location.rb +32 -0
- data/lib/bio/io/biosql/location_qualifier_value.rb +11 -0
- data/lib/bio/io/biosql/ontology.rb +10 -0
- data/lib/bio/io/biosql/reference.rb +9 -0
- data/lib/bio/io/biosql/seqfeature.rb +32 -0
- data/lib/bio/io/biosql/seqfeature_dbxref.rb +11 -0
- data/lib/bio/io/biosql/seqfeature_path.rb +11 -0
- data/lib/bio/io/biosql/seqfeature_qualifier_value.rb +20 -0
- data/lib/bio/io/biosql/seqfeature_relationship.rb +11 -0
- data/lib/bio/io/biosql/taxon.rb +12 -0
- data/lib/bio/io/biosql/taxon_name.rb +9 -0
- data/lib/bio/io/biosql/term.rb +27 -0
- data/lib/bio/io/biosql/term_dbxref.rb +11 -0
- data/lib/bio/io/biosql/term_path.rb +12 -0
- data/lib/bio/io/biosql/term_relationship.rb +13 -0
- data/lib/bio/io/biosql/term_relationship_term.rb +11 -0
- data/lib/bio/io/biosql/term_synonym.rb +10 -0
- data/lib/bio/io/das.rb +7 -7
- data/lib/bio/io/ddbjxml.rb +57 -0
- data/lib/bio/io/ensembl.rb +2 -2
- data/lib/bio/io/fetch.rb +28 -14
- data/lib/bio/io/flatfile.rb +17 -853
- data/lib/bio/io/flatfile/autodetection.rb +545 -0
- data/lib/bio/io/flatfile/buffer.rb +237 -0
- data/lib/bio/io/flatfile/index.rb +17 -7
- data/lib/bio/io/flatfile/indexer.rb +30 -12
- data/lib/bio/io/flatfile/splitter.rb +297 -0
- data/lib/bio/io/hinv.rb +442 -0
- data/lib/bio/io/keggapi.rb +2 -2
- data/lib/bio/io/ncbirest.rb +733 -0
- data/lib/bio/io/pubmed.rb +34 -80
- data/lib/bio/io/registry.rb +2 -2
- data/lib/bio/io/sql.rb +178 -357
- data/lib/bio/io/togows.rb +458 -0
- data/lib/bio/location.rb +106 -11
- data/lib/bio/pathway.rb +120 -14
- data/lib/bio/reference.rb +115 -101
- data/lib/bio/sequence.rb +164 -183
- data/lib/bio/sequence/adapter.rb +108 -0
- data/lib/bio/sequence/common.rb +22 -45
- data/lib/bio/sequence/compat.rb +2 -2
- data/lib/bio/sequence/dblink.rb +54 -0
- data/lib/bio/sequence/format.rb +254 -77
- data/lib/bio/sequence/format_raw.rb +23 -0
- data/lib/bio/shell.rb +3 -1
- data/lib/bio/shell/core.rb +2 -2
- data/lib/bio/shell/plugin/entry.rb +33 -4
- data/lib/bio/shell/plugin/ncbirest.rb +64 -0
- data/lib/bio/shell/plugin/togows.rb +40 -0
- data/lib/bio/shell/rails/vendor/plugins/{generators → bioruby/generators}/bioruby/bioruby_generator.rb +0 -0
- data/lib/bio/shell/rails/vendor/plugins/{generators → bioruby/generators}/bioruby/templates/_classes.rhtml +0 -0
- data/lib/bio/shell/rails/vendor/plugins/{generators → bioruby/generators}/bioruby/templates/_log.rhtml +0 -0
- data/lib/bio/shell/rails/vendor/plugins/{generators → bioruby/generators}/bioruby/templates/_methods.rhtml +0 -0
- data/lib/bio/shell/rails/vendor/plugins/{generators → bioruby/generators}/bioruby/templates/_modules.rhtml +0 -0
- data/lib/bio/shell/rails/vendor/plugins/{generators → bioruby/generators}/bioruby/templates/_variables.rhtml +0 -0
- data/lib/bio/shell/rails/vendor/plugins/{generators → bioruby/generators}/bioruby/templates/bioruby-bg.gif +0 -0
- data/lib/bio/shell/rails/vendor/plugins/{generators → bioruby/generators}/bioruby/templates/bioruby-gem.png +0 -0
- data/lib/bio/shell/rails/vendor/plugins/{generators → bioruby/generators}/bioruby/templates/bioruby-link.gif +0 -0
- data/lib/bio/shell/rails/vendor/plugins/{generators → bioruby/generators}/bioruby/templates/bioruby.css +0 -0
- data/lib/bio/shell/rails/vendor/plugins/{generators → bioruby/generators}/bioruby/templates/bioruby.rhtml +0 -0
- data/lib/bio/shell/rails/vendor/plugins/{generators → bioruby/generators}/bioruby/templates/bioruby_controller.rb +0 -0
- data/lib/bio/shell/rails/vendor/plugins/{generators → bioruby/generators}/bioruby/templates/bioruby_helper.rb +0 -0
- data/lib/bio/shell/rails/vendor/plugins/{generators → bioruby/generators}/bioruby/templates/commands.rhtml +0 -0
- data/lib/bio/shell/rails/vendor/plugins/{generators → bioruby/generators}/bioruby/templates/history.rhtml +0 -0
- data/lib/bio/shell/rails/vendor/plugins/{generators → bioruby/generators}/bioruby/templates/index.rhtml +0 -0
- data/lib/bio/shell/rails/vendor/plugins/{generators → bioruby/generators}/bioruby/templates/spinner.gif +0 -0
- data/lib/bio/tree.rb +4 -2
- data/lib/bio/util/color_scheme.rb +2 -2
- data/lib/bio/util/contingency_table.rb +2 -2
- data/lib/bio/util/restriction_enzyme.rb +2 -2
- data/lib/bio/util/restriction_enzyme/single_strand.rb +6 -5
- data/lib/bio/version.rb +25 -0
- data/rdoc.zsh +8 -0
- data/sample/any2fasta.rb +0 -0
- data/sample/biofetch.rb +0 -0
- data/sample/dbget +0 -0
- data/sample/demo_sequence.rb +158 -0
- data/sample/enzymes.rb +0 -0
- data/sample/fasta2tab.rb +0 -0
- data/sample/fastagrep.rb +72 -0
- data/sample/fastasort.rb +54 -0
- data/sample/fsplit.rb +0 -0
- data/sample/gb2fasta.rb +2 -3
- data/sample/gb2tab.rb +0 -0
- data/sample/gbtab2mysql.rb +0 -0
- data/sample/genes2nuc.rb +0 -0
- data/sample/genes2pep.rb +0 -0
- data/sample/genes2tab.rb +0 -0
- data/sample/genome2rb.rb +0 -0
- data/sample/genome2tab.rb +0 -0
- data/sample/goslim.rb +0 -0
- data/sample/gt2fasta.rb +0 -0
- data/sample/na2aa.rb +34 -0
- data/sample/pmfetch.rb +0 -0
- data/sample/pmsearch.rb +0 -0
- data/sample/ssearch2tab.rb +0 -0
- data/sample/tfastx2tab.rb +0 -0
- data/sample/vs-genes.rb +0 -0
- data/setup.rb +1596 -0
- data/test/data/blast/blastp-multi.m7 +188 -0
- data/test/data/command/echoarg2.bat +1 -0
- data/test/data/paml/codeml/control_file.txt +30 -0
- data/test/data/paml/codeml/output.txt +78 -0
- data/test/data/paml/codeml/rates +217 -0
- data/test/data/rpsblast/misc.rpsblast +193 -0
- data/test/data/soft/GDS100_partial.soft +0 -0
- data/test/data/soft/GSE3457_family_partial.soft +0 -0
- data/test/functional/bio/appl/test_pts1.rb +115 -0
- data/test/functional/bio/io/test_ensembl.rb +123 -80
- data/test/functional/bio/io/test_togows.rb +267 -0
- data/test/functional/bio/sequence/test_output_embl.rb +51 -0
- data/test/functional/bio/test_command.rb +301 -0
- data/test/runner.rb +17 -1
- data/test/unit/bio/appl/blast/test_ncbioptions.rb +112 -0
- data/test/unit/bio/appl/blast/test_report.rb +753 -35
- data/test/unit/bio/appl/blast/test_rpsblast.rb +398 -0
- data/test/unit/bio/appl/paml/codeml/test_rates.rb +45 -0
- data/test/unit/bio/appl/paml/codeml/test_report.rb +45 -0
- data/test/unit/bio/appl/paml/test_codeml.rb +174 -0
- data/test/unit/bio/appl/test_blast.rb +135 -4
- data/test/unit/bio/appl/test_fasta.rb +2 -2
- data/test/unit/bio/appl/test_pts1.rb +1 -64
- data/test/unit/bio/db/embl/test_common.rb +15 -15
- data/test/unit/bio/db/embl/test_embl.rb +4 -4
- data/test/unit/bio/db/embl/test_embl_rel89.rb +5 -5
- data/test/unit/bio/db/embl/test_embl_to_bioseq.rb +203 -0
- data/test/unit/bio/db/embl/test_sptr.rb +38 -1
- data/test/unit/bio/db/pdb/test_pdb.rb +2 -2
- data/test/unit/bio/db/test_gff.rb +1151 -25
- data/test/unit/bio/db/test_medline.rb +127 -0
- data/test/unit/bio/db/test_nexus.rb +5 -1
- data/test/unit/bio/db/test_prosite.rb +4 -4
- data/test/unit/bio/io/flatfile/test_autodetection.rb +375 -0
- data/test/unit/bio/io/flatfile/test_buffer.rb +251 -0
- data/test/unit/bio/io/flatfile/test_splitter.rb +369 -0
- data/test/unit/bio/io/test_ddbjxml.rb +8 -3
- data/test/unit/bio/io/test_fastacmd.rb +5 -5
- data/test/unit/bio/io/test_flatfile.rb +357 -106
- data/test/unit/bio/io/test_soapwsdl.rb +2 -2
- data/test/unit/bio/io/test_togows.rb +161 -0
- data/test/unit/bio/sequence/test_common.rb +210 -11
- data/test/unit/bio/sequence/test_compat.rb +3 -3
- data/test/unit/bio/sequence/test_dblink.rb +58 -0
- data/test/unit/bio/sequence/test_na.rb +2 -2
- data/test/unit/bio/test_command.rb +111 -50
- data/test/unit/bio/test_feature.rb +29 -1
- data/test/unit/bio/test_location.rb +566 -6
- data/test/unit/bio/test_pathway.rb +91 -65
- data/test/unit/bio/test_reference.rb +67 -13
- data/test/unit/bio/util/restriction_enzyme/analysis/test_calculated_cuts.rb +3 -3
- data/test/unit/bio/util/restriction_enzyme/analysis/test_cut_ranges.rb +3 -3
- data/test/unit/bio/util/restriction_enzyme/analysis/test_sequence_range.rb +3 -3
- data/test/unit/bio/util/restriction_enzyme/double_stranded/test_aligned_strands.rb +4 -3
- data/test/unit/bio/util/restriction_enzyme/double_stranded/test_cut_location_pair.rb +3 -3
- data/test/unit/bio/util/restriction_enzyme/double_stranded/test_cut_location_pair_in_enzyme_notation.rb +3 -3
- data/test/unit/bio/util/restriction_enzyme/double_stranded/test_cut_locations.rb +3 -3
- data/test/unit/bio/util/restriction_enzyme/double_stranded/test_cut_locations_in_enzyme_notation.rb +3 -3
- data/test/unit/bio/util/restriction_enzyme/single_strand/test_cut_locations_in_enzyme_notation.rb +3 -3
- data/test/unit/bio/util/restriction_enzyme/test_analysis.rb +3 -3
- data/test/unit/bio/util/restriction_enzyme/test_cut_symbol.rb +4 -4
- data/test/unit/bio/util/restriction_enzyme/test_double_stranded.rb +3 -3
- data/test/unit/bio/util/restriction_enzyme/test_single_strand.rb +3 -3
- data/test/unit/bio/util/restriction_enzyme/test_single_strand_complement.rb +3 -3
- data/test/unit/bio/util/restriction_enzyme/test_string_formatting.rb +3 -3
- data/test/unit/bio/util/test_restriction_enzyme.rb +3 -3
- metadata +202 -167
- data/test/unit/bio/appl/blast/test_xmlparser.rb +0 -388
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
# Copytight:: Copyright (C) 2005 Mitsuteru Nakao <n@bioruby.org>
|
|
5
5
|
# License:: The Ruby License
|
|
6
6
|
#
|
|
7
|
-
# $Id
|
|
7
|
+
# $Id:$
|
|
8
8
|
#
|
|
9
9
|
|
|
10
10
|
require 'pathname'
|
|
@@ -25,7 +25,7 @@ class TestSOAPWSDL < Test::Unit::TestCase
|
|
|
25
25
|
|
|
26
26
|
def test_methods
|
|
27
27
|
methods = ['list_methods','wsdl', 'wsdl=', 'log', 'log=']
|
|
28
|
-
assert_equal(methods.sort, (@obj.instance_methods - Object.methods).sort)
|
|
28
|
+
assert_equal(methods.sort, (@obj.instance_methods - Object.methods).sort.collect { |x| x.to_s })
|
|
29
29
|
end
|
|
30
30
|
|
|
31
31
|
end
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
#
|
|
2
|
+
# test/unit/bio/io/test_togows.rb - Unit test for Bio::TogoWS
|
|
3
|
+
#
|
|
4
|
+
# Copyright:: Copyright (C) 2009
|
|
5
|
+
# Naohisa Goto <ng@bioruby.org>
|
|
6
|
+
# License:: The Ruby License
|
|
7
|
+
#
|
|
8
|
+
# $Id:$
|
|
9
|
+
#
|
|
10
|
+
|
|
11
|
+
require 'pathname'
|
|
12
|
+
libpath = Pathname.new(File.join(File.dirname(__FILE__), ['..'] * 4, 'lib')).cleanpath.to_s
|
|
13
|
+
$:.unshift(libpath) unless $:.include?(libpath)
|
|
14
|
+
|
|
15
|
+
require 'uri'
|
|
16
|
+
require 'net/http'
|
|
17
|
+
require 'bio/version'
|
|
18
|
+
require 'bio/io/togows'
|
|
19
|
+
require 'test/unit'
|
|
20
|
+
|
|
21
|
+
module Bio
|
|
22
|
+
|
|
23
|
+
# unit test for Bio::TogoWS::REST
|
|
24
|
+
class TestTogoWSREST < Test::Unit::TestCase
|
|
25
|
+
|
|
26
|
+
def setup
|
|
27
|
+
@togows = Bio::TogoWS::REST.new
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def test_debug_default
|
|
31
|
+
assert_equal(false, @togows.debug)
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def test_debug
|
|
35
|
+
assert_equal(true, @togows.debug = true)
|
|
36
|
+
assert_equal(true, @togows.debug)
|
|
37
|
+
assert_equal(false, @togows.debug = false)
|
|
38
|
+
assert_equal(false, @togows.debug)
|
|
39
|
+
assert_equal(true, @togows.debug = true)
|
|
40
|
+
assert_equal(true, @togows.debug)
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def test_internal_http
|
|
44
|
+
assert_kind_of(Net::HTTP, @togows.internal_http)
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
end #class TestTogoWSREST
|
|
48
|
+
|
|
49
|
+
# unit test for Bio::TogoWS::REST private methods
|
|
50
|
+
class TestTogoWSRESTprivate < Test::Unit::TestCase
|
|
51
|
+
|
|
52
|
+
def setup
|
|
53
|
+
@togows = Bio::TogoWS::REST.new
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
def test_make_path
|
|
57
|
+
a_and_q = {
|
|
58
|
+
'/ab/cde/fghi' => [ 'ab', 'cde', 'fghi' ],
|
|
59
|
+
'/a+b/a%2Bb/a%2Fb/a%26b/a%3Bb/a%2Cb/a%3Bb' =>
|
|
60
|
+
[ 'a b', 'a+b', 'a/b', 'a&b', 'a;b', 'a,b', 'a;b' ]
|
|
61
|
+
}
|
|
62
|
+
count = 0
|
|
63
|
+
a_and_q.each do |k,v|
|
|
64
|
+
assert_equal(k, @togows.instance_eval { make_path(v) })
|
|
65
|
+
count += 1
|
|
66
|
+
end
|
|
67
|
+
assert_equal(a_and_q.size, count)
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
def test_prepare_return_value
|
|
71
|
+
dummyclass = Struct.new(:code, :body)
|
|
72
|
+
dummy200 = dummyclass.new("200", "this is test")
|
|
73
|
+
assert_equal("this is test",
|
|
74
|
+
@togows.instance_eval { prepare_return_value(dummy200) })
|
|
75
|
+
dummy404 = dummyclass.new("404", "not found")
|
|
76
|
+
assert_equal(nil,
|
|
77
|
+
@togows.instance_eval { prepare_return_value(dummy404) })
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
end #class TestTogoWSRESTprivate
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
# unit test for Bio::TogoWS::REST class methods
|
|
84
|
+
class TestTogoWSRESTclassMethod < Test::Unit::TestCase
|
|
85
|
+
|
|
86
|
+
def test_new
|
|
87
|
+
assert_instance_of(Bio::TogoWS::REST, Bio::TogoWS::REST.new)
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
def test_new_with_uri_string
|
|
91
|
+
t = Bio::TogoWS::REST.new('http://localhost:1234/test')
|
|
92
|
+
assert_instance_of(Bio::TogoWS::REST, t)
|
|
93
|
+
http = t.internal_http
|
|
94
|
+
assert_equal('localhost', http.address)
|
|
95
|
+
assert_equal(1234, http.port)
|
|
96
|
+
assert_equal('/test/', t.instance_eval { @pathbase })
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
def test_new_with_uri_object
|
|
100
|
+
u = URI.parse('http://localhost:1234/test')
|
|
101
|
+
t = Bio::TogoWS::REST.new(u)
|
|
102
|
+
assert_instance_of(Bio::TogoWS::REST, t)
|
|
103
|
+
http = t.internal_http
|
|
104
|
+
assert_equal('localhost', http.address)
|
|
105
|
+
assert_equal(1234, http.port)
|
|
106
|
+
assert_equal('/test/', t.instance_eval { @pathbase })
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
def test_entry
|
|
110
|
+
assert_respond_to(Bio::TogoWS::REST, :entry)
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
def test_search
|
|
114
|
+
assert_respond_to(Bio::TogoWS::REST, :search)
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
def test_convert
|
|
118
|
+
assert_respond_to(Bio::TogoWS::REST, :convert)
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
def test_retrieve
|
|
122
|
+
assert_respond_to(Bio::TogoWS::REST, :retrieve)
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
def test_entry_database_list
|
|
126
|
+
assert_respond_to(Bio::TogoWS::REST, :entry_database_list)
|
|
127
|
+
end
|
|
128
|
+
|
|
129
|
+
def test_search_database_list
|
|
130
|
+
assert_respond_to(Bio::TogoWS::REST, :search_database_list)
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
end #class TestTogoWSRESTclassMethod
|
|
134
|
+
|
|
135
|
+
# dummy class for testing Bio::TogoWS::AccessWait
|
|
136
|
+
class DummyAccessWait
|
|
137
|
+
include Bio::TogoWS::AccessWait
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
# unit test for Bio::TogoWS::AccessWait (all methods are private)
|
|
141
|
+
class TestTogoWSAccessWait < Test::Unit::TestCase
|
|
142
|
+
def setup
|
|
143
|
+
@obj = DummyAccessWait.new
|
|
144
|
+
end
|
|
145
|
+
|
|
146
|
+
def test_togows_access_wait
|
|
147
|
+
assert_kind_of(Numeric, @obj.instance_eval { togows_access_wait })
|
|
148
|
+
|
|
149
|
+
waits = 0
|
|
150
|
+
2.times { waits += @obj.instance_eval { togows_access_wait } }
|
|
151
|
+
assert(waits > 0)
|
|
152
|
+
end
|
|
153
|
+
|
|
154
|
+
def test_reset_togows_access_wait
|
|
155
|
+
assert_nothing_raised {
|
|
156
|
+
@obj.instance_eval { reset_togows_access_wait }
|
|
157
|
+
}
|
|
158
|
+
end
|
|
159
|
+
end #class TestTogoWSAccessWait
|
|
160
|
+
|
|
161
|
+
end #module Bio
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
#
|
|
2
2
|
# test/unit/bio/sequence/test_common.rb - Unit test for Bio::Sequencce::Common
|
|
3
3
|
#
|
|
4
|
-
# Copyright:: Copyright (C) 2006
|
|
4
|
+
# Copyright:: Copyright (C) 2006-2008
|
|
5
|
+
# Mitsuteru C. Nakao <n@bioruby.org>,
|
|
6
|
+
# Naohisa Goto <ng@bioruby.org>
|
|
5
7
|
# License:: The Ruby License
|
|
6
8
|
#
|
|
7
|
-
# $Id
|
|
9
|
+
# $Id:$
|
|
8
10
|
#
|
|
9
11
|
|
|
10
12
|
require 'pathname'
|
|
@@ -15,7 +17,7 @@ require 'test/unit'
|
|
|
15
17
|
require 'bio/sequence'
|
|
16
18
|
require 'bio/sequence/common'
|
|
17
19
|
|
|
18
|
-
module Bio
|
|
20
|
+
module Bio; module TestSequenceCommon
|
|
19
21
|
|
|
20
22
|
class TSequence < String
|
|
21
23
|
include Bio::Sequence::Common
|
|
@@ -86,13 +88,13 @@ module Bio
|
|
|
86
88
|
class TestSequenceCommonNormalize < Test::Unit::TestCase
|
|
87
89
|
def test_no_normalize
|
|
88
90
|
str = "atgcatgcatgcatgcaaaA"
|
|
89
|
-
obj =
|
|
91
|
+
obj = TSequence.new(str)
|
|
90
92
|
assert_equal("atgcatgcatgcatgcaaaA", obj)
|
|
91
93
|
end
|
|
92
94
|
|
|
93
95
|
def test_normalize_A
|
|
94
96
|
str = "atgcatgcatgcatgcaaaA"
|
|
95
|
-
seq =
|
|
97
|
+
seq = TSequence.new(str)
|
|
96
98
|
assert_equal("atgcatgcatgcatgcaaaA", seq)
|
|
97
99
|
obj = seq.normalize!
|
|
98
100
|
assert_equal("atgcatgcatgcatgcaaaA", obj)
|
|
@@ -100,7 +102,7 @@ module Bio
|
|
|
100
102
|
|
|
101
103
|
def test_normalize_a
|
|
102
104
|
str = "atgcatgcatgcatgcaaa"
|
|
103
|
-
seq =
|
|
105
|
+
seq = TSequence.new(str)
|
|
104
106
|
assert_equal("atgcatgcatgcatgcaaa", seq)
|
|
105
107
|
obj = seq.normalize!
|
|
106
108
|
assert_equal("atgcatgcatgcatgcaaa", obj)
|
|
@@ -108,16 +110,213 @@ module Bio
|
|
|
108
110
|
end
|
|
109
111
|
|
|
110
112
|
|
|
111
|
-
class
|
|
113
|
+
class TestSequenceCommonRandomize < Test::Unit::TestCase
|
|
112
114
|
|
|
113
|
-
def
|
|
114
|
-
|
|
115
|
+
def setup
|
|
116
|
+
@str = "attcacgcctgctattcccgtcagcctgagcttgccgcgaagctgatgaaagatgttatc"
|
|
117
|
+
@seq = TSequence.new(@str)
|
|
118
|
+
@orig = TSequence.new(@str)
|
|
115
119
|
end
|
|
116
120
|
|
|
121
|
+
# test for Bio::Sequence::Common#randomize(hash = nil)
|
|
117
122
|
def test_randomize
|
|
118
|
-
|
|
123
|
+
rseqs = (0..2).collect { |i| @seq.randomize }
|
|
124
|
+
|
|
125
|
+
# not breaking given seq?
|
|
126
|
+
assert_equal(@orig, @seq)
|
|
127
|
+
|
|
128
|
+
# same length?
|
|
129
|
+
rseqs.each do |rseq|
|
|
130
|
+
assert_equal(@orig.length, rseq.length)
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
# same composition?
|
|
134
|
+
[ 'a', 'c', 'g', 't', 'n' ].each do |chr|
|
|
135
|
+
count = @orig.count(chr)
|
|
136
|
+
rseqs.each do |rseq|
|
|
137
|
+
assert_equal(count, rseq.count(chr))
|
|
138
|
+
end
|
|
139
|
+
end
|
|
140
|
+
|
|
141
|
+
# randomized? (very simple check)
|
|
142
|
+
assert(rseqs[0] != rseqs[1])
|
|
143
|
+
assert(rseqs[0] != rseqs[2])
|
|
144
|
+
assert(rseqs[1] != rseqs[2])
|
|
145
|
+
end
|
|
146
|
+
|
|
147
|
+
# testing Bio::Sequence::Common#randomize() { |x| ... }
|
|
148
|
+
def test_randomize_with_block
|
|
149
|
+
composition = Hash.new(0)
|
|
150
|
+
[ 'a', 'c', 'g', 't' ].each do |chr|
|
|
151
|
+
composition[chr] = @seq.count(chr)
|
|
152
|
+
end
|
|
153
|
+
|
|
154
|
+
rseqs = (0..2).collect do |i|
|
|
155
|
+
newcomposition = Hash.new(0)
|
|
156
|
+
newseq = ''
|
|
157
|
+
ret = @seq.randomize do |c|
|
|
158
|
+
assert_kind_of(TSequence, c)
|
|
159
|
+
newcomposition[c] += 1
|
|
160
|
+
newseq.concat c
|
|
161
|
+
end
|
|
162
|
+
# same length?
|
|
163
|
+
assert_equal(@orig.length, newseq.length)
|
|
164
|
+
# same composition?
|
|
165
|
+
assert_equal(composition, newcomposition)
|
|
166
|
+
# returned value is empty sequence?
|
|
167
|
+
assert_equal(TSequence.new(''), ret)
|
|
168
|
+
# not breaking given seq?
|
|
169
|
+
assert_equal(@orig, @seq)
|
|
170
|
+
newseq
|
|
171
|
+
end
|
|
172
|
+
|
|
173
|
+
# randomized? (very simple check)
|
|
174
|
+
assert(rseqs[0] != rseqs[1])
|
|
175
|
+
assert(rseqs[0] != rseqs[2])
|
|
176
|
+
assert(rseqs[1] != rseqs[2])
|
|
177
|
+
end
|
|
178
|
+
|
|
179
|
+
# testing Bio::Sequence::Common#randomize(hash)
|
|
180
|
+
def test_randomize_with_hash
|
|
181
|
+
hash = { 'a' => 20, 'c' => 19, 'g' => 18, 't' => 17 }
|
|
182
|
+
hash.default = 0
|
|
183
|
+
len = 0
|
|
184
|
+
hash.each_value { |v| len += v }
|
|
185
|
+
|
|
186
|
+
rseqs = (0..2).collect do |i|
|
|
187
|
+
rseq = @seq.randomize(hash)
|
|
188
|
+
# same length?
|
|
189
|
+
assert_equal(len, rseq.length)
|
|
190
|
+
# same composition?
|
|
191
|
+
[ 'a', 'c', 'g', 't', 'n' ].each do |chr|
|
|
192
|
+
assert_equal(hash[chr], rseq.count(chr))
|
|
193
|
+
end
|
|
194
|
+
# returned value is instance of TSequence?
|
|
195
|
+
assert_instance_of(TSequence, rseq)
|
|
196
|
+
# not breaking given seq?
|
|
197
|
+
assert_equal(@orig, @seq)
|
|
198
|
+
rseq
|
|
199
|
+
end
|
|
200
|
+
|
|
201
|
+
# randomized? (very simple check)
|
|
202
|
+
assert(rseqs[0] != rseqs[1])
|
|
203
|
+
assert(rseqs[0] != rseqs[2])
|
|
204
|
+
assert(rseqs[1] != rseqs[2])
|
|
119
205
|
end
|
|
120
206
|
|
|
207
|
+
# testing Bio::Sequence::Common#randomize(hash) { |x| ... }
|
|
208
|
+
def test_randomize_with_hash_block
|
|
209
|
+
hash = { 'a' => 20, 'c' => 19, 'g' => 18, 't' => 17 }
|
|
210
|
+
hash.default = 0
|
|
211
|
+
len = 0
|
|
212
|
+
hash.each_value { |v| len += v }
|
|
213
|
+
|
|
214
|
+
rseqs = (0..2).collect do |i|
|
|
215
|
+
newcomposition = Hash.new(0)
|
|
216
|
+
newseq = ''
|
|
217
|
+
ret = @seq.randomize(hash) do |c|
|
|
218
|
+
#assert_kind_of(TSequence, c)
|
|
219
|
+
assert_kind_of(String, c)
|
|
220
|
+
newcomposition[c] += 1
|
|
221
|
+
newseq.concat c
|
|
222
|
+
end
|
|
223
|
+
# same length?
|
|
224
|
+
assert_equal(len, newseq.length)
|
|
225
|
+
# same composition?
|
|
226
|
+
assert_equal(hash, newcomposition)
|
|
227
|
+
# returned value is empty TSequence?
|
|
228
|
+
assert_equal(TSequence.new(''), ret)
|
|
229
|
+
# not breaking given seq?
|
|
230
|
+
assert_equal(@orig, @seq)
|
|
231
|
+
newseq
|
|
232
|
+
end
|
|
233
|
+
|
|
234
|
+
# randomized? (very simple check)
|
|
235
|
+
assert(rseqs[0] != rseqs[1])
|
|
236
|
+
assert(rseqs[0] != rseqs[2])
|
|
237
|
+
assert(rseqs[1] != rseqs[2])
|
|
238
|
+
end
|
|
239
|
+
|
|
240
|
+
def chi2(hist, f, k)
|
|
241
|
+
chi2 = 0
|
|
242
|
+
(0...k).each do |i|
|
|
243
|
+
chi2 += ((hist[i] - f) ** 2).quo(f)
|
|
244
|
+
end
|
|
245
|
+
chi2
|
|
246
|
+
end
|
|
247
|
+
private :chi2
|
|
248
|
+
|
|
249
|
+
# chi-square test for distribution of chi2 values from
|
|
250
|
+
# distribution of index('a')
|
|
251
|
+
def randomize_equiprobability
|
|
252
|
+
# Reference: http://www.geocities.jp/m_hiroi/light/pystat04.html
|
|
253
|
+
seq = TSequence.new('ccccgggtta') # length must be 10
|
|
254
|
+
k = 10
|
|
255
|
+
hist = Array.new(k, 0)
|
|
256
|
+
iter = 200
|
|
257
|
+
# F for index('a')
|
|
258
|
+
f = iter.quo(seq.length).to_f
|
|
259
|
+
|
|
260
|
+
# chi2 distribution, degree of freedom 9
|
|
261
|
+
# Reference: http://www.geocities.jp/m_hiroi/light/pystat04.html
|
|
262
|
+
# Reference: http://keisan.casio.jp/has10/SpecExec.cgi
|
|
263
|
+
# P = 0.9, 0.8, 0.7, ... 0.1, 0
|
|
264
|
+
chi2_table = [ 14.684, 12.242, 10.656, 9.414, 8.343,
|
|
265
|
+
7.357, 6.393, 5.380, 4.168, 0.000 ]
|
|
266
|
+
|
|
267
|
+
chi2_hist = Array.new(k, 0)
|
|
268
|
+
chi2_iter = 200
|
|
269
|
+
chi2_iter.times do
|
|
270
|
+
hist.fill(0)
|
|
271
|
+
iter.times { hist[yield(seq).index('a')] += 1 }
|
|
272
|
+
chi2 = chi2(hist, f, k)
|
|
273
|
+
idx = (0...(chi2_table.size)).find { |i| chi2 >= chi2_table[i] }
|
|
274
|
+
chi2_hist[idx] += 1
|
|
275
|
+
end
|
|
276
|
+
|
|
277
|
+
chi2_f = chi2_iter.quo(k).to_f
|
|
278
|
+
chi2_chi2 = chi2(chi2_hist, chi2_f, k)
|
|
279
|
+
#$stderr.puts chi2_chi2
|
|
280
|
+
|
|
281
|
+
## chi-square test, freedom 9, significance level 5%
|
|
282
|
+
#assert_operator(16.919, :>, chi2_chi2, "test of chi2 < 16.919 failed (#{chi2_chi2})")
|
|
283
|
+
# chi-square test, freedom 9, significance level 1%
|
|
284
|
+
assert_operator(21.666, :>, chi2_chi2, "test of chi2 < 21.666 failed (#{chi2_chi2})")
|
|
285
|
+
end
|
|
286
|
+
private :randomize_equiprobability
|
|
287
|
+
|
|
288
|
+
def test_randomize_equiprobability
|
|
289
|
+
randomize_equiprobability { |seq| seq.randomize }
|
|
290
|
+
end
|
|
291
|
+
|
|
292
|
+
def test_randomize_with_hash_equiprobability
|
|
293
|
+
hash = { 'c' => 4, 'g' => 3, 't' => 2, 'a' => 1 }
|
|
294
|
+
randomize_equiprobability { |seq| seq.randomize(hash) }
|
|
295
|
+
end
|
|
296
|
+
|
|
297
|
+
## disabled because it takes too long time.
|
|
298
|
+
#def test_randomize_with_block_equiprobability
|
|
299
|
+
# randomize_equiprobability do |seq|
|
|
300
|
+
# newseq = ''
|
|
301
|
+
# seq.randomize do |c|
|
|
302
|
+
# newseq.concat c
|
|
303
|
+
# end
|
|
304
|
+
# newseq
|
|
305
|
+
# end
|
|
306
|
+
#end
|
|
307
|
+
|
|
308
|
+
## disabled because it takes too long time.
|
|
309
|
+
#def test_randomize_with_hash_block_equiprobability
|
|
310
|
+
# hash = { 'c' => 4, 'g' => 3, 't' => 2, 'a' => 1 }
|
|
311
|
+
# randomize_equiprobability do |seq|
|
|
312
|
+
# newseq = ''
|
|
313
|
+
# seq.randomize(hash) do |c|
|
|
314
|
+
# newseq.concat c
|
|
315
|
+
# end
|
|
316
|
+
# newseq
|
|
317
|
+
# end
|
|
318
|
+
#end
|
|
319
|
+
|
|
121
320
|
end
|
|
122
321
|
|
|
123
322
|
|
|
@@ -171,4 +370,4 @@ module Bio
|
|
|
171
370
|
|
|
172
371
|
end
|
|
173
372
|
|
|
174
|
-
end
|
|
373
|
+
end; end #module Bio; module TestSequenceCommon
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
# Copyright:: Copyright (C) 2006 Mitsuteru C. Nakao <n@bioruby.org>
|
|
5
5
|
# License:: The Ruby License
|
|
6
6
|
#
|
|
7
|
-
# $Id
|
|
7
|
+
# $Id:$
|
|
8
8
|
#
|
|
9
9
|
|
|
10
10
|
require 'pathname'
|
|
@@ -15,7 +15,7 @@ require 'test/unit'
|
|
|
15
15
|
require 'bio/sequence'
|
|
16
16
|
require 'bio/sequence/compat'
|
|
17
17
|
|
|
18
|
-
module Bio
|
|
18
|
+
module Bio; module TestSequenceCompat
|
|
19
19
|
|
|
20
20
|
class TSequence < String
|
|
21
21
|
include Bio::Sequence::Common
|
|
@@ -66,4 +66,4 @@ module Bio
|
|
|
66
66
|
end
|
|
67
67
|
end
|
|
68
68
|
|
|
69
|
-
end
|
|
69
|
+
end; end #module Bio; module TestSequenceCompat
|