bio 1.1.0 → 1.2.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 +4 -3
- data/lib/bio.rb +3 -3
- data/lib/bio/appl/blast/format0.rb +3 -2
- data/lib/bio/appl/blast/format8.rb +5 -3
- data/lib/bio/db/kegg/compound.rb +6 -1
- data/lib/bio/db/kegg/enzyme.rb +3 -3
- data/lib/bio/db/kegg/genes.rb +2 -2
- data/lib/bio/db/kegg/glycan.rb +5 -5
- data/lib/bio/db/kegg/orthology.rb +27 -3
- data/lib/bio/db/newick.rb +203 -55
- data/lib/bio/io/flatfile.rb +2 -2
- data/lib/bio/io/flatfile/indexer.rb +2 -2
- data/lib/bio/io/keggapi.rb +2 -1
- data/lib/bio/io/pubmed.rb +223 -81
- data/lib/bio/sequence/common.rb +6 -3
- data/lib/bio/shell/interface.rb +2 -2
- data/lib/bio/shell/rails/vendor/plugins/generators/bioruby/bioruby_generator.rb +5 -5
- data/lib/bio/shell/rails/vendor/plugins/generators/bioruby/templates/bioruby.css +7 -8
- data/lib/bio/shell/rails/vendor/plugins/generators/bioruby/templates/bioruby.rhtml +1 -1
- data/lib/bio/shell/rails/vendor/plugins/generators/bioruby/templates/index.rhtml +21 -17
- data/lib/bio/shell/rails/vendor/plugins/generators/bioruby/templates/spinner.gif +0 -0
- data/test/functional/bio/io/test_ensembl.rb +87 -4
- data/test/unit/bio/db/test_newick.rb +238 -1
- data/test/unit/bio/sequence/test_aa.rb +3 -2
- data/test/unit/bio/sequence/test_common.rb +11 -2
- data/test/unit/bio/sequence/test_na.rb +63 -1
- metadata +4 -4
- data/lib/bio/shell/rails/vendor/plugins/generators/bioruby/templates/bioruby-console.png +0 -0
data/lib/bio/sequence/common.rb
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
# Ryan Raaum <ryan@raaum.org>
|
7
7
|
# License:: The Ruby License
|
8
8
|
#
|
9
|
-
# $Id: common.rb,v 1.
|
9
|
+
# $Id: common.rb,v 1.5 2007/12/03 06:19:12 nakao Exp $
|
10
10
|
#
|
11
11
|
|
12
12
|
module Bio
|
@@ -91,10 +91,13 @@ module Common
|
|
91
91
|
# puts s #=> "atgcatgcatgcatgc"
|
92
92
|
# ---
|
93
93
|
# *Returns*:: current Bio::Sequence::NA/AA object (modified)
|
94
|
-
def
|
94
|
+
def concat(*arg)
|
95
95
|
super(self.class.new(*arg))
|
96
96
|
end
|
97
|
-
|
97
|
+
|
98
|
+
def <<(*arg)
|
99
|
+
concat(*arg)
|
100
|
+
end
|
98
101
|
|
99
102
|
# Create a new sequence by adding to an existing sequence.
|
100
103
|
# The existing sequence is not modified.
|
data/lib/bio/shell/interface.rb
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
# Toshiaki Katayama <k@bioruby.org>
|
6
6
|
# License:: The Ruby License
|
7
7
|
#
|
8
|
-
# $Id: interface.rb,v 1.
|
8
|
+
# $Id: interface.rb,v 1.19 2007/11/15 07:08:49 k Exp $
|
9
9
|
#
|
10
10
|
|
11
11
|
module Bio::Shell
|
@@ -152,7 +152,7 @@ module Bio::Shell
|
|
152
152
|
datadir = Bio::Shell.data_dir
|
153
153
|
message = "Save file '#{file}' in '#{datadir}' directory? [y/n] "
|
154
154
|
if ! file[/^#{datadir}/] and Bio::Shell.ask_yes_or_no(message)
|
155
|
-
file = datadir
|
155
|
+
file = File.join(datadir, file)
|
156
156
|
end
|
157
157
|
if File.exists?(file)
|
158
158
|
message = "Overwrite existing '#{file}' file? [y/n] "
|
@@ -5,7 +5,7 @@ class BiorubyGenerator < Rails::Generator::Base
|
|
5
5
|
m.directory 'app/helpers'
|
6
6
|
m.directory 'app/views/bioruby'
|
7
7
|
m.directory 'app/views/layouts'
|
8
|
-
m.directory 'public/images'
|
8
|
+
m.directory 'public/images/bioruby'
|
9
9
|
m.directory 'public/stylesheets'
|
10
10
|
m.file 'bioruby_controller.rb', 'app/controllers/bioruby_controller.rb'
|
11
11
|
m.file 'bioruby_helper.rb', 'app/helpers/bioruby_helper.rb'
|
@@ -18,10 +18,10 @@ class BiorubyGenerator < Rails::Generator::Base
|
|
18
18
|
m.file 'history.rhtml', 'app/views/bioruby/history.rhtml'
|
19
19
|
m.file 'index.rhtml', 'app/views/bioruby/index.rhtml'
|
20
20
|
m.file 'bioruby.rhtml', 'app/views/layouts/bioruby.rhtml'
|
21
|
-
m.file '
|
22
|
-
m.file 'bioruby-
|
23
|
-
m.file 'bioruby-
|
24
|
-
m.file 'bioruby-
|
21
|
+
m.file 'spinner.gif', 'public/images/bioruby/spinner.gif'
|
22
|
+
m.file 'bioruby-gem.png', 'public/images/bioruby/gem.png'
|
23
|
+
m.file 'bioruby-link.gif', 'public/images/bioruby/link.gif'
|
24
|
+
m.file 'bioruby-bg.gif', 'public/images/bioruby/bg.gif'
|
25
25
|
m.file 'bioruby.css', 'public/stylesheets/bioruby.css'
|
26
26
|
end
|
27
27
|
end
|
@@ -3,7 +3,7 @@
|
|
3
3
|
body {
|
4
4
|
margin: 0;
|
5
5
|
color: #555555;
|
6
|
-
background: url("/images/bioruby
|
6
|
+
background: url("/images/bioruby/bg.gif") repeat-y center;
|
7
7
|
font-family: "trebuchet ms", verdana, arial, helvetica, sans-serif;
|
8
8
|
font-size: 12px;
|
9
9
|
}
|
@@ -22,7 +22,7 @@ div#title {
|
|
22
22
|
padding-right: 200px;
|
23
23
|
margin-bottom: 20px;
|
24
24
|
text-align: left;
|
25
|
-
background: url("/images/bioruby
|
25
|
+
background: url("/images/bioruby/gem.png") no-repeat left bottom;
|
26
26
|
}
|
27
27
|
|
28
28
|
div#title .titletop {
|
@@ -169,6 +169,11 @@ div#side li {
|
|
169
169
|
|
170
170
|
div#side img {
|
171
171
|
padding: 5px;
|
172
|
+
/* centering */
|
173
|
+
display: block;
|
174
|
+
margin-left: auto;
|
175
|
+
margin-right: auto;
|
176
|
+
border: 0px;
|
172
177
|
}
|
173
178
|
|
174
179
|
/* history */
|
@@ -198,11 +203,6 @@ div#command {
|
|
198
203
|
/* image */
|
199
204
|
|
200
205
|
img {
|
201
|
-
/* centering */
|
202
|
-
display: block;
|
203
|
-
margin-left: auto;
|
204
|
-
margin-right: auto;
|
205
|
-
border: 0px;
|
206
206
|
}
|
207
207
|
|
208
208
|
/* em */
|
@@ -335,7 +335,6 @@ input[type=submit] {
|
|
335
335
|
/* textarea */
|
336
336
|
|
337
337
|
textarea {
|
338
|
-
background: url("/images/bioruby-console.png") no-repeat center;
|
339
338
|
background-color: #eaedeb;
|
340
339
|
font-family: monospace;
|
341
340
|
font-size: 12px;
|
@@ -28,7 +28,7 @@
|
|
28
28
|
<%= render :partial => "variables" %>
|
29
29
|
|
30
30
|
<br>
|
31
|
-
<a href="http://bioruby.org/"><img src="/images/bioruby
|
31
|
+
<a href="http://bioruby.org/"><img src="/images/bioruby/link.gif" border=0></a>
|
32
32
|
</div><!-- side -->
|
33
33
|
|
34
34
|
<div id="title">
|
@@ -1,22 +1,26 @@
|
|
1
1
|
<div id="console">
|
2
|
-
<%- if flash[:notice] -%>
|
3
|
-
<div id="notice"><p><%= flash[:notice] %></p></div><br>
|
4
|
-
<%- end -%>
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
<
|
9
|
-
<
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
results
|
18
|
-
<%=
|
2
|
+
<%- if flash[:notice] -%>
|
3
|
+
<div id="notice"><p><%= flash[:notice] %></p></div><br>
|
4
|
+
<%- end -%>
|
5
|
+
<% form_remote_tag(:url => {:action => "evaluate"}, :position => "top",
|
6
|
+
:before => %(Element.show('spinner')),
|
7
|
+
:complete => %(Element.hide('spinner'))) do %>
|
8
|
+
<img id="spinner" src="/images/bioruby/spinner.gif" style="display:none">
|
9
|
+
<b>BioRuby script:</b>
|
10
|
+
<br/>
|
11
|
+
<textarea id="script" name="script" rows=10 cols=80></textarea>
|
12
|
+
<br/>
|
13
|
+
<input type="submit" value="Evaluate">
|
14
|
+
<input type="reset" value="Clear">
|
15
|
+
|
16
|
+
Show [
|
17
|
+
<%= link_to_remote "All", :url => {:action => "results", :limit => 0} %> |
|
18
|
+
<%= link_to_remote "Last 5", :url => {:action => "results", :limit => 5} %> |
|
19
|
+
<%= link_to_remote "Previous", :url => {:action => "results", :limit => 1} %>
|
20
|
+
] or <%= link_to "Hide", :action => "index" %> results<br/>
|
21
|
+
<% end %>
|
19
22
|
</div>
|
23
|
+
|
20
24
|
<div id="logs">
|
21
25
|
</div>
|
22
26
|
|
@@ -5,7 +5,7 @@
|
|
5
5
|
# Mitsuteru C. Nakao <n@bioruby.org>
|
6
6
|
# License:: The Ruby License
|
7
7
|
#
|
8
|
-
# $Id: test_ensembl.rb,v 1.
|
8
|
+
# $Id: test_ensembl.rb,v 1.5 2007/11/10 16:57:43 nakao Exp $
|
9
9
|
#
|
10
10
|
|
11
11
|
require 'pathname'
|
@@ -73,13 +73,47 @@ class FuncTestEnsemblHuman < Test::Unit::TestCase
|
|
73
73
|
end
|
74
74
|
|
75
75
|
def test_gff_exportview
|
76
|
-
line = "chromosome:NCBI36:4:1149206:1149209:1
|
76
|
+
line = ["chromosome:NCBI36:4:1149206:1149209:1",
|
77
|
+
"Ensembl",
|
78
|
+
"Gene",
|
79
|
+
"-839",
|
80
|
+
"2747",
|
81
|
+
".",
|
82
|
+
"+",
|
83
|
+
".",
|
84
|
+
"gene_id=ENSG00000206158; transcript_id=ENST00000382964; exon_id=ENSE00001494097; gene_type=KNOWN_protein_coding\n"].join("\t") + "\n"
|
85
|
+
line = ["4",
|
86
|
+
"Ensembl",
|
87
|
+
"Gene",
|
88
|
+
"1148366",
|
89
|
+
"1151952",
|
90
|
+
".",
|
91
|
+
"+",
|
92
|
+
"1",
|
93
|
+
"gene_id=ENSG00000206158; transcript_id=ENST00000382964; exon_id=ENSE00001494097; gene_type=KNOWN_protein_coding"].join("\t") + "\n"
|
77
94
|
gff = @serv.exportview(4, 1149206, 1149209, ['gene'])
|
78
95
|
assert_equal(line, gff)
|
79
96
|
end
|
80
97
|
|
81
98
|
def test_gff_exportview_with_named_args
|
82
|
-
line = "chromosome:NCBI36:4:1149206:1149209:1
|
99
|
+
line = ["chromosome:NCBI36:4:1149206:1149209:1",
|
100
|
+
"Ensembl",
|
101
|
+
"Gene",
|
102
|
+
"-839",
|
103
|
+
"2747",
|
104
|
+
".",
|
105
|
+
"+",
|
106
|
+
".",
|
107
|
+
"gene_id=ENSG00000206158; transcript_id=ENST00000382964; exon_id=ENSE00001494097; gene_type=KNOWN_protein_coding"].join("\t") + "\n"
|
108
|
+
line = ["4",
|
109
|
+
"Ensembl",
|
110
|
+
"Gene",
|
111
|
+
"1148366",
|
112
|
+
"1151952",
|
113
|
+
".",
|
114
|
+
"+",
|
115
|
+
"1",
|
116
|
+
"gene_id=ENSG00000206158; transcript_id=ENST00000382964; exon_id=ENSE00001494097; gene_type=KNOWN_protein_coding"].join("\t") + "\n"
|
83
117
|
gff = @serv.exportview(:seq_region_name => 4,
|
84
118
|
:anchor1 => 1149206,
|
85
119
|
:anchor2 => 1149209,
|
@@ -88,7 +122,56 @@ class FuncTestEnsemblHuman < Test::Unit::TestCase
|
|
88
122
|
end
|
89
123
|
|
90
124
|
def test_tab_exportview_with_named_args
|
91
|
-
line = "seqname
|
125
|
+
line = [["seqname",
|
126
|
+
"source",
|
127
|
+
"feature",
|
128
|
+
"start",
|
129
|
+
"end",
|
130
|
+
"score",
|
131
|
+
"strand",
|
132
|
+
"frame",
|
133
|
+
"gene_id",
|
134
|
+
"transcript_id",
|
135
|
+
"exon_id",
|
136
|
+
"gene_type"].join("\t"),
|
137
|
+
["chromosome:NCBI36:4:1149206:1149209:1",
|
138
|
+
"Ensembl",
|
139
|
+
"Gene",
|
140
|
+
"-839",
|
141
|
+
"2747",
|
142
|
+
".",
|
143
|
+
"+",
|
144
|
+
".",
|
145
|
+
"ENSG00000206158",
|
146
|
+
"ENST00000382964",
|
147
|
+
"ENSE00001494097",
|
148
|
+
"KNOWN_protein_coding"].join("\t") + "\n"
|
149
|
+
].join("\n")
|
150
|
+
line = [["seqname",
|
151
|
+
"source",
|
152
|
+
"feature",
|
153
|
+
"start",
|
154
|
+
"end",
|
155
|
+
"score",
|
156
|
+
"strand",
|
157
|
+
"frame",
|
158
|
+
"gene_id",
|
159
|
+
"transcript_id",
|
160
|
+
"exon_id",
|
161
|
+
"gene_type"].join("\t"),
|
162
|
+
["4",
|
163
|
+
"Ensembl",
|
164
|
+
"Gene",
|
165
|
+
"1148366",
|
166
|
+
"1151952",
|
167
|
+
".",
|
168
|
+
"+",
|
169
|
+
"1",
|
170
|
+
"ENSG00000206158",
|
171
|
+
"ENST00000382964",
|
172
|
+
"ENSE00001494097",
|
173
|
+
"KNOWN_protein_coding"].join("\t") + "\n"
|
174
|
+
].join("\n")
|
92
175
|
gff = @serv.exportview(:seq_region_name => 4,
|
93
176
|
:anchor1 => 1149206,
|
94
177
|
:anchor2 => 1149209,
|
@@ -6,7 +6,7 @@
|
|
6
6
|
# Naohisa Goto <ng@bioruby.org>
|
7
7
|
# License:: The Ruby License
|
8
8
|
#
|
9
|
-
# $Id: test_newick.rb,v 1.
|
9
|
+
# $Id: test_newick.rb,v 1.6 2007/12/12 16:06:22 ngoto Exp $
|
10
10
|
#
|
11
11
|
|
12
12
|
require 'test/unit'
|
@@ -53,4 +53,241 @@ module Bio
|
|
53
53
|
end
|
54
54
|
|
55
55
|
end #class TestNewick
|
56
|
+
|
57
|
+
class TestNewick2 < Test::Unit::TestCase
|
58
|
+
|
59
|
+
TREE_STRING = <<-END_OF_TREE_STRING
|
60
|
+
(
|
61
|
+
(
|
62
|
+
'this is test':0.0625,
|
63
|
+
'test2 (abc, def)':0.125
|
64
|
+
) 'internal node''s name' : 0.25,
|
65
|
+
(
|
66
|
+
'''':0.03125,
|
67
|
+
(
|
68
|
+
'ABCAC_HUMAN [ABC superfamily]':0.015625,
|
69
|
+
hypothetical_protein:0.5
|
70
|
+
) ABC : 0.25 [99]
|
71
|
+
) test3 :0.5
|
72
|
+
)root;
|
73
|
+
END_OF_TREE_STRING
|
74
|
+
|
75
|
+
def test_string_tree
|
76
|
+
newick = Bio::Newick.new(TREE_STRING)
|
77
|
+
tree = newick.tree
|
78
|
+
assert_equal('root', tree.root.name)
|
79
|
+
assert_equal([
|
80
|
+
"this is test",
|
81
|
+
"test2 (abc, def)",
|
82
|
+
"internal node\'s name",
|
83
|
+
"\'",
|
84
|
+
"ABCAC_HUMAN [ABC superfamily]",
|
85
|
+
"hypothetical protein",
|
86
|
+
"ABC",
|
87
|
+
"test3",
|
88
|
+
"root"
|
89
|
+
].sort,
|
90
|
+
tree.nodes.collect { |x| x.name }.sort)
|
91
|
+
|
92
|
+
assert_equal(tree.children(tree.root).collect { |x| x.name }.sort,
|
93
|
+
[ "internal node\'s name", "test3" ])
|
94
|
+
|
95
|
+
node = tree.get_node_by_name('ABC')
|
96
|
+
assert_equal(99, node.bootstrap)
|
97
|
+
|
98
|
+
assert_equal(1.5625,
|
99
|
+
tree.distance(tree.get_node_by_name('hypothetical protein'),
|
100
|
+
tree.get_node_by_name('this is test')))
|
101
|
+
end
|
102
|
+
|
103
|
+
end #class TestNewick2
|
104
|
+
|
105
|
+
class TestNewickPrivate < Test::Unit::TestCase
|
106
|
+
def setup
|
107
|
+
@newick = Bio::Newick.new('') # dummy data
|
108
|
+
end
|
109
|
+
|
110
|
+
def test_parse_newick_leaf
|
111
|
+
leaf_tokens = [ "A:B _C(D,E)F\'s G[H]", :":", '0.5', :"[",
|
112
|
+
"&&NHX", :":", "S=human", :":", "E=1.1.1.1", :"]" ]
|
113
|
+
node = Bio::Tree::Node.new
|
114
|
+
edge = Bio::Tree::Edge.new
|
115
|
+
options = {}
|
116
|
+
|
117
|
+
assert_equal(true,
|
118
|
+
@newick.instance_eval do
|
119
|
+
__parse_newick_leaf(leaf_tokens, node, edge, options)
|
120
|
+
end)
|
121
|
+
|
122
|
+
assert_equal(:nhx, @newick.options[:original_format])
|
123
|
+
assert_equal("A:B _C(D,E)F\'s G[H]", node.name)
|
124
|
+
assert_equal("human", node.scientific_name)
|
125
|
+
assert_equal("1.1.1.1", node.ec_number)
|
126
|
+
assert_equal(0.5, edge.distance)
|
127
|
+
end
|
128
|
+
|
129
|
+
def test_parse_newick_get_tokens_for_leaf
|
130
|
+
input = [ "A:B _C(D,E)F\'s G[H]", :":", '0.5', :"[",
|
131
|
+
"&&NHX", :":", "S=human", :":", "E=1.1.1.1", :"]",
|
132
|
+
:",", :"(", "bbb", :":", "0.2", :")" ]
|
133
|
+
leaf_should_be = [ "A:B _C(D,E)F\'s G[H]", :":", '0.5', :"[",
|
134
|
+
"&&NHX", :":", "S=human", :":", "E=1.1.1.1", :"]" ]
|
135
|
+
rest_should_be = [ :",", :"(", "bbb", :":", "0.2", :")" ]
|
136
|
+
|
137
|
+
assert_equal(leaf_should_be,
|
138
|
+
@newick.instance_eval do
|
139
|
+
__parse_newick_get_tokens_for_leaf(input)
|
140
|
+
end)
|
141
|
+
|
142
|
+
assert_equal(rest_should_be, input)
|
143
|
+
end
|
144
|
+
|
145
|
+
def test_parse_newick_tokenize
|
146
|
+
examples =
|
147
|
+
[
|
148
|
+
[
|
149
|
+
'(a,b);', # input
|
150
|
+
[ :"(", 'a', :",", 'b', :")" ], # normal parser result
|
151
|
+
[ :"(", 'a', :",", 'b', :")" ], # naive parser result
|
152
|
+
],
|
153
|
+
[
|
154
|
+
# input
|
155
|
+
"(\'A:B _C(D,E)F\'\'s G[H]\':0.5[&&NHX:S=human:E=1.1.1.1], \n(bbb:0.2, c_d_e[&&NHX:B=100]);",
|
156
|
+
# normal parser result
|
157
|
+
[ :"(", "A:B _C(D,E)F\'s G[H]", :":", '0.5', :"[",
|
158
|
+
"&&NHX", :":", "S=human", :":", "E=1.1.1.1", :"]",
|
159
|
+
:",", :"(", "bbb", :":", "0.2", :",",
|
160
|
+
"c d e", :"[", "&&NHX", :":", "B=100", :"]", :")" ],
|
161
|
+
# naive parser result
|
162
|
+
[ :"(", "\'A", :":", "B _C", :"(", "D", :",", "E",
|
163
|
+
:")", "F\'\'s G", :"[", "H", :"]", "\'", :":", '0.5', :"[",
|
164
|
+
"&&NHX", :":", "S=human", :":", "E=1.1.1.1", :"]",
|
165
|
+
:",", :"(", "bbb", :":", "0.2", :",",
|
166
|
+
"c_d_e", :"[", "&&NHX", :":", "B=100", :"]", :")" ]
|
167
|
+
]
|
168
|
+
]
|
169
|
+
|
170
|
+
examples.each do |a|
|
171
|
+
# normal parser
|
172
|
+
assert_equal(a[1],
|
173
|
+
@newick.instance_eval do
|
174
|
+
__parse_newick_tokenize(a[0], {})
|
175
|
+
end)
|
176
|
+
|
177
|
+
# naive parser
|
178
|
+
assert_equal(a[2],
|
179
|
+
@newick.instance_eval do
|
180
|
+
__parse_newick_tokenize(a[0], { :parser => :naive })
|
181
|
+
end)
|
182
|
+
end
|
183
|
+
end
|
184
|
+
end #class TestNewickPrivate
|
185
|
+
|
186
|
+
class TestBioTreeOutputPrivate < Test::Unit::TestCase
|
187
|
+
|
188
|
+
def setup
|
189
|
+
@tree = Bio::Tree.new
|
190
|
+
end
|
191
|
+
|
192
|
+
def test_to_newick_format_label
|
193
|
+
# unquoted_label
|
194
|
+
assert_equal('ABC', @tree.instance_eval do
|
195
|
+
__to_newick_format_label('ABC', {})
|
196
|
+
end)
|
197
|
+
|
198
|
+
# unquoted_label, replaces blank to underscore
|
199
|
+
assert_equal('A_B_C', @tree.instance_eval do
|
200
|
+
__to_newick_format_label('A B C', {})
|
201
|
+
end)
|
202
|
+
|
203
|
+
# quoted_label example 1
|
204
|
+
assert_equal("\'A B_C\'", @tree.instance_eval do
|
205
|
+
__to_newick_format_label('A B_C', {})
|
206
|
+
end)
|
207
|
+
|
208
|
+
# quoted_label example 2
|
209
|
+
assert_equal("\'A(B),C\'", @tree.instance_eval do
|
210
|
+
__to_newick_format_label('A(B),C', {})
|
211
|
+
end)
|
212
|
+
|
213
|
+
# normal formatter
|
214
|
+
assert_equal("\'A_B_C\'", @tree.instance_eval do
|
215
|
+
__to_newick_format_label('A_B_C', {})
|
216
|
+
end)
|
217
|
+
# naive formatter
|
218
|
+
assert_equal("A_B_C", @tree.instance_eval do
|
219
|
+
__to_newick_format_label('A_B_C',
|
220
|
+
{ :parser => :naive })
|
221
|
+
end)
|
222
|
+
end
|
223
|
+
|
224
|
+
|
225
|
+
def test_to_newick_format_leaf
|
226
|
+
node = Bio::Tree::Node.new('ABC')
|
227
|
+
edge = Bio::Tree::Edge.new(0.5)
|
228
|
+
|
229
|
+
assert_equal('ABC:0.5', @tree.instance_eval do
|
230
|
+
__to_newick_format_leaf(node, edge, {})
|
231
|
+
end)
|
232
|
+
|
233
|
+
# disable branch length
|
234
|
+
assert_equal('ABC', @tree.instance_eval do
|
235
|
+
__to_newick_format_leaf(node, edge,
|
236
|
+
{ :branch_length_style =>
|
237
|
+
:disabled })
|
238
|
+
end)
|
239
|
+
|
240
|
+
node.bootstrap = 98
|
241
|
+
# default: molphy style bootstrap
|
242
|
+
assert_equal('ABC:0.5[98]', @tree.instance_eval do
|
243
|
+
__to_newick_format_leaf(node, edge, {})
|
244
|
+
end)
|
245
|
+
# force molphy style bootstrap
|
246
|
+
assert_equal('ABC:0.5[98]', @tree.instance_eval do
|
247
|
+
__to_newick_format_leaf(node, edge,
|
248
|
+
{ :bootstrap_style => :molphy })
|
249
|
+
end)
|
250
|
+
# disable bootstrap output
|
251
|
+
assert_equal('ABC:0.5', @tree.instance_eval do
|
252
|
+
__to_newick_format_leaf(node, edge,
|
253
|
+
{ :bootstrap_style =>
|
254
|
+
:disabled })
|
255
|
+
end)
|
256
|
+
|
257
|
+
# force traditional bootstrap style
|
258
|
+
assert_equal('ABC98:0.5', @tree.instance_eval do
|
259
|
+
__to_newick_format_leaf(node, edge,
|
260
|
+
{ :bootstrap_style =>
|
261
|
+
:traditional })
|
262
|
+
end)
|
263
|
+
# normally, when traditional style, no node name allowed for the node
|
264
|
+
node2 = Bio::Tree::Node.new
|
265
|
+
node2.bootstrap = 98
|
266
|
+
assert_equal('98:0.5', @tree.instance_eval do
|
267
|
+
__to_newick_format_leaf(node2, edge,
|
268
|
+
{ :bootstrap_style =>
|
269
|
+
:traditional })
|
270
|
+
end)
|
271
|
+
|
272
|
+
end
|
273
|
+
|
274
|
+
def test_to_newick_format_leaf_NHX
|
275
|
+
node = Bio::Tree::Node.new('ADH')
|
276
|
+
edge = Bio::Tree::Edge.new(0.5)
|
277
|
+
node.bootstrap = 98
|
278
|
+
node.ec_number = '1.1.1.1'
|
279
|
+
node.scientific_name = 'human'
|
280
|
+
node.taxonomy_id = '9606'
|
281
|
+
node.events.push :gene_duplication
|
282
|
+
edge.log_likelihood = 1.5
|
283
|
+
edge.width = 3
|
284
|
+
|
285
|
+
str = 'ADH:0.5[&&NHX:B=98:D=Y:E=1.1.1.1:L=1.5:S=human:T=9606:W=3]'
|
286
|
+
assert_equal(str, @tree.instance_eval do
|
287
|
+
__to_newick_format_leaf_NHX(node, edge, {})
|
288
|
+
end)
|
289
|
+
end
|
290
|
+
|
291
|
+
end #class TestBioTreeOutputPrivate
|
292
|
+
|
56
293
|
end #module Bio
|