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
|
# Copyright:: 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'
|
|
@@ -21,8 +21,9 @@ class TestDDBJXMLConstants < Test::Unit::TestCase
|
|
|
21
21
|
|
|
22
22
|
def test_constants
|
|
23
23
|
constants = ["DDBJ", "TxSearch", "ClustalW", "PML", "Gib", "Fasta",
|
|
24
|
-
"BASE_URI", "SRS", "SERVER_URI", "Gtop", "GetEntry",
|
|
25
|
-
|
|
24
|
+
"BASE_URI", "SRS", "SERVER_URI", "Gtop", "GetEntry",
|
|
25
|
+
"Blast", "RequestManager"].sort
|
|
26
|
+
assert_equal(constants, Bio::DDBJ::XML.constants.sort.collect{|x| x.to_s})
|
|
26
27
|
end
|
|
27
28
|
|
|
28
29
|
def test_base_url
|
|
@@ -69,6 +70,10 @@ class TestDDBJXMLConstants < Test::Unit::TestCase
|
|
|
69
70
|
assert_equal("http://xml.nig.ac.jp/wsdl/TxSearch.wsdl", Bio::DDBJ::XML::TxSearch::SERVER_URI)
|
|
70
71
|
end
|
|
71
72
|
|
|
73
|
+
def test_requestmanager_server_url
|
|
74
|
+
assert_equal("http://xml.nig.ac.jp/wsdl/RequestManager.wsdl", Bio::DDBJ::XML::RequestManager::SERVER_URI)
|
|
75
|
+
end
|
|
76
|
+
|
|
72
77
|
end
|
|
73
78
|
|
|
74
79
|
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
# Copyright:: Copyright (C) 2006 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'
|
|
@@ -20,11 +20,11 @@ module Bio
|
|
|
20
20
|
class TestFastacmd < Test::Unit::TestCase
|
|
21
21
|
|
|
22
22
|
def setup
|
|
23
|
-
@obj = Bio::Blast::Fastacmd.new(
|
|
23
|
+
@obj = Bio::Blast::Fastacmd.new('/dev/null')
|
|
24
24
|
end
|
|
25
25
|
|
|
26
26
|
def test_database
|
|
27
|
-
assert_equal(
|
|
27
|
+
assert_equal('/dev/null', @obj.database)
|
|
28
28
|
end
|
|
29
29
|
|
|
30
30
|
def test_fastacmd
|
|
@@ -32,9 +32,9 @@ class TestFastacmd < Test::Unit::TestCase
|
|
|
32
32
|
end
|
|
33
33
|
|
|
34
34
|
def test_methods
|
|
35
|
-
method_list = [
|
|
35
|
+
method_list = [ :get_by_id, :fetch, :each_entry, :each ]
|
|
36
36
|
method_list.each do |method|
|
|
37
|
-
assert(@obj.
|
|
37
|
+
assert(@obj.respond_to?(method))
|
|
38
38
|
end
|
|
39
39
|
end
|
|
40
40
|
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
#
|
|
10
10
|
|
|
11
11
|
require 'pathname'
|
|
12
|
-
libpath = Pathname.new(File.join(File.dirname(__FILE__), ['..'] *
|
|
12
|
+
libpath = Pathname.new(File.join(File.dirname(__FILE__), ['..'] * 4, 'lib')).cleanpath.to_s
|
|
13
13
|
$:.unshift(libpath) unless $:.include?(libpath)
|
|
14
14
|
|
|
15
15
|
require 'test/unit'
|
|
@@ -23,159 +23,410 @@ module TestFlatFile
|
|
|
23
23
|
|
|
24
24
|
bioruby_root = Pathname.new(File.join(File.dirname(__FILE__), ['..'] * 4)).cleanpath.to_s
|
|
25
25
|
TestDataPath = Pathname.new(File.join(bioruby_root, 'test', 'data')).cleanpath.to_s
|
|
26
|
-
|
|
26
|
+
TestData01 = File.join(TestDataPath, 'fasta', 'example1.txt')
|
|
27
|
+
|
|
28
|
+
TestData01Ent1def =
|
|
29
|
+
"At1g02580 mRNA (2291 bp) UTR's and CDS"
|
|
30
|
+
TestData01Ent4def =
|
|
31
|
+
'At1g65300: mRNA 837bp (shortened from start)'
|
|
32
|
+
TestData01Ent4naseq = Bio::Sequence::NA.new <<__END_OF_SEQ__
|
|
33
|
+
ttcatctttacctcttcctattgttgcgaatgcagctgcaccagtcg
|
|
34
|
+
gatttgatggtcctatgtttcaatatcataatcaaaatcagcaaaagccggttcaattccaatatcaggctcttta
|
|
35
|
+
tgatttttatgatcagattccaaagaaaattcatggttttaatatgaatatgaataaggattcgaatcaaagtatg
|
|
36
|
+
gttttggatttgaatcaaaatcttaatgatggagaggacgagggcattccttgcatggacaacaacaactaccacc
|
|
37
|
+
ccgaaatcgattgtctcgctaccgtcaccactgcccccactgatgtttgtgctcctaacatcaccaatgatctcta
|
|
38
|
+
g
|
|
39
|
+
__END_OF_SEQ__
|
|
40
|
+
|
|
41
|
+
# test Bio::FlatFile class method
|
|
42
|
+
class TestFlatFileClassMethod < Test::Unit::TestCase
|
|
27
43
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
44
|
+
def setup
|
|
45
|
+
@filename = TestData01
|
|
46
|
+
@klass = Bio::FastaFormat
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
# test template for Bio::FlatFile.open
|
|
50
|
+
def open_TestData01(*arg)
|
|
51
|
+
assert_instance_of(Bio::FlatFile,
|
|
52
|
+
ff = Bio::FlatFile.open(*arg))
|
|
53
|
+
assert_equal(@klass, ff.dbclass)
|
|
54
|
+
assert_nil(ff.close)
|
|
55
|
+
end
|
|
56
|
+
private :open_TestData01
|
|
57
|
+
|
|
58
|
+
# test template for Bio::FlatFile.open with block
|
|
59
|
+
def open_with_block_TestData01(*arg)
|
|
60
|
+
ret = Bio::FlatFile.open(*arg) do |ff|
|
|
61
|
+
assert_instance_of(Bio::FlatFile, ff)
|
|
62
|
+
assert_equal(@klass, ff.dbclass)
|
|
63
|
+
ff.each do |e|
|
|
64
|
+
assert_instance_of(@klass, e)
|
|
65
|
+
assert_instance_of(String, ff.entry_raw)
|
|
66
|
+
end
|
|
67
|
+
'test return value'
|
|
68
|
+
end
|
|
69
|
+
assert_equal('test return value', ret)
|
|
70
|
+
end
|
|
71
|
+
private :open_with_block_TestData01
|
|
72
|
+
|
|
73
|
+
def test_open_0arg
|
|
74
|
+
assert_raise(ArgumentError) { Bio::FlatFile.open }
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
def test_open_1arg_nil
|
|
78
|
+
assert_raise(ArgumentError) { Bio::FlatFile.open(nil) }
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
def test_open_1arg_class
|
|
82
|
+
assert_raise(ArgumentError) { Bio::FlatFile.open(Bio::GenBank) }
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
def test_open_1arg_filename
|
|
86
|
+
open_TestData01(@filename)
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
def test_open_1arg_io
|
|
90
|
+
io = File.open(@filename)
|
|
91
|
+
open_TestData01(io)
|
|
92
|
+
assert(io.closed?)
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
def test_open_1arg_with_block
|
|
96
|
+
open_with_block_TestData01(@filename)
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
def test_open_1arg_io_with_block
|
|
100
|
+
io = File.open(@filename)
|
|
101
|
+
open_with_block_TestData01(io)
|
|
102
|
+
# When IO object is given, the IO is NOT automatically closed.
|
|
103
|
+
assert_equal(false, io.closed?)
|
|
104
|
+
assert_nothing_raised { io.close }
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
def test_open_2arg_autodetect
|
|
108
|
+
open_TestData01(nil, @filename)
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
def test_open_2arg_autodetect_with_block
|
|
112
|
+
open_with_block_TestData01(nil, @filename)
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
def test_open_2arg_autodetect_io
|
|
116
|
+
io = File.open(@filename)
|
|
117
|
+
open_TestData01(nil, io)
|
|
118
|
+
assert(io.closed?)
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
def test_open_2arg_autodetect_io_with_block
|
|
122
|
+
io = File.open(@filename)
|
|
123
|
+
open_with_block_TestData01(nil, io)
|
|
124
|
+
# When IO object is given, the IO is NOT automatically closed.
|
|
125
|
+
assert_equal(false, io.closed?)
|
|
126
|
+
assert_nothing_raised { io.close }
|
|
127
|
+
end
|
|
128
|
+
|
|
129
|
+
def test_open_2arg_class
|
|
130
|
+
open_TestData01(@klass, @filename)
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
def test_open_2arg_class_with_block
|
|
134
|
+
open_with_block_TestData01(@klass, @filename)
|
|
135
|
+
end
|
|
136
|
+
|
|
137
|
+
def test_open_2arg_class_io
|
|
138
|
+
io = File.open(@filename)
|
|
139
|
+
open_TestData01(@klass, io)
|
|
140
|
+
assert(io.closed?)
|
|
141
|
+
end
|
|
142
|
+
|
|
143
|
+
def test_open_2arg_class_io_with_block
|
|
144
|
+
io = File.open(@filename)
|
|
145
|
+
open_with_block_TestData01(@klass, io)
|
|
146
|
+
# When IO object is given, the IO is NOT automatically closed.
|
|
147
|
+
assert_equal(false, io.closed?)
|
|
148
|
+
assert_nothing_raised { io.close }
|
|
149
|
+
end
|
|
150
|
+
|
|
151
|
+
def test_open_2arg_filename_mode
|
|
152
|
+
open_TestData01(@filename, 'r')
|
|
153
|
+
end
|
|
154
|
+
|
|
155
|
+
def test_open_2arg_filename_mode_with_block
|
|
156
|
+
open_with_block_TestData01(@filename, 'r')
|
|
157
|
+
end
|
|
158
|
+
|
|
159
|
+
def test_open_3arg
|
|
160
|
+
open_TestData01(nil, @filename, 'r')
|
|
161
|
+
open_TestData01(@klass, @filename, 'r')
|
|
162
|
+
open_TestData01(@filename, File::RDONLY, 0)
|
|
163
|
+
end
|
|
164
|
+
|
|
165
|
+
def test_open_3arg_with_block
|
|
166
|
+
open_with_block_TestData01(nil, @filename, 'r')
|
|
167
|
+
open_with_block_TestData01(@klass, @filename, 'r')
|
|
168
|
+
open_with_block_TestData01(@filename, File::RDONLY, 0)
|
|
34
169
|
end
|
|
35
170
|
|
|
36
|
-
def
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
171
|
+
def test_open_4arg
|
|
172
|
+
open_TestData01(nil, @filename, File::RDONLY, 0)
|
|
173
|
+
open_TestData01(Bio::FastaFormat,
|
|
174
|
+
@filename, File::RDONLY, 0)
|
|
175
|
+
|
|
176
|
+
open_with_block_TestData01(nil, @filename, File::RDONLY, 0)
|
|
177
|
+
open_with_block_TestData01(Bio::FastaFormat,
|
|
178
|
+
@filename, File::RDONLY, 0)
|
|
179
|
+
end
|
|
180
|
+
|
|
181
|
+
# test template for Bio::FlatFile.auto
|
|
182
|
+
def auto_TestData01(*arg)
|
|
183
|
+
assert_instance_of(Bio::FlatFile,
|
|
184
|
+
ff = Bio::FlatFile.auto(*arg))
|
|
185
|
+
assert_equal(@klass, ff.dbclass)
|
|
186
|
+
assert_nil(ff.close)
|
|
187
|
+
end
|
|
188
|
+
private :auto_TestData01
|
|
189
|
+
|
|
190
|
+
# test template for Bio::FlatFile.auto with block
|
|
191
|
+
def auto_with_block_TestData01(*arg)
|
|
192
|
+
ret = Bio::FlatFile.auto(*arg) do |ff|
|
|
193
|
+
assert_instance_of(Bio::FlatFile, ff)
|
|
194
|
+
assert_equal(@klass, ff.dbclass)
|
|
195
|
+
ff.each do |e|
|
|
196
|
+
assert_instance_of(@klass, e)
|
|
197
|
+
assert_instance_of(String, ff.entry_raw)
|
|
198
|
+
end
|
|
199
|
+
'test return value'
|
|
200
|
+
end
|
|
201
|
+
assert_equal('test return value', ret)
|
|
202
|
+
end
|
|
203
|
+
private :auto_with_block_TestData01
|
|
204
|
+
|
|
205
|
+
def test_auto_0arg
|
|
206
|
+
assert_raise(ArgumentError) { Bio::FlatFile.auto }
|
|
207
|
+
end
|
|
208
|
+
|
|
209
|
+
def test_auto_1arg_filename
|
|
210
|
+
auto_TestData01(@filename)
|
|
211
|
+
end
|
|
212
|
+
|
|
213
|
+
def test_auto_1arg_io
|
|
214
|
+
io = File.open(@filename)
|
|
215
|
+
auto_TestData01(io)
|
|
216
|
+
assert(io.closed?)
|
|
217
|
+
end
|
|
218
|
+
|
|
219
|
+
def test_auto_1arg_with_block
|
|
220
|
+
auto_with_block_TestData01(@filename)
|
|
221
|
+
end
|
|
222
|
+
|
|
223
|
+
def test_auto_1arg_io_with_block
|
|
224
|
+
io = File.open(@filename)
|
|
225
|
+
auto_with_block_TestData01(io)
|
|
226
|
+
# When IO object is given, the IO is NOT automatically closed.
|
|
227
|
+
assert_equal(false, io.closed?)
|
|
228
|
+
assert_nothing_raised { io.close }
|
|
229
|
+
end
|
|
230
|
+
|
|
231
|
+
def test_auto_2arg_filename_mode
|
|
232
|
+
auto_TestData01(@filename, 'r')
|
|
233
|
+
end
|
|
234
|
+
|
|
235
|
+
def test_auto_2arg_filename_mode_with_block
|
|
236
|
+
auto_with_block_TestData01(@filename, 'r')
|
|
237
|
+
end
|
|
238
|
+
|
|
239
|
+
def test_auto_3arg
|
|
240
|
+
auto_TestData01(@filename, File::RDONLY, 0)
|
|
40
241
|
end
|
|
41
242
|
|
|
42
|
-
def
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
243
|
+
def test_auto_3arg_with_block
|
|
244
|
+
auto_with_block_TestData01(@filename, File::RDONLY, 0)
|
|
245
|
+
end
|
|
246
|
+
|
|
247
|
+
def test_to_a
|
|
248
|
+
assert_instance_of(Array,
|
|
249
|
+
a = Bio::FlatFile.to_a(@filename))
|
|
250
|
+
assert_equal(5, a.size)
|
|
251
|
+
assert_instance_of(Bio::FastaFormat, a[3])
|
|
252
|
+
assert_equal(TestData01Ent4def,
|
|
253
|
+
a[3].definition)
|
|
254
|
+
|
|
255
|
+
assert_equal(TestData01Ent4naseq, a[3].naseq)
|
|
256
|
+
end
|
|
257
|
+
|
|
258
|
+
def test_foreach
|
|
259
|
+
Bio::FlatFile.foreach(@filename) do |ent|
|
|
260
|
+
assert_instance_of(Bio::FastaFormat, ent)
|
|
48
261
|
end
|
|
49
|
-
assert_raise(IOError) { obj2.close }
|
|
50
262
|
end
|
|
51
|
-
end #class TestBufferedInputStreamClassMethod
|
|
52
263
|
|
|
53
|
-
|
|
264
|
+
def test_new_2arg_nil
|
|
265
|
+
io = File.open(@filename)
|
|
266
|
+
assert_instance_of(Bio::FlatFile,
|
|
267
|
+
ff = Bio::FlatFile.new(nil, io))
|
|
268
|
+
assert_equal(@klass, ff.dbclass)
|
|
269
|
+
assert_nil(ff.close)
|
|
270
|
+
end
|
|
271
|
+
|
|
272
|
+
def test_new_2arg_class
|
|
273
|
+
io = File.open(@filename)
|
|
274
|
+
assert_instance_of(Bio::FlatFile,
|
|
275
|
+
ff = Bio::FlatFile.new(@klass, io))
|
|
276
|
+
assert_equal(@klass, ff.dbclass)
|
|
277
|
+
assert_nil(ff.close)
|
|
278
|
+
end
|
|
279
|
+
|
|
280
|
+
end #class TestFlatFileClassMethod
|
|
281
|
+
|
|
282
|
+
# test Bio::FlatFile instance methods
|
|
283
|
+
class TestFlatFileFastaFormat < Test::Unit::TestCase
|
|
54
284
|
def setup
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
@
|
|
285
|
+
@klass = Bio::FastaFormat
|
|
286
|
+
@filename = TestData01
|
|
287
|
+
@ff = Bio::FlatFile.open(@klass, @filename)
|
|
58
288
|
end
|
|
59
289
|
|
|
60
290
|
def test_to_io
|
|
61
|
-
|
|
291
|
+
assert_instance_of(File, @ff.to_io)
|
|
62
292
|
end
|
|
63
293
|
|
|
64
|
-
def
|
|
65
|
-
|
|
294
|
+
def test_path
|
|
295
|
+
assert_equal(@filename, @ff.path)
|
|
66
296
|
end
|
|
67
297
|
|
|
68
|
-
def
|
|
69
|
-
@
|
|
70
|
-
|
|
71
|
-
|
|
298
|
+
def test_next_entry
|
|
299
|
+
assert_instance_of(@klass, ent = @ff.next_entry)
|
|
300
|
+
assert_equal(TestData01Ent1def, ent.definition)
|
|
301
|
+
assert_instance_of(@klass, ent = @ff.next_entry)
|
|
302
|
+
assert_instance_of(@klass, ent = @ff.next_entry)
|
|
303
|
+
assert_instance_of(@klass, ent = @ff.next_entry)
|
|
304
|
+
assert_equal(TestData01Ent4def, ent.definition)
|
|
305
|
+
assert_equal(TestData01Ent4naseq, ent.naseq)
|
|
72
306
|
end
|
|
73
307
|
|
|
74
|
-
def
|
|
75
|
-
@
|
|
76
|
-
@
|
|
77
|
-
@
|
|
78
|
-
assert_equal(
|
|
308
|
+
def test_entry_raw
|
|
309
|
+
4.times { @ff.next_entry }
|
|
310
|
+
assert_instance_of(String, str = @ff.entry_raw)
|
|
311
|
+
assert_equal(TestData01Ent4def, @klass.new(str).definition)
|
|
312
|
+
assert_equal(TestData01Ent4naseq, @klass.new(str).naseq)
|
|
79
313
|
end
|
|
80
314
|
|
|
81
|
-
def
|
|
82
|
-
|
|
83
|
-
assert_equal(
|
|
315
|
+
def test_entry_pos_flag
|
|
316
|
+
# default is nil
|
|
317
|
+
assert_equal(nil, @ff.entry_pos_flag)
|
|
318
|
+
# set as true
|
|
319
|
+
assert_equal(true, @ff.entry_pos_flag = true)
|
|
320
|
+
assert_equal(true, @ff.entry_pos_flag)
|
|
84
321
|
end
|
|
85
|
-
|
|
86
|
-
def
|
|
87
|
-
|
|
322
|
+
|
|
323
|
+
def test_start_pos_ended_pos_not_recorded
|
|
324
|
+
# default is nil
|
|
325
|
+
assert_equal(nil, @ff.entry_start_pos)
|
|
326
|
+
#
|
|
327
|
+
@ff.entry_pos_flag = false
|
|
328
|
+
@ff.next_entry
|
|
329
|
+
# nil if not recorded
|
|
330
|
+
assert_equal(nil, @ff.entry_start_pos)
|
|
331
|
+
assert_equal(nil, @ff.entry_ended_pos)
|
|
332
|
+
@ff.next_entry
|
|
333
|
+
# nil if not recorded
|
|
334
|
+
assert_equal(nil, @ff.entry_start_pos)
|
|
335
|
+
assert_equal(nil, @ff.entry_ended_pos)
|
|
88
336
|
end
|
|
89
337
|
|
|
90
|
-
def
|
|
91
|
-
|
|
92
|
-
|
|
338
|
+
def test_start_pos
|
|
339
|
+
@ff.entry_pos_flag = true
|
|
340
|
+
@ff.next_entry
|
|
341
|
+
assert_equal(0, @ff.entry_start_pos)
|
|
342
|
+
@ff.next_entry
|
|
343
|
+
# On Windows, the values might be different.
|
|
344
|
+
assert_equal(2367, @ff.entry_start_pos)
|
|
93
345
|
end
|
|
94
346
|
|
|
95
|
-
def
|
|
96
|
-
|
|
97
|
-
|
|
347
|
+
def test_ended_pos
|
|
348
|
+
@ff.entry_pos_flag = true
|
|
349
|
+
@ff.next_entry
|
|
350
|
+
# On Windows, the values might be different.
|
|
351
|
+
assert_equal(2367, @ff.entry_ended_pos)
|
|
352
|
+
@ff.next_entry
|
|
353
|
+
# On Windows, the values might be different.
|
|
354
|
+
assert_equal(3244, @ff.entry_ended_pos)
|
|
98
355
|
end
|
|
99
356
|
|
|
100
|
-
def
|
|
101
|
-
|
|
102
|
-
@
|
|
103
|
-
|
|
357
|
+
def test_each_entry
|
|
358
|
+
i = 0
|
|
359
|
+
@ff.each_entry do |ent|
|
|
360
|
+
assert_instance_of(@klass, ent)
|
|
361
|
+
i += 1
|
|
362
|
+
if i == 4 then
|
|
363
|
+
assert_equal(TestData01Ent4def, ent.definition)
|
|
364
|
+
assert_equal(TestData01Ent4naseq, ent.naseq)
|
|
365
|
+
end
|
|
366
|
+
end
|
|
104
367
|
end
|
|
105
368
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
@obj.prefetch_gets
|
|
110
|
-
@obj.gets
|
|
111
|
-
assert_equal(@obj.gets, str)
|
|
369
|
+
# each is an alias of each_entry
|
|
370
|
+
def test_each
|
|
371
|
+
assert_nothing_raised { @ff.each {} }
|
|
112
372
|
end
|
|
113
373
|
|
|
114
|
-
def
|
|
115
|
-
@
|
|
116
|
-
@
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
assert_nil(@obj.ungets(str2))
|
|
120
|
-
assert_nil(@obj.ungets(str1))
|
|
121
|
-
assert_equal(str1, @obj.gets)
|
|
122
|
-
assert_equal(str2, @obj.gets)
|
|
374
|
+
def test_rewind
|
|
375
|
+
@ff.next_entry
|
|
376
|
+
assert_not_equal(0, @ff.pos)
|
|
377
|
+
assert_equal(0, @ff.rewind)
|
|
378
|
+
assert_equal(0, @ff.pos)
|
|
123
379
|
end
|
|
124
380
|
|
|
125
|
-
def
|
|
126
|
-
|
|
381
|
+
def test_close
|
|
382
|
+
assert_nil(@ff.close)
|
|
127
383
|
end
|
|
128
384
|
|
|
129
|
-
def
|
|
130
|
-
@
|
|
131
|
-
|
|
385
|
+
def test_pos
|
|
386
|
+
assert_equal(0, @ff.pos)
|
|
387
|
+
@ff.next_entry
|
|
388
|
+
assert_not_equal(0, @ff.pos)
|
|
132
389
|
end
|
|
133
390
|
|
|
134
|
-
def
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
assert_equal(c, @obj.getc)
|
|
391
|
+
def test_eof?
|
|
392
|
+
5.times { @ff.next_entry }
|
|
393
|
+
assert_equal(true, @ff.eof?)
|
|
138
394
|
end
|
|
139
395
|
|
|
140
|
-
def
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
assert_equal(
|
|
396
|
+
def test_raw
|
|
397
|
+
# default false
|
|
398
|
+
assert_equal(false, @ff.raw)
|
|
399
|
+
# changes to true
|
|
400
|
+
assert_equal(true, @ff.raw = true)
|
|
401
|
+
@ff.each do |ent|
|
|
402
|
+
assert_instance_of(String, ent)
|
|
403
|
+
end
|
|
145
404
|
end
|
|
146
405
|
|
|
147
|
-
def
|
|
148
|
-
|
|
149
|
-
str += @obj.prefetch_gets
|
|
150
|
-
assert_equal(str, @obj.prefetch_buffer)
|
|
406
|
+
def test_dbclass
|
|
407
|
+
assert_equal(@klass, @ff.dbclass)
|
|
151
408
|
end
|
|
152
409
|
|
|
153
|
-
def
|
|
154
|
-
|
|
155
|
-
@
|
|
156
|
-
@
|
|
157
|
-
str = @obj.prefetch_gets
|
|
158
|
-
@obj.gets
|
|
159
|
-
assert_equal(str, @obj.gets)
|
|
410
|
+
def test_dbclass_eq
|
|
411
|
+
klass = Bio::FastaNumericFormat
|
|
412
|
+
assert_equal(klass, @ff.dbclass = klass)
|
|
413
|
+
assert_equal(klass, @ff.dbclass)
|
|
160
414
|
end
|
|
161
415
|
|
|
162
|
-
def
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
# test using IO object
|
|
167
|
-
io = @obj.to_io
|
|
168
|
-
io.rewind
|
|
169
|
-
assert_equal(str, io.gets("\n>"))
|
|
416
|
+
def test_dbclass_nil
|
|
417
|
+
assert_equal(nil, @ff.dbclass = nil)
|
|
418
|
+
assert_equal(nil, @ff.dbclass)
|
|
419
|
+
assert_raise(Bio::FlatFile::UnknownDataFormatError) { @ff.next_entry }
|
|
170
420
|
end
|
|
171
421
|
|
|
172
|
-
def
|
|
173
|
-
@
|
|
174
|
-
|
|
175
|
-
assert_equal(
|
|
422
|
+
def test_autodetect
|
|
423
|
+
@ff.dbclass = nil
|
|
424
|
+
assert_equal(@klass, @ff.autodetect)
|
|
425
|
+
assert_equal(@klass, @ff.dbclass)
|
|
176
426
|
end
|
|
177
|
-
|
|
178
|
-
end #class
|
|
427
|
+
|
|
428
|
+
end #class TestFlatFileFastaFormat
|
|
429
|
+
|
|
179
430
|
|
|
180
431
|
class TestFlatFileWithCustomClass < Test::Unit::TestCase
|
|
181
432
|
|