bio 1.2.1 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- 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
@@ -5,68 +5,17 @@
|
|
5
5
|
# Moses Hohman <mmhohman@northwestern.edu>
|
6
6
|
# License:: The Ruby License
|
7
7
|
#
|
8
|
-
# $Id
|
8
|
+
# $Id:$
|
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__), [".."]*3, "lib")).cleanpath.to_s
|
13
13
|
$:.unshift(libpath) unless $:.include?(libpath)
|
14
14
|
|
15
15
|
require 'test/unit'
|
16
16
|
require 'bio/pathway'
|
17
17
|
|
18
|
-
class Float
|
19
|
-
NaN = 0/0.0
|
20
|
-
Infinity = 1/0.0
|
21
|
-
end
|
22
|
-
|
23
|
-
class Array
|
24
|
-
def sum
|
25
|
-
inject { | sum, val | sum += val }
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
18
|
module Bio
|
30
|
-
class Pathway
|
31
|
-
# bug in subgraph: does not include nodes w/o edges
|
32
|
-
def subgraph(list = nil)
|
33
|
-
if list
|
34
|
-
@label.clear
|
35
|
-
list.each { |node| @label[node] = true }
|
36
|
-
end
|
37
|
-
sub_graph = Pathway.new([], @undirected)
|
38
|
-
@graph.each do |from, hash|
|
39
|
-
next unless @label[from]
|
40
|
-
sub_graph.graph[from] = {}
|
41
|
-
hash.each do |to, relation|
|
42
|
-
next unless @label[to]
|
43
|
-
sub_graph.graph[from][to] = relation
|
44
|
-
end
|
45
|
-
end
|
46
|
-
sub_graph
|
47
|
-
end
|
48
|
-
|
49
|
-
# bug in cliquishness: subgraph of neighbors does not include nodes w/o edges
|
50
|
-
def subgraph_adjacency_matrix(nodes)
|
51
|
-
adjacency_matrix = to_matrix(0).to_a
|
52
|
-
node_indices = nodes.collect { |x| @index[x] }
|
53
|
-
subgraph = adjacency_matrix.values_at(*(node_indices))
|
54
|
-
subgraph.collect! { |row| row.values_at(*(node_indices)) }
|
55
|
-
end
|
56
|
-
|
57
|
-
# bug in cliquishness: subgraph of neighbors does not include nodes w/o edges
|
58
|
-
# Throws exception if graph is directed
|
59
|
-
def cliquishness(node)
|
60
|
-
raise "Cannot calculate cliquishness in directed graph" if not undirected?
|
61
|
-
neighbors = @graph[node].keys
|
62
|
-
return Float::NaN if neighbors.size==0
|
63
|
-
return 1 if neighbors.size==1
|
64
|
-
# divide by two to avoid double-counting
|
65
|
-
num_neighbor_edges = subgraph_adjacency_matrix(neighbors).flatten.sum/2
|
66
|
-
num_complete_edges = neighbors.size*(neighbors.size-1)/2
|
67
|
-
num_neighbor_edges.to_f / num_complete_edges.to_f
|
68
|
-
end
|
69
|
-
end
|
70
19
|
|
71
20
|
class TestMyGraph < Test::Unit::TestCase
|
72
21
|
def test_cliquishness
|
@@ -82,7 +31,10 @@ module Bio
|
|
82
31
|
assert_equal(0, graph.cliquishness(1), "1's cliquishness wrong")
|
83
32
|
assert_equal(1, graph.cliquishness(2), "2's cliquishness wrong")
|
84
33
|
assert_in_delta(0.33, graph.cliquishness(3), 0.01, "3's cliquishness wrong")
|
85
|
-
|
34
|
+
# Because cliquishness (clustering coefficient) for a node
|
35
|
+
# that has only one neighbor node is undefined, test for
|
36
|
+
# node 4 is commented out.
|
37
|
+
#assert_equal(1, graph.cliquishness(4), "4's cliquishness wrong")
|
86
38
|
assert_equal(0, graph.cliquishness(5), "5's cliquishness wrong")
|
87
39
|
assert_in_delta(0.16, graph.cliquishness(6), 0.01, "6's cliquishness wrong")
|
88
40
|
end
|
@@ -104,6 +56,8 @@ module Bio
|
|
104
56
|
end
|
105
57
|
|
106
58
|
class TestSampleGraph < Test::Unit::TestCase
|
59
|
+
|
60
|
+
TheInfinity = 1/0.0
|
107
61
|
|
108
62
|
# Sample Graph :
|
109
63
|
# +----------------+
|
@@ -139,6 +93,54 @@ module Bio
|
|
139
93
|
end
|
140
94
|
|
141
95
|
def test_to_matrix
|
96
|
+
matrix = @graph.to_matrix(0)
|
97
|
+
index = @graph.index
|
98
|
+
# expected values
|
99
|
+
source_matrix =
|
100
|
+
[
|
101
|
+
#v w x y z q r s t u
|
102
|
+
[0, 1, 0, 0, 0, 0, 0, 0, 0, 0], #v
|
103
|
+
[0, 0, 0, 0, 0, 0, 0, 1, 0, 0], #w
|
104
|
+
[0, 0, 0, 0, 1, 0, 0, 0, 0, 0], #x
|
105
|
+
[0, 0, 0, 0, 0, 1, 0, 0, 0, 0], #y
|
106
|
+
[0, 0, 1, 0, 0, 0, 0, 0, 0, 0], #z
|
107
|
+
[0, 1, 0, 0, 0, 0, 0, 1, 1, 0], #q
|
108
|
+
[0, 0, 0, 1, 0, 0, 0, 0, 0, 1], #r
|
109
|
+
[1, 0, 0, 0, 0, 0, 0, 0, 0, 0], #s
|
110
|
+
[0, 0, 1, 1, 0, 0, 0, 0, 0, 0], #t
|
111
|
+
[0, 0, 0, 1, 0, 0, 0, 0, 0, 0] #u
|
112
|
+
]
|
113
|
+
source_index = {
|
114
|
+
"v"=>0, "w"=>1, "x"=>2, "y"=>3, "z"=>4,
|
115
|
+
"q"=>5, "r"=>6, "s"=>7, "t"=>8, "u"=>9
|
116
|
+
}
|
117
|
+
# test index size
|
118
|
+
assert_equal(10, source_index.size)
|
119
|
+
# test index keys
|
120
|
+
assert_equal(source_index.keys.sort, index.keys.sort)
|
121
|
+
# test index values
|
122
|
+
assert_equal(source_index.values.sort, index.values.sort)
|
123
|
+
# prepare expected matrix
|
124
|
+
ary = Array.new(index.size)
|
125
|
+
ary.collect! { |a| Array.new(index.size) }
|
126
|
+
index.each do |row_k, row_v|
|
127
|
+
src_row = source_index[row_k]
|
128
|
+
index.each do |col_k, col_v|
|
129
|
+
src_col = source_index[col_k]
|
130
|
+
ary[row_v][col_v] = source_matrix[src_row][src_col]
|
131
|
+
end
|
132
|
+
end
|
133
|
+
expected_matrix = Matrix.rows(ary)
|
134
|
+
# test the matrix
|
135
|
+
assert_equal(expected_matrix, matrix, "matrix wrong")
|
136
|
+
end
|
137
|
+
|
138
|
+
def test_to_matrix_fixed_index
|
139
|
+
# begin workaround removing depencency to order of Hash#each
|
140
|
+
%w( v w x y z q r s t u ).each_with_index do |x, i|
|
141
|
+
@graph.index[x] = i
|
142
|
+
end
|
143
|
+
# end workaround removing depencency to order of Hash#each
|
142
144
|
assert_equal(Matrix[
|
143
145
|
[0, 1, 0, 0, 0, 0, 0, 0, 0, 0],
|
144
146
|
[0, 0, 0, 0, 0, 0, 0, 1, 0, 0],
|
@@ -155,6 +157,11 @@ module Bio
|
|
155
157
|
end
|
156
158
|
|
157
159
|
def test_dump_matrix
|
160
|
+
# begin workaround removing depencency to order of Hash#each
|
161
|
+
%w( v w x y z q r s t u ).each_with_index do |x, i|
|
162
|
+
@graph.index[x] = i
|
163
|
+
end
|
164
|
+
# end workaround removing depencency to order of Hash#each
|
158
165
|
dumped = "[" +
|
159
166
|
"# v, w, x, y, z, q, r, s, t, u\n" +
|
160
167
|
" [0, 1, 0, 0, 0, 0, 0, 0, 0, 0],\n" + # v
|
@@ -171,6 +178,11 @@ module Bio
|
|
171
178
|
end
|
172
179
|
|
173
180
|
def test_dump_list
|
181
|
+
# begin workaround removing depencency to order of Hash#each
|
182
|
+
%w( v w x y z q r s t u ).each_with_index do |x, i|
|
183
|
+
@graph.index[x] = i
|
184
|
+
end
|
185
|
+
# end workaround removing depencency to order of Hash#each
|
174
186
|
dumped = "v => w (1)\n" +
|
175
187
|
"w => s (1)\n" +
|
176
188
|
"x => z (1)\n" +
|
@@ -187,22 +199,34 @@ module Bio
|
|
187
199
|
def test_extract_subgraph_by_label
|
188
200
|
hash = { 'q' => "L1", 's' => "L2", 'v' => "L3", 'w' => "L4" }
|
189
201
|
@graph.label = hash
|
202
|
+
subgraph = @graph.subgraph
|
203
|
+
# begin workaround removing depencency to order of Hash#each
|
204
|
+
%w( v w q s ).each_with_index do |x, i|
|
205
|
+
subgraph.index[x] = i
|
206
|
+
end
|
207
|
+
# end workaround removing depencency to order of Hash#each
|
190
208
|
dumped =
|
191
209
|
"v => w (1)\n" +
|
192
210
|
"w => s (1)\n" +
|
193
211
|
"q => w (1), s (1)\n" +
|
194
212
|
"s => v (1)\n"
|
195
|
-
assert_equal(dumped,
|
213
|
+
assert_equal(dumped, subgraph.dump_list)
|
196
214
|
end
|
197
215
|
|
198
216
|
def test_extract_subgraph_by_list
|
217
|
+
subgraph = @graph.subgraph(['q', 't', 'x', 'y', 'z'])
|
218
|
+
# begin workaround removing depencency to order of Hash#each
|
219
|
+
%w( x y z q t ).each_with_index do |x, i|
|
220
|
+
subgraph.index[x] = i
|
221
|
+
end
|
222
|
+
# end workaround removing depencency to order of Hash#each
|
199
223
|
dumped =
|
200
224
|
"x => z (1)\n" +
|
201
225
|
"y => q (1)\n" +
|
202
226
|
"z => x (1)\n" +
|
203
227
|
"q => t (1)\n" +
|
204
228
|
"t => x (1), y (1)\n"
|
205
|
-
assert_equal(dumped,
|
229
|
+
assert_equal(dumped, subgraph.dump_list)
|
206
230
|
end
|
207
231
|
|
208
232
|
def test_extract_subgraph_retains_disconnected_nodes
|
@@ -221,10 +245,6 @@ module Bio
|
|
221
245
|
# v | | v |
|
222
246
|
# (v)----->(w)<---+ (z)----+
|
223
247
|
|
224
|
-
def test_cliquishness_raises_exception_for_directed_graph
|
225
|
-
assert_raises (RuntimeError) { @graph.cliquishness('q') }
|
226
|
-
end
|
227
|
-
|
228
248
|
def test_undirected_cliquishness
|
229
249
|
@graph.undirected
|
230
250
|
assert_in_delta(0.33, @graph.cliquishness('q'), 0.01)
|
@@ -277,7 +297,13 @@ module Bio
|
|
277
297
|
end
|
278
298
|
|
279
299
|
def test_depth_first_search
|
280
|
-
|
300
|
+
# fixing node order to aviod dependency of Hash#each_key
|
301
|
+
%w( v w x y z q r s t u ).each_with_index do |x, i|
|
302
|
+
@graph.index[x] = i
|
303
|
+
end
|
304
|
+
# exec dfs
|
305
|
+
timestamp, tree, back, cross, forward =
|
306
|
+
@graph.depth_first_search
|
281
307
|
assert_equal({
|
282
308
|
"v"=>[1, 6],
|
283
309
|
"w"=>[2, 5],
|
@@ -329,10 +355,10 @@ module Bio
|
|
329
355
|
"y"=>2,
|
330
356
|
"z"=>3,
|
331
357
|
"q"=>0,
|
332
|
-
"r"=>
|
358
|
+
"r"=>TheInfinity,
|
333
359
|
"s"=>1,
|
334
360
|
"t"=>1,
|
335
|
-
"u"=>
|
361
|
+
"u"=>TheInfinity}, distances, "distances wrong")
|
336
362
|
assert_equal({
|
337
363
|
"v"=>"s",
|
338
364
|
"w"=>"q",
|
@@ -355,10 +381,10 @@ module Bio
|
|
355
381
|
"y"=>2,
|
356
382
|
"z"=>3,
|
357
383
|
"q"=>0,
|
358
|
-
"r"=>
|
384
|
+
"r"=>TheInfinity,
|
359
385
|
"s"=>1,
|
360
386
|
"t"=>1,
|
361
|
-
"u"=>
|
387
|
+
"u"=>TheInfinity}, distances, "distances wrong")
|
362
388
|
assert_equal({
|
363
389
|
"v"=>"s",
|
364
390
|
"w"=>"q",
|
@@ -5,7 +5,7 @@
|
|
5
5
|
# Mitsuteru C. Nakao <n@bioruby.org>
|
6
6
|
# License:: The Ruby License
|
7
7
|
#
|
8
|
-
# $Id: test_reference.rb,v 1.3
|
8
|
+
# $Id: test_reference.rb,v 1.3.2.2 2008/06/17 12:24:41 ngoto Exp $
|
9
9
|
#
|
10
10
|
|
11
11
|
require 'pathname'
|
@@ -14,6 +14,7 @@ $:.unshift(libpath) unless $:.include?(libpath)
|
|
14
14
|
|
15
15
|
require 'test/unit'
|
16
16
|
require 'bio/reference'
|
17
|
+
require 'bio/compat/references'
|
17
18
|
|
18
19
|
|
19
20
|
module Bio
|
@@ -90,7 +91,7 @@ module Bio
|
|
90
91
|
end
|
91
92
|
|
92
93
|
def test_format_endnote
|
93
|
-
str = "%0 Journal Article\n%A Hoge, J.P.\n%A Fuga, F.B.\n%D 2001\n%T Title of the study.\n%J Theor. J. Hoge\n%V 12\n%N 3\n%P 123-145\n%M 12345678\n%U http://
|
94
|
+
str = "%0 Journal Article\n%A Hoge, J.P.\n%A Fuga, F.B.\n%D 2001\n%T Title of the study.\n%J Theor. J. Hoge\n%V 12\n%N 3\n%P 123-145\n%M 12345678\n%U http://example.com\n%X Hoge fuga. hoge fuga.\n%K Hoge\n%+ Tokyo"
|
94
95
|
assert_equal(str, @obj.format('endnote'))
|
95
96
|
assert_equal(str, @obj.endnote)
|
96
97
|
end
|
@@ -102,21 +103,47 @@ module Bio
|
|
102
103
|
end
|
103
104
|
|
104
105
|
def test_format_bibtex
|
105
|
-
str =<<
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
106
|
+
str =<<__END__
|
107
|
+
@article{PMID:12345678,
|
108
|
+
author = {Hoge, J.P. and Fuga, F.B.},
|
109
|
+
title = {Title of the study.},
|
110
|
+
journal = {Theor. J. Hoge},
|
111
|
+
year = {2001},
|
112
|
+
volume = {12},
|
113
|
+
number = {3},
|
114
|
+
pages = {123--145},
|
115
|
+
url = {http://example.com},
|
116
|
+
}
|
117
|
+
__END__
|
116
118
|
assert_equal(str, @obj.format('bibtex'))
|
117
119
|
assert_equal(str, @obj.bibtex)
|
118
120
|
end
|
119
121
|
|
122
|
+
def test_format_bibtex_with_arguments
|
123
|
+
str =<<__END__
|
124
|
+
@inproceedings{YourArticle,
|
125
|
+
author = {Hoge, J.P. and Fuga, F.B.},
|
126
|
+
title = {Title of the study.},
|
127
|
+
year = {2001},
|
128
|
+
volume = {12},
|
129
|
+
number = {3},
|
130
|
+
pages = {123--145},
|
131
|
+
booktitle = {Theor. J. Hoge},
|
132
|
+
month = {December},
|
133
|
+
}
|
134
|
+
__END__
|
135
|
+
assert_equal(str, @obj.format('bibtex', 'inproceedings', 'YourArticle',
|
136
|
+
{ 'journal' => false,
|
137
|
+
'url' => false,
|
138
|
+
'booktitle' => @obj.journal,
|
139
|
+
'month' => 'December'}))
|
140
|
+
assert_equal(str, @obj.bibtex('inproceedings', 'YourArticle',
|
141
|
+
{ 'journal' => false,
|
142
|
+
'url' => false,
|
143
|
+
'booktitle' => @obj.journal,
|
144
|
+
'month' => 'December'}))
|
145
|
+
end
|
146
|
+
|
120
147
|
def test_format_rd
|
121
148
|
str = "== Title of the study.\n\n* Hoge, J.P. and Fuga, F.B.\n\n* Theor. J. Hoge 2001 12:123-145 [PMID:12345678]\n\nHoge fuga. hoge fuga."
|
122
149
|
assert_equal(str, @obj.format('rd'))
|
@@ -172,15 +199,42 @@ END
|
|
172
199
|
|
173
200
|
end
|
174
201
|
|
202
|
+
class NullStderr
|
203
|
+
def initialize
|
204
|
+
@log = []
|
205
|
+
end
|
206
|
+
|
207
|
+
def write(*arg)
|
208
|
+
#p arg
|
209
|
+
@log.push([ :write, *arg ])
|
210
|
+
nil
|
211
|
+
end
|
212
|
+
|
213
|
+
def method_missing(*arg)
|
214
|
+
#p arg
|
215
|
+
@log.push arg
|
216
|
+
nil
|
217
|
+
end
|
218
|
+
end
|
219
|
+
|
175
220
|
class TestReferences < Test::Unit::TestCase
|
176
221
|
|
177
222
|
def setup
|
223
|
+
# To suppress warning messages, $stderr is replaced by dummy object.
|
224
|
+
@stderr_orig = $stderr
|
225
|
+
$stderr = NullStderr.new
|
226
|
+
|
178
227
|
hash = {}
|
179
228
|
ary = [Bio::Reference.new(hash),
|
180
229
|
Bio::Reference.new(hash)]
|
181
230
|
@obj = Bio::References.new(ary)
|
182
231
|
end
|
183
232
|
|
233
|
+
def teardown
|
234
|
+
# bring back $stderr
|
235
|
+
$stderr = @stderr_orig
|
236
|
+
end
|
237
|
+
|
184
238
|
def test_append
|
185
239
|
hash = {}
|
186
240
|
ref = Bio::Reference.new(hash)
|
@@ -5,7 +5,7 @@
|
|
5
5
|
# Copyright:: Copyright (c) 2005-2007 Midwinter Laboratories, LLC (http://midwinterlabs.com)
|
6
6
|
# License:: The Ruby License
|
7
7
|
#
|
8
|
-
# $Id
|
8
|
+
# $Id:$
|
9
9
|
#
|
10
10
|
|
11
11
|
require 'pathname'
|
@@ -19,7 +19,7 @@ require 'bio/util/restriction_enzyme/range/cut_ranges'
|
|
19
19
|
require 'bio/util/restriction_enzyme/range/horizontal_cut_range'
|
20
20
|
require 'bio/util/restriction_enzyme/range/vertical_cut_range'
|
21
21
|
|
22
|
-
module Bio #:nodoc:
|
22
|
+
module Bio; module TestRestrictionEnzyme #:nodoc:
|
23
23
|
|
24
24
|
class TestAnalysisCalculatedCuts < Test::Unit::TestCase #:nodoc:
|
25
25
|
|
@@ -296,4 +296,4 @@ class TestAnalysisCalculatedCuts < Test::Unit::TestCase #:nodoc:
|
|
296
296
|
|
297
297
|
end
|
298
298
|
|
299
|
-
end
|
299
|
+
end; end
|
@@ -5,7 +5,7 @@
|
|
5
5
|
# Copyright:: Copyright (c) 2005-2007 Midwinter Laboratories, LLC (http://midwinterlabs.com)
|
6
6
|
# License:: The Ruby License
|
7
7
|
#
|
8
|
-
# $Id
|
8
|
+
# $Id:$
|
9
9
|
#
|
10
10
|
|
11
11
|
require 'pathname'
|
@@ -21,7 +21,7 @@ require 'bio/util/restriction_enzyme/range/horizontal_cut_range'
|
|
21
21
|
require 'bio/util/restriction_enzyme/range/vertical_cut_range'
|
22
22
|
require 'bio/util/restriction_enzyme/range/cut_ranges'
|
23
23
|
|
24
|
-
module Bio #:nodoc:
|
24
|
+
module Bio; module TestRestrictionEnzyme #:nodoc:
|
25
25
|
|
26
26
|
class TestCutRanges < Test::Unit::TestCase #:nodoc:
|
27
27
|
|
@@ -100,4 +100,4 @@ class TestCutRanges < Test::Unit::TestCase #:nodoc:
|
|
100
100
|
assert_equal(false, @obj_3.include?(6))
|
101
101
|
end
|
102
102
|
end
|
103
|
-
end
|
103
|
+
end; end
|
@@ -5,7 +5,7 @@
|
|
5
5
|
# Copyright:: Copyright (c) 2005-2007 Midwinter Laboratories, LLC (http://midwinterlabs.com)
|
6
6
|
# License:: The Ruby License
|
7
7
|
#
|
8
|
-
# $Id
|
8
|
+
# $Id:$
|
9
9
|
#
|
10
10
|
|
11
11
|
require 'pathname'
|
@@ -21,7 +21,7 @@ require 'bio/util/restriction_enzyme/range/horizontal_cut_range'
|
|
21
21
|
require 'bio/util/restriction_enzyme/range/vertical_cut_range'
|
22
22
|
require 'bio/util/restriction_enzyme/range/cut_ranges'
|
23
23
|
|
24
|
-
module Bio #:nodoc:
|
24
|
+
module Bio; module TestRestrictionEnzyme #:nodoc:
|
25
25
|
|
26
26
|
class TestAnalysisSequenceRange < Test::Unit::TestCase #:nodoc:
|
27
27
|
|
@@ -237,4 +237,4 @@ class TestAnalysisSequenceRange < Test::Unit::TestCase #:nodoc:
|
|
237
237
|
end
|
238
238
|
|
239
239
|
end
|
240
|
-
end
|
240
|
+
end; end
|