bio-svgenes 0.2.3 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.DS_Store +0 -0
- data/VERSION +1 -1
- data/bio-svgenes.gemspec +59 -4
- data/doc/.DS_Store +0 -0
- data/doc/Bio.html +141 -0
- data/doc/Bio/.DS_Store +0 -0
- data/doc/Bio/Graphics.html +147 -0
- data/doc/Bio/Graphics/Glyph.html +1061 -0
- data/doc/Bio/Graphics/MiniFeature.html +342 -0
- data/doc/Bio/Graphics/Page.html +1200 -0
- data/doc/Bio/Graphics/Primitive.html +278 -0
- data/doc/Bio/Graphics/SVGEE.html +471 -0
- data/doc/Bio/Graphics/Track.html +506 -0
- data/doc/LICENSE_txt.html +118 -0
- data/doc/created.rid +9 -0
- data/doc/images/add.png +0 -0
- data/doc/images/arrow_up.png +0 -0
- data/doc/images/brick.png +0 -0
- data/doc/images/brick_link.png +0 -0
- data/doc/images/bug.png +0 -0
- data/doc/images/bullet_black.png +0 -0
- data/doc/images/bullet_toggle_minus.png +0 -0
- data/doc/images/bullet_toggle_plus.png +0 -0
- data/doc/images/date.png +0 -0
- data/doc/images/delete.png +0 -0
- data/doc/images/find.png +0 -0
- data/doc/images/loadingAnimation.gif +0 -0
- data/doc/images/macFFBgHack.png +0 -0
- data/doc/images/package.png +0 -0
- data/doc/images/page_green.png +0 -0
- data/doc/images/page_white_text.png +0 -0
- data/doc/images/page_white_width.png +0 -0
- data/doc/images/plugin.png +0 -0
- data/doc/images/ruby.png +0 -0
- data/doc/images/tag_blue.png +0 -0
- data/doc/images/tag_green.png +0 -0
- data/doc/images/transparent.png +0 -0
- data/doc/images/wrench.png +0 -0
- data/doc/images/wrench_orange.png +0 -0
- data/doc/images/zoom.png +0 -0
- data/doc/index.html +94 -0
- data/doc/js/darkfish.js +155 -0
- data/doc/js/jquery.js +18 -0
- data/doc/js/navigation.js +142 -0
- data/doc/js/search.js +94 -0
- data/doc/js/search_index.js +1 -0
- data/doc/js/searcher.js +228 -0
- data/doc/rdoc.css +595 -0
- data/doc/table_of_contents.html +162 -0
- data/test/gene.gff +4 -0
- data/test/json_config.json +17 -0
- data/test/test_glyph.rb +33 -0
- data/test/test_mini_feature.rb +37 -0
- data/test/test_page.rb +127 -0
- data/test/test_primitive.rb +45 -0
- data/test/test_svgee.rb +73 -0
- data/test/test_track.rb +53 -0
- data/test/test_transcripts.gff +4 -0
- metadata +94 -14
@@ -0,0 +1,162 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
|
3
|
+
<html>
|
4
|
+
<head>
|
5
|
+
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
|
6
|
+
|
7
|
+
<title>Table of Contents - RDoc Documentation</title>
|
8
|
+
|
9
|
+
<link type="text/css" media="screen" href="./rdoc.css" rel="stylesheet">
|
10
|
+
|
11
|
+
<script type="text/javascript">
|
12
|
+
var rdoc_rel_prefix = "./";
|
13
|
+
</script>
|
14
|
+
|
15
|
+
<script type="text/javascript" charset="utf-8" src="./js/jquery.js"></script>
|
16
|
+
<script type="text/javascript" charset="utf-8" src="./js/navigation.js"></script>
|
17
|
+
<script type="text/javascript" charset="utf-8" src="./js/search_index.js"></script>
|
18
|
+
<script type="text/javascript" charset="utf-8" src="./js/search.js"></script>
|
19
|
+
<script type="text/javascript" charset="utf-8" src="./js/searcher.js"></script>
|
20
|
+
<script type="text/javascript" charset="utf-8" src="./js/darkfish.js"></script>
|
21
|
+
|
22
|
+
|
23
|
+
<body class="indexpage">
|
24
|
+
<h1>Table of Contents - RDoc Documentation</h1>
|
25
|
+
|
26
|
+
<h2>Pages</h2>
|
27
|
+
<ul>
|
28
|
+
<li class="file">
|
29
|
+
<a href="LICENSE_txt.html">LICENSE</a>
|
30
|
+
</li>
|
31
|
+
|
32
|
+
</ul>
|
33
|
+
|
34
|
+
<h2 id="classes">Classes/Modules</h2>
|
35
|
+
<ul>
|
36
|
+
<li class="module">
|
37
|
+
<a href="Bio.html">Bio</a>
|
38
|
+
</li>
|
39
|
+
<li class="class">
|
40
|
+
<a href="Bio/Graphics.html">Bio::Graphics</a>
|
41
|
+
</li>
|
42
|
+
<li class="class">
|
43
|
+
<a href="Bio/Graphics/Glyph.html">Bio::Graphics::Glyph</a>
|
44
|
+
</li>
|
45
|
+
<li class="class">
|
46
|
+
<a href="Bio/Graphics/MiniFeature.html">Bio::Graphics::MiniFeature</a>
|
47
|
+
</li>
|
48
|
+
<li class="class">
|
49
|
+
<a href="Bio/Graphics/Page.html">Bio::Graphics::Page</a>
|
50
|
+
</li>
|
51
|
+
<li class="class">
|
52
|
+
<a href="Bio/Graphics/Primitive.html">Bio::Graphics::Primitive</a>
|
53
|
+
</li>
|
54
|
+
<li class="class">
|
55
|
+
<a href="Bio/Graphics/SVGEE.html">Bio::Graphics::SVGEE</a>
|
56
|
+
</li>
|
57
|
+
<li class="class">
|
58
|
+
<a href="Bio/Graphics/Track.html">Bio::Graphics::Track</a>
|
59
|
+
</li>
|
60
|
+
|
61
|
+
</ul>
|
62
|
+
|
63
|
+
<h2 id="methods">Methods</h2>
|
64
|
+
<ul>
|
65
|
+
|
66
|
+
<li class="method"><a href="Bio/Graphics/Glyph.html#method-c-circle">::circle — Bio::Graphics::Glyph</a>
|
67
|
+
|
68
|
+
<li class="method"><a href="Bio/Graphics/Glyph.html#method-c-directed">::directed — Bio::Graphics::Glyph</a>
|
69
|
+
|
70
|
+
<li class="method"><a href="Bio/Graphics/Glyph.html#method-c-down_triangle">::down_triangle — Bio::Graphics::Glyph</a>
|
71
|
+
|
72
|
+
<li class="method"><a href="Bio/Graphics/Page.html#method-c-from_json">::from_json — Bio::Graphics::Page</a>
|
73
|
+
|
74
|
+
<li class="method"><a href="Bio/Graphics/Glyph.html#method-c-generic">::generic — Bio::Graphics::Glyph</a>
|
75
|
+
|
76
|
+
<li class="method"><a href="Bio/Graphics/Glyph.html#method-c-gradient">::gradient — Bio::Graphics::Glyph</a>
|
77
|
+
|
78
|
+
<li class="method"><a href="Bio/Graphics/Glyph.html#method-c-gradients">::gradients — Bio::Graphics::Glyph</a>
|
79
|
+
|
80
|
+
<li class="method"><a href="Bio/Graphics/Glyph.html#method-c-label">::label — Bio::Graphics::Glyph</a>
|
81
|
+
|
82
|
+
<li class="method"><a href="Bio/Graphics/Track.html#method-c-new">::new — Bio::Graphics::Track</a>
|
83
|
+
|
84
|
+
<li class="method"><a href="Bio/Graphics/SVGEE.html#method-c-new">::new — Bio::Graphics::SVGEE</a>
|
85
|
+
|
86
|
+
<li class="method"><a href="Bio/Graphics/Page.html#method-c-new">::new — Bio::Graphics::Page</a>
|
87
|
+
|
88
|
+
<li class="method"><a href="Bio/Graphics/MiniFeature.html#method-c-new">::new — Bio::Graphics::MiniFeature</a>
|
89
|
+
|
90
|
+
<li class="method"><a href="Bio/Graphics/Primitive.html#method-c-new">::new — Bio::Graphics::Primitive</a>
|
91
|
+
|
92
|
+
<li class="method"><a href="Bio/Graphics/Page.html#method-c-parse_gff">::parse_gff — Bio::Graphics::Page</a>
|
93
|
+
|
94
|
+
<li class="method"><a href="Bio/Graphics/Glyph.html#method-c-scale">::scale — Bio::Graphics::Glyph</a>
|
95
|
+
|
96
|
+
<li class="method"><a href="Bio/Graphics/Glyph.html#method-c-span">::span — Bio::Graphics::Glyph</a>
|
97
|
+
|
98
|
+
<li class="method"><a href="Bio/Graphics/Glyph.html#method-c-transcript">::transcript — Bio::Graphics::Glyph</a>
|
99
|
+
|
100
|
+
<li class="method"><a href="Bio/Graphics/Glyph.html#method-c-up_triangle">::up_triangle — Bio::Graphics::Glyph</a>
|
101
|
+
|
102
|
+
<li class="method"><a href="Bio/Graphics/Track.html#method-i-add">#add — Bio::Graphics::Track</a>
|
103
|
+
|
104
|
+
<li class="method"><a href="Bio/Graphics/SVGEE.html#method-i-add_primitive">#add_primitive — Bio::Graphics::SVGEE</a>
|
105
|
+
|
106
|
+
<li class="method"><a href="Bio/Graphics/Page.html#method-i-add_track">#add_track — Bio::Graphics::Page</a>
|
107
|
+
|
108
|
+
<li class="method"><a href="Bio/Graphics/SVGEE.html#method-i-close_tag">#close_tag — Bio::Graphics::SVGEE</a>
|
109
|
+
|
110
|
+
<li class="method"><a href="Bio/Graphics/SVGEE.html#method-i-draw">#draw — Bio::Graphics::SVGEE</a>
|
111
|
+
|
112
|
+
<li class="method"><a href="Bio/Graphics/Page.html#method-i-draw">#draw — Bio::Graphics::Page</a>
|
113
|
+
|
114
|
+
<li class="method"><a href="Bio/Graphics/Page.html#method-i-draw_circle">#draw_circle — Bio::Graphics::Page</a>
|
115
|
+
|
116
|
+
<li class="method"><a href="Bio/Graphics/Page.html#method-i-draw_directed">#draw_directed — Bio::Graphics::Page</a>
|
117
|
+
|
118
|
+
<li class="method"><a href="Bio/Graphics/Page.html#method-i-draw_down_triangle">#draw_down_triangle — Bio::Graphics::Page</a>
|
119
|
+
|
120
|
+
<li class="method"><a href="Bio/Graphics/Page.html#method-i-draw_features">#draw_features — Bio::Graphics::Page</a>
|
121
|
+
|
122
|
+
<li class="method"><a href="Bio/Graphics/Page.html#method-i-draw_generic">#draw_generic — Bio::Graphics::Page</a>
|
123
|
+
|
124
|
+
<li class="method"><a href="Bio/Graphics/Page.html#method-i-draw_histogram">#draw_histogram — Bio::Graphics::Page</a>
|
125
|
+
|
126
|
+
<li class="method"><a href="Bio/Graphics/Page.html#method-i-draw_label">#draw_label — Bio::Graphics::Page</a>
|
127
|
+
|
128
|
+
<li class="method"><a href="Bio/Graphics/Page.html#method-i-draw_scale">#draw_scale — Bio::Graphics::Page</a>
|
129
|
+
|
130
|
+
<li class="method"><a href="Bio/Graphics/Page.html#method-i-draw_span">#draw_span — Bio::Graphics::Page</a>
|
131
|
+
|
132
|
+
<li class="method"><a href="Bio/Graphics/Page.html#method-i-draw_transcript">#draw_transcript — Bio::Graphics::Page</a>
|
133
|
+
|
134
|
+
<li class="method"><a href="Bio/Graphics/Page.html#method-i-draw_up_triangle">#draw_up_triangle — Bio::Graphics::Page</a>
|
135
|
+
|
136
|
+
<li class="method"><a href="Bio/Graphics/Page.html#method-i-get_limits">#get_limits — Bio::Graphics::Page</a>
|
137
|
+
|
138
|
+
<li class="method"><a href="Bio/Graphics/Page.html#method-i-get_markup">#get_markup — Bio::Graphics::Page</a>
|
139
|
+
|
140
|
+
<li class="method"><a href="Bio/Graphics/Track.html#method-i-get_rows">#get_rows — Bio::Graphics::Track</a>
|
141
|
+
|
142
|
+
<li class="method"><a href="Bio/Graphics/SVGEE.html#method-i-gradient">#gradient — Bio::Graphics::SVGEE</a>
|
143
|
+
|
144
|
+
<li class="method"><a href="Bio/Graphics/SVGEE.html#method-i-open_tag">#open_tag — Bio::Graphics::SVGEE</a>
|
145
|
+
|
146
|
+
<li class="method"><a href="Bio/Graphics/Track.html#method-i-overlaps">#overlaps — Bio::Graphics::Track</a>
|
147
|
+
|
148
|
+
<li class="method"><a href="Bio/Graphics/Page.html#method-i-to_px">#to_px — Bio::Graphics::Page</a>
|
149
|
+
|
150
|
+
<li class="method"><a href="Bio/Graphics/Primitive.html#method-i-update">#update — Bio::Graphics::Primitive</a>
|
151
|
+
|
152
|
+
<li class="method"><a href="Bio/Graphics/Page.html#method-i-write">#write — Bio::Graphics::Page</a>
|
153
|
+
|
154
|
+
</ul>
|
155
|
+
|
156
|
+
|
157
|
+
<footer id="validator-badges">
|
158
|
+
<p><a href="http://validator.w3.org/check/referer">[Validate]</a>
|
159
|
+
<p>Generated by <a href="https://github.com/rdoc/rdoc">RDoc</a> 4.0.0.rc.2.1.
|
160
|
+
<p>Generated with the <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish Rdoc Generator</a> 3.
|
161
|
+
</footer>
|
162
|
+
|
data/test/gene.gff
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
{
|
2
|
+
"Page":{"width":800, "height":800, "intervals":15},
|
3
|
+
"Tracks": [
|
4
|
+
{
|
5
|
+
"glyph":"transcript",
|
6
|
+
"name":"Transcripts",
|
7
|
+
"label":true,
|
8
|
+
"file":"test/test_transcripts.gff",
|
9
|
+
"file_type":"gff",
|
10
|
+
"exon_fill_color":"green_white_radial",
|
11
|
+
"utr_fill_color":"blue_white_radial",
|
12
|
+
"stroke_width":1,
|
13
|
+
"gap_marker":"angled"
|
14
|
+
}
|
15
|
+
]
|
16
|
+
}
|
17
|
+
|
data/test/test_glyph.rb
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
$: << File.expand_path(File.dirname(__FILE__) + '/../lib')
|
2
|
+
$: << File.expand_path('.')
|
3
|
+
require 'rubygems'
|
4
|
+
require "test/unit"
|
5
|
+
require 'helper'
|
6
|
+
require 'pp'
|
7
|
+
|
8
|
+
|
9
|
+
class TestGlyph < Test::Unit::TestCase
|
10
|
+
|
11
|
+
def setup
|
12
|
+
@circle_glyph = Bio::Graphics::Glyph.circle({})
|
13
|
+
@generic_glyph = Bio::Graphics::Glyph.generic({})
|
14
|
+
@label_glyph = Bio::Graphics::Glyph.label({})
|
15
|
+
@directed_glyph = Bio::Graphics::Glyph.directed(:x => 0, :y => 0, :width => 10)
|
16
|
+
@scale_glyph = Bio::Graphics::Glyph.scale(:start => 2, :stop => 100, :width => 10, :number_of_intervals => 5)
|
17
|
+
@down_triangle_glyph =Bio::Graphics::Glyph.down_triangle(:x => 0, :y => 0, :width => 10)
|
18
|
+
@up_triangle_glyph = Bio::Graphics::Glyph.up_triangle(:x => 0, :y => 0, :width => 10)
|
19
|
+
@span_glyph = Bio::Graphics::Glyph.span(:x => 0, :y => 0, :width => 10)
|
20
|
+
@glyphs = [@circle_glyph, @generic_glyph, @directed_glyph, @scale_glyph, @label_glyph, @down_triangle_glyph, @up_triangle_glyph, @span_glyph]
|
21
|
+
end
|
22
|
+
|
23
|
+
|
24
|
+
def test_glyphs
|
25
|
+
@glyphs.each do |g|
|
26
|
+
assert(g.length > 0)
|
27
|
+
g.each do |o|
|
28
|
+
assert_equal(Bio::Graphics::Primitive, o.class, "not all objects in array are Bio::Graphics::Primitive. #{o.class} encountered")
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
$: << File.expand_path(File.dirname(__FILE__) + '/../lib')
|
2
|
+
$: << File.expand_path('.')
|
3
|
+
require 'rubygems'
|
4
|
+
require 'helper'
|
5
|
+
require 'pp'
|
6
|
+
|
7
|
+
|
8
|
+
class TestMiniFeature < Test::Unit::TestCase
|
9
|
+
|
10
|
+
def setup
|
11
|
+
@mini1 = Bio::Graphics::MiniFeature.new(:start=>3631, :end=>5899, :strand=>'+', :exons=>[4000, 4500, 4700, 5000], :utrs=>[3631, 3650], :segment_height=>5, :id=>"AT1G01010")
|
12
|
+
@mini2 = Bio::Graphics::MiniFeature.new(:start=>5928, :end=>8737, :strand=>'-', :exons=>[7000, 7150, 7200, 8000], :utrs=>[5928, 6500], :segment_height=>5, :id=>"AT1G01020")
|
13
|
+
|
14
|
+
# :start, :end, :strand, :exons, :utrs, :block_gaps, :segment_height, :id
|
15
|
+
end
|
16
|
+
|
17
|
+
|
18
|
+
def test_parse
|
19
|
+
#no methods in mini_feature, so just testing the accessor
|
20
|
+
assert_equal(3631, @mini1.start, "From TestMiniFeature test_parse, @mini1 start site is incorrect (#{@mini1.start})")
|
21
|
+
assert_equal(5899, @mini1.end, "From TestMiniFeature test_parse, @mini1 end site is incorrect (#{@mini1.end})")
|
22
|
+
assert_equal('+', @mini1.strand, "From TestMiniFeature test_parse, @mini1 strand is incorrect (#{@mini1.strand})")
|
23
|
+
assert_equal([4000, 4500, 4700, 5000], @mini1.exons, "From TestMiniFeature test_parse, @mini1 exons are incorrect (#{@mini1.exons})")
|
24
|
+
|
25
|
+
assert_equal([3631, 3650], @mini1.utrs, "From TestMiniFeature test_parse, @mini1 utrs are incorrect (#{@mini1.utrs})")
|
26
|
+
assert_equal(5, @mini1.segment_height, "From TestMiniFeature test_parse, @mini1 segment_height is incorrect")
|
27
|
+
assert_equal("AT1G01010", @mini1.id, "From TestMiniFeature test_parse, @mini1 id is incorrect (#{@mini1.id})")
|
28
|
+
|
29
|
+
assert_equal(5928, @mini2.start, "From TestMiniFeature test_parse, @mini2 start site is incorrect (#{@mini2.start})")
|
30
|
+
assert_equal(8737, @mini2.end, "From TestMiniFeature test_parse, @mini2 end site is incorrect (#{@mini2.end})")
|
31
|
+
assert_equal('-', @mini2.strand, "From TestMiniFeature test_parse, @mini2 strand is incorrect (#{@mini2.strand})")
|
32
|
+
assert_equal([7000, 7150, 7200, 8000], @mini2.exons, "From TestMiniFeature test_parse, @mini2 exons are incorrect (#{@mini2.exons})")
|
33
|
+
assert_equal([5928, 6500],@mini2.utrs, "From TestMiniFeature test_parse, @mini2 utrs are incorrect (#{@mini2.utrs})")
|
34
|
+
assert_equal(5, @mini2.segment_height, "From TestMiniFeature test_parse, @mini2 segment_height is incorrect")
|
35
|
+
assert_equal("AT1G01020", @mini2.id, "From TestMiniFeature test_parse, @mini2 id is incorrect (#{@mini2.id})")
|
36
|
+
end
|
37
|
+
end
|
data/test/test_page.rb
ADDED
@@ -0,0 +1,127 @@
|
|
1
|
+
$: << File.expand_path(File.dirname(__FILE__) + '/../lib')
|
2
|
+
$: << File.expand_path('.')
|
3
|
+
require 'rubygems'
|
4
|
+
#require 'json'
|
5
|
+
require 'bio-svgenes'
|
6
|
+
require 'test/unit'
|
7
|
+
require 'helper'
|
8
|
+
require 'pp'
|
9
|
+
|
10
|
+
module Bio
|
11
|
+
class Graphics
|
12
|
+
class Page
|
13
|
+
attr_accessor :scale_start, :scale_stop, :nt_per_px_x, :width, :tracks, :track_top, :height
|
14
|
+
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
class TestPage < Test::Unit::TestCase
|
20
|
+
|
21
|
+
def setup
|
22
|
+
|
23
|
+
@page = Bio::Graphics::Page.new(:width => 800,:height => 110, :number_of_intervals => 10)
|
24
|
+
|
25
|
+
end
|
26
|
+
|
27
|
+
|
28
|
+
def test_class
|
29
|
+
assert_equal(Bio::Graphics::Page, @page.class, "From TestPage, test_class. @page should be a Bio::Graphics::Page but a #{@page.class} is found")
|
30
|
+
end
|
31
|
+
|
32
|
+
def test_get_limits
|
33
|
+
#pp @page
|
34
|
+
@generic_track = @page.add_track(:glyph => :generic, :name => 'generic_features', :label => true, :track_height => 10)
|
35
|
+
@feature1 = Bio::Graphics::MiniFeature.new(:start => 923, :end => 2212, :strand => '+', :id => "MyFeature")
|
36
|
+
@feature2 = Bio::Graphics::MiniFeature.new(:start => 3000, :end => 3500, :strand => '+', :id => "MyFeature2")
|
37
|
+
@generic_track.add(@feature1)
|
38
|
+
@generic_track.add(@feature2)
|
39
|
+
@page.get_limits
|
40
|
+
|
41
|
+
assert_equal(923, @page.scale_start, "From TestPage, test_get_limits. scale_start is wrong value (#{@page.scale_start})")
|
42
|
+
assert_equal(3500, @page.scale_stop, "From TestPage, test_get_limits. scale_stop is wrong value (#{@page.scale_stop})")
|
43
|
+
assert_equal(800, @page.width, "From TestPage, test_get_limits. width is wrong value (#{@page.width})")
|
44
|
+
#@nt_per_px_x = (@scale_stop - @scale_start).to_f / @width.to_f
|
45
|
+
#which is equal to (3500-923)/800 = 3.22125
|
46
|
+
assert_equal(3.22125, @page.nt_per_px_x, "From TestPage, test_get_limits. nt_per_px_x is wrong value (#{@page.nt_per_px_x})")
|
47
|
+
|
48
|
+
end
|
49
|
+
|
50
|
+
def test_add_track
|
51
|
+
|
52
|
+
@generic_track2 = @page.add_track(:glyph => :generic, :name => 'generic_features2', :label => true, :track_height => 10)
|
53
|
+
#add_track returns the last track added (@generic_track2 in this case)
|
54
|
+
#test that the last track in the tracks array is a Track
|
55
|
+
assert_equal(Bio::Graphics::Track, @page.tracks.last.class, "From TestPage, test_add_track. Looking for a Bio::Graphics::Track but encountered a (#{@page.tracks.last.class})" )
|
56
|
+
#check that the current name of the new track and the last track returned from the tracks array are the same
|
57
|
+
assert_equal(@generic_track2.name, @page.tracks.last.name, "From TestPage, test_add_track. The feature names do not match (#{@generic_track2.name} and #{@page.tracks.last.name})")
|
58
|
+
|
59
|
+
end
|
60
|
+
|
61
|
+
def test_draw_features
|
62
|
+
#get the track top before drawing the features, as we want to calculate it manually later
|
63
|
+
tt = @page.track_top
|
64
|
+
|
65
|
+
#create a new track, features and add the features to the track. The features are overlapping so there will be two rows
|
66
|
+
@generic_track = @page.add_track(:glyph => :generic, :name => 'generic_features', :label => true, :track_height => 10)
|
67
|
+
@feature1 = Bio::Graphics::MiniFeature.new(:start => 923, :end => 2212, :strand => '+', :id => "MyFeature")
|
68
|
+
@feature2 = Bio::Graphics::MiniFeature.new(:start => 2000, :end => 3500, :strand => '+', :id => "MyFeature2")
|
69
|
+
@generic_track.add(@feature1)
|
70
|
+
@generic_track.add(@feature2)
|
71
|
+
#draw the features which should update @page.track_top
|
72
|
+
@page.draw_features(@generic_track)
|
73
|
+
|
74
|
+
|
75
|
+
#caluclate the track_top (tt) manually (the code in draw_features that does this is provided in comments)
|
76
|
+
th = @generic_track.track_height
|
77
|
+
fh = @generic_track.feature_height
|
78
|
+
nr = @generic_track.number_rows
|
79
|
+
|
80
|
+
#@track_top += (track.track_height) + 20
|
81
|
+
tt += th + 20
|
82
|
+
#@track_top += (track.feature_height * track.number_rows * 2) + 20
|
83
|
+
tt += (fh*nr*2)+20
|
84
|
+
|
85
|
+
assert_equal(tt, @page.track_top, "From TestPage, test_draw_features. track_top is incorrect")
|
86
|
+
end
|
87
|
+
|
88
|
+
def test_json
|
89
|
+
#create a new page from the json_config.json file
|
90
|
+
json_file = ("test/json_config.json")
|
91
|
+
out_file = ("test/from_json.svg")
|
92
|
+
p = Bio::Graphics::Page.from_json(:json => json_file, :outfile => out_file )
|
93
|
+
#test that the outfile exists and has a size > 0
|
94
|
+
assert(File.size?('test/from_json.svg') > 0, "From TestJson, method test_file_exists: File doesn't exist, or is empty")
|
95
|
+
#delete the temp :outfile
|
96
|
+
File.delete('test/from_json.svg')
|
97
|
+
|
98
|
+
end
|
99
|
+
|
100
|
+
|
101
|
+
def test_parse_gff
|
102
|
+
#create a parent and child gff entry both starting at position 900
|
103
|
+
gff1 = "ctg123 . mRNA 900 9200 . + . ID=mRNA00001;Name=EDEN.1"
|
104
|
+
gff2 = "ctg123 . utr 900 1000 . + . ID=utr00001;Parent=mRNA00001"
|
105
|
+
#open a temp file and write the gff to it
|
106
|
+
temp_file = File.new('temp_gff.gff', 'w')
|
107
|
+
temp_file.puts(gff1)
|
108
|
+
temp_file.puts(gff2)
|
109
|
+
temp_file.close_write
|
110
|
+
|
111
|
+
#open and parse the file
|
112
|
+
gff_obj = Bio::Graphics::Page.parse_gff('temp_gff.gff')
|
113
|
+
#test to see if it returns an array of length 2 (the number of gff entries that should be in it)
|
114
|
+
assert_equal(2, gff_obj.length, "From TestJson, method test_parse_gff: array of gff objects should be of length 2 but is of length #{gff_obj.length}")
|
115
|
+
|
116
|
+
#test to make sure each array object is a GFF3::Record and that it starts at 900
|
117
|
+
gff_obj.each do |o|
|
118
|
+
assert_equal(Bio::GFF::GFF3::Record, o.class, "From TestJson, method test_parse_gff: array of gff objects should contain only Bio::GFF::GFF3::Record objects, but contains #{o.class} objects")
|
119
|
+
assert_equal(900, o.start, "From TestJson, method test_parse_gff: gff object should start at position 900 but starts at #{o.start}")
|
120
|
+
end
|
121
|
+
#delete the temp file
|
122
|
+
File.delete(temp_file.path.to_s)
|
123
|
+
|
124
|
+
end
|
125
|
+
|
126
|
+
|
127
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
$: << File.expand_path(File.dirname(__FILE__) + '/../lib')
|
2
|
+
$: << File.expand_path('.')
|
3
|
+
require 'rubygems'
|
4
|
+
require 'helper'
|
5
|
+
|
6
|
+
|
7
|
+
class TestPrimitive < Test::Unit::TestCase
|
8
|
+
def setup
|
9
|
+
|
10
|
+
@circle_glyph = Bio::Graphics::Glyph.circle({})
|
11
|
+
@generic_glyph = Bio::Graphics::Glyph.generic({})
|
12
|
+
@label_glyph = Bio::Graphics::Glyph.label({})
|
13
|
+
@directed_glyph = Bio::Graphics::Glyph.directed(:x => 0, :y => 0, :width => 10)
|
14
|
+
@down_triangle_glyph =Bio::Graphics::Glyph.down_triangle(:x => 0, :y => 0, :width => 10)
|
15
|
+
@up_triangle_glyph = Bio::Graphics::Glyph.up_triangle(:x => 0, :y => 0, :width => 10)
|
16
|
+
@span_glyph = Bio::Graphics::Glyph.span(:x => 0, :y => 0, :width => 10)
|
17
|
+
|
18
|
+
|
19
|
+
end
|
20
|
+
|
21
|
+
|
22
|
+
def test_init
|
23
|
+
@circle_glyph.each do |g|
|
24
|
+
assert_equal(:circle, g.primitive, "circle_glyph should be a circle, but is a #{g.class}")
|
25
|
+
end
|
26
|
+
@generic_glyph.each do |g|
|
27
|
+
assert_equal(:rectangle, g.primitive, "generic_glyph should be a rectangle, but is a #{g.class}")
|
28
|
+
end
|
29
|
+
@label_glyph.each do |g|
|
30
|
+
assert_equal(:text, g.primitive, "label_glyph should be a text, but is a #{g.class}")
|
31
|
+
end
|
32
|
+
@directed_glyph.each do |g|
|
33
|
+
assert_equal(:polygon, g.primitive, "directed_glyph should be a polygon, but is a #{g.class}")
|
34
|
+
end
|
35
|
+
@down_triangle_glyph.each do |g|
|
36
|
+
assert_equal(:polygon, g.primitive, "down_triangle_glyph should be a polygon, but is a #{g.class}")
|
37
|
+
end
|
38
|
+
@up_triangle_glyph.each do |g|
|
39
|
+
assert_equal(:polygon, g.primitive, "up_triangle_glyph should be a polygon, but is a #{g.class}")
|
40
|
+
end
|
41
|
+
@span_glyph.each do |g|
|
42
|
+
assert_equal(:line, g.primitive, "span_glyph should be a line, but is a #{g.class}")
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
data/test/test_svgee.rb
ADDED
@@ -0,0 +1,73 @@
|
|
1
|
+
$: << File.expand_path(File.dirname(__FILE__) + '/../lib')
|
2
|
+
$: << File.expand_path('.')
|
3
|
+
require 'rubygems'
|
4
|
+
require 'helper'
|
5
|
+
require 'bio-svgenes'
|
6
|
+
require 'test/unit'
|
7
|
+
require 'pp'
|
8
|
+
|
9
|
+
module Bio
|
10
|
+
class Graphics
|
11
|
+
class SVGEE
|
12
|
+
attr_accessor :width, :height, :style
|
13
|
+
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
class TestSvgee < Test::Unit::TestCase
|
19
|
+
def setup
|
20
|
+
|
21
|
+
@svg = Bio::Graphics::SVGEE.new({})
|
22
|
+
|
23
|
+
end
|
24
|
+
|
25
|
+
|
26
|
+
def test_svg_class
|
27
|
+
assert_equal(Bio::Graphics::SVGEE, @svg.class)
|
28
|
+
end
|
29
|
+
|
30
|
+
|
31
|
+
def test_svg_methods
|
32
|
+
|
33
|
+
#test to see if the svg instance is empty, other than those default variables
|
34
|
+
assert_equal([], @svg.primitives, "From Class:TestSvgee, method:test_svg_methods, @svg.primitives should be empty")
|
35
|
+
assert_equal("100%", @svg.height, "From Class:TestSvgee, method:test_svg_methods, @svg.height should be 100%")
|
36
|
+
assert_equal("100%", @svg.width, "From Class:TestSvgee, method:test_svg_methods, @svg.width should be 100%")
|
37
|
+
assert_equal(nil, @svg.style, "From Class:TestSvgee, method:test_svg_methods, @svg.style should be nil")
|
38
|
+
|
39
|
+
#create a circle
|
40
|
+
circ = @svg.circle(:x_center => 40, :y_center => 40, :radius => 20, :fill_color => "url(#grad1)")
|
41
|
+
|
42
|
+
#test to see if there is one and only one entry into the primitives array
|
43
|
+
assert_equal(1, @svg.primitives.length, "From Class:TestSvgee, method:test_svg_methods, Added a circle. @svg.primitives should be one")
|
44
|
+
#check that the primitive type is a :circle
|
45
|
+
assert_equal(:circle, circ.primitive, "From Class:TestSvgee, method:test_svg_methods, @svg.primitive does not return a :circle")
|
46
|
+
|
47
|
+
|
48
|
+
rect = @svg.rectangle(:x => 125, :y => 125, :width => 100, :height => 50, :fill_color => 'red', :stroke => 'black', :stroke_width => 2, :style => "fill-opacity:0.1;stroke-opacity:0.9")
|
49
|
+
#test to see if there is one and only one entry into the primitives array
|
50
|
+
assert_equal(2, @svg.primitives.length, "From Class:TestSvgee, method:test_svg_methods, Added a rectangle. @svg.primitives should be two")
|
51
|
+
#check that the primitive type is a :circle
|
52
|
+
assert_equal(:rectangle, rect.primitive, "From Class:TestSvgee, method:test_svg_methods, @svg.primitive does not return a :rectangle")
|
53
|
+
|
54
|
+
elli = @svg.ellipse(:x_center => 100, :y_center => 190, :x_radius => 40, :y_radius => 20, :fill_color => 'green', :stroke => 'black')
|
55
|
+
assert_equal(3, @svg.primitives.length, "From Class:TestSvgee, method:test_svg_methods, Added an ellipse. @svg.primitives should be three")
|
56
|
+
#check that the primitive type is a :circle
|
57
|
+
assert_equal(:ellipse, elli.primitive, "From Class:TestSvgee, method:test_svg_methods, @svg.primitive does not return an :ellipse")
|
58
|
+
|
59
|
+
|
60
|
+
end
|
61
|
+
|
62
|
+
def test_add_primitive
|
63
|
+
#get the current number of primitives
|
64
|
+
no_prims = @svg.primitives.length
|
65
|
+
|
66
|
+
@circle_glyph = Bio::Graphics::Glyph.circle({})
|
67
|
+
@circle_glyph.each do |g|
|
68
|
+
|
69
|
+
@svg.add_primitive(g)
|
70
|
+
end
|
71
|
+
assert_equal(no_prims+1, @svg.primitives.length, "From Class:TestSvgee, method:test_add_primitive, @svg should only have increased by one")
|
72
|
+
end
|
73
|
+
end
|